summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureDecoder.h
diff options
context:
space:
mode:
authorConnor McLaughlin <stenzek@gmail.com>2019-07-15 18:08:15 +1000
committerGitHub <noreply@github.com>2019-07-15 18:08:15 +1000
commit58e12395c242a839ce561395014e631b9e945685 (patch)
treeeef0c948d64df352f6b37e0625e4dbd917d8f7e4 /Source/Core/VideoCommon/TextureDecoder.h
parent533f6bfeb9a0c624d7837d0ce8daaac586e21233 (diff)
parent946571b7595b6b24e02cf8622f2bd5935b5aa360 (diff)
Merge pull request #8240 from stenzek/spoderman
TextureCache: Support reinterpreting formats for VRAM textures
Diffstat (limited to 'Source/Core/VideoCommon/TextureDecoder.h')
-rw-r--r--Source/Core/VideoCommon/TextureDecoder.h41
1 files changed, 41 insertions, 0 deletions
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);