summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-06-02 13:17:09 -0500
committerGravatar Subv2018-06-02 13:17:09 -0500
commit99f9d47d16aaa943d952ab4b0a46837b2685aed2 (patch)
tree64bdd12bc324acbeb7073e688e50bf641413da40 /src
parentMerge pull request #492 from mailwl/time (diff)
downloadyuzu-99f9d47d16aaa943d952ab4b0a46837b2685aed2.tar.gz
yuzu-99f9d47d16aaa943d952ab4b0a46837b2685aed2.tar.xz
yuzu-99f9d47d16aaa943d952ab4b0a46837b2685aed2.zip
GPU: Implemented the DXN1 (BC4) texture format.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h7
-rw-r--r--src/video_core/textures/decoders.cpp6
3 files changed, 16 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 10a460a82..65d643447 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -53,6 +53,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
53 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1 53 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1
54 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23 54 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23
55 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45 55 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45
56 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, true}, // DXN1
56}}; 57}};
57 58
58static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) { 59static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) {
@@ -113,7 +114,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
113 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>, 114 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>,
114 MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>, 115 MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>,
115 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, 116 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
116 MortonCopy<true, PixelFormat::DXT45>, 117 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
117}; 118};
118 119
119static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr, 120static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr,
@@ -126,7 +127,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
126 MortonCopy<false, PixelFormat::A1B5G5R5>, 127 MortonCopy<false, PixelFormat::A1B5G5R5>,
127 MortonCopy<false, PixelFormat::R8>, 128 MortonCopy<false, PixelFormat::R8>,
128 MortonCopy<false, PixelFormat::RGBA16F>, 129 MortonCopy<false, PixelFormat::RGBA16F>,
129 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45 formats is not yet supported 130 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1 formats is not yet supported
131 nullptr,
130 nullptr, 132 nullptr,
131 nullptr, 133 nullptr,
132 nullptr, 134 nullptr,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 07461017d..6f08678ab 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -63,6 +63,7 @@ struct SurfaceParams {
63 DXT1 = 6, 63 DXT1 = 6,
64 DXT23 = 7, 64 DXT23 = 7,
65 DXT45 = 8, 65 DXT45 = 8,
66 DXN1 = 9, // This is also known as BC4
66 67
67 Max, 68 Max,
68 Invalid = 255, 69 Invalid = 255,
@@ -107,6 +108,7 @@ struct SurfaceParams {
107 4, // DXT1 108 4, // DXT1
108 4, // DXT23 109 4, // DXT23
109 4, // DXT45 110 4, // DXT45
111 4, // DXN1
110 }}; 112 }};
111 113
112 ASSERT(static_cast<size_t>(format) < compression_factor_table.size()); 114 ASSERT(static_cast<size_t>(format) < compression_factor_table.size());
@@ -130,6 +132,7 @@ struct SurfaceParams {
130 64, // DXT1 132 64, // DXT1
131 128, // DXT23 133 128, // DXT23
132 128, // DXT45 134 128, // DXT45
135 64, // DXN1
133 }}; 136 }};
134 137
135 ASSERT(static_cast<size_t>(format) < bpp_table.size()); 138 ASSERT(static_cast<size_t>(format) < bpp_table.size());
@@ -185,6 +188,8 @@ struct SurfaceParams {
185 return PixelFormat::DXT23; 188 return PixelFormat::DXT23;
186 case Tegra::Texture::TextureFormat::DXT45: 189 case Tegra::Texture::TextureFormat::DXT45:
187 return PixelFormat::DXT45; 190 return PixelFormat::DXT45;
191 case Tegra::Texture::TextureFormat::DXN1:
192 return PixelFormat::DXN1;
188 default: 193 default:
189 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 194 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
190 UNREACHABLE(); 195 UNREACHABLE();
@@ -212,6 +217,8 @@ struct SurfaceParams {
212 return Tegra::Texture::TextureFormat::DXT23; 217 return Tegra::Texture::TextureFormat::DXT23;
213 case PixelFormat::DXT45: 218 case PixelFormat::DXT45:
214 return Tegra::Texture::TextureFormat::DXT45; 219 return Tegra::Texture::TextureFormat::DXT45;
220 case PixelFormat::DXN1:
221 return Tegra::Texture::TextureFormat::DXN1;
215 default: 222 default:
216 UNREACHABLE(); 223 UNREACHABLE();
217 } 224 }
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 0179663e8..2d2af5554 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -46,6 +46,7 @@ void CopySwizzledData(u32 width, u32 height, u32 bytes_per_pixel, u32 out_bytes_
46u32 BytesPerPixel(TextureFormat format) { 46u32 BytesPerPixel(TextureFormat format) {
47 switch (format) { 47 switch (format) {
48 case TextureFormat::DXT1: 48 case TextureFormat::DXT1:
49 case TextureFormat::DXN1:
49 // In this case a 'pixel' actually refers to a 4x4 tile. 50 // In this case a 'pixel' actually refers to a 4x4 tile.
50 return 8; 51 return 8;
51 case TextureFormat::DXT23: 52 case TextureFormat::DXT23:
@@ -79,7 +80,9 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
79 case TextureFormat::DXT1: 80 case TextureFormat::DXT1:
80 case TextureFormat::DXT23: 81 case TextureFormat::DXT23:
81 case TextureFormat::DXT45: 82 case TextureFormat::DXT45:
82 // In the DXT formats, each 4x4 tile is swizzled instead of just individual pixel values. 83 case TextureFormat::DXN1:
84 // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel
85 // values.
83 CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data, 86 CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data,
84 unswizzled_data.data(), true, block_height); 87 unswizzled_data.data(), true, block_height);
85 break; 88 break;
@@ -109,6 +112,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
109 case TextureFormat::DXT1: 112 case TextureFormat::DXT1:
110 case TextureFormat::DXT23: 113 case TextureFormat::DXT23:
111 case TextureFormat::DXT45: 114 case TextureFormat::DXT45:
115 case TextureFormat::DXN1:
112 case TextureFormat::A8R8G8B8: 116 case TextureFormat::A8R8G8B8:
113 case TextureFormat::A2B10G10R10: 117 case TextureFormat::A2B10G10R10:
114 case TextureFormat::A1B5G5R5: 118 case TextureFormat::A1B5G5R5: