diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 69 |
1 files changed, 55 insertions, 14 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 8dfb49507..60c99c126 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -2038,9 +2038,9 @@ private: | |||
| 2038 | break; | 2038 | break; |
| 2039 | } | 2039 | } |
| 2040 | case OpCode::Id::TEX: { | 2040 | case OpCode::Id::TEX: { |
| 2041 | ASSERT_MSG(instr.tex.array == 0, "TEX arrays unimplemented"); | ||
| 2042 | Tegra::Shader::TextureType texture_type{instr.tex.texture_type}; | 2041 | Tegra::Shader::TextureType texture_type{instr.tex.texture_type}; |
| 2043 | std::string coord; | 2042 | std::string coord; |
| 2043 | const bool is_array = instr.tex.array != 0; | ||
| 2044 | 2044 | ||
| 2045 | ASSERT_MSG(!instr.tex.UsesMiscMode(Tegra::Shader::TextureMiscMode::NODEP), | 2045 | ASSERT_MSG(!instr.tex.UsesMiscMode(Tegra::Shader::TextureMiscMode::NODEP), |
| 2046 | "NODEP is not implemented"); | 2046 | "NODEP is not implemented"); |
| @@ -2055,21 +2055,59 @@ private: | |||
| 2055 | 2055 | ||
| 2056 | switch (num_coordinates) { | 2056 | switch (num_coordinates) { |
| 2057 | case 1: { | 2057 | case 1: { |
| 2058 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8); | 2058 | if (is_array) { |
| 2059 | coord = "float coords = " + x + ';'; | 2059 | const std::string index = regs.GetRegisterAsInteger(instr.gpr8); |
| 2060 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | ||
| 2061 | coord = "vec2 coords = vec2(" + x + ", " + index + ");"; | ||
| 2062 | } else { | ||
| 2063 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8); | ||
| 2064 | coord = "float coords = " + x + ';'; | ||
| 2065 | } | ||
| 2060 | break; | 2066 | break; |
| 2061 | } | 2067 | } |
| 2062 | case 2: { | 2068 | case 2: { |
| 2063 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8); | 2069 | if (is_array) { |
| 2064 | const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | 2070 | const std::string index = regs.GetRegisterAsInteger(instr.gpr8); |
| 2065 | coord = "vec2 coords = vec2(" + x + ", " + y + ");"; | 2071 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); |
| 2072 | const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 2); | ||
| 2073 | coord = "vec3 coords = vec3(" + x + ", " + y + ", " + index + ");"; | ||
| 2074 | } else { | ||
| 2075 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8); | ||
| 2076 | const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | ||
| 2077 | coord = "vec2 coords = vec2(" + x + ", " + y + ");"; | ||
| 2078 | } | ||
| 2066 | break; | 2079 | break; |
| 2067 | } | 2080 | } |
| 2068 | case 3: { | 2081 | case 3: { |
| 2069 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8); | 2082 | if (depth_compare) { |
| 2070 | const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | 2083 | if (is_array) { |
| 2071 | const std::string z = regs.GetRegisterAsFloat(instr.gpr20); | 2084 | const std::string index = regs.GetRegisterAsInteger(instr.gpr8); |
| 2072 | coord = "vec3 coords = vec3(" + x + ", " + y + ", " + z + ");"; | 2085 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); |
| 2086 | const std::string y = regs.GetRegisterAsFloat(instr.gpr20); | ||
| 2087 | const std::string z = regs.GetRegisterAsFloat(instr.gpr20.Value() + 1); | ||
| 2088 | coord = "vec4 coords = vec4(" + x + ", " + y + ", " + z + ", " + index + | ||
| 2089 | ");"; | ||
| 2090 | } else { | ||
| 2091 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8); | ||
| 2092 | const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | ||
| 2093 | const std::string z = regs.GetRegisterAsFloat(instr.gpr20); | ||
| 2094 | coord = "vec3 coords = vec3(" + x + ", " + y + ", " + z + ");"; | ||
| 2095 | } | ||
| 2096 | } else { | ||
| 2097 | if (is_array) { | ||
| 2098 | const std::string index = regs.GetRegisterAsInteger(instr.gpr8); | ||
| 2099 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | ||
| 2100 | const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 2); | ||
| 2101 | const std::string z = regs.GetRegisterAsFloat(instr.gpr8.Value() + 3); | ||
| 2102 | coord = "vec4 coords = vec4(" + x + ", " + y + ", " + z + ", " + index + | ||
| 2103 | ");"; | ||
| 2104 | } else { | ||
| 2105 | const std::string x = regs.GetRegisterAsFloat(instr.gpr8); | ||
| 2106 | const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | ||
| 2107 | const std::string z = regs.GetRegisterAsFloat(instr.gpr8.Value() + 2); | ||
| 2108 | coord = "vec3 coords = vec3(" + x + ", " + y + ", " + z + ");"; | ||
| 2109 | } | ||
| 2110 | } | ||
| 2073 | break; | 2111 | break; |
| 2074 | } | 2112 | } |
| 2075 | default: | 2113 | default: |
| @@ -2088,7 +2126,7 @@ private: | |||
| 2088 | std::string op_c; | 2126 | std::string op_c; |
| 2089 | 2127 | ||
| 2090 | const std::string sampler = | 2128 | const std::string sampler = |
| 2091 | GetSampler(instr.sampler, texture_type, false, depth_compare); | 2129 | GetSampler(instr.sampler, texture_type, is_array, depth_compare); |
| 2092 | // Add an extra scope and declare the texture coords inside to prevent | 2130 | // Add an extra scope and declare the texture coords inside to prevent |
| 2093 | // overwriting them in case they are used as outputs of the texs instruction. | 2131 | // overwriting them in case they are used as outputs of the texs instruction. |
| 2094 | 2132 | ||
| @@ -2108,10 +2146,13 @@ private: | |||
| 2108 | } | 2146 | } |
| 2109 | case Tegra::Shader::TextureProcessMode::LB: | 2147 | case Tegra::Shader::TextureProcessMode::LB: |
| 2110 | case Tegra::Shader::TextureProcessMode::LBA: { | 2148 | case Tegra::Shader::TextureProcessMode::LBA: { |
| 2111 | if (num_coordinates <= 2) { | 2149 | if (depth_compare) { |
| 2112 | op_c = regs.GetRegisterAsFloat(instr.gpr20); | 2150 | if (is_array) |
| 2151 | op_c = regs.GetRegisterAsFloat(instr.gpr20.Value() + 2); | ||
| 2152 | else | ||
| 2153 | op_c = regs.GetRegisterAsFloat(instr.gpr20.Value() + 1); | ||
| 2113 | } else { | 2154 | } else { |
| 2114 | op_c = regs.GetRegisterAsFloat(instr.gpr20.Value() + 1); | 2155 | op_c = regs.GetRegisterAsFloat(instr.gpr20); |
| 2115 | } | 2156 | } |
| 2116 | // TODO: Figure if A suffix changes the equation at all. | 2157 | // TODO: Figure if A suffix changes the equation at all. |
| 2117 | texture = "texture(" + sampler + ", coords, " + op_c + ')'; | 2158 | texture = "texture(" + sampler + ", coords, " + op_c + ')'; |