summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp31
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h15
-rw-r--r--src/video_core/textures/decoders.cpp3
3 files changed, 40 insertions, 9 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 4efe20c70..c171c4c5b 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -105,6 +105,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
105 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 105 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
106 true}, // BC7U 106 true}, // BC7U
107 {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
108 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8
108 109
109 // DepthStencil formats 110 // DepthStencil formats
110 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, 111 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm,
@@ -196,8 +197,9 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
196 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, 197 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
197 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, 198 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
198 MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, 199 MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
199 MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, 200 MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::Z24S8>,
200 MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, 201 MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>,
202 MortonCopy<true, PixelFormat::Z16>,
201}; 203};
202 204
203static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), 205static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@@ -217,7 +219,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
217 nullptr, 219 nullptr,
218 nullptr, 220 nullptr,
219 nullptr, 221 nullptr,
220 MortonCopy<false, PixelFormat::ABGR8>, 222 nullptr,
223 MortonCopy<false, PixelFormat::G8R8>,
221 MortonCopy<false, PixelFormat::Z24S8>, 224 MortonCopy<false, PixelFormat::Z24S8>,
222 MortonCopy<false, PixelFormat::S8Z24>, 225 MortonCopy<false, PixelFormat::S8Z24>,
223 MortonCopy<false, PixelFormat::Z32F>, 226 MortonCopy<false, PixelFormat::Z32F>,
@@ -274,10 +277,10 @@ static void ConvertS8Z24ToZ24S8(std::vector<u8>& data, u32 width, u32 height) {
274 277
275 S8Z24 input_pixel{}; 278 S8Z24 input_pixel{};
276 Z24S8 output_pixel{}; 279 Z24S8 output_pixel{};
277 280 const auto bpp{CachedSurface::GetGLBytesPerPixel(PixelFormat::S8Z24)};
278 for (size_t y = 0; y < height; ++y) { 281 for (size_t y = 0; y < height; ++y) {
279 for (size_t x = 0; x < width; ++x) { 282 for (size_t x = 0; x < width; ++x) {
280 const size_t offset{4 * (y * width + x)}; 283 const size_t offset{bpp * (y * width + x)};
281 std::memcpy(&input_pixel, &data[offset], sizeof(S8Z24)); 284 std::memcpy(&input_pixel, &data[offset], sizeof(S8Z24));
282 output_pixel.s8.Assign(input_pixel.s8); 285 output_pixel.s8.Assign(input_pixel.s8);
283 output_pixel.z24.Assign(input_pixel.z24); 286 output_pixel.z24.Assign(input_pixel.z24);
@@ -285,6 +288,19 @@ static void ConvertS8Z24ToZ24S8(std::vector<u8>& data, u32 width, u32 height) {
285 } 288 }
286 } 289 }
287} 290}
291
292static void ConvertG8R8ToR8G8(std::vector<u8>& data, u32 width, u32 height) {
293 const auto bpp{CachedSurface::GetGLBytesPerPixel(PixelFormat::G8R8)};
294 for (size_t y = 0; y < height; ++y) {
295 for (size_t x = 0; x < width; ++x) {
296 const size_t offset{bpp * (y * width + x)};
297 const u8 temp{data[offset]};
298 data[offset] = data[offset + 1];
299 data[offset + 1] = temp;
300 }
301 }
302}
303
288/** 304/**
289 * Helper function to perform software conversion (as needed) when loading a buffer from Switch 305 * Helper function to perform software conversion (as needed) when loading a buffer from Switch
290 * memory. This is for Maxwell pixel formats that cannot be represented as-is in OpenGL or with 306 * memory. This is for Maxwell pixel formats that cannot be represented as-is in OpenGL or with
@@ -305,6 +321,11 @@ static void ConvertFormatAsNeeded_LoadGLBuffer(std::vector<u8>& data, PixelForma
305 // Convert the S8Z24 depth format to Z24S8, as OpenGL does not support S8Z24. 321 // Convert the S8Z24 depth format to Z24S8, as OpenGL does not support S8Z24.
306 ConvertS8Z24ToZ24S8(data, width, height); 322 ConvertS8Z24ToZ24S8(data, width, height);
307 break; 323 break;
324
325 case PixelFormat::G8R8:
326 // Convert the G8R8 color format to R8G8, as OpenGL does not support G8R8.
327 ConvertG8R8ToR8G8(data, width, height);
328 break;
308 } 329 }
309} 330}
310 331
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 0f5b1ff32..718c45ce1 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -37,14 +37,15 @@ struct SurfaceParams {
37 DXN1 = 11, // This is also known as BC4 37 DXN1 = 11, // This is also known as BC4
38 BC7U = 12, 38 BC7U = 12,
39 ASTC_2D_4X4 = 13, 39 ASTC_2D_4X4 = 13,
40 G8R8 = 14,
40 41
41 MaxColorFormat, 42 MaxColorFormat,
42 43
43 // DepthStencil formats 44 // DepthStencil formats
44 Z24S8 = 14, 45 Z24S8 = 15,
45 S8Z24 = 15, 46 S8Z24 = 16,
46 Z32F = 16, 47 Z32F = 17,
47 Z16 = 17, 48 Z16 = 18,
48 49
49 MaxDepthStencilFormat, 50 MaxDepthStencilFormat,
50 51
@@ -96,6 +97,7 @@ struct SurfaceParams {
96 4, // DXN1 97 4, // DXN1
97 4, // BC7U 98 4, // BC7U
98 4, // ASTC_2D_4X4 99 4, // ASTC_2D_4X4
100 1, // G8R8
99 1, // Z24S8 101 1, // Z24S8
100 1, // S8Z24 102 1, // S8Z24
101 1, // Z32F 103 1, // Z32F
@@ -125,6 +127,7 @@ struct SurfaceParams {
125 64, // DXN1 127 64, // DXN1
126 128, // BC7U 128 128, // BC7U
127 32, // ASTC_2D_4X4 129 32, // ASTC_2D_4X4
130 16, // G8R8
128 32, // Z24S8 131 32, // Z24S8
129 32, // S8Z24 132 32, // S8Z24
130 32, // Z32F 133 32, // Z32F
@@ -186,6 +189,8 @@ struct SurfaceParams {
186 return PixelFormat::A1B5G5R5; 189 return PixelFormat::A1B5G5R5;
187 case Tegra::Texture::TextureFormat::R8: 190 case Tegra::Texture::TextureFormat::R8:
188 return PixelFormat::R8; 191 return PixelFormat::R8;
192 case Tegra::Texture::TextureFormat::G8R8:
193 return PixelFormat::G8R8;
189 case Tegra::Texture::TextureFormat::R16_G16_B16_A16: 194 case Tegra::Texture::TextureFormat::R16_G16_B16_A16:
190 return PixelFormat::RGBA16F; 195 return PixelFormat::RGBA16F;
191 case Tegra::Texture::TextureFormat::BF10GF11RF11: 196 case Tegra::Texture::TextureFormat::BF10GF11RF11:
@@ -223,6 +228,8 @@ struct SurfaceParams {
223 return Tegra::Texture::TextureFormat::A1B5G5R5; 228 return Tegra::Texture::TextureFormat::A1B5G5R5;
224 case PixelFormat::R8: 229 case PixelFormat::R8:
225 return Tegra::Texture::TextureFormat::R8; 230 return Tegra::Texture::TextureFormat::R8;
231 case PixelFormat::G8R8:
232 return Tegra::Texture::TextureFormat::G8R8;
226 case PixelFormat::RGBA16F: 233 case PixelFormat::RGBA16F:
227 return Tegra::Texture::TextureFormat::R16_G16_B16_A16; 234 return Tegra::Texture::TextureFormat::R16_G16_B16_A16;
228 case PixelFormat::R11FG11FB10F: 235 case PixelFormat::R11FG11FB10F:
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index a4ba9f66a..be18aa299 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -62,6 +62,7 @@ u32 BytesPerPixel(TextureFormat format) {
62 return 4; 62 return 4;
63 case TextureFormat::A1B5G5R5: 63 case TextureFormat::A1B5G5R5:
64 case TextureFormat::B5G6R5: 64 case TextureFormat::B5G6R5:
65 case TextureFormat::G8R8:
65 return 2; 66 return 2;
66 case TextureFormat::R8: 67 case TextureFormat::R8:
67 return 1; 68 return 1;
@@ -112,6 +113,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
112 case TextureFormat::A1B5G5R5: 113 case TextureFormat::A1B5G5R5:
113 case TextureFormat::B5G6R5: 114 case TextureFormat::B5G6R5:
114 case TextureFormat::R8: 115 case TextureFormat::R8:
116 case TextureFormat::G8R8:
115 case TextureFormat::R16_G16_B16_A16: 117 case TextureFormat::R16_G16_B16_A16:
116 case TextureFormat::R32_G32_B32_A32: 118 case TextureFormat::R32_G32_B32_A32:
117 case TextureFormat::BF10GF11RF11: 119 case TextureFormat::BF10GF11RF11:
@@ -167,6 +169,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
167 case TextureFormat::A1B5G5R5: 169 case TextureFormat::A1B5G5R5:
168 case TextureFormat::B5G6R5: 170 case TextureFormat::B5G6R5:
169 case TextureFormat::R8: 171 case TextureFormat::R8:
172 case TextureFormat::G8R8:
170 case TextureFormat::BF10GF11RF11: 173 case TextureFormat::BF10GF11RF11:
171 case TextureFormat::R32_G32_B32_A32: 174 case TextureFormat::R32_G32_B32_A32:
172 // TODO(Subv): For the time being just forward the same data without any decoding. 175 // TODO(Subv): For the time being just forward the same data without any decoding.