diff options
| author | 2018-08-19 13:58:45 -0400 | |
|---|---|---|
| committer | 2018-08-19 13:58:45 -0400 | |
| commit | 85da529f156610434902cf61f446abdf8a2a9d00 (patch) | |
| tree | 4bca6ad6e364d6b8c4067790884b3320ad5a61f4 /src | |
| parent | Merge pull request #1109 from Subv/ldg_decode (diff) | |
| parent | Shaders: Implemented a stack for the SSY/SYNC instructions. (diff) | |
| download | yuzu-85da529f156610434902cf61f446abdf8a2a9d00.tar.gz yuzu-85da529f156610434902cf61f446abdf8a2a9d00.tar.xz yuzu-85da529f156610434902cf61f446abdf8a2a9d00.zip | |
Merge pull request #1101 from Subv/ssy_stack
Shaders: Implemented a stack for the SSY/SYNC instructions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 4007ecc02..7ae745356 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -842,6 +842,33 @@ private: | |||
| 842 | shader.AddLine('}'); | 842 | shader.AddLine('}'); |
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | /* | ||
| 846 | * Emits code to push the input target address to the SSY address stack, incrementing the stack | ||
| 847 | * top. | ||
| 848 | */ | ||
| 849 | void EmitPushToSSYStack(u32 target) { | ||
| 850 | shader.AddLine('{'); | ||
| 851 | ++shader.scope; | ||
| 852 | shader.AddLine("ssy_stack[ssy_stack_top] = " + std::to_string(target) + "u;"); | ||
| 853 | shader.AddLine("ssy_stack_top++;"); | ||
| 854 | --shader.scope; | ||
| 855 | shader.AddLine('}'); | ||
| 856 | } | ||
| 857 | |||
| 858 | /* | ||
| 859 | * Emits code to pop an address from the SSY address stack, setting the jump address to the | ||
| 860 | * popped address and decrementing the stack top. | ||
| 861 | */ | ||
| 862 | void EmitPopFromSSYStack() { | ||
| 863 | shader.AddLine('{'); | ||
| 864 | ++shader.scope; | ||
| 865 | shader.AddLine("ssy_stack_top--;"); | ||
| 866 | shader.AddLine("jmp_to = ssy_stack[ssy_stack_top];"); | ||
| 867 | shader.AddLine("break;"); | ||
| 868 | --shader.scope; | ||
| 869 | shader.AddLine('}'); | ||
| 870 | } | ||
| 871 | |||
| 845 | /** | 872 | /** |
| 846 | * Compiles a single instruction from Tegra to GLSL. | 873 | * Compiles a single instruction from Tegra to GLSL. |
| 847 | * @param offset the offset of the Tegra shader instruction. | 874 | * @param offset the offset of the Tegra shader instruction. |
| @@ -1870,13 +1897,13 @@ private: | |||
| 1870 | ASSERT_MSG(instr.bra.constant_buffer == 0, "Constant buffer SSY is not supported"); | 1897 | ASSERT_MSG(instr.bra.constant_buffer == 0, "Constant buffer SSY is not supported"); |
| 1871 | 1898 | ||
| 1872 | u32 target = offset + instr.bra.GetBranchTarget(); | 1899 | u32 target = offset + instr.bra.GetBranchTarget(); |
| 1873 | shader.AddLine("ssy_target = " + std::to_string(target) + "u;"); | 1900 | EmitPushToSSYStack(target); |
| 1874 | break; | 1901 | break; |
| 1875 | } | 1902 | } |
| 1876 | case OpCode::Id::SYNC: { | 1903 | case OpCode::Id::SYNC: { |
| 1877 | // The SYNC opcode jumps to the address previously set by the SSY opcode | 1904 | // The SYNC opcode jumps to the address previously set by the SSY opcode |
| 1878 | ASSERT(instr.flow.cond == Tegra::Shader::FlowCondition::Always); | 1905 | ASSERT(instr.flow.cond == Tegra::Shader::FlowCondition::Always); |
| 1879 | shader.AddLine("{ jmp_to = ssy_target; break; }"); | 1906 | EmitPopFromSSYStack(); |
| 1880 | break; | 1907 | break; |
| 1881 | } | 1908 | } |
| 1882 | case OpCode::Id::DEPBAR: { | 1909 | case OpCode::Id::DEPBAR: { |
| @@ -1947,7 +1974,13 @@ private: | |||
| 1947 | } else { | 1974 | } else { |
| 1948 | labels.insert(subroutine.begin); | 1975 | labels.insert(subroutine.begin); |
| 1949 | shader.AddLine("uint jmp_to = " + std::to_string(subroutine.begin) + "u;"); | 1976 | shader.AddLine("uint jmp_to = " + std::to_string(subroutine.begin) + "u;"); |
| 1950 | shader.AddLine("uint ssy_target = 0u;"); | 1977 | |
| 1978 | // TODO(Subv): Figure out the actual depth of the SSY stack, for now it seems | ||
| 1979 | // unlikely that shaders will use 20 nested SSYs. | ||
| 1980 | constexpr u32 SSY_STACK_SIZE = 20; | ||
| 1981 | shader.AddLine("uint ssy_stack[" + std::to_string(SSY_STACK_SIZE) + "];"); | ||
| 1982 | shader.AddLine("uint ssy_stack_top = 0u;"); | ||
| 1983 | |||
| 1951 | shader.AddLine("while (true) {"); | 1984 | shader.AddLine("while (true) {"); |
| 1952 | ++shader.scope; | 1985 | ++shader.scope; |
| 1953 | 1986 | ||