summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-07-04 17:22:48 -0500
committerGravatar Subv2018-07-07 09:17:48 -0500
commit4633dd9505e69fe03d6e1c704a53fa7a7d15b391 (patch)
tree4571c9577674aadb70f2bb0fad90f18581751f13 /src
parentMerge pull request #631 from lioncash/dynarmic (diff)
downloadyuzu-4633dd9505e69fe03d6e1c704a53fa7a7d15b391.tar.gz
yuzu-4633dd9505e69fe03d6e1c704a53fa7a7d15b391.tar.xz
yuzu-4633dd9505e69fe03d6e1c704a53fa7a7d15b391.zip
GPU: Implemented the BC7U texture format.
Note: Our version of glad exports GL_COMPRESSED_RGBA_BPTC_UNORM as GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, maybe it's time we update it.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp10
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h15
-rw-r--r--src/video_core/textures/decoders.cpp3
3 files changed, 21 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 57d7763ff..323ff7408 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -102,6 +102,8 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
102 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 102 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
103 true}, // DXT45 103 true}, // DXT45
104 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1 104 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1
105 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
106 true}, // BC7U
105 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 107 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
106 108
107 // DepthStencil formats 109 // DepthStencil formats
@@ -191,8 +193,9 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
191 MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>, 193 MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>,
192 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, 194 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
193 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, 195 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
194 MortonCopy<true, PixelFormat::ASTC_2D_4X4>, MortonCopy<true, PixelFormat::Z24S8>, 196 MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
195 MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, 197 MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>,
198 MortonCopy<true, PixelFormat::Z32F>,
196}; 199};
197 200
198static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), 201static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@@ -206,7 +209,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
206 MortonCopy<false, PixelFormat::RGBA16F>, 209 MortonCopy<false, PixelFormat::RGBA16F>,
207 MortonCopy<false, PixelFormat::R11FG11FB10F>, 210 MortonCopy<false, PixelFormat::R11FG11FB10F>,
208 MortonCopy<false, PixelFormat::RGBA32UI>, 211 MortonCopy<false, PixelFormat::RGBA32UI>,
209 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1 formats is not yet supported 212 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1/BC7U formats is not yet supported
213 nullptr,
210 nullptr, 214 nullptr,
211 nullptr, 215 nullptr,
212 nullptr, 216 nullptr,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index b4d7f8ebe..1bedae992 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -35,14 +35,15 @@ 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 ASTC_2D_4X4 = 12, 38 BC7U = 12,
39 ASTC_2D_4X4 = 13,
39 40
40 MaxColorFormat, 41 MaxColorFormat,
41 42
42 // DepthStencil formats 43 // DepthStencil formats
43 Z24S8 = 13, 44 Z24S8 = 14,
44 S8Z24 = 14, 45 S8Z24 = 15,
45 Z32F = 15, 46 Z32F = 16,
46 47
47 MaxDepthStencilFormat, 48 MaxDepthStencilFormat,
48 49
@@ -92,6 +93,7 @@ struct SurfaceParams {
92 4, // DXT23 93 4, // DXT23
93 4, // DXT45 94 4, // DXT45
94 4, // DXN1 95 4, // DXN1
96 4, // BC7U
95 4, // ASTC_2D_4X4 97 4, // ASTC_2D_4X4
96 1, // Z24S8 98 1, // Z24S8
97 1, // S8Z24 99 1, // S8Z24
@@ -119,6 +121,7 @@ struct SurfaceParams {
119 128, // DXT23 121 128, // DXT23
120 128, // DXT45 122 128, // DXT45
121 64, // DXN1 123 64, // DXN1
124 128, // BC7U
122 32, // ASTC_2D_4X4 125 32, // ASTC_2D_4X4
123 32, // Z24S8 126 32, // Z24S8
124 32, // S8Z24 127 32, // S8Z24
@@ -192,6 +195,8 @@ struct SurfaceParams {
192 return PixelFormat::DXT45; 195 return PixelFormat::DXT45;
193 case Tegra::Texture::TextureFormat::DXN1: 196 case Tegra::Texture::TextureFormat::DXN1:
194 return PixelFormat::DXN1; 197 return PixelFormat::DXN1;
198 case Tegra::Texture::TextureFormat::BC7U:
199 return PixelFormat::BC7U;
195 case Tegra::Texture::TextureFormat::ASTC_2D_4X4: 200 case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
196 return PixelFormat::ASTC_2D_4X4; 201 return PixelFormat::ASTC_2D_4X4;
197 default: 202 default:
@@ -227,6 +232,8 @@ struct SurfaceParams {
227 return Tegra::Texture::TextureFormat::DXT45; 232 return Tegra::Texture::TextureFormat::DXT45;
228 case PixelFormat::DXN1: 233 case PixelFormat::DXN1:
229 return Tegra::Texture::TextureFormat::DXN1; 234 return Tegra::Texture::TextureFormat::DXN1;
235 case PixelFormat::BC7U:
236 return Tegra::Texture::TextureFormat::BC7U;
230 case PixelFormat::ASTC_2D_4X4: 237 case PixelFormat::ASTC_2D_4X4:
231 return Tegra::Texture::TextureFormat::ASTC_2D_4X4; 238 return Tegra::Texture::TextureFormat::ASTC_2D_4X4;
232 default: 239 default:
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index d5ab4e4f9..b3937b2fe 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -52,6 +52,7 @@ u32 BytesPerPixel(TextureFormat format) {
52 return 8; 52 return 8;
53 case TextureFormat::DXT23: 53 case TextureFormat::DXT23:
54 case TextureFormat::DXT45: 54 case TextureFormat::DXT45:
55 case TextureFormat::BC7U:
55 // In this case a 'pixel' actually refers to a 4x4 tile. 56 // In this case a 'pixel' actually refers to a 4x4 tile.
56 return 16; 57 return 16;
57 case TextureFormat::ASTC_2D_4X4: 58 case TextureFormat::ASTC_2D_4X4:
@@ -98,6 +99,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
98 case TextureFormat::DXT23: 99 case TextureFormat::DXT23:
99 case TextureFormat::DXT45: 100 case TextureFormat::DXT45:
100 case TextureFormat::DXN1: 101 case TextureFormat::DXN1:
102 case TextureFormat::BC7U:
101 // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel 103 // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel
102 // values. 104 // values.
103 CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data, 105 CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data,
@@ -155,6 +157,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
155 case TextureFormat::DXT23: 157 case TextureFormat::DXT23:
156 case TextureFormat::DXT45: 158 case TextureFormat::DXT45:
157 case TextureFormat::DXN1: 159 case TextureFormat::DXN1:
160 case TextureFormat::BC7U:
158 case TextureFormat::ASTC_2D_4X4: 161 case TextureFormat::ASTC_2D_4X4:
159 case TextureFormat::A8R8G8B8: 162 case TextureFormat::A8R8G8B8:
160 case TextureFormat::A2B10G10R10: 163 case TextureFormat::A2B10G10R10: