summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2018-10-20 02:16:38 -0300
committerGravatar ReinUsesLisp2018-10-20 02:19:30 -0300
commit3ec795d95ef0b265526dc922fef7be816270c3cf (patch)
tree30e2cffde9a7d285396937888fb33f162c902401 /src
parentMerge pull request #1501 from ReinUsesLisp/half-float (diff)
downloadyuzu-3ec795d95ef0b265526dc922fef7be816270c3cf.tar.gz
yuzu-3ec795d95ef0b265526dc922fef7be816270c3cf.tar.xz
yuzu-3ec795d95ef0b265526dc922fef7be816270c3cf.zip
gl_shader_decompiler: Move position varying declaration back to gl_shader_gen
The intention of declaring them in gl_shader_decompiler was to be able to use blocks to implement geometry shaders. But that wasn't needed in the end and it caused issues when both vertex stages were being used, resulting in a redeclaration of "position".
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp13
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp7
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.h2
3 files changed, 9 insertions, 13 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index e050b063a..a427353e9 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -30,8 +30,6 @@ using Tegra::Shader::SubOp;
30constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH; 30constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH;
31constexpr u32 PROGRAM_HEADER_SIZE = sizeof(Tegra::Shader::Header); 31constexpr u32 PROGRAM_HEADER_SIZE = sizeof(Tegra::Shader::Header);
32 32
33enum : u32 { POSITION_VARYING_LOCATION = 0, GENERIC_VARYING_START_LOCATION = 1 };
34
35constexpr u32 MAX_GEOMETRY_BUFFERS = 6; 33constexpr u32 MAX_GEOMETRY_BUFFERS = 6;
36constexpr u32 MAX_ATTRIBUTES = 0x100; // Size in vec4s, this value is untested 34constexpr u32 MAX_ATTRIBUTES = 0x100; // Size in vec4s, this value is untested
37 35
@@ -591,13 +589,6 @@ private:
591 589
592 /// Generates declarations for input attributes. 590 /// Generates declarations for input attributes.
593 void GenerateInputAttrs() { 591 void GenerateInputAttrs() {
594 if (stage != Maxwell3D::Regs::ShaderStage::Vertex) {
595 const std::string attr =
596 stage == Maxwell3D::Regs::ShaderStage::Geometry ? "gs_position[]" : "position";
597 declarations.AddLine("layout (location = " + std::to_string(POSITION_VARYING_LOCATION) +
598 ") in vec4 " + attr + ';');
599 }
600
601 for (const auto element : declr_input_attribute) { 592 for (const auto element : declr_input_attribute) {
602 // TODO(bunnei): Use proper number of elements for these 593 // TODO(bunnei): Use proper number of elements for these
603 u32 idx = 594 u32 idx =
@@ -620,10 +611,6 @@ private:
620 611
621 /// Generates declarations for output attributes. 612 /// Generates declarations for output attributes.
622 void GenerateOutputAttrs() { 613 void GenerateOutputAttrs() {
623 if (stage != Maxwell3D::Regs::ShaderStage::Fragment) {
624 declarations.AddLine("layout (location = " + std::to_string(POSITION_VARYING_LOCATION) +
625 ") out vec4 position;");
626 }
627 for (const auto& index : declr_output_attribute) { 614 for (const auto& index : declr_output_attribute) {
628 // TODO(bunnei): Use proper number of elements for these 615 // TODO(bunnei): Use proper number of elements for these
629 const u32 idx = static_cast<u32>(index) - 616 const u32 idx = static_cast<u32>(index) -
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index 1e5eb32df..ecbc9d8ed 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -23,6 +23,8 @@ out gl_PerVertex {
23 vec4 gl_Position; 23 vec4 gl_Position;
24}; 24};
25 25
26layout (location = 0) out vec4 position;
27
26layout(std140) uniform vs_config { 28layout(std140) uniform vs_config {
27 vec4 viewport_flip; 29 vec4 viewport_flip;
28 uvec4 instance_id; 30 uvec4 instance_id;
@@ -96,6 +98,9 @@ out gl_PerVertex {
96 vec4 gl_Position; 98 vec4 gl_Position;
97}; 99};
98 100
101layout (location = 0) in vec4 gs_position[];
102layout (location = 0) out vec4 position;
103
99layout (std140) uniform gs_config { 104layout (std140) uniform gs_config {
100 vec4 viewport_flip; 105 vec4 viewport_flip;
101 uvec4 instance_id; 106 uvec4 instance_id;
@@ -131,6 +136,8 @@ layout(location = 5) out vec4 FragColor5;
131layout(location = 6) out vec4 FragColor6; 136layout(location = 6) out vec4 FragColor6;
132layout(location = 7) out vec4 FragColor7; 137layout(location = 7) out vec4 FragColor7;
133 138
139layout (location = 0) in vec4 position;
140
134layout (std140) uniform fs_config { 141layout (std140) uniform fs_config {
135 vec4 viewport_flip; 142 vec4 viewport_flip;
136 uvec4 instance_id; 143 uvec4 instance_id;
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h
index 79596087a..520b9d4e3 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.h
+++ b/src/video_core/renderer_opengl/gl_shader_gen.h
@@ -16,6 +16,8 @@ namespace OpenGL::GLShader {
16constexpr std::size_t MAX_PROGRAM_CODE_LENGTH{0x1000}; 16constexpr std::size_t MAX_PROGRAM_CODE_LENGTH{0x1000};
17using ProgramCode = std::vector<u64>; 17using ProgramCode = std::vector<u64>;
18 18
19enum : u32 { POSITION_VARYING_LOCATION = 0, GENERIC_VARYING_START_LOCATION = 1 };
20
19class ConstBufferEntry { 21class ConstBufferEntry {
20 using Maxwell = Tegra::Engines::Maxwell3D::Regs; 22 using Maxwell = Tegra::Engines::Maxwell3D::Regs;
21 23