From 5f27a2e60a04e1ba35937c5a9638de12e791d6ca Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 6 Apr 2018 21:17:31 -0700 Subject: [PATCH] Vulkan: Track tags on emu textures. --- GPU/Vulkan/DepalettizeShaderVulkan.cpp | 2 ++ GPU/Vulkan/DrawEngineVulkan.cpp | 3 +++ GPU/Vulkan/FramebufferVulkan.cpp | 1 + GPU/Vulkan/TextureCacheVulkan.cpp | 5 +++++ 4 files changed, 11 insertions(+) diff --git a/GPU/Vulkan/DepalettizeShaderVulkan.cpp b/GPU/Vulkan/DepalettizeShaderVulkan.cpp index b7dec11221..1cc701a28f 100644 --- a/GPU/Vulkan/DepalettizeShaderVulkan.cpp +++ b/GPU/Vulkan/DepalettizeShaderVulkan.cpp @@ -120,6 +120,7 @@ VulkanTexture *DepalShaderCacheVulkan::GetClutTexture(GEPaletteFormat clutFormat u32 clutId = GetClutID(clutFormat, clutHash); auto oldtex = texCache_.find(clutId); if (oldtex != texCache_.end()) { + oldtex->second->texture->Touch(); oldtex->second->lastFrame = gpuStats.numFlips; return oldtex->second->texture; } @@ -132,6 +133,7 @@ VulkanTexture *DepalShaderCacheVulkan::GetClutTexture(GEPaletteFormat clutFormat uint32_t pushOffset = push_->PushAligned(rawClut, 1024, 4, &pushBuffer); VulkanTexture *vktex = new VulkanTexture(vulkan_, alloc_); + vktex->SetTag("DepalClut"); VkCommandBuffer cmd = (VkCommandBuffer)draw_->GetNativeObject(Draw::NativeObject::INIT_COMMANDBUFFER); if (!vktex->CreateDirect(cmd, texturePixels, 1, 1, destFormat, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, &componentMapping)) { diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index a394275262..fbbb05261f 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -258,6 +258,7 @@ void DrawEngineVulkan::BeginFrame() { if (!nullTexture_) { VkCommandBuffer cmdInit = (VkCommandBuffer)draw_->GetNativeObject(Draw::NativeObject::INIT_COMMANDBUFFER); nullTexture_ = new VulkanTexture(vulkan_, textureCache_->GetAllocator()); + nullTexture_->SetTag("Null"); int w = 8; int h = 8; nullTexture_->CreateDirect(cmdInit, w, h, 1, VK_FORMAT_A8B8G8R8_UNORM_PACK32, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -273,6 +274,8 @@ void DrawEngineVulkan::BeginFrame() { } nullTexture_->UploadMip(cmdInit, 0, w, h, bindBuf, bindOffset, w); nullTexture_->EndCreate(cmdInit); + } else { + nullTexture_->Touch(); } DirtyAllUBOs(); diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index 98753526fa..73495acca5 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -204,6 +204,7 @@ void FramebufferManagerVulkan::MakePixelTexture(const u8 *srcPixels, GEBufferFor // There's only ever a few of these alive, don't need to stress the allocator with these big ones. drawPixelsTex_ = new VulkanTexture(vulkan_, nullptr); + drawPixelsTex_->SetTag("DrawPixels"); if (!drawPixelsTex_->CreateDirect(initCmd, width, height, 1, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)) { // out of memory? delete drawPixelsTex_; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index c917badc48..289184cf78 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -317,6 +317,7 @@ void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) { return; } + entry->vkTex->Touch(); imageView_ = entry->vkTex->GetImageView(); SamplerCacheKey key{}; UpdateSamplingParams(*entry, key); @@ -580,6 +581,10 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { break; } + char texName[128]{}; + snprintf(texName, sizeof(texName), "Texture%08x", entry->addr); + image->SetTag(texName); + bool allocSuccess = image->CreateDirect(cmdInit, w * scaleFactor, h * scaleFactor, maxLevel + 1, actualFmt, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, mapping); if (!allocSuccess && !lowMemoryMode_) { WARN_LOG_REPORT(G3D, "Texture cache ran out of GPU memory; switching to low memory mode");