diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/shader_bytecode.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 29 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 3 |
3 files changed, 28 insertions, 5 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index 6cd08d28b..af7756266 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h | |||
| @@ -79,6 +79,7 @@ union Attribute { | |||
| 79 | constexpr explicit Attribute(u64 value) : value(value) {} | 79 | constexpr explicit Attribute(u64 value) : value(value) {} |
| 80 | 80 | ||
| 81 | enum class Index : u64 { | 81 | enum class Index : u64 { |
| 82 | PointSize = 6, | ||
| 82 | Position = 7, | 83 | Position = 7, |
| 83 | Attribute_0 = 8, | 84 | Attribute_0 = 8, |
| 84 | Attribute_31 = 39, | 85 | Attribute_31 = 39, |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index fe4d1bd83..81ffb24e4 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <set> | 6 | #include <set> |
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include <string_view> | 8 | #include <string_view> |
| 9 | #include <unordered_set> | ||
| 9 | 10 | ||
| 10 | #include <boost/optional.hpp> | 11 | #include <boost/optional.hpp> |
| 11 | #include <fmt/format.h> | 12 | #include <fmt/format.h> |
| @@ -276,7 +277,8 @@ public: | |||
| 276 | GLSLRegisterManager(ShaderWriter& shader, ShaderWriter& declarations, | 277 | GLSLRegisterManager(ShaderWriter& shader, ShaderWriter& declarations, |
| 277 | const Maxwell3D::Regs::ShaderStage& stage, const std::string& suffix, | 278 | const Maxwell3D::Regs::ShaderStage& stage, const std::string& suffix, |
| 278 | const Tegra::Shader::Header& header) | 279 | const Tegra::Shader::Header& header) |
| 279 | : shader{shader}, declarations{declarations}, stage{stage}, suffix{suffix}, header{header} { | 280 | : shader{shader}, declarations{declarations}, stage{stage}, suffix{suffix}, header{header}, |
| 281 | fixed_pipeline_output_attributes_used{} { | ||
| 280 | BuildRegisterList(); | 282 | BuildRegisterList(); |
| 281 | BuildInputList(); | 283 | BuildInputList(); |
| 282 | } | 284 | } |
| @@ -480,7 +482,12 @@ public: | |||
| 480 | std::to_string(static_cast<u32>(attribute)) + ']' + | 482 | std::to_string(static_cast<u32>(attribute)) + ']' + |
| 481 | GetSwizzle(elem) + " = " + src + ';'); | 483 | GetSwizzle(elem) + " = " + src + ';'); |
| 482 | } else { | 484 | } else { |
| 483 | shader.AddLine(dest + GetSwizzle(elem) + " = " + src + ';'); | 485 | if (attribute == Attribute::Index::PointSize) { |
| 486 | fixed_pipeline_output_attributes_used.insert(attribute); | ||
| 487 | shader.AddLine(dest + " = " + src + ';'); | ||
| 488 | } else { | ||
| 489 | shader.AddLine(dest + GetSwizzle(elem) + " = " + src + ';'); | ||
| 490 | } | ||
| 484 | } | 491 | } |
| 485 | } | 492 | } |
| 486 | } | 493 | } |
| @@ -524,6 +531,7 @@ public: | |||
| 524 | 531 | ||
| 525 | /// Add declarations. | 532 | /// Add declarations. |
| 526 | void GenerateDeclarations(const std::string& suffix) { | 533 | void GenerateDeclarations(const std::string& suffix) { |
| 534 | GenerateVertex(); | ||
| 527 | GenerateRegisters(suffix); | 535 | GenerateRegisters(suffix); |
| 528 | GenerateInternalFlags(); | 536 | GenerateInternalFlags(); |
| 529 | GenerateInputAttrs(); | 537 | GenerateInputAttrs(); |
| @@ -683,6 +691,20 @@ private: | |||
| 683 | declarations.AddNewLine(); | 691 | declarations.AddNewLine(); |
| 684 | } | 692 | } |
| 685 | 693 | ||
| 694 | void GenerateVertex() { | ||
| 695 | if (stage != Maxwell3D::Regs::ShaderStage::Vertex) | ||
| 696 | return; | ||
| 697 | declarations.AddLine("out gl_PerVertex {"); | ||
| 698 | ++declarations.scope; | ||
| 699 | declarations.AddLine("vec4 gl_Position;"); | ||
| 700 | for (auto& o : fixed_pipeline_output_attributes_used) { | ||
| 701 | if (o == Attribute::Index::PointSize) | ||
| 702 | declarations.AddLine("float gl_PointSize;"); | ||
| 703 | } | ||
| 704 | --declarations.scope; | ||
| 705 | declarations.AddLine("};"); | ||
| 706 | } | ||
| 707 | |||
| 686 | /// Generates code representing a temporary (GPR) register. | 708 | /// Generates code representing a temporary (GPR) register. |
| 687 | std::string GetRegister(const Register& reg, unsigned elem) { | 709 | std::string GetRegister(const Register& reg, unsigned elem) { |
| 688 | if (reg == Register::ZeroIndex) { | 710 | if (reg == Register::ZeroIndex) { |
| @@ -836,6 +858,8 @@ private: | |||
| 836 | /// Generates code representing the declaration name of an output attribute register. | 858 | /// Generates code representing the declaration name of an output attribute register. |
| 837 | std::string GetOutputAttribute(Attribute::Index attribute) { | 859 | std::string GetOutputAttribute(Attribute::Index attribute) { |
| 838 | switch (attribute) { | 860 | switch (attribute) { |
| 861 | case Attribute::Index::PointSize: | ||
| 862 | return "gl_PointSize"; | ||
| 839 | case Attribute::Index::Position: | 863 | case Attribute::Index::Position: |
| 840 | return "position"; | 864 | return "position"; |
| 841 | default: | 865 | default: |
| @@ -870,6 +894,7 @@ private: | |||
| 870 | const Maxwell3D::Regs::ShaderStage& stage; | 894 | const Maxwell3D::Regs::ShaderStage& stage; |
| 871 | const std::string& suffix; | 895 | const std::string& suffix; |
| 872 | const Tegra::Shader::Header& header; | 896 | const Tegra::Shader::Header& header; |
| 897 | std::unordered_set<Attribute::Index> fixed_pipeline_output_attributes_used; | ||
| 873 | }; | 898 | }; |
| 874 | 899 | ||
| 875 | class GLSLGenerator { | 900 | class GLSLGenerator { |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index e883ffb1d..dfb562706 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -19,9 +19,6 @@ ProgramResult GenerateVertexShader(const ShaderSetup& setup) { | |||
| 19 | out += Decompiler::GetCommonDeclarations(); | 19 | out += Decompiler::GetCommonDeclarations(); |
| 20 | 20 | ||
| 21 | out += R"( | 21 | out += R"( |
| 22 | out gl_PerVertex { | ||
| 23 | vec4 gl_Position; | ||
| 24 | }; | ||
| 25 | 22 | ||
| 26 | layout (location = 0) out vec4 position; | 23 | layout (location = 0) out vec4 position; |
| 27 | 24 | ||