From 946571b7595b6b24e02cf8622f2bd5935b5aa360 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 14 Jul 2019 15:24:12 +1000 Subject: TextureCache: Support reinterpreting formats for VRAM textures --- Source/Core/VideoCommon/TextureDecoder.h | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'Source/Core/VideoCommon/TextureDecoder.h') diff --git a/Source/Core/VideoCommon/TextureDecoder.h b/Source/Core/VideoCommon/TextureDecoder.h index a1313afab1..7a08a6514a 100644 --- a/Source/Core/VideoCommon/TextureDecoder.h +++ b/Source/Core/VideoCommon/TextureDecoder.h @@ -99,6 +99,47 @@ static inline bool IsValidTLUTFormat(TLUTFormat tlutfmt) tlutfmt == TLUTFormat::RGB5A3; } +static inline bool IsCompatibleTextureFormat(TextureFormat from_format, TextureFormat to_format) +{ + if (from_format == to_format) + return true; + + // Indexed and paletted formats are "compatible", that is do not require conversion. + switch (from_format) + { + case TextureFormat::I4: + case TextureFormat::C4: + return to_format == TextureFormat::I4 || to_format == TextureFormat::C4; + + case TextureFormat::I8: + case TextureFormat::C8: + return to_format == TextureFormat::I8 || to_format == TextureFormat::C8; + + default: + return false; + } +} + +static inline bool CanReinterpretTextureOnGPU(TextureFormat from_format, TextureFormat to_format) +{ + // Currently, we can only reinterpret textures of the same width. + switch (from_format) + { + case TextureFormat::I8: + case TextureFormat::IA4: + return to_format == TextureFormat::I8 || to_format == TextureFormat::IA4; + + case TextureFormat::IA8: + case TextureFormat::RGB565: + case TextureFormat::RGB5A3: + return to_format == TextureFormat::IA8 || to_format == TextureFormat::RGB565 || + to_format == TextureFormat::RGB5A3; + + default: + return false; + } +} + int TexDecoder_GetTexelSizeInNibbles(TextureFormat format); int TexDecoder_GetTextureSizeInBytes(int width, int height, TextureFormat format); int TexDecoder_GetBlockWidthInTexels(TextureFormat format); -- cgit v1.2.3