VERY experimental Nintendo Switch 2 emulator
C++
Implemented TXQ dimension query type, used by SMO.
FernandoS276dd5b335700c
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.hindex 9bfeff5b6b..6cfdb6e278 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 {TextureCube = 3,};+enum class TextureQueryType : u64 {+ Dimension = 1,+ TextureType = 2,+ SamplePosition = 5,+ Filter = 16,+ LevelOfDetail = 18,+ Wrap = 20,+ BorderColor = 22,+};+enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 };enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 };@@ -518,6 +528,11 @@ union Instruction {}} tex;+ union {+ BitField<22, 6, TextureQueryType> query_type;+ BitField<31, 4, u64> component_mask;+ } txq;+union {BitField<28, 1, u64> array;BitField<29, 2, TextureType> texture_type;@@ -670,7 +685,7 @@ public:LDG, // Load from global memorySTG, // Store in global memoryTEX,- TXQ, // Texture Query+ TXQ, // Texture QueryTEXS, // Texture Fetch with scalar/non-vec4 source/destinationsTLDS, // Texture Load with scalar/non-vec4 source/destinationsTLD4, // Texture Load 4diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cppindex 172ba83356..6d895bbb67 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:WriteTexsInstruction(instr, coord, texture);break;}+ case OpCode::Id::TXQ: {+ // TODO: the new commits on the texture refactor, change the way samplers work.+ // Sadly, not all texture instructions specify the type of texture their sampler+ // uses. This must be fixed at a later instance.+ const std::string sampler =+ GetSampler(instr.sampler, Tegra::Shader::TextureType::Texture2D, false);+ switch (instr.txq.query_type) {+ case Tegra::Shader::TextureQueryType::Dimension: {+ const std::string texture = "textureQueryLevels(" + sampler + ')';+ regs.SetRegisterToInteger(instr.gpr0, true, 0, texture, 1, 1);+ break;+ }+ default: {+ LOG_CRITICAL(HW_GPU, "Unhandled texture query type: {}",+ static_cast<u32>(instr.txq.query_type.Value()));+ UNREACHABLE();+ }+ }+ break;+ }default: {LOG_CRITICAL(HW_GPU, "Unhandled memory instruction: {}", opcode->GetName());UNREACHABLE();