diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/engines/shader_bytecode.h | 10 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 34 |
2 files changed, 43 insertions, 1 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index 2db906ea5..58f2904ce 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h | |||
| @@ -254,6 +254,15 @@ enum class TextureQueryType : u64 { | |||
| 254 | BorderColor = 22, | 254 | BorderColor = 22, |
| 255 | }; | 255 | }; |
| 256 | 256 | ||
| 257 | enum class TextureProcessMode : u64 { | ||
| 258 | None = 0, | ||
| 259 | LZ = 1, // Unknown, appears to be the same as none. | ||
| 260 | LB = 2, // Load Bias. | ||
| 261 | LL = 3, // Load LOD (LevelOfDetail) | ||
| 262 | LBA = 6, // Load Bias. The A is unknown, does not appear to differ with LB | ||
| 263 | LLA = 7 // Load LOD. The A is unknown, does not appear to differ with LL | ||
| 264 | }; | ||
| 265 | |||
| 257 | enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 }; | 266 | enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 }; |
| 258 | enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 }; | 267 | enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 }; |
| 259 | 268 | ||
| @@ -573,6 +582,7 @@ union Instruction { | |||
| 573 | BitField<28, 1, u64> array; | 582 | BitField<28, 1, u64> array; |
| 574 | BitField<29, 2, TextureType> texture_type; | 583 | BitField<29, 2, TextureType> texture_type; |
| 575 | BitField<31, 4, u64> component_mask; | 584 | BitField<31, 4, u64> component_mask; |
| 585 | BitField<55, 3, TextureProcessMode> process_mode; | ||
| 576 | 586 | ||
| 577 | bool IsComponentEnabled(size_t component) const { | 587 | bool IsComponentEnabled(size_t component) const { |
| 578 | return ((1ull << component) & component_mask) != 0; | 588 | return ((1ull << component) & component_mask) != 0; |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 582c811e0..2d56370c7 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -1853,15 +1853,47 @@ private: | |||
| 1853 | coord = "vec2 coords = vec2(" + x + ", " + y + ");"; | 1853 | coord = "vec2 coords = vec2(" + x + ", " + y + ");"; |
| 1854 | texture_type = Tegra::Shader::TextureType::Texture2D; | 1854 | texture_type = Tegra::Shader::TextureType::Texture2D; |
| 1855 | } | 1855 | } |
| 1856 | // TODO: make sure coordinates are always indexed to gpr8 and gpr20 is always bias | ||
| 1857 | // or lod. | ||
| 1858 | const std::string op_c = regs.GetRegisterAsFloat(instr.gpr20); | ||
| 1856 | 1859 | ||
| 1857 | const std::string sampler = GetSampler(instr.sampler, texture_type, false); | 1860 | const std::string sampler = GetSampler(instr.sampler, texture_type, false); |
| 1858 | // Add an extra scope and declare the texture coords inside to prevent | 1861 | // Add an extra scope and declare the texture coords inside to prevent |
| 1859 | // overwriting them in case they are used as outputs of the texs instruction. | 1862 | // overwriting them in case they are used as outputs of the texs instruction. |
| 1863 | |||
| 1860 | shader.AddLine("{"); | 1864 | shader.AddLine("{"); |
| 1861 | ++shader.scope; | 1865 | ++shader.scope; |
| 1862 | shader.AddLine(coord); | 1866 | shader.AddLine(coord); |
| 1863 | const std::string texture = "texture(" + sampler + ", coords)"; | 1867 | std::string texture; |
| 1864 | 1868 | ||
| 1869 | switch (instr.tex.process_mode) { | ||
| 1870 | case Tegra::Shader::TextureProcessMode::None: { | ||
| 1871 | texture = "texture(" + sampler + ", coords)"; | ||
| 1872 | break; | ||
| 1873 | } | ||
| 1874 | case Tegra::Shader::TextureProcessMode::LZ: { | ||
| 1875 | texture = "textureLod(" + sampler + ", coords, 0.0)"; | ||
| 1876 | break; | ||
| 1877 | } | ||
| 1878 | case Tegra::Shader::TextureProcessMode::LB: | ||
| 1879 | case Tegra::Shader::TextureProcessMode::LBA: { | ||
| 1880 | // TODO: Figure if A suffix changes the equation at all. | ||
| 1881 | texture = "texture(" + sampler + ", coords, " + op_c + ')'; | ||
| 1882 | break; | ||
| 1883 | } | ||
| 1884 | case Tegra::Shader::TextureProcessMode::LL: | ||
| 1885 | case Tegra::Shader::TextureProcessMode::LLA: { | ||
| 1886 | // TODO: Figure if A suffix changes the equation at all. | ||
| 1887 | texture = "textureLod(" + sampler + ", coords, " + op_c + ')'; | ||
| 1888 | break; | ||
| 1889 | } | ||
| 1890 | default: { | ||
| 1891 | texture = "texture(" + sampler + ", coords)"; | ||
| 1892 | LOG_CRITICAL(HW_GPU, "Unhandled texture process mode {}", | ||
| 1893 | static_cast<u32>(instr.tex.process_mode.Value())); | ||
| 1894 | UNREACHABLE(); | ||
| 1895 | } | ||
| 1896 | } | ||
| 1865 | size_t dest_elem{}; | 1897 | size_t dest_elem{}; |
| 1866 | for (size_t elem = 0; elem < 4; ++elem) { | 1898 | for (size_t elem = 0; elem < 4; ++elem) { |
| 1867 | if (!instr.tex.IsComponentEnabled(elem)) { | 1899 | if (!instr.tex.IsComponentEnabled(elem)) { |