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