From ef4a6cf873412c220272b49950fa4741a33d326d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 29 Jul 2022 18:27:52 +0200 Subject: [PATCH] Remove support for 16-bit replacement texture formats --- Core/TextureReplacer.cpp | 49 ++++--------------------------- Core/TextureReplacer.h | 9 ++---- GPU/D3D11/TextureCacheD3D11.cpp | 6 ---- GPU/Directx9/TextureCacheDX9.cpp | 6 ---- GPU/GLES/TextureCacheGLES.cpp | 6 ---- GPU/Vulkan/TextureCacheVulkan.cpp | 6 ---- 6 files changed, 8 insertions(+), 74 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index af50be26c2..9c793affe2 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -635,50 +635,13 @@ void TextureReplacer::NotifyTextureDecoded(const ReplacedTextureDecodeInfo &repl SimpleBuf saveBuf; - // Since we're copying, change the format meanwhile. Not much extra cost. - if (replacedInfo.fmt != ReplacedTextureFormat::F_8888) { - saveBuf.resize((pitch * h) / sizeof(u16)); - switch (replacedInfo.fmt) { - case ReplacedTextureFormat::F_5650: - ConvertRGB565ToRGBA8888(saveBuf.data(), (const u16 *)data, (pitch * h) / sizeof(u16)); - break; - case ReplacedTextureFormat::F_5551: - ConvertRGBA5551ToRGBA8888(saveBuf.data(), (const u16 *)data, (pitch * h) / sizeof(u16)); - break; - case ReplacedTextureFormat::F_4444: - ConvertRGBA4444ToRGBA8888(saveBuf.data(), (const u16 *)data, (pitch * h) / sizeof(u16)); - break; - case ReplacedTextureFormat::F_0565_ABGR: - ConvertBGR565ToRGBA8888(saveBuf.data(), (const u16 *)data, (pitch * h) / sizeof(u16)); - break; - case ReplacedTextureFormat::F_1555_ABGR: - ConvertABGR1555ToRGBA8888(saveBuf.data(), (const u16 *)data, (pitch * h) / sizeof(u16)); - break; - case ReplacedTextureFormat::F_4444_ABGR: - ConvertABGR4444ToRGBA8888(saveBuf.data(), (const u16 *)data, (pitch * h) / sizeof(u16)); - break; - case ReplacedTextureFormat::F_8888_BGRA: - ConvertBGRA8888ToRGBA8888(saveBuf.data(), (const u32 *)data, (pitch * h) / sizeof(u32)); - break; - case ReplacedTextureFormat::F_8888: - // Impossible. Just so we can get warnings on other missed formats. - break; - } - - data = saveBuf.data(); - if (replacedInfo.fmt != ReplacedTextureFormat::F_8888_BGRA) { - // We doubled our pitch. - pitch *= 2; - } - } else { - // Copy data to a buffer so we can send it to the thread. Might as well compact-away the pitch - // while we're at it. - saveBuf.resize(w * h); - for (int y = 0; y < h; y++) { - memcpy((u8 *)saveBuf.data() + y * w * 4, (const u8 *)data + y * pitch, w * sizeof(u32)); - } - pitch = w * 4; + // Copy data to a buffer so we can send it to the thread. Might as well compact-away the pitch + // while we're at it. + saveBuf.resize(w * h); + for (int y = 0; y < h; y++) { + memcpy((u8 *)saveBuf.data() + y * w * 4, (const u8 *)data + y * pitch, w * sizeof(u32)); } + pitch = w * 4; TextureSaveTask *task = new TextureSaveTask(std::move(saveBuf)); // Should probably do a proper move constructor but this'll work. diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index ae621c2d72..6a636d8b1d 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -36,14 +36,9 @@ class ReplacedTextureTask; class LimitedWaitable; enum class ReplacedTextureFormat { - F_5650, - F_5551, - F_4444, F_8888, - F_0565_ABGR, - F_1555_ABGR, - F_4444_ABGR, - F_8888_BGRA, + // Might add compressed formats here later, maybe universal ones like Basis. + // We don't bother with the 16-bit formats for replacement storage, they're not commonly used these days. }; // These must match the constants in TextureCacheCommon. diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 58a38cb677..f5934333c2 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -607,18 +607,12 @@ CheckAlphaResult TextureCacheD3D11::CheckAlpha(const u32 *pixelData, u32 dstFmt, ReplacedTextureFormat FromD3D11Format(u32 fmt) { switch (fmt) { - case DXGI_FORMAT_B5G6R5_UNORM: return ReplacedTextureFormat::F_5650; - case DXGI_FORMAT_B5G5R5A1_UNORM: return ReplacedTextureFormat::F_5551; - case DXGI_FORMAT_B4G4R4A4_UNORM: return ReplacedTextureFormat::F_4444; case DXGI_FORMAT_B8G8R8A8_UNORM: default: return ReplacedTextureFormat::F_8888; } } DXGI_FORMAT ToDXGIFormat(ReplacedTextureFormat fmt) { switch (fmt) { - case ReplacedTextureFormat::F_5650: return DXGI_FORMAT_B5G6R5_UNORM; - case ReplacedTextureFormat::F_5551: return DXGI_FORMAT_B5G5R5A1_UNORM; - case ReplacedTextureFormat::F_4444: return DXGI_FORMAT_B4G4R4A4_UNORM; case ReplacedTextureFormat::F_8888: default: return DXGI_FORMAT_B8G8R8A8_UNORM; } } diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index a2d9f72922..e58ff8edf4 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -541,18 +541,12 @@ CheckAlphaResult TextureCacheDX9::CheckAlpha(const u32 *pixelData, u32 dstFmt, i ReplacedTextureFormat FromD3D9Format(u32 fmt) { switch (fmt) { - case D3DFMT_R5G6B5: return ReplacedTextureFormat::F_5650; - case D3DFMT_A1R5G5B5: return ReplacedTextureFormat::F_5551; - case D3DFMT_A4R4G4B4: return ReplacedTextureFormat::F_4444; case D3DFMT_A8R8G8B8: default: return ReplacedTextureFormat::F_8888; } } D3DFORMAT ToD3D9Format(ReplacedTextureFormat fmt) { switch (fmt) { - case ReplacedTextureFormat::F_5650: return D3DFMT_R5G6B5; - case ReplacedTextureFormat::F_5551: return D3DFMT_A1R5G5B5; - case ReplacedTextureFormat::F_4444: return D3DFMT_A4R4G4B4; case ReplacedTextureFormat::F_8888: default: return D3DFMT_A8R8G8B8; } } diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 66607cb539..926879d3af 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -428,18 +428,12 @@ void TextureCacheGLES::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer, ReplacedTextureFormat FromDataFormat(Draw::DataFormat fmt) { // TODO: 16-bit formats are incorrect, since swizzled. switch (fmt) { - case Draw::DataFormat::R5G6B5_UNORM_PACK16: return ReplacedTextureFormat::F_0565_ABGR; - case Draw::DataFormat::R5G5B5A1_UNORM_PACK16: return ReplacedTextureFormat::F_1555_ABGR; - case Draw::DataFormat::R4G4B4A4_UNORM_PACK16: return ReplacedTextureFormat::F_4444_ABGR; case Draw::DataFormat::R8G8B8A8_UNORM: default: return ReplacedTextureFormat::F_8888; } } Draw::DataFormat ToDataFormat(ReplacedTextureFormat fmt) { switch (fmt) { - case ReplacedTextureFormat::F_5650: return Draw::DataFormat::R5G6B5_UNORM_PACK16; - case ReplacedTextureFormat::F_5551: return Draw::DataFormat::R5G5B5A1_UNORM_PACK16; - case ReplacedTextureFormat::F_4444: return Draw::DataFormat::R4G4B4A4_UNORM_PACK16; case ReplacedTextureFormat::F_8888: default: return Draw::DataFormat::R8G8B8A8_UNORM; } } diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 972b93d04d..0e6825a4cd 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -566,18 +566,12 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer ReplacedTextureFormat FromVulkanFormat(VkFormat fmt) { switch (fmt) { - case VULKAN_565_FORMAT: return ReplacedTextureFormat::F_5650; - case VULKAN_1555_FORMAT: return ReplacedTextureFormat::F_5551; - case VULKAN_4444_FORMAT: return ReplacedTextureFormat::F_4444; case VULKAN_8888_FORMAT: default: return ReplacedTextureFormat::F_8888; } } VkFormat ToVulkanFormat(ReplacedTextureFormat fmt) { switch (fmt) { - case ReplacedTextureFormat::F_5650: return VULKAN_565_FORMAT; - case ReplacedTextureFormat::F_5551: return VULKAN_1555_FORMAT; - case ReplacedTextureFormat::F_4444: return VULKAN_4444_FORMAT; case ReplacedTextureFormat::F_8888: default: return VULKAN_8888_FORMAT; } }