diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 81ffb24e4..c1a86755a 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -279,6 +279,7 @@ public: | |||
| 279 | const Tegra::Shader::Header& header) | 279 | const Tegra::Shader::Header& header) |
| 280 | : 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{} { | 281 | fixed_pipeline_output_attributes_used{} { |
| 282 | local_memory_size = 0; | ||
| 282 | BuildRegisterList(); | 283 | BuildRegisterList(); |
| 283 | BuildInputList(); | 284 | BuildInputList(); |
| 284 | } | 285 | } |
| @@ -436,6 +437,24 @@ public: | |||
| 436 | shader.AddLine(dest + " = " + src + ';'); | 437 | shader.AddLine(dest + " = " + src + ';'); |
| 437 | } | 438 | } |
| 438 | 439 | ||
| 440 | std::string GetLocalMemoryAsFloat(const std::string index) { | ||
| 441 | return "lmem[" + index + "]"; | ||
| 442 | } | ||
| 443 | |||
| 444 | std::string GetLocalMemoryAsInteger(const std::string index, bool is_signed = false) { | ||
| 445 | const std::string func{is_signed ? "floatToIntBits" : "floatBitsToUint"}; | ||
| 446 | return func + "(lmem[" + index + "])"; | ||
| 447 | } | ||
| 448 | |||
| 449 | void SetLocalMemoryAsFloat(const std::string index, const std::string value) { | ||
| 450 | shader.AddLine("lmem[" + index + "] = " + value); | ||
| 451 | } | ||
| 452 | |||
| 453 | void SetLocalMemoryAsInteger(const std::string index, const std::string value, bool is_signed = false) { | ||
| 454 | const std::string func{is_signed ? "intBitsToFloat" : "uintBitsToFloat"}; | ||
| 455 | shader.AddLine("lmem[" + index + "] = " + func + '(' + value + ')'); | ||
| 456 | } | ||
| 457 | |||
| 439 | std::string GetControlCode(const Tegra::Shader::ControlCode cc) const { | 458 | std::string GetControlCode(const Tegra::Shader::ControlCode cc) const { |
| 440 | switch (cc) { | 459 | switch (cc) { |
| 441 | case Tegra::Shader::ControlCode::NEU: | 460 | case Tegra::Shader::ControlCode::NEU: |
| @@ -533,6 +552,7 @@ public: | |||
| 533 | void GenerateDeclarations(const std::string& suffix) { | 552 | void GenerateDeclarations(const std::string& suffix) { |
| 534 | GenerateVertex(); | 553 | GenerateVertex(); |
| 535 | GenerateRegisters(suffix); | 554 | GenerateRegisters(suffix); |
| 555 | GenerateLocalMemory(); | ||
| 536 | GenerateInternalFlags(); | 556 | GenerateInternalFlags(); |
| 537 | GenerateInputAttrs(); | 557 | GenerateInputAttrs(); |
| 538 | GenerateOutputAttrs(); | 558 | GenerateOutputAttrs(); |
| @@ -578,6 +598,10 @@ public: | |||
| 578 | return entry.GetName(); | 598 | return entry.GetName(); |
| 579 | } | 599 | } |
| 580 | 600 | ||
| 601 | void SetLocalMemory(u64 lmem) { | ||
| 602 | local_memory_size = lmem; | ||
| 603 | } | ||
| 604 | |||
| 581 | private: | 605 | private: |
| 582 | /// Generates declarations for registers. | 606 | /// Generates declarations for registers. |
| 583 | void GenerateRegisters(const std::string& suffix) { | 607 | void GenerateRegisters(const std::string& suffix) { |
| @@ -588,6 +612,14 @@ private: | |||
| 588 | declarations.AddNewLine(); | 612 | declarations.AddNewLine(); |
| 589 | } | 613 | } |
| 590 | 614 | ||
| 615 | /// Generates declarations for local memory. | ||
| 616 | void GenerateLocalMemory() { | ||
| 617 | if (local_memory_size > 0) { | ||
| 618 | declarations.AddLine("float lmem[" + std::to_string((local_memory_size - 1 + 4) / 4) + "];"); | ||
| 619 | declarations.AddNewLine(); | ||
| 620 | } | ||
| 621 | } | ||
| 622 | |||
| 591 | /// Generates declarations for internal flags. | 623 | /// Generates declarations for internal flags. |
| 592 | void GenerateInternalFlags() { | 624 | void GenerateInternalFlags() { |
| 593 | for (u32 ii = 0; ii < static_cast<u64>(InternalFlag::Amount); ii++) { | 625 | for (u32 ii = 0; ii < static_cast<u64>(InternalFlag::Amount); ii++) { |
| @@ -895,6 +927,7 @@ private: | |||
| 895 | const std::string& suffix; | 927 | const std::string& suffix; |
| 896 | const Tegra::Shader::Header& header; | 928 | const Tegra::Shader::Header& header; |
| 897 | std::unordered_set<Attribute::Index> fixed_pipeline_output_attributes_used; | 929 | std::unordered_set<Attribute::Index> fixed_pipeline_output_attributes_used; |
| 930 | u64 local_memory_size; | ||
| 898 | }; | 931 | }; |
| 899 | 932 | ||
| 900 | class GLSLGenerator { | 933 | class GLSLGenerator { |
| @@ -904,6 +937,9 @@ public: | |||
| 904 | : subroutines(subroutines), program_code(program_code), main_offset(main_offset), | 937 | : subroutines(subroutines), program_code(program_code), main_offset(main_offset), |
| 905 | stage(stage), suffix(suffix) { | 938 | stage(stage), suffix(suffix) { |
| 906 | std::memcpy(&header, program_code.data(), sizeof(Tegra::Shader::Header)); | 939 | std::memcpy(&header, program_code.data(), sizeof(Tegra::Shader::Header)); |
| 940 | local_memory_size = (header.common2.shader_local_memory_high_size << 24) | | ||
| 941 | header.common1.shader_local_memory_low_size; | ||
| 942 | regs.SetLocalMemory(local_memory_size); | ||
| 907 | Generate(suffix); | 943 | Generate(suffix); |
| 908 | } | 944 | } |
| 909 | 945 | ||
| @@ -3575,6 +3611,7 @@ private: | |||
| 3575 | const u32 main_offset; | 3611 | const u32 main_offset; |
| 3576 | Maxwell3D::Regs::ShaderStage stage; | 3612 | Maxwell3D::Regs::ShaderStage stage; |
| 3577 | const std::string& suffix; | 3613 | const std::string& suffix; |
| 3614 | u64 local_memory_size; | ||
| 3578 | 3615 | ||
| 3579 | ShaderWriter shader; | 3616 | ShaderWriter shader; |
| 3580 | ShaderWriter declarations; | 3617 | ShaderWriter declarations; |