summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp11
-rw-r--r--src/video_core/textures/decoders.cpp9
-rw-r--r--src/video_core/textures/decoders.h3
-rw-r--r--src/video_core/textures/texture.h7
4 files changed, 23 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 213b20a21..9d005936d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -1041,9 +1041,18 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextu
1041 params.height = config.tic.Height(); 1041 params.height = config.tic.Height();
1042 params.is_tiled = config.tic.IsTiled(); 1042 params.is_tiled = config.tic.IsTiled();
1043 params.pixel_format = SurfaceParams::PixelFormatFromTextureFormat(config.tic.format); 1043 params.pixel_format = SurfaceParams::PixelFormatFromTextureFormat(config.tic.format);
1044
1045 if (config.tic.IsTiled()) {
1046 params.block_height = config.tic.BlockHeight();
1047 } else {
1048 // Use the texture-provided stride value if the texture isn't tiled.
1049 params.stride = params.PixelsInBytes(config.tic.Pitch());
1050 }
1051
1044 params.UpdateParams(); 1052 params.UpdateParams();
1045 1053
1046 if (config.tic.Width() % 8 != 0 || config.tic.Height() % 8 != 0) { 1054 if (config.tic.Width() % 8 != 0 || config.tic.Height() % 8 != 0 ||
1055 params.stride != params.width) {
1047 Surface src_surface; 1056 Surface src_surface;
1048 MathUtil::Rectangle<u32> rect; 1057 MathUtil::Rectangle<u32> rect;
1049 std::tie(src_surface, rect) = GetSurfaceSubRect(params, ScaleMatch::Ignore, true); 1058 std::tie(src_surface, rect) = GetSurfaceSubRect(params, ScaleMatch::Ignore, true);
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 2e87281eb..9c2a10d2e 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -56,23 +56,22 @@ u32 BytesPerPixel(TextureFormat format) {
56 } 56 }
57} 57}
58 58
59std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height) { 59std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height,
60 u32 block_height) {
60 u8* data = Memory::GetPointer(address); 61 u8* data = Memory::GetPointer(address);
61 u32 bytes_per_pixel = BytesPerPixel(format); 62 u32 bytes_per_pixel = BytesPerPixel(format);
62 63
63 static constexpr u32 DefaultBlockHeight = 16;
64
65 std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); 64 std::vector<u8> unswizzled_data(width * height * bytes_per_pixel);
66 65
67 switch (format) { 66 switch (format) {
68 case TextureFormat::DXT1: 67 case TextureFormat::DXT1:
69 // In the DXT1 format, each 4x4 tile is swizzled instead of just individual pixel values. 68 // In the DXT1 format, each 4x4 tile is swizzled instead of just individual pixel values.
70 CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data, 69 CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data,
71 unswizzled_data.data(), true, DefaultBlockHeight); 70 unswizzled_data.data(), true, block_height);
72 break; 71 break;
73 case TextureFormat::A8R8G8B8: 72 case TextureFormat::A8R8G8B8:
74 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, 73 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
75 unswizzled_data.data(), true, DefaultBlockHeight); 74 unswizzled_data.data(), true, block_height);
76 break; 75 break;
77 default: 76 default:
78 UNIMPLEMENTED_MSG("Format not implemented"); 77 UNIMPLEMENTED_MSG("Format not implemented");
diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h
index 0c21694ff..a700911cf 100644
--- a/src/video_core/textures/decoders.h
+++ b/src/video_core/textures/decoders.h
@@ -14,7 +14,8 @@ namespace Texture {
14/** 14/**
15 * Unswizzles a swizzled texture without changing its format. 15 * Unswizzles a swizzled texture without changing its format.
16 */ 16 */
17std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height); 17std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height,
18 u32 block_height = TICEntry::DefaultBlockHeight);
18 19
19/** 20/**
20 * Decodes an unswizzled texture into a A8R8G8B8 texture. 21 * Decodes an unswizzled texture into a A8R8G8B8 texture.
diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h
index 58cbb2115..09d2317e0 100644
--- a/src/video_core/textures/texture.h
+++ b/src/video_core/textures/texture.h
@@ -105,6 +105,13 @@ struct TICEntry {
105 return height_minus_1 + 1; 105 return height_minus_1 + 1;
106 } 106 }
107 107
108 u32 BlockHeight() const {
109 ASSERT(header_version == TICHeaderVersion::BlockLinear ||
110 header_version == TICHeaderVersion::BlockLinearColorKey);
111 // The block height is stored in log2 format.
112 return 1 << block_height;
113 }
114
108 bool IsTiled() const { 115 bool IsTiled() const {
109 return header_version == TICHeaderVersion::BlockLinear || 116 return header_version == TICHeaderVersion::BlockLinear ||
110 header_version == TICHeaderVersion::BlockLinearColorKey; 117 header_version == TICHeaderVersion::BlockLinearColorKey;