From fbf6008a03800e3fe7d12a09eec0bf3abf340407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 9 Aug 2020 09:35:56 +0200 Subject: [PATCH] Set debug names for more framebuffers and textures --- Common/Vulkan/VulkanImage.cpp | 4 ++++ GPU/Common/FramebufferManagerCommon.cpp | 15 +++++++++++---- GPU/Common/PresentationCommon.cpp | 2 +- GPU/Vulkan/TextureCacheVulkan.cpp | 2 +- UI/GameInfoCache.cpp | 2 +- UI/Store.cpp | 2 +- UI/TextureUtil.cpp | 4 ++-- UI/TextureUtil.h | 4 ++-- ext/native/thin3d/VulkanRenderManager.cpp | 2 ++ ext/native/thin3d/thin3d.h | 2 +- ext/native/thin3d/thin3d_vulkan.cpp | 4 +++- 11 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Common/Vulkan/VulkanImage.cpp b/Common/Vulkan/VulkanImage.cpp index d6f3f53877..1d9b8d7ffe 100644 --- a/Common/Vulkan/VulkanImage.cpp +++ b/Common/Vulkan/VulkanImage.cpp @@ -71,6 +71,9 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *all return false; } + // Apply the tag + vulkan_->SetDebugName(image_, tag_.c_str()); + VkMemoryRequirements mem_reqs{}; bool dedicatedAllocation = false; vulkan_->GetImageMemoryRequirements(image_, &mem_reqs, &dedicatedAllocation); @@ -161,6 +164,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *all return true; } +// TODO: Batch these. void VulkanTexture::UploadMip(VkCommandBuffer cmd, int mip, int mipWidth, int mipHeight, VkBuffer buffer, uint32_t offset, size_t rowLength) { VkBufferImageCopy copy_region{}; copy_region.bufferOffset = offset; diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 5be05dfded..556e2519ee 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1060,7 +1060,9 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, } shaderManager_->DirtyLastShader(); - vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, (Draw::FBColorDepth)vfb->colorDepth }); + char name[256]; + snprintf(name, sizeof(name), "%08x_%08x", vfb->fb_address, vfb->z_address); + vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, (Draw::FBColorDepth)vfb->colorDepth, name }); if (old.fbo) { INFO_LOG(FRAMEBUF, "Resizing FBO for %08x : %d x %d x %d", vfb->fb_address, w, h, vfb->format); if (vfb->fbo) { @@ -1329,7 +1331,9 @@ VirtualFramebuffer *FramebufferManagerCommon::CreateRAMFramebuffer(uint32_t fbAd vfb->usageFlags = FB_USAGE_RENDERTARGET; SetColorUpdated(vfb, 0); textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_CREATED); - vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, (Draw::FBColorDepth)vfb->colorDepth }); + char name[64]; + snprintf(name, sizeof(name), "%08x_color_RAM", vfb->fb_address); + vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, (Draw::FBColorDepth)vfb->colorDepth, name }); vfbs_.push_back(vfb); u32 byteSize = ColorBufferByteSize(vfb); @@ -1417,7 +1421,9 @@ bool FramebufferManagerCommon::CreateDownloadTempBuffer(VirtualFramebuffer *nvfb } } - nvfb->fbo = draw_->CreateFramebuffer({ nvfb->bufferWidth, nvfb->bufferHeight, 1, 1, false, (Draw::FBColorDepth)nvfb->colorDepth }); + char name[64]; + snprintf(name, sizeof(name), "download_temp"); + nvfb->fbo = draw_->CreateFramebuffer({ nvfb->bufferWidth, nvfb->bufferHeight, 1, 1, false, (Draw::FBColorDepth)nvfb->colorDepth, name }); if (!nvfb->fbo) { ERROR_LOG(FRAMEBUF, "Error creating GL FBO! %i x %i", nvfb->renderWidth, nvfb->renderHeight); return false; @@ -1744,7 +1750,8 @@ Draw::Framebuffer *FramebufferManagerCommon::GetTempFBO(TempFBO reason, u16 w, u textureCache_->ForgetLastTexture(); bool z_stencil = reason == TempFBO::STENCIL; - Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, 1, z_stencil, depth }); + const char *name = "temp_fbo"; + Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, 1, z_stencil, depth, name }); if (!fbo) return fbo; diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 09bf2c2009..9ef488ffda 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -317,7 +317,7 @@ bool PresentationCommon::AllocateFramebuffer(int w, int h) { } // No depth/stencil for post processing - Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, 1, false, Draw::FBO_8888 }); + Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, 1, false, Draw::FBO_8888, "presentation" }); if (!fbo) { return false; } diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 8631e4cdea..d15f68988a 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -859,7 +859,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { } char texName[128]{}; - snprintf(texName, sizeof(texName), "Texture%08x", entry->addr); + snprintf(texName, sizeof(texName), "texture_%08x_%s", entry->addr, GeTextureFormatToString((GETextureFormat)entry->format)); image->SetTag(texName); bool allocSuccess = image->CreateDirect(cmdInit, allocator_, w * scaleFactor, h * scaleFactor, maxLevel + 1, actualFmt, imageLayout, usage, mapping); diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 32c9684db0..e1c2db94f0 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -789,7 +789,7 @@ void GameInfoCache::SetupTexture(std::shared_ptr &info, Draw::DrawCont using namespace Draw; if (tex.data.size()) { if (!tex.texture) { - tex.texture = CreateTextureFromFileData(thin3d, (const uint8_t *)tex.data.data(), (int)tex.data.size(), ImageFileType::DETECT); + tex.texture = CreateTextureFromFileData(thin3d, (const uint8_t *)tex.data.data(), (int)tex.data.size(), ImageFileType::DETECT, false, info->GetTitle().c_str()); if (tex.texture) { tex.timeLoaded = time_now_d(); } else { diff --git a/UI/Store.cpp b/UI/Store.cpp index 780a7f4c99..f52a1ae916 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -139,7 +139,7 @@ void HttpImageFileView::Draw(UIContext &dc) { } if (!textureData_.empty()) { - texture_ = CreateTextureFromFileData(dc.GetDrawContext(), (const uint8_t *)(textureData_.data()), (int)textureData_.size(), DETECT); + texture_ = CreateTextureFromFileData(dc.GetDrawContext(), (const uint8_t *)(textureData_.data()), (int)textureData_.size(), DETECT, false, "store_icon"); if (!texture_) textureFailed_ = true; textureData_.clear(); diff --git a/UI/TextureUtil.cpp b/UI/TextureUtil.cpp index b9f9b8966a..0d05bbc448 100644 --- a/UI/TextureUtil.cpp +++ b/UI/TextureUtil.cpp @@ -202,11 +202,11 @@ Draw::Texture *ManagedTexture::GetTexture() { } // TODO: Remove the code duplication between this and LoadFromFileData -std::unique_ptr CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType type, bool generateMips) { +std::unique_ptr CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType type, bool generateMips, const char *name) { if (!draw) return std::unique_ptr(); ManagedTexture *mtex = new ManagedTexture(draw); - if (mtex->LoadFromFileData(data, size, type, generateMips, nullptr)) { + if (mtex->LoadFromFileData(data, size, type, generateMips, name)) { return std::unique_ptr(mtex); } else { // Best to return a null pointer if we fail! diff --git a/UI/TextureUtil.h b/UI/TextureUtil.h index 61abbfc2c8..d5ebca8a5c 100644 --- a/UI/TextureUtil.h +++ b/UI/TextureUtil.h @@ -39,8 +39,8 @@ private: bool loadPending_ = false; }; -std::unique_ptr CreateTextureFromFile(Draw::DrawContext *draw, const char *filename, ImageFileType fileType, bool generateMips = false); -std::unique_ptr CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType fileType, bool generateMips = false); +std::unique_ptr CreateTextureFromFile(Draw::DrawContext *draw, const char *filename, ImageFileType fileType, bool generateMips); +std::unique_ptr CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType fileType, bool generateMips, const char *name); class GameIconView : public UI::InertView { public: diff --git a/ext/native/thin3d/VulkanRenderManager.cpp b/ext/native/thin3d/VulkanRenderManager.cpp index a595bfe29a..01e692de59 100644 --- a/ext/native/thin3d/VulkanRenderManager.cpp +++ b/ext/native/thin3d/VulkanRenderManager.cpp @@ -718,6 +718,8 @@ bool VulkanRenderManager::InitDepthStencilBuffer(VkCommandBuffer cmd) { if (res != VK_SUCCESS) return false; + vulkan_->SetDebugName(depth_.image, "BackbufferDepth"); + bool dedicatedAllocation = false; VkMemoryRequirements mem_reqs; vulkan_->GetImageMemoryRequirements(depth_.image, &mem_reqs, &dedicatedAllocation); diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index d3ae7c20d4..ced1d8df67 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -538,7 +538,7 @@ struct TextureDesc { int mipLevels; bool generateMips; // Optional, for tracking memory usage and graphcis debuggers. - std::string tag; + const char *tag; // Does not take ownership over pointed-to data. std::vector initData; TextureCallback initDataCallback; diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 3c90511893..7c033aeed3 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -714,7 +714,9 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanPushBuffer *push, const Textur height_ = desc.height; depth_ = desc.depth; vkTex_ = new VulkanTexture(vulkan_); - vkTex_->SetTag(desc.tag); + if (desc.tag) { + vkTex_->SetTag(desc.tag); + } VkFormat vulkanFormat = DataFormatToVulkan(format_); int bpp = GetBpp(vulkanFormat); int bytesPerPixel = bpp / 8;