From c2a5b65f8d49593da653727227f76d1bb77f1d7f Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 28 Aug 2018 16:10:26 +0300 Subject: [PATCH] [D3D12] Packed texture format swizzles --- src/xenia/gpu/d3d12/texture_cache.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/xenia/gpu/d3d12/texture_cache.cc b/src/xenia/gpu/d3d12/texture_cache.cc index df5f43bca..80f7472b4 100644 --- a/src/xenia/gpu/d3d12/texture_cache.cc +++ b/src/xenia/gpu/d3d12/texture_cache.cc @@ -726,7 +726,13 @@ void TextureCache::TextureKeyFromFetchConstant( // something broken) the quick and dirty way - by changing them to 4 and 5. swizzle &= ~(swizzle_constant >> 1); // Remap the swizzle according to the texture format. - if (format == TextureFormat::k_DXT3A) { + if (format == TextureFormat::k_1_5_5_5 || format == TextureFormat::k_5_6_5 || + format == TextureFormat::k_4_4_4_4) { + // Swap red and blue. + swizzle ^= (~swizzle & (1 | (1 << 3) | (1 << 6) | (1 << 9)) & + (swizzle_not_constant >> 2)) + << 1; + } else if (format == TextureFormat::k_DXT3A) { // DXT3A is emulated as DXT3 with zero color, but the alpha should be // replicated into all channels. // http://fileadmin.cs.lth.se/cs/Personal/Michael_Doggett/talks/unc-xenos-doggett.pdf