diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 2363b9d87..740a1006a 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -30,7 +30,7 @@ using Tegra::Shader::SubOp; | |||
| 30 | constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH; | 30 | constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH; |
| 31 | constexpr u32 PROGRAM_HEADER_SIZE = sizeof(Tegra::Shader::Header); | 31 | constexpr u32 PROGRAM_HEADER_SIZE = sizeof(Tegra::Shader::Header); |
| 32 | 32 | ||
| 33 | constexpr u32 POSITION_VARYING_LOCATION = 15; | 33 | enum : u32 { POSITION_VARYING_LOCATION = 0, GENERIC_VARYING_START_LOCATION = 1 }; |
| 34 | 34 | ||
| 35 | constexpr u32 MAX_GEOMETRY_BUFFERS = 6; | 35 | constexpr u32 MAX_GEOMETRY_BUFFERS = 6; |
| 36 | constexpr u32 MAX_ATTRIBUTES = 0x100; // Size in vec4s, this value is untested | 36 | constexpr u32 MAX_ATTRIBUTES = 0x100; // Size in vec4s, this value is untested |
| @@ -559,7 +559,10 @@ private: | |||
| 559 | // TODO(bunnei): Use proper number of elements for these | 559 | // TODO(bunnei): Use proper number of elements for these |
| 560 | u32 idx = | 560 | u32 idx = |
| 561 | static_cast<u32>(element.first) - static_cast<u32>(Attribute::Index::Attribute_0); | 561 | static_cast<u32>(element.first) - static_cast<u32>(Attribute::Index::Attribute_0); |
| 562 | ASSERT(idx != POSITION_VARYING_LOCATION); | 562 | if (stage != Maxwell3D::Regs::ShaderStage::Vertex) { |
| 563 | // If inputs are varyings, add an offset | ||
| 564 | idx += GENERIC_VARYING_START_LOCATION; | ||
| 565 | } | ||
| 563 | 566 | ||
| 564 | std::string attr{GetInputAttribute(element.first, element.second)}; | 567 | std::string attr{GetInputAttribute(element.first, element.second)}; |
| 565 | if (stage == Maxwell3D::Regs::ShaderStage::Geometry) { | 568 | if (stage == Maxwell3D::Regs::ShaderStage::Geometry) { |
| @@ -580,10 +583,11 @@ private: | |||
| 580 | } | 583 | } |
| 581 | for (const auto& index : declr_output_attribute) { | 584 | for (const auto& index : declr_output_attribute) { |
| 582 | // TODO(bunnei): Use proper number of elements for these | 585 | // TODO(bunnei): Use proper number of elements for these |
| 583 | declarations.AddLine("layout (location = " + | 586 | const u32 idx = static_cast<u32>(index) - |
| 584 | std::to_string(static_cast<u32>(index) - | 587 | static_cast<u32>(Attribute::Index::Attribute_0) + |
| 585 | static_cast<u32>(Attribute::Index::Attribute_0)) + | 588 | GENERIC_VARYING_START_LOCATION; |
| 586 | ") out vec4 " + GetOutputAttribute(index) + ';'); | 589 | declarations.AddLine("layout (location = " + std::to_string(idx) + ") out vec4 " + |
| 590 | GetOutputAttribute(index) + ';'); | ||
| 587 | } | 591 | } |
| 588 | declarations.AddNewLine(); | 592 | declarations.AddNewLine(); |
| 589 | } | 593 | } |