summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp44
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h159
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp35
-rw-r--r--src/video_core/renderer_opengl/maxwell_to_gl.h25
5 files changed, 173 insertions, 96 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 52a649e2f..9d1549fe9 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -648,11 +648,11 @@ std::tuple<u8*, GLintptr, u32> RasterizerOpenGL::SetupConstBuffers(
648 648
649 if (used_buffer.IsIndirect()) { 649 if (used_buffer.IsIndirect()) {
650 // Buffer is accessed indirectly, so upload the entire thing 650 // Buffer is accessed indirectly, so upload the entire thing
651 size = buffer.size * sizeof(float); 651 size = buffer.size;
652 652
653 if (size > MaxConstbufferSize) { 653 if (size > MaxConstbufferSize) {
654 LOG_ERROR(HW_GPU, "indirect constbuffer size {} exceeds maximum {}", size, 654 LOG_CRITICAL(HW_GPU, "indirect constbuffer size {} exceeds maximum {}", size,
655 MaxConstbufferSize); 655 MaxConstbufferSize);
656 size = MaxConstbufferSize; 656 size = MaxConstbufferSize;
657 } 657 }
658 } else { 658 } else {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 5d58ebd4f..b6947b97b 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -94,11 +94,11 @@ struct FormatTuple {
94static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ 94static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{
95 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // ABGR8U 95 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // ABGR8U
96 {GL_RGBA8, GL_RGBA, GL_BYTE, ComponentType::SNorm, false}, // ABGR8S 96 {GL_RGBA8, GL_RGBA, GL_BYTE, ComponentType::SNorm, false}, // ABGR8S
97 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, ComponentType::UNorm, false}, // B5G6R5 97 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, ComponentType::UNorm, false}, // B5G6R5U
98 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, ComponentType::UNorm, 98 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, ComponentType::UNorm,
99 false}, // A2B10G10R10 99 false}, // A2B10G10R10U
100 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, ComponentType::UNorm, false}, // A1B5G5R5 100 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, ComponentType::UNorm, false}, // A1B5G5R5U
101 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // R8 101 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // R8U
102 {GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, ComponentType::UInt, false}, // R8UI 102 {GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, ComponentType::UInt, false}, // R8UI
103 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, ComponentType::Float, false}, // RGBA16F 103 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, ComponentType::Float, false}, // RGBA16F
104 {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RGBA16U 104 {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RGBA16U
@@ -119,13 +119,14 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
119 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 119 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
120 true}, // BC7U 120 true}, // BC7U
121 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 121 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
122 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8 122 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8U
123 {GL_RG8, GL_RG, GL_BYTE, ComponentType::SNorm, false}, // G8R8S
123 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 124 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
124 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F 125 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F
125 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F 126 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F
126 {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F 127 {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F
127 {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F 128 {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F
128 {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM 129 {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16U
129 {GL_R16_SNORM, GL_RED, GL_SHORT, ComponentType::SNorm, false}, // R16S 130 {GL_R16_SNORM, GL_RED, GL_SHORT, ComponentType::SNorm, false}, // R16S
130 {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // R16UI 131 {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // R16UI
131 {GL_R16I, GL_RED_INTEGER, GL_SHORT, ComponentType::SInt, false}, // R16I 132 {GL_R16I, GL_RED_INTEGER, GL_SHORT, ComponentType::SInt, false}, // R16I
@@ -242,10 +243,10 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU
242 // clang-format off 243 // clang-format off
243 MortonCopy<true, PixelFormat::ABGR8U>, 244 MortonCopy<true, PixelFormat::ABGR8U>,
244 MortonCopy<true, PixelFormat::ABGR8S>, 245 MortonCopy<true, PixelFormat::ABGR8S>,
245 MortonCopy<true, PixelFormat::B5G6R5>, 246 MortonCopy<true, PixelFormat::B5G6R5U>,
246 MortonCopy<true, PixelFormat::A2B10G10R10>, 247 MortonCopy<true, PixelFormat::A2B10G10R10U>,
247 MortonCopy<true, PixelFormat::A1B5G5R5>, 248 MortonCopy<true, PixelFormat::A1B5G5R5U>,
248 MortonCopy<true, PixelFormat::R8>, 249 MortonCopy<true, PixelFormat::R8U>,
249 MortonCopy<true, PixelFormat::R8UI>, 250 MortonCopy<true, PixelFormat::R8UI>,
250 MortonCopy<true, PixelFormat::RGBA16F>, 251 MortonCopy<true, PixelFormat::RGBA16F>,
251 MortonCopy<true, PixelFormat::RGBA16U>, 252 MortonCopy<true, PixelFormat::RGBA16U>,
@@ -260,13 +261,14 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU
260 MortonCopy<true, PixelFormat::DXN2SNORM>, 261 MortonCopy<true, PixelFormat::DXN2SNORM>,
261 MortonCopy<true, PixelFormat::BC7U>, 262 MortonCopy<true, PixelFormat::BC7U>,
262 MortonCopy<true, PixelFormat::ASTC_2D_4X4>, 263 MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
263 MortonCopy<true, PixelFormat::G8R8>, 264 MortonCopy<true, PixelFormat::G8R8U>,
265 MortonCopy<true, PixelFormat::G8R8S>,
264 MortonCopy<true, PixelFormat::BGRA8>, 266 MortonCopy<true, PixelFormat::BGRA8>,
265 MortonCopy<true, PixelFormat::RGBA32F>, 267 MortonCopy<true, PixelFormat::RGBA32F>,
266 MortonCopy<true, PixelFormat::RG32F>, 268 MortonCopy<true, PixelFormat::RG32F>,
267 MortonCopy<true, PixelFormat::R32F>, 269 MortonCopy<true, PixelFormat::R32F>,
268 MortonCopy<true, PixelFormat::R16F>, 270 MortonCopy<true, PixelFormat::R16F>,
269 MortonCopy<true, PixelFormat::R16UNORM>, 271 MortonCopy<true, PixelFormat::R16U>,
270 MortonCopy<true, PixelFormat::R16S>, 272 MortonCopy<true, PixelFormat::R16S>,
271 MortonCopy<true, PixelFormat::R16UI>, 273 MortonCopy<true, PixelFormat::R16UI>,
272 MortonCopy<true, PixelFormat::R16I>, 274 MortonCopy<true, PixelFormat::R16I>,
@@ -295,10 +297,10 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU
295 // clang-format off 297 // clang-format off
296 MortonCopy<false, PixelFormat::ABGR8U>, 298 MortonCopy<false, PixelFormat::ABGR8U>,
297 MortonCopy<false, PixelFormat::ABGR8S>, 299 MortonCopy<false, PixelFormat::ABGR8S>,
298 MortonCopy<false, PixelFormat::B5G6R5>, 300 MortonCopy<false, PixelFormat::B5G6R5U>,
299 MortonCopy<false, PixelFormat::A2B10G10R10>, 301 MortonCopy<false, PixelFormat::A2B10G10R10U>,
300 MortonCopy<false, PixelFormat::A1B5G5R5>, 302 MortonCopy<false, PixelFormat::A1B5G5R5U>,
301 MortonCopy<false, PixelFormat::R8>, 303 MortonCopy<false, PixelFormat::R8U>,
302 MortonCopy<false, PixelFormat::R8UI>, 304 MortonCopy<false, PixelFormat::R8UI>,
303 MortonCopy<false, PixelFormat::RGBA16F>, 305 MortonCopy<false, PixelFormat::RGBA16F>,
304 MortonCopy<false, PixelFormat::RGBA16U>, 306 MortonCopy<false, PixelFormat::RGBA16U>,
@@ -315,13 +317,14 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU
315 nullptr, 317 nullptr,
316 nullptr, 318 nullptr,
317 nullptr, 319 nullptr,
318 MortonCopy<false, PixelFormat::G8R8>, 320 MortonCopy<false, PixelFormat::G8R8U>,
321 MortonCopy<false, PixelFormat::G8R8S>,
319 MortonCopy<false, PixelFormat::BGRA8>, 322 MortonCopy<false, PixelFormat::BGRA8>,
320 MortonCopy<false, PixelFormat::RGBA32F>, 323 MortonCopy<false, PixelFormat::RGBA32F>,
321 MortonCopy<false, PixelFormat::RG32F>, 324 MortonCopy<false, PixelFormat::RG32F>,
322 MortonCopy<false, PixelFormat::R32F>, 325 MortonCopy<false, PixelFormat::R32F>,
323 MortonCopy<false, PixelFormat::R16F>, 326 MortonCopy<false, PixelFormat::R16F>,
324 MortonCopy<false, PixelFormat::R16UNORM>, 327 MortonCopy<false, PixelFormat::R16U>,
325 MortonCopy<false, PixelFormat::R16S>, 328 MortonCopy<false, PixelFormat::R16S>,
326 MortonCopy<false, PixelFormat::R16UI>, 329 MortonCopy<false, PixelFormat::R16UI>,
327 MortonCopy<false, PixelFormat::R16I>, 330 MortonCopy<false, PixelFormat::R16I>,
@@ -461,7 +464,7 @@ static void ConvertS8Z24ToZ24S8(std::vector<u8>& data, u32 width, u32 height) {
461} 464}
462 465
463static void ConvertG8R8ToR8G8(std::vector<u8>& data, u32 width, u32 height) { 466static void ConvertG8R8ToR8G8(std::vector<u8>& data, u32 width, u32 height) {
464 const auto bpp{CachedSurface::GetGLBytesPerPixel(PixelFormat::G8R8)}; 467 const auto bpp{CachedSurface::GetGLBytesPerPixel(PixelFormat::G8R8U)};
465 for (size_t y = 0; y < height; ++y) { 468 for (size_t y = 0; y < height; ++y) {
466 for (size_t x = 0; x < width; ++x) { 469 for (size_t x = 0; x < width; ++x) {
467 const size_t offset{bpp * (y * width + x)}; 470 const size_t offset{bpp * (y * width + x)};
@@ -493,7 +496,8 @@ static void ConvertFormatAsNeeded_LoadGLBuffer(std::vector<u8>& data, PixelForma
493 ConvertS8Z24ToZ24S8(data, width, height); 496 ConvertS8Z24ToZ24S8(data, width, height);
494 break; 497 break;
495 498
496 case PixelFormat::G8R8: 499 case PixelFormat::G8R8U:
500 case PixelFormat::G8R8S:
497 // Convert the G8R8 color format to R8G8, as OpenGL does not support G8R8. 501 // Convert the G8R8 color format to R8G8, as OpenGL does not support G8R8.
498 ConvertG8R8ToR8G8(data, width, height); 502 ConvertG8R8ToR8G8(data, width, height);
499 break; 503 break;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 0de87d8c2..55cf3782c 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -25,10 +25,10 @@ struct SurfaceParams {
25 enum class PixelFormat { 25 enum class PixelFormat {
26 ABGR8U = 0, 26 ABGR8U = 0,
27 ABGR8S = 1, 27 ABGR8S = 1,
28 B5G6R5 = 2, 28 B5G6R5U = 2,
29 A2B10G10R10 = 3, 29 A2B10G10R10U = 3,
30 A1B5G5R5 = 4, 30 A1B5G5R5U = 4,
31 R8 = 5, 31 R8U = 5,
32 R8UI = 6, 32 R8UI = 6,
33 RGBA16F = 7, 33 RGBA16F = 7,
34 RGBA16U = 8, 34 RGBA16U = 8,
@@ -43,36 +43,37 @@ struct SurfaceParams {
43 DXN2SNORM = 17, 43 DXN2SNORM = 17,
44 BC7U = 18, 44 BC7U = 18,
45 ASTC_2D_4X4 = 19, 45 ASTC_2D_4X4 = 19,
46 G8R8 = 20, 46 G8R8U = 20,
47 BGRA8 = 21, 47 G8R8S = 21,
48 RGBA32F = 22, 48 BGRA8 = 22,
49 RG32F = 23, 49 RGBA32F = 23,
50 R32F = 24, 50 RG32F = 24,
51 R16F = 25, 51 R32F = 25,
52 R16UNORM = 26, 52 R16F = 26,
53 R16S = 27, 53 R16U = 27,
54 R16UI = 28, 54 R16S = 28,
55 R16I = 29, 55 R16UI = 29,
56 RG16 = 30, 56 R16I = 30,
57 RG16F = 31, 57 RG16 = 31,
58 RG16UI = 32, 58 RG16F = 32,
59 RG16I = 33, 59 RG16UI = 33,
60 RG16S = 34, 60 RG16I = 34,
61 RGB32F = 35, 61 RG16S = 35,
62 SRGBA8 = 36, 62 RGB32F = 36,
63 RG8U = 37, 63 SRGBA8 = 37,
64 RG8S = 38, 64 RG8U = 38,
65 RG32UI = 39, 65 RG8S = 39,
66 R32UI = 40, 66 RG32UI = 40,
67 R32UI = 41,
67 68
68 MaxColorFormat, 69 MaxColorFormat,
69 70
70 // DepthStencil formats 71 // DepthStencil formats
71 Z24S8 = 41, 72 Z24S8 = 42,
72 S8Z24 = 42, 73 S8Z24 = 43,
73 Z32F = 43, 74 Z32F = 44,
74 Z16 = 44, 75 Z16 = 45,
75 Z32FS8 = 45, 76 Z32FS8 = 46,
76 77
77 MaxDepthStencilFormat, 78 MaxDepthStencilFormat,
78 79
@@ -112,10 +113,10 @@ struct SurfaceParams {
112 constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{ 113 constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{
113 1, // ABGR8U 114 1, // ABGR8U
114 1, // ABGR8S 115 1, // ABGR8S
115 1, // B5G6R5 116 1, // B5G6R5U
116 1, // A2B10G10R10 117 1, // A2B10G10R10U
117 1, // A1B5G5R5 118 1, // A1B5G5R5U
118 1, // R8 119 1, // R8U
119 1, // R8UI 120 1, // R8UI
120 1, // RGBA16F 121 1, // RGBA16F
121 1, // RGBA16U 122 1, // RGBA16U
@@ -130,13 +131,14 @@ struct SurfaceParams {
130 4, // DXN2SNORM 131 4, // DXN2SNORM
131 4, // BC7U 132 4, // BC7U
132 4, // ASTC_2D_4X4 133 4, // ASTC_2D_4X4
133 1, // G8R8 134 1, // G8R8U
135 1, // G8R8S
134 1, // BGRA8 136 1, // BGRA8
135 1, // RGBA32F 137 1, // RGBA32F
136 1, // RG32F 138 1, // RG32F
137 1, // R32F 139 1, // R32F
138 1, // R16F 140 1, // R16F
139 1, // R16UNORM 141 1, // R16U
140 1, // R16S 142 1, // R16S
141 1, // R16UI 143 1, // R16UI
142 1, // R16I 144 1, // R16I
@@ -169,10 +171,10 @@ struct SurfaceParams {
169 constexpr std::array<u32, MaxPixelFormat> bpp_table = {{ 171 constexpr std::array<u32, MaxPixelFormat> bpp_table = {{
170 32, // ABGR8U 172 32, // ABGR8U
171 32, // ABGR8S 173 32, // ABGR8S
172 16, // B5G6R5 174 16, // B5G6R5U
173 32, // A2B10G10R10 175 32, // A2B10G10R10U
174 16, // A1B5G5R5 176 16, // A1B5G5R5U
175 8, // R8 177 8, // R8U
176 8, // R8UI 178 8, // R8UI
177 64, // RGBA16F 179 64, // RGBA16F
178 64, // RGBA16U 180 64, // RGBA16U
@@ -187,13 +189,14 @@ struct SurfaceParams {
187 128, // DXN2SNORM 189 128, // DXN2SNORM
188 128, // BC7U 190 128, // BC7U
189 32, // ASTC_2D_4X4 191 32, // ASTC_2D_4X4
190 16, // G8R8 192 16, // G8R8U
193 16, // G8R8S
191 32, // BGRA8 194 32, // BGRA8
192 128, // RGBA32F 195 128, // RGBA32F
193 64, // RG32F 196 64, // RG32F
194 32, // R32F 197 32, // R32F
195 16, // R16F 198 16, // R16F
196 16, // R16UNORM 199 16, // R16U
197 16, // R16S 200 16, // R16S
198 16, // R16UI 201 16, // R16UI
199 16, // R16I 202 16, // R16I
@@ -253,7 +256,7 @@ struct SurfaceParams {
253 case Tegra::RenderTargetFormat::BGRA8_UNORM: 256 case Tegra::RenderTargetFormat::BGRA8_UNORM:
254 return PixelFormat::BGRA8; 257 return PixelFormat::BGRA8;
255 case Tegra::RenderTargetFormat::RGB10_A2_UNORM: 258 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
256 return PixelFormat::A2B10G10R10; 259 return PixelFormat::A2B10G10R10U;
257 case Tegra::RenderTargetFormat::RGBA16_FLOAT: 260 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
258 return PixelFormat::RGBA16F; 261 return PixelFormat::RGBA16F;
259 case Tegra::RenderTargetFormat::RGBA16_UNORM: 262 case Tegra::RenderTargetFormat::RGBA16_UNORM:
@@ -267,11 +270,11 @@ struct SurfaceParams {
267 case Tegra::RenderTargetFormat::R11G11B10_FLOAT: 270 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
268 return PixelFormat::R11FG11FB10F; 271 return PixelFormat::R11FG11FB10F;
269 case Tegra::RenderTargetFormat::B5G6R5_UNORM: 272 case Tegra::RenderTargetFormat::B5G6R5_UNORM:
270 return PixelFormat::B5G6R5; 273 return PixelFormat::B5G6R5U;
271 case Tegra::RenderTargetFormat::RGBA32_UINT: 274 case Tegra::RenderTargetFormat::RGBA32_UINT:
272 return PixelFormat::RGBA32UI; 275 return PixelFormat::RGBA32UI;
273 case Tegra::RenderTargetFormat::R8_UNORM: 276 case Tegra::RenderTargetFormat::R8_UNORM:
274 return PixelFormat::R8; 277 return PixelFormat::R8U;
275 case Tegra::RenderTargetFormat::R8_UINT: 278 case Tegra::RenderTargetFormat::R8_UINT:
276 return PixelFormat::R8UI; 279 return PixelFormat::R8UI;
277 case Tegra::RenderTargetFormat::RG16_FLOAT: 280 case Tegra::RenderTargetFormat::RG16_FLOAT:
@@ -291,7 +294,7 @@ struct SurfaceParams {
291 case Tegra::RenderTargetFormat::R16_FLOAT: 294 case Tegra::RenderTargetFormat::R16_FLOAT:
292 return PixelFormat::R16F; 295 return PixelFormat::R16F;
293 case Tegra::RenderTargetFormat::R16_UNORM: 296 case Tegra::RenderTargetFormat::R16_UNORM:
294 return PixelFormat::R16UNORM; 297 return PixelFormat::R16U;
295 case Tegra::RenderTargetFormat::R16_SNORM: 298 case Tegra::RenderTargetFormat::R16_SNORM:
296 return PixelFormat::R16S; 299 return PixelFormat::R16S;
297 case Tegra::RenderTargetFormat::R16_UINT: 300 case Tegra::RenderTargetFormat::R16_UINT:
@@ -325,15 +328,33 @@ struct SurfaceParams {
325 static_cast<u32>(component_type)); 328 static_cast<u32>(component_type));
326 UNREACHABLE(); 329 UNREACHABLE();
327 case Tegra::Texture::TextureFormat::B5G6R5: 330 case Tegra::Texture::TextureFormat::B5G6R5:
328 return PixelFormat::B5G6R5; 331 switch (component_type) {
332 case Tegra::Texture::ComponentType::UNORM:
333 return PixelFormat::B5G6R5U;
334 }
335 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
336 static_cast<u32>(component_type));
337 UNREACHABLE();
329 case Tegra::Texture::TextureFormat::A2B10G10R10: 338 case Tegra::Texture::TextureFormat::A2B10G10R10:
330 return PixelFormat::A2B10G10R10; 339 switch (component_type) {
340 case Tegra::Texture::ComponentType::UNORM:
341 return PixelFormat::A2B10G10R10U;
342 }
343 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
344 static_cast<u32>(component_type));
345 UNREACHABLE();
331 case Tegra::Texture::TextureFormat::A1B5G5R5: 346 case Tegra::Texture::TextureFormat::A1B5G5R5:
332 return PixelFormat::A1B5G5R5; 347 switch (component_type) {
348 case Tegra::Texture::ComponentType::UNORM:
349 return PixelFormat::A1B5G5R5U;
350 }
351 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
352 static_cast<u32>(component_type));
353 UNREACHABLE();
333 case Tegra::Texture::TextureFormat::R8: 354 case Tegra::Texture::TextureFormat::R8:
334 switch (component_type) { 355 switch (component_type) {
335 case Tegra::Texture::ComponentType::UNORM: 356 case Tegra::Texture::ComponentType::UNORM:
336 return PixelFormat::R8; 357 return PixelFormat::R8U;
337 case Tegra::Texture::ComponentType::UINT: 358 case Tegra::Texture::ComponentType::UINT:
338 return PixelFormat::R8UI; 359 return PixelFormat::R8UI;
339 } 360 }
@@ -341,11 +362,33 @@ struct SurfaceParams {
341 static_cast<u32>(component_type)); 362 static_cast<u32>(component_type));
342 UNREACHABLE(); 363 UNREACHABLE();
343 case Tegra::Texture::TextureFormat::G8R8: 364 case Tegra::Texture::TextureFormat::G8R8:
344 return PixelFormat::G8R8; 365 switch (component_type) {
366 case Tegra::Texture::ComponentType::UNORM:
367 return PixelFormat::G8R8U;
368 case Tegra::Texture::ComponentType::SNORM:
369 return PixelFormat::G8R8S;
370 }
371 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
372 static_cast<u32>(component_type));
373 UNREACHABLE();
345 case Tegra::Texture::TextureFormat::R16_G16_B16_A16: 374 case Tegra::Texture::TextureFormat::R16_G16_B16_A16:
346 return PixelFormat::RGBA16F; 375 switch (component_type) {
376 case Tegra::Texture::ComponentType::UNORM:
377 return PixelFormat::RGBA16U;
378 case Tegra::Texture::ComponentType::FLOAT:
379 return PixelFormat::RGBA16F;
380 }
381 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
382 static_cast<u32>(component_type));
383 UNREACHABLE();
347 case Tegra::Texture::TextureFormat::BF10GF11RF11: 384 case Tegra::Texture::TextureFormat::BF10GF11RF11:
348 return PixelFormat::R11FG11FB10F; 385 switch (component_type) {
386 case Tegra::Texture::ComponentType::FLOAT:
387 return PixelFormat::R11FG11FB10F;
388 }
389 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
390 static_cast<u32>(component_type));
391 UNREACHABLE();
349 case Tegra::Texture::TextureFormat::R32_G32_B32_A32: 392 case Tegra::Texture::TextureFormat::R32_G32_B32_A32:
350 switch (component_type) { 393 switch (component_type) {
351 case Tegra::Texture::ComponentType::FLOAT: 394 case Tegra::Texture::ComponentType::FLOAT:
@@ -367,13 +410,19 @@ struct SurfaceParams {
367 static_cast<u32>(component_type)); 410 static_cast<u32>(component_type));
368 UNREACHABLE(); 411 UNREACHABLE();
369 case Tegra::Texture::TextureFormat::R32_G32_B32: 412 case Tegra::Texture::TextureFormat::R32_G32_B32:
370 return PixelFormat::RGB32F; 413 switch (component_type) {
414 case Tegra::Texture::ComponentType::FLOAT:
415 return PixelFormat::RGB32F;
416 }
417 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
418 static_cast<u32>(component_type));
419 UNREACHABLE();
371 case Tegra::Texture::TextureFormat::R16: 420 case Tegra::Texture::TextureFormat::R16:
372 switch (component_type) { 421 switch (component_type) {
373 case Tegra::Texture::ComponentType::FLOAT: 422 case Tegra::Texture::ComponentType::FLOAT:
374 return PixelFormat::R16F; 423 return PixelFormat::R16F;
375 case Tegra::Texture::ComponentType::UNORM: 424 case Tegra::Texture::ComponentType::UNORM:
376 return PixelFormat::R16UNORM; 425 return PixelFormat::R16U;
377 case Tegra::Texture::ComponentType::SNORM: 426 case Tegra::Texture::ComponentType::SNORM:
378 return PixelFormat::R16S; 427 return PixelFormat::R16S;
379 case Tegra::Texture::ComponentType::UINT: 428 case Tegra::Texture::ComponentType::UINT:
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 6834d7085..dabf98b74 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -383,15 +383,13 @@ public:
383 } 383 }
384 } 384 }
385 385
386 std::string GetUniformIndirect(u64 index, s64 offset, const Register& index_reg, 386 std::string GetUniformIndirect(u64 cbuf_index, s64 offset, const std::string& index_str,
387 GLSLRegister::Type type) { 387 GLSLRegister::Type type) {
388 declr_const_buffers[index].MarkAsUsedIndirect(index, stage); 388 declr_const_buffers[cbuf_index].MarkAsUsedIndirect(cbuf_index, stage);
389 389
390 std::string final_offset = "((floatBitsToInt(" + GetRegister(index_reg, 0) + ") + " + 390 std::string final_offset = fmt::format("({} + {})", index_str, offset / 4);
391 std::to_string(offset) + ") / 4)"; 391 std::string value = 'c' + std::to_string(cbuf_index) + '[' + final_offset + " / 4][" +
392 392 final_offset + " % 4]";
393 std::string value =
394 'c' + std::to_string(index) + '[' + final_offset + " / 4][" + final_offset + " % 4]";
395 393
396 if (type == GLSLRegister::Type::Float) { 394 if (type == GLSLRegister::Type::Float) {
397 return value; 395 return value;
@@ -1355,11 +1353,16 @@ private:
1355 case OpCode::Id::LD_C: { 1353 case OpCode::Id::LD_C: {
1356 ASSERT_MSG(instr.ld_c.unknown == 0, "Unimplemented"); 1354 ASSERT_MSG(instr.ld_c.unknown == 0, "Unimplemented");
1357 1355
1356 // Add an extra scope and declare the index register inside to prevent
1357 // overwriting it in case it is used as an output of the LD instruction.
1358 shader.AddLine("{");
1359 ++shader.scope;
1360
1361 shader.AddLine("uint index = (" + regs.GetRegisterAsInteger(instr.gpr8, 0, false) +
1362 " / 4) & (MAX_CONSTBUFFER_ELEMENTS - 1);");
1363
1358 std::string op_a = 1364 std::string op_a =
1359 regs.GetUniformIndirect(instr.cbuf36.index, instr.cbuf36.offset + 0, instr.gpr8, 1365 regs.GetUniformIndirect(instr.cbuf36.index, instr.cbuf36.offset + 0, "index",
1360 GLSLRegister::Type::Float);
1361 std::string op_b =
1362 regs.GetUniformIndirect(instr.cbuf36.index, instr.cbuf36.offset + 4, instr.gpr8,
1363 GLSLRegister::Type::Float); 1366 GLSLRegister::Type::Float);
1364 1367
1365 switch (instr.ld_c.type.Value()) { 1368 switch (instr.ld_c.type.Value()) {
@@ -1367,16 +1370,22 @@ private:
1367 regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1); 1370 regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1);
1368 break; 1371 break;
1369 1372
1370 case Tegra::Shader::UniformType::Double: 1373 case Tegra::Shader::UniformType::Double: {
1374 std::string op_b =
1375 regs.GetUniformIndirect(instr.cbuf36.index, instr.cbuf36.offset + 4,
1376 "index", GLSLRegister::Type::Float);
1371 regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1); 1377 regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1);
1372 regs.SetRegisterToFloat(instr.gpr0.Value() + 1, 0, op_b, 1, 1); 1378 regs.SetRegisterToFloat(instr.gpr0.Value() + 1, 0, op_b, 1, 1);
1373 break; 1379 break;
1374 1380 }
1375 default: 1381 default:
1376 LOG_CRITICAL(HW_GPU, "Unhandled type: {}", 1382 LOG_CRITICAL(HW_GPU, "Unhandled type: {}",
1377 static_cast<unsigned>(instr.ld_c.type.Value())); 1383 static_cast<unsigned>(instr.ld_c.type.Value()));
1378 UNREACHABLE(); 1384 UNREACHABLE();
1379 } 1385 }
1386
1387 --shader.scope;
1388 shader.AddLine("}");
1380 break; 1389 break;
1381 } 1390 }
1382 case OpCode::Id::ST_A: { 1391 case OpCode::Id::ST_A: {
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h
index 83ea0cfc0..8f719fdd8 100644
--- a/src/video_core/renderer_opengl/maxwell_to_gl.h
+++ b/src/video_core/renderer_opengl/maxwell_to_gl.h
@@ -24,16 +24,25 @@ using Maxwell = Tegra::Engines::Maxwell3D::Regs;
24 24
25inline GLenum VertexType(Maxwell::VertexAttribute attrib) { 25inline GLenum VertexType(Maxwell::VertexAttribute attrib) {
26 switch (attrib.type) { 26 switch (attrib.type) {
27 case Maxwell::VertexAttribute::Type::UnsignedInt:
27 case Maxwell::VertexAttribute::Type::UnsignedNorm: { 28 case Maxwell::VertexAttribute::Type::UnsignedNorm: {
28 29
29 switch (attrib.size) { 30 switch (attrib.size) {
30 case Maxwell::VertexAttribute::Size::Size_8: 31 case Maxwell::VertexAttribute::Size::Size_8:
31 case Maxwell::VertexAttribute::Size::Size_8_8: 32 case Maxwell::VertexAttribute::Size::Size_8_8:
33 case Maxwell::VertexAttribute::Size::Size_8_8_8:
32 case Maxwell::VertexAttribute::Size::Size_8_8_8_8: 34 case Maxwell::VertexAttribute::Size::Size_8_8_8_8:
33 return GL_UNSIGNED_BYTE; 35 return GL_UNSIGNED_BYTE;
36 case Maxwell::VertexAttribute::Size::Size_16:
34 case Maxwell::VertexAttribute::Size::Size_16_16: 37 case Maxwell::VertexAttribute::Size::Size_16_16:
38 case Maxwell::VertexAttribute::Size::Size_16_16_16:
35 case Maxwell::VertexAttribute::Size::Size_16_16_16_16: 39 case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
36 return GL_UNSIGNED_SHORT; 40 return GL_UNSIGNED_SHORT;
41 case Maxwell::VertexAttribute::Size::Size_32:
42 case Maxwell::VertexAttribute::Size::Size_32_32:
43 case Maxwell::VertexAttribute::Size::Size_32_32_32:
44 case Maxwell::VertexAttribute::Size::Size_32_32_32_32:
45 return GL_UNSIGNED_INT;
37 case Maxwell::VertexAttribute::Size::Size_10_10_10_2: 46 case Maxwell::VertexAttribute::Size::Size_10_10_10_2:
38 return GL_UNSIGNED_INT_2_10_10_10_REV; 47 return GL_UNSIGNED_INT_2_10_10_10_REV;
39 } 48 }
@@ -43,16 +52,25 @@ inline GLenum VertexType(Maxwell::VertexAttribute attrib) {
43 return {}; 52 return {};
44 } 53 }
45 54
55 case Maxwell::VertexAttribute::Type::SignedInt:
46 case Maxwell::VertexAttribute::Type::SignedNorm: { 56 case Maxwell::VertexAttribute::Type::SignedNorm: {
47 57
48 switch (attrib.size) { 58 switch (attrib.size) {
49 case Maxwell::VertexAttribute::Size::Size_32_32_32: 59 case Maxwell::VertexAttribute::Size::Size_8:
50 return GL_INT;
51 case Maxwell::VertexAttribute::Size::Size_8_8: 60 case Maxwell::VertexAttribute::Size::Size_8_8:
61 case Maxwell::VertexAttribute::Size::Size_8_8_8:
52 case Maxwell::VertexAttribute::Size::Size_8_8_8_8: 62 case Maxwell::VertexAttribute::Size::Size_8_8_8_8:
53 return GL_BYTE; 63 return GL_BYTE;
64 case Maxwell::VertexAttribute::Size::Size_16:
54 case Maxwell::VertexAttribute::Size::Size_16_16: 65 case Maxwell::VertexAttribute::Size::Size_16_16:
66 case Maxwell::VertexAttribute::Size::Size_16_16_16:
67 case Maxwell::VertexAttribute::Size::Size_16_16_16_16:
55 return GL_SHORT; 68 return GL_SHORT;
69 case Maxwell::VertexAttribute::Size::Size_32:
70 case Maxwell::VertexAttribute::Size::Size_32_32:
71 case Maxwell::VertexAttribute::Size::Size_32_32_32:
72 case Maxwell::VertexAttribute::Size::Size_32_32_32_32:
73 return GL_INT;
56 case Maxwell::VertexAttribute::Size::Size_10_10_10_2: 74 case Maxwell::VertexAttribute::Size::Size_10_10_10_2:
57 return GL_INT_2_10_10_10_REV; 75 return GL_INT_2_10_10_10_REV;
58 } 76 }
@@ -62,9 +80,6 @@ inline GLenum VertexType(Maxwell::VertexAttribute attrib) {
62 return {}; 80 return {};
63 } 81 }
64 82
65 case Maxwell::VertexAttribute::Type::UnsignedInt:
66 return GL_UNSIGNED_INT;
67
68 case Maxwell::VertexAttribute::Type::Float: 83 case Maxwell::VertexAttribute::Type::Float:
69 return GL_FLOAT; 84 return GL_FLOAT;
70 } 85 }