summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Khangaroo2018-08-09 12:57:13 -0400
committerGravatar bunnei2018-08-09 12:57:13 -0400
commit5cb6eceecfe1b631f8da5b41559076c8a880e26a (patch)
treef8f850ed708a247d35aa60ea7a25b979b616465c /src
parentMerge pull request #988 from lioncash/color (diff)
downloadyuzu-5cb6eceecfe1b631f8da5b41559076c8a880e26a.tar.gz
yuzu-5cb6eceecfe1b631f8da5b41559076c8a880e26a.tar.xz
yuzu-5cb6eceecfe1b631f8da5b41559076c8a880e26a.zip
Implement BC5/DXN2 (#996)
- Used by Kirby Star Allies.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp26
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h49
-rw-r--r--src/video_core/textures/decoders.cpp3
3 files changed, 45 insertions, 33 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 257aa9571..2e68dab11 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -109,6 +109,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
109 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 109 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
110 true}, // DXT45 110 true}, // DXT45
111 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1 111 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1
112 {GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN2
112 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 113 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
113 true}, // BC7U 114 true}, // BC7U
114 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 115 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
@@ -218,17 +219,17 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
218 MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>, 219 MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>,
219 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, 220 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
220 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, 221 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
221 MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, 222 MortonCopy<true, PixelFormat::DXN2>, MortonCopy<true, PixelFormat::BC7U>,
222 MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, 223 MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::G8R8>,
223 MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, 224 MortonCopy<true, PixelFormat::BGRA8>, MortonCopy<true, PixelFormat::RGBA32F>,
224 MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>, 225 MortonCopy<true, PixelFormat::RG32F>, MortonCopy<true, PixelFormat::R32F>,
225 MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::RG16>, 226 MortonCopy<true, PixelFormat::R16F>, MortonCopy<true, PixelFormat::R16UNORM>,
226 MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>, 227 MortonCopy<true, PixelFormat::RG16>, MortonCopy<true, PixelFormat::RG16F>,
227 MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>, 228 MortonCopy<true, PixelFormat::RG16UI>, MortonCopy<true, PixelFormat::RG16I>,
228 MortonCopy<true, PixelFormat::RGB32F>, MortonCopy<true, PixelFormat::SRGBA8>, 229 MortonCopy<true, PixelFormat::RG16S>, MortonCopy<true, PixelFormat::RGB32F>,
229 MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, 230 MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::Z24S8>,
230 MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, 231 MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>,
231 MortonCopy<true, PixelFormat::Z32FS8>, 232 MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32FS8>,
232}; 233};
233 234
234static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), 235static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@@ -242,7 +243,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
242 MortonCopy<false, PixelFormat::RGBA16F>, 243 MortonCopy<false, PixelFormat::RGBA16F>,
243 MortonCopy<false, PixelFormat::R11FG11FB10F>, 244 MortonCopy<false, PixelFormat::R11FG11FB10F>,
244 MortonCopy<false, PixelFormat::RGBA32UI>, 245 MortonCopy<false, PixelFormat::RGBA32UI>,
245 // TODO(Subv): Swizzling DXT1/DXT23/DXT45/DXN1/BC7U/ASTC_2D_4X4 formats is not supported 246 // TODO(Subv): Swizzling DXT1/DXT23/DXT45/DXN1/DXN2/BC7U/ASTC_2D_4X4 formats is not
247 // supported
246 nullptr, 248 nullptr,
247 nullptr, 249 nullptr,
248 nullptr, 250 nullptr,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 4168129f9..6f01b2bf0 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -35,31 +35,32 @@ struct SurfaceParams {
35 DXT23 = 9, 35 DXT23 = 9,
36 DXT45 = 10, 36 DXT45 = 10,
37 DXN1 = 11, // This is also known as BC4 37 DXN1 = 11, // This is also known as BC4
38 BC7U = 12, 38 DXN2 = 12, // This is also known as BC5
39 ASTC_2D_4X4 = 13, 39 BC7U = 13,
40 G8R8 = 14, 40 ASTC_2D_4X4 = 14,
41 BGRA8 = 15, 41 G8R8 = 15,
42 RGBA32F = 16, 42 BGRA8 = 16,
43 RG32F = 17, 43 RGBA32F = 17,
44 R32F = 18, 44 RG32F = 18,
45 R16F = 19, 45 R32F = 19,
46 R16UNORM = 20, 46 R16F = 20,
47 RG16 = 21, 47 R16UNORM = 21,
48 RG16F = 22, 48 RG16 = 22,
49 RG16UI = 23, 49 RG16F = 23,
50 RG16I = 24, 50 RG16UI = 24,
51 RG16S = 25, 51 RG16I = 25,
52 RGB32F = 26, 52 RG16S = 26,
53 SRGBA8 = 27, 53 RGB32F = 27,
54 SRGBA8 = 28,
54 55
55 MaxColorFormat, 56 MaxColorFormat,
56 57
57 // DepthStencil formats 58 // DepthStencil formats
58 Z24S8 = 28, 59 Z24S8 = 29,
59 S8Z24 = 29, 60 S8Z24 = 30,
60 Z32F = 30, 61 Z32F = 31,
61 Z16 = 31, 62 Z16 = 32,
62 Z32FS8 = 32, 63 Z32FS8 = 33,
63 64
64 MaxDepthStencilFormat, 65 MaxDepthStencilFormat,
65 66
@@ -109,6 +110,7 @@ struct SurfaceParams {
109 4, // DXT23 110 4, // DXT23
110 4, // DXT45 111 4, // DXT45
111 4, // DXN1 112 4, // DXN1
113 4, // DXN2
112 4, // BC7U 114 4, // BC7U
113 4, // ASTC_2D_4X4 115 4, // ASTC_2D_4X4
114 1, // G8R8 116 1, // G8R8
@@ -153,6 +155,7 @@ struct SurfaceParams {
153 128, // DXT23 155 128, // DXT23
154 128, // DXT45 156 128, // DXT45
155 64, // DXN1 157 64, // DXN1
158 128, // DXN2
156 128, // BC7U 159 128, // BC7U
157 32, // ASTC_2D_4X4 160 32, // ASTC_2D_4X4
158 16, // G8R8 161 16, // G8R8
@@ -305,6 +308,8 @@ struct SurfaceParams {
305 return PixelFormat::DXT45; 308 return PixelFormat::DXT45;
306 case Tegra::Texture::TextureFormat::DXN1: 309 case Tegra::Texture::TextureFormat::DXN1:
307 return PixelFormat::DXN1; 310 return PixelFormat::DXN1;
311 case Tegra::Texture::TextureFormat::DXN2:
312 return PixelFormat::DXN2;
308 case Tegra::Texture::TextureFormat::BC7U: 313 case Tegra::Texture::TextureFormat::BC7U:
309 return PixelFormat::BC7U; 314 return PixelFormat::BC7U;
310 case Tegra::Texture::TextureFormat::ASTC_2D_4X4: 315 case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
@@ -362,6 +367,8 @@ struct SurfaceParams {
362 return Tegra::Texture::TextureFormat::DXT45; 367 return Tegra::Texture::TextureFormat::DXT45;
363 case PixelFormat::DXN1: 368 case PixelFormat::DXN1:
364 return Tegra::Texture::TextureFormat::DXN1; 369 return Tegra::Texture::TextureFormat::DXN1;
370 case PixelFormat::DXN2:
371 return Tegra::Texture::TextureFormat::DXN2;
365 case PixelFormat::BC7U: 372 case PixelFormat::BC7U:
366 return Tegra::Texture::TextureFormat::BC7U; 373 return Tegra::Texture::TextureFormat::BC7U;
367 case PixelFormat::ASTC_2D_4X4: 374 case PixelFormat::ASTC_2D_4X4:
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 65db84ad3..7ea66584c 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -54,6 +54,7 @@ u32 BytesPerPixel(TextureFormat format) {
54 return 8; 54 return 8;
55 case TextureFormat::DXT23: 55 case TextureFormat::DXT23:
56 case TextureFormat::DXT45: 56 case TextureFormat::DXT45:
57 case TextureFormat::DXN2:
57 case TextureFormat::BC7U: 58 case TextureFormat::BC7U:
58 // In this case a 'pixel' actually refers to a 4x4 tile. 59 // In this case a 'pixel' actually refers to a 4x4 tile.
59 return 16; 60 return 16;
@@ -113,6 +114,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
113 case TextureFormat::DXT23: 114 case TextureFormat::DXT23:
114 case TextureFormat::DXT45: 115 case TextureFormat::DXT45:
115 case TextureFormat::DXN1: 116 case TextureFormat::DXN1:
117 case TextureFormat::DXN2:
116 case TextureFormat::BC7U: 118 case TextureFormat::BC7U:
117 // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel 119 // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel
118 // values. 120 // values.
@@ -179,6 +181,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
179 case TextureFormat::DXT23: 181 case TextureFormat::DXT23:
180 case TextureFormat::DXT45: 182 case TextureFormat::DXT45:
181 case TextureFormat::DXN1: 183 case TextureFormat::DXN1:
184 case TextureFormat::DXN2:
182 case TextureFormat::BC7U: 185 case TextureFormat::BC7U:
183 case TextureFormat::ASTC_2D_4X4: 186 case TextureFormat::ASTC_2D_4X4:
184 case TextureFormat::A8R8G8B8: 187 case TextureFormat::A8R8G8B8: