1
0
Fork 0
forked from suyu/suyu

Shader: Added bitfields for the texture type of the various sampling instructions.

This commit is contained in:
Subv 2018-08-19 12:46:35 -05:00
parent 656758fd81
commit 73b937b190

View file

@ -222,6 +222,13 @@ enum class PredicateResultMode : u64 {
NotZero = 0x3, NotZero = 0x3,
}; };
enum class TextureType : u64 {
Texture1D = 0,
Texture2D = 1,
Texture3D = 2,
TextureCube = 3,
};
union Instruction { union Instruction {
Instruction& operator=(const Instruction& instr) { Instruction& operator=(const Instruction& instr) {
value = instr.value; value = instr.value;
@ -429,6 +436,8 @@ union Instruction {
} conversion; } conversion;
union { union {
BitField<28, 1, u64> array;
BitField<29, 2, TextureType> texture_type;
BitField<31, 4, u64> component_mask; BitField<31, 4, u64> component_mask;
bool IsComponentEnabled(size_t component) const { bool IsComponentEnabled(size_t component) const {
@ -437,9 +446,39 @@ union Instruction {
} tex; } tex;
union { union {
BitField<50, 3, u64> component_mask_selector; BitField<28, 1, u64> array;
BitField<29, 2, TextureType> texture_type;
BitField<56, 2, u64> component;
} tld4;
union {
BitField<52, 2, u64> component;
} tld4s;
union {
BitField<0, 8, Register> gpr0; BitField<0, 8, Register> gpr0;
BitField<28, 8, Register> gpr28; BitField<28, 8, Register> gpr28;
BitField<50, 3, u64> component_mask_selector;
BitField<53, 4, u64> texture_info;
TextureType GetTextureType() const {
// The TEXS instruction has a weird encoding for the texture type.
if (texture_info == 0)
return TextureType::Texture1D;
if (texture_info >= 1 && texture_info <= 9)
return TextureType::Texture2D;
if (texture_info >= 10 && texture_info <= 11)
return TextureType::Texture3D;
if (texture_info >= 12 && texture_info <= 13)
return TextureType::TextureCube;
UNIMPLEMENTED();
}
bool IsArrayTexture() const {
// TEXS only supports Texture2D arrays.
return texture_info >= 7 && texture_info <= 9;
}
bool HasTwoDestinations() const { bool HasTwoDestinations() const {
return gpr28.Value() != Register::ZeroIndex; return gpr28.Value() != Register::ZeroIndex;
@ -459,6 +498,31 @@ union Instruction {
} }
} texs; } texs;
union {
BitField<53, 4, u64> texture_info;
TextureType GetTextureType() const {
// The TLDS instruction has a weird encoding for the texture type.
if (texture_info >= 0 && texture_info <= 1) {
return TextureType::Texture1D;
}
if (texture_info == 2 || texture_info == 8 || texture_info == 12 ||
texture_info >= 4 && texture_info <= 6) {
return TextureType::Texture2D;
}
if (texture_info == 7) {
return TextureType::Texture3D;
}
UNIMPLEMENTED();
}
bool IsArrayTexture() const {
// TEXS only supports Texture2D arrays.
return texture_info == 8;
}
} tlds;
union { union {
BitField<20, 24, u64> target; BitField<20, 24, u64> target;
BitField<5, 1, u64> constant_buffer; BitField<5, 1, u64> constant_buffer;