diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index 9c793affe2..c38ef1fe44 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -410,7 +410,7 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey, } ReplacedTextureLevel level; - level.fmt = ReplacedTextureFormat::F_8888; + level.fmt = Draw::DataFormat::R8G8B8A8_UNORM; level.file = filename; bool good = PopulateLevel(level); @@ -657,7 +657,7 @@ void TextureReplacer::NotifyTextureDecoded(const ReplacedTextureDecodeInfo &repl // Remember that we've saved this for next time. // Should be OK that the actual disk write may not be finished yet. ReplacedTextureLevel saved; - saved.fmt = ReplacedTextureFormat::F_8888; + saved.fmt = Draw::DataFormat::R8G8B8A8_UNORM; saved.file = filename; saved.w = w; saved.h = h; diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index 6a636d8b1d..1daaa1e30f 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -25,6 +25,7 @@ #include "Common/CommonTypes.h" #include "Common/MemoryUtil.h" #include "Common/File/Path.h" +#include "Common/GPU/DataFormat.h" #include "GPU/Common/TextureDecoder.h" #include "GPU/ge_constants.h" @@ -35,12 +36,6 @@ class TextureReplacer; class ReplacedTextureTask; class LimitedWaitable; -enum class ReplacedTextureFormat { - F_8888, - // 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. enum class ReplacedTextureAlpha { UNKNOWN = 0x04, @@ -57,7 +52,7 @@ enum class ReplacedTextureHash { struct ReplacedTextureLevel { int w; int h; - ReplacedTextureFormat fmt; + Draw::DataFormat fmt; // NOTE: Right now, the only supported format is Draw::DataFormat::R8G8B8A8_UNORM. Path file; }; @@ -141,11 +136,11 @@ struct ReplacedTexture { return (int)levels_.size() - 1; } - ReplacedTextureFormat Format(int level) { + Draw::DataFormat Format(int level) { if ((size_t)level < levels_.size()) { return levels_[level].fmt; } - return ReplacedTextureFormat::F_8888; + return Draw::DataFormat::R8G8B8A8_UNORM; } u8 AlphaStatus() { @@ -180,7 +175,7 @@ struct ReplacedTextureDecodeInfo { bool isVideo; bool isFinal; int scaleFactor; - ReplacedTextureFormat fmt; + Draw::DataFormat fmt; }; enum class ReplacerDecimateMode { diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index f5934333c2..4da2fa6664 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -605,15 +605,15 @@ CheckAlphaResult TextureCacheD3D11::CheckAlpha(const u32 *pixelData, u32 dstFmt, } } -ReplacedTextureFormat FromD3D11Format(u32 fmt) { +Draw::DataFormat FromD3D11Format(u32 fmt) { switch (fmt) { - case DXGI_FORMAT_B8G8R8A8_UNORM: default: return ReplacedTextureFormat::F_8888; + case DXGI_FORMAT_B8G8R8A8_UNORM: default: return Draw::DataFormat::R8G8B8A8_UNORM; } } -DXGI_FORMAT ToDXGIFormat(ReplacedTextureFormat fmt) { +DXGI_FORMAT ToDXGIFormat(Draw::DataFormat fmt) { switch (fmt) { - case ReplacedTextureFormat::F_8888: default: return DXGI_FORMAT_B8G8R8A8_UNORM; + case Draw::DataFormat::R8G8B8A8_UNORM: default: return DXGI_FORMAT_B8G8R8A8_UNORM; } } diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index e58ff8edf4..e424408ee8 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -539,15 +539,15 @@ CheckAlphaResult TextureCacheDX9::CheckAlpha(const u32 *pixelData, u32 dstFmt, i } } -ReplacedTextureFormat FromD3D9Format(u32 fmt) { +Draw::DataFormat FromD3D9Format(u32 fmt) { switch (fmt) { - case D3DFMT_A8R8G8B8: default: return ReplacedTextureFormat::F_8888; + case D3DFMT_A8R8G8B8: default: return Draw::DataFormat::R8G8B8A8_UNORM; } } -D3DFORMAT ToD3D9Format(ReplacedTextureFormat fmt) { +D3DFORMAT ToD3D9Format(Draw::DataFormat fmt) { switch (fmt) { - case ReplacedTextureFormat::F_8888: default: return D3DFMT_A8R8G8B8; + case Draw::DataFormat::R8G8B8A8_UNORM: default: return D3DFMT_A8R8G8B8; } } diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 926879d3af..18359ff341 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -425,19 +425,6 @@ void TextureCacheGLES::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer, gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE); } -ReplacedTextureFormat FromDataFormat(Draw::DataFormat fmt) { - // TODO: 16-bit formats are incorrect, since swizzled. - switch (fmt) { - case Draw::DataFormat::R8G8B8A8_UNORM: default: return ReplacedTextureFormat::F_8888; - } -} - -Draw::DataFormat ToDataFormat(ReplacedTextureFormat fmt) { - switch (fmt) { - case ReplacedTextureFormat::F_8888: default: return Draw::DataFormat::R8G8B8A8_UNORM; - } -} - void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) { entry->status &= ~TexCacheEntry::STATUS_ALPHA_MASK; @@ -640,7 +627,7 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r if (replaced.GetSize(level, w, h)) { PROFILE_THIS_SCOPE("replacetex"); - int bpp = replaced.Format(level) == ReplacedTextureFormat::F_8888 ? 4 : 2; + int bpp = (int)DataFormatSizeInBytes(replaced.Format(level)); decPitch = w * bpp; uint8_t *rearrange = (uint8_t *)AllocateAlignedMemory(decPitch * h, 16); double replaceStart = time_now_d(); @@ -648,7 +635,7 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r replacementTimeThisFrame_ += time_now_d() - replaceStart; pixelData = rearrange; - dstFmt = ToDataFormat(replaced.Format(level)); + dstFmt = replaced.Format(level); } else { PROFILE_THIS_SCOPE("decodetex"); @@ -683,7 +670,7 @@ void TextureCacheGLES::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &r replacedInfo.isVideo = IsVideo(entry.addr); replacedInfo.isFinal = (entry.status & TexCacheEntry::STATUS_TO_SCALE) == 0; replacedInfo.scaleFactor = scaleFactor; - replacedInfo.fmt = FromDataFormat(dstFmt); + replacedInfo.fmt = dstFmt; replacer_.NotifyTextureDecoded(replacedInfo, pixelData, decPitch, level, w, h); } diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 0e6825a4cd..d22b9d3cb9 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -564,15 +564,15 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer curSampler_ = samplerCache_.GetOrCreateSampler(samplerKey); } -ReplacedTextureFormat FromVulkanFormat(VkFormat fmt) { +static Draw::DataFormat FromVulkanFormat(VkFormat fmt) { switch (fmt) { - case VULKAN_8888_FORMAT: default: return ReplacedTextureFormat::F_8888; + case VULKAN_8888_FORMAT: default: return Draw::DataFormat::R8G8B8A8_UNORM; } } -VkFormat ToVulkanFormat(ReplacedTextureFormat fmt) { +static VkFormat ToVulkanFormat(Draw::DataFormat fmt) { switch (fmt) { - case ReplacedTextureFormat::F_8888: default: return VULKAN_8888_FORMAT; + case Draw::DataFormat::R8G8B8A8_UNORM: default: return VULKAN_8888_FORMAT; } }