From fde550ef66e18572c63519f6a4f6fda3bbed243e Mon Sep 17 00:00:00 2001 From: nmzik Date: Tue, 8 Sep 2026 13:32:41 +0400 Subject: [PATCH] graphics: simplify texture cleanup and swizzle decoding --- .../host_gpu/renderer/cache/textureCache.cpp | 6 +----- .../host_gpu/renderer/image/textureCommon.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/graphics/host_gpu/renderer/cache/textureCache.cpp b/src/graphics/host_gpu/renderer/cache/textureCache.cpp index 76154e237..cfc94f5db 100644 --- a/src/graphics/host_gpu/renderer/cache/textureCache.cpp +++ b/src/graphics/host_gpu/renderer/cache/textureCache.cpp @@ -187,15 +187,11 @@ TextureCache::TextureCache(GraphicContext& graphics, CommandScheduler& scheduler } TextureCache::~TextureCache() { - std::vector registered; m_slot_images.ForEach([&](ImageId id, const Image& image) { if (image.registered) { - registered.push_back(id); + UnregisterImage(id); } }); - for (const auto id: registered) { - UnregisterImage(id); - } } bool TextureCache::SameBacking(const ImageInfo& cached, const ImageInfo& requested, diff --git a/src/graphics/host_gpu/renderer/image/textureCommon.cpp b/src/graphics/host_gpu/renderer/image/textureCommon.cpp index bd72601db..848fcadb1 100644 --- a/src/graphics/host_gpu/renderer/image/textureCommon.cpp +++ b/src/graphics/host_gpu/renderer/image/textureCommon.cpp @@ -5,6 +5,7 @@ #include "graphics/guest_gpu/gpu_format.h" #include "graphics/host_gpu/renderer/image/tiler.h" #include "graphics/host_gpu/vulkanCommon.h" +#include "graphics/shader/shader.h" #include #include @@ -104,18 +105,14 @@ vk::ComponentSwizzle TextureGetComponentSwizzle(uint8_t s) { return vk::ComponentSwizzle::eIdentity; } -static uint32_t TextureGetDstSel(uint32_t swizzle, uint32_t channel) { - return (swizzle >> (channel * 3u)) & 0x7u; -} - } // namespace vk::ComponentMapping TextureGetComponentMapping(uint32_t swizzle) { vk::ComponentMapping components {}; - components.r = TextureGetComponentSwizzle(static_cast(TextureGetDstSel(swizzle, 0))); - components.g = TextureGetComponentSwizzle(static_cast(TextureGetDstSel(swizzle, 1))); - components.b = TextureGetComponentSwizzle(static_cast(TextureGetDstSel(swizzle, 2))); - components.a = TextureGetComponentSwizzle(static_cast(TextureGetDstSel(swizzle, 3))); + components.r = TextureGetComponentSwizzle(GetDstSel(swizzle, 0)); + components.g = TextureGetComponentSwizzle(GetDstSel(swizzle, 1)); + components.b = TextureGetComponentSwizzle(GetDstSel(swizzle, 2)); + components.a = TextureGetComponentSwizzle(GetDstSel(swizzle, 3)); return components; }