Merge pull request #1261 from FernandoS27/txq

shader_decompiler: Implemented (Partialy) TXQ
This commit is contained in:
bunnei 2018-09-09 19:43:10 -04:00 committed by GitHub
commit 0acf9b351f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 2 deletions

View File

@ -244,6 +244,16 @@ enum class TextureType : u64 {
TextureCube = 3, 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 IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 };
enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 }; enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 };
@ -518,6 +528,11 @@ union Instruction {
} }
} tex; } tex;
union {
BitField<22, 6, TextureQueryType> query_type;
BitField<31, 4, u64> component_mask;
} txq;
union { union {
BitField<28, 1, u64> array; BitField<28, 1, u64> array;
BitField<29, 2, TextureType> texture_type; BitField<29, 2, TextureType> texture_type;
@ -670,7 +685,7 @@ public:
LDG, // Load from global memory LDG, // Load from global memory
STG, // Store in global memory STG, // Store in global memory
TEX, TEX,
TEXQ, // Texture Query TXQ, // Texture Query
TEXS, // Texture Fetch with scalar/non-vec4 source/destinations TEXS, // Texture Fetch with scalar/non-vec4 source/destinations
TLDS, // Texture Load with scalar/non-vec4 source/destinations TLDS, // Texture Load with scalar/non-vec4 source/destinations
TLD4, // Texture Load 4 TLD4, // Texture Load 4
@ -894,7 +909,7 @@ private:
INST("1110111011010---", Id::LDG, Type::Memory, "LDG"), INST("1110111011010---", Id::LDG, Type::Memory, "LDG"),
INST("1110111011011---", Id::STG, Type::Memory, "STG"), INST("1110111011011---", Id::STG, Type::Memory, "STG"),
INST("110000----111---", Id::TEX, Type::Memory, "TEX"), INST("110000----111---", Id::TEX, Type::Memory, "TEX"),
INST("1101111101001---", Id::TEXQ, Type::Memory, "TEXQ"), INST("1101111101001---", Id::TXQ, Type::Memory, "TXQ"),
INST("1101100---------", Id::TEXS, Type::Memory, "TEXS"), INST("1101100---------", Id::TEXS, Type::Memory, "TEXS"),
INST("1101101---------", Id::TLDS, Type::Memory, "TLDS"), INST("1101101---------", Id::TLDS, Type::Memory, "TLDS"),
INST("110010----111---", Id::TLD4, Type::Memory, "TLD4"), INST("110010----111---", Id::TLD4, Type::Memory, "TLD4"),

View File

@ -1920,6 +1920,26 @@ private:
WriteTexsInstruction(instr, coord, texture); WriteTexsInstruction(instr, coord, texture);
break; 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: { default: {
LOG_CRITICAL(HW_GPU, "Unhandled memory instruction: {}", opcode->GetName()); LOG_CRITICAL(HW_GPU, "Unhandled memory instruction: {}", opcode->GetName());
UNREACHABLE(); UNREACHABLE();