summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar FernandoS272018-09-07 21:09:39 -0400
committerGravatar FernandoS272018-09-12 12:28:22 -0400
commita99d9db32faef06c74a1e2fd5fc8715a8f3016e1 (patch)
tree9fb83a733934972e9d2ec30117c89ca73b529679 /src
parentMerge pull request #1291 from lioncash/default (diff)
downloadyuzu-a99d9db32faef06c74a1e2fd5fc8715a8f3016e1.tar.gz
yuzu-a99d9db32faef06c74a1e2fd5fc8715a8f3016e1.tar.xz
yuzu-a99d9db32faef06c74a1e2fd5fc8715a8f3016e1.zip
Implemented Texture Processing Modes
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/shader_bytecode.h10
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp34
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 9176a8dbc..7d3e2f8fc 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
257enum 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
257enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 }; 266enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 };
258enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 }; 267enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 };
259 268
@@ -522,6 +531,7 @@ union Instruction {
522 BitField<28, 1, u64> array; 531 BitField<28, 1, u64> array;
523 BitField<29, 2, TextureType> texture_type; 532 BitField<29, 2, TextureType> texture_type;
524 BitField<31, 4, u64> component_mask; 533 BitField<31, 4, u64> component_mask;
534 BitField<55, 3, TextureProcessMode> process_mode;
525 535
526 bool IsComponentEnabled(size_t component) const { 536 bool IsComponentEnabled(size_t component) const {
527 return ((1ull << component) & component_mask) != 0; 537 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 e350113f1..64f3f341a 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -1786,15 +1786,47 @@ private:
1786 coord = "vec2 coords = vec2(" + x + ", " + y + ");"; 1786 coord = "vec2 coords = vec2(" + x + ", " + y + ");";
1787 texture_type = Tegra::Shader::TextureType::Texture2D; 1787 texture_type = Tegra::Shader::TextureType::Texture2D;
1788 } 1788 }
1789 // TODO: make sure coordinates are always indexed to gpr8 and gpr20 is always bias
1790 // or lod.
1791 const std::string op_c = regs.GetRegisterAsFloat(instr.gpr20);
1789 1792
1790 const std::string sampler = GetSampler(instr.sampler, texture_type, false); 1793 const std::string sampler = GetSampler(instr.sampler, texture_type, false);
1791 // Add an extra scope and declare the texture coords inside to prevent 1794 // Add an extra scope and declare the texture coords inside to prevent
1792 // overwriting them in case they are used as outputs of the texs instruction. 1795 // overwriting them in case they are used as outputs of the texs instruction.
1796
1793 shader.AddLine("{"); 1797 shader.AddLine("{");
1794 ++shader.scope; 1798 ++shader.scope;
1795 shader.AddLine(coord); 1799 shader.AddLine(coord);
1796 const std::string texture = "texture(" + sampler + ", coords)"; 1800 std::string texture;
1797 1801
1802 switch (instr.tex.process_mode) {
1803 case Tegra::Shader::TextureProcessMode::None: {
1804 texture = "texture(" + sampler + ", coords)";
1805 break;
1806 }
1807 case Tegra::Shader::TextureProcessMode::LZ: {
1808 texture = "textureLod(" + sampler + ", coords, 0.0)";
1809 break;
1810 }
1811 case Tegra::Shader::TextureProcessMode::LB:
1812 case Tegra::Shader::TextureProcessMode::LBA: {
1813 // TODO: Figure if A suffix changes the equation at all.
1814 texture = "texture(" + sampler + ", coords, " + op_c + ')';
1815 break;
1816 }
1817 case Tegra::Shader::TextureProcessMode::LL:
1818 case Tegra::Shader::TextureProcessMode::LLA: {
1819 // TODO: Figure if A suffix changes the equation at all.
1820 texture = "textureLod(" + sampler + ", coords, " + op_c + ')';
1821 break;
1822 }
1823 default: {
1824 texture = "texture(" + sampler + ", coords)";
1825 LOG_CRITICAL(HW_GPU, "Unhandled texture process mode {}",
1826 static_cast<u32>(instr.tex.process_mode.Value()));
1827 UNREACHABLE();
1828 }
1829 }
1798 size_t dest_elem{}; 1830 size_t dest_elem{};
1799 for (size_t elem = 0; elem < 4; ++elem) { 1831 for (size_t elem = 0; elem < 4; ++elem) {
1800 if (!instr.tex.IsComponentEnabled(elem)) { 1832 if (!instr.tex.IsComponentEnabled(elem)) {