diff options
| -rw-r--r-- | src/video_core/engines/shader_bytecode.h | 19 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 20 |
2 files changed, 37 insertions, 2 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index d2388673e..6cfdb6e27 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h | |||
| @@ -244,6 +244,16 @@ enum class TextureType : u64 { | |||
| 244 | TextureCube = 3, | 244 | TextureCube = 3, |
| 245 | }; | 245 | }; |
| 246 | 246 | ||
| 247 | enum class TextureQueryType : u64 { | ||
| 248 | Dimension = 1, | ||
| 249 | TextureType = 2, | ||
| 250 | SamplePosition = 5, | ||
| 251 | Filter = 16, | ||
| 252 | LevelOfDetail = 18, | ||
| 253 | Wrap = 20, | ||
| 254 | BorderColor = 22, | ||
| 255 | }; | ||
| 256 | |||
| 247 | enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 }; | 257 | enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 }; |
| 248 | enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 }; | 258 | enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 }; |
| 249 | 259 | ||
| @@ -519,6 +529,11 @@ union Instruction { | |||
| 519 | } tex; | 529 | } tex; |
| 520 | 530 | ||
| 521 | union { | 531 | union { |
| 532 | BitField<22, 6, TextureQueryType> query_type; | ||
| 533 | BitField<31, 4, u64> component_mask; | ||
| 534 | } txq; | ||
| 535 | |||
| 536 | union { | ||
| 522 | BitField<28, 1, u64> array; | 537 | BitField<28, 1, u64> array; |
| 523 | BitField<29, 2, TextureType> texture_type; | 538 | BitField<29, 2, TextureType> texture_type; |
| 524 | BitField<56, 2, u64> component; | 539 | BitField<56, 2, u64> component; |
| @@ -670,7 +685,7 @@ public: | |||
| 670 | LDG, // Load from global memory | 685 | LDG, // Load from global memory |
| 671 | STG, // Store in global memory | 686 | STG, // Store in global memory |
| 672 | TEX, | 687 | TEX, |
| 673 | TEXQ, // Texture Query | 688 | TXQ, // Texture Query |
| 674 | TEXS, // Texture Fetch with scalar/non-vec4 source/destinations | 689 | TEXS, // Texture Fetch with scalar/non-vec4 source/destinations |
| 675 | TLDS, // Texture Load with scalar/non-vec4 source/destinations | 690 | TLDS, // Texture Load with scalar/non-vec4 source/destinations |
| 676 | TLD4, // Texture Load 4 | 691 | TLD4, // Texture Load 4 |
| @@ -894,7 +909,7 @@ private: | |||
| 894 | INST("1110111011010---", Id::LDG, Type::Memory, "LDG"), | 909 | INST("1110111011010---", Id::LDG, Type::Memory, "LDG"), |
| 895 | INST("1110111011011---", Id::STG, Type::Memory, "STG"), | 910 | INST("1110111011011---", Id::STG, Type::Memory, "STG"), |
| 896 | INST("110000----111---", Id::TEX, Type::Memory, "TEX"), | 911 | INST("110000----111---", Id::TEX, Type::Memory, "TEX"), |
| 897 | INST("1101111101001---", Id::TEXQ, Type::Memory, "TEXQ"), | 912 | INST("1101111101001---", Id::TXQ, Type::Memory, "TXQ"), |
| 898 | INST("1101100---------", Id::TEXS, Type::Memory, "TEXS"), | 913 | INST("1101100---------", Id::TEXS, Type::Memory, "TEXS"), |
| 899 | INST("1101101---------", Id::TLDS, Type::Memory, "TLDS"), | 914 | INST("1101101---------", Id::TLDS, Type::Memory, "TLDS"), |
| 900 | INST("110010----111---", Id::TLD4, Type::Memory, "TLD4"), | 915 | INST("110010----111---", Id::TLD4, Type::Memory, "TLD4"), |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 172ba8335..6d895bbb6 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -1920,6 +1920,26 @@ private: | |||
| 1920 | WriteTexsInstruction(instr, coord, texture); | 1920 | WriteTexsInstruction(instr, coord, texture); |
| 1921 | break; | 1921 | break; |
| 1922 | } | 1922 | } |
| 1923 | case OpCode::Id::TXQ: { | ||
| 1924 | // TODO: the new commits on the texture refactor, change the way samplers work. | ||
| 1925 | // Sadly, not all texture instructions specify the type of texture their sampler | ||
| 1926 | // uses. This must be fixed at a later instance. | ||
| 1927 | const std::string sampler = | ||
| 1928 | GetSampler(instr.sampler, Tegra::Shader::TextureType::Texture2D, false); | ||
| 1929 | switch (instr.txq.query_type) { | ||
| 1930 | case Tegra::Shader::TextureQueryType::Dimension: { | ||
| 1931 | const std::string texture = "textureQueryLevels(" + sampler + ')'; | ||
| 1932 | regs.SetRegisterToInteger(instr.gpr0, true, 0, texture, 1, 1); | ||
| 1933 | break; | ||
| 1934 | } | ||
| 1935 | default: { | ||
| 1936 | LOG_CRITICAL(HW_GPU, "Unhandled texture query type: {}", | ||
| 1937 | static_cast<u32>(instr.txq.query_type.Value())); | ||
| 1938 | UNREACHABLE(); | ||
| 1939 | } | ||
| 1940 | } | ||
| 1941 | break; | ||
| 1942 | } | ||
| 1923 | default: { | 1943 | default: { |
| 1924 | LOG_CRITICAL(HW_GPU, "Unhandled memory instruction: {}", opcode->GetName()); | 1944 | LOG_CRITICAL(HW_GPU, "Unhandled memory instruction: {}", opcode->GetName()); |
| 1925 | UNREACHABLE(); | 1945 | UNREACHABLE(); |