mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 08:13:05 +00:00
shader: decode RDNA2 bit-reverse SDWA source selectors
Co-authored-by: TheCruZ <thecruzwtf@gmail.com>
This commit is contained in:
1 parent
ec3e48cdde
commit
d890bb190c
3 files changed
+55
No files matched your search
@@ -551,6 +551,7 @@ constexpr Vop1SdwaRule VOP1_SDWA_RULES[] = {
|
|||||||
// partial destination may combine with any source selector.
|
// partial destination may combine with any source selector.
|
||||||
{Opcode::V_NOT_B32, SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), SdwaSelBytes() | SdwaSelWords(),
|
{Opcode::V_NOT_B32, SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), SdwaSelBytes() | SdwaSelWords(),
|
||||||
SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), false},
|
SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), false},
|
||||||
|
{Opcode::V_BFREV_B32, SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), 0, 0, false},
|
||||||
{Opcode::V_FFBL_B32, SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), 0, 0, false},
|
{Opcode::V_FFBL_B32, SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), 0, 0, false},
|
||||||
{Opcode::V_FFBH_U32, SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), 0, 0, false},
|
{Opcode::V_FFBH_U32, SdwaSelBytes() | SdwaSelWords() | SdwaSelFull(), 0, 0, false},
|
||||||
{Opcode::V_CVT_F32_F16, SdwaSelWords() | SdwaSelFull(), 0, 0, true},
|
{Opcode::V_CVT_F32_F16, SdwaSelWords() | SdwaSelFull(), 0, 0, true},
|
||||||
|
|||||||
@@ -20361,6 +20361,36 @@ TestCase VectorFfbhI32NativeAndVop3OnGpu() {
|
|||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestCase Vop1SdwaBfrevSourceSelectors() {
|
||||||
|
using O = ShaderOpcode;
|
||||||
|
constexpr u32 expected[2][7] = {
|
||||||
|
{0x8f000000u, 0xd5000000u, 0x21000000u, 0x49000000u,
|
||||||
|
0x8fd50000u, 0x21490000u, 0x8fd52149u},
|
||||||
|
{0x8fffffffu, 0xd5ffffffu, 0x21ffffffu, 0x49ffffffu,
|
||||||
|
0x8fd5ffffu, 0x2149ffffu, 0x8fd52149u}};
|
||||||
|
TestCase test;
|
||||||
|
test.name = "Vop1SdwaBfrevSourceSelectors";
|
||||||
|
for (u32 sext = 0; sext < 2; sext++) {
|
||||||
|
for (u32 selector = 0; selector < 7; selector++) {
|
||||||
|
const u32 index = static_cast<u32>(test.initial.size());
|
||||||
|
AppendVMovU32(&test.code, 30, index * 4u);
|
||||||
|
AppendBufferLoadDword(&test.code, 0, 30);
|
||||||
|
// selector=4, sext=0 reproduces captured words 7e0070f9, 00040600.
|
||||||
|
test.code.insert(test.code.end(),
|
||||||
|
{0x7e0070f9u, EncodeVop1Sdwa(0, 6, 0, selector, sext)});
|
||||||
|
AppendStoreVgpr(&test.code, 0, index);
|
||||||
|
test.initial.push_back(0x9284abf1u);
|
||||||
|
test.expected.push_back(expected[sext][selector]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AppendEnd(&test.code);
|
||||||
|
test.opcodes = {O::V_MOV_B32, O::BUFFER_LOAD_DWORD, O::V_BFREV_B32,
|
||||||
|
O::BUFFER_STORE_DWORD, O::S_ENDPGM};
|
||||||
|
test.decoded_counts = {{"V_BFREV_B32 v0, v0.sdwa(sel=4,sext=0)", 1}};
|
||||||
|
test.required_spirv = {"OpBitFieldUExtract", "OpBitFieldSExtract", "OpBitReverse"};
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
TestCase Vop1SdwaFfbhCapturedScalarLowWordSource() {
|
TestCase Vop1SdwaFfbhCapturedScalarLowWordSource() {
|
||||||
using O = ShaderOpcode;
|
using O = ShaderOpcode;
|
||||||
|
|
||||||
@@ -32274,6 +32304,7 @@ std::vector<TestCase> MakeCases() {
|
|||||||
AddCase(VectorVop3MoveAppliesFloatSourceModifiers);
|
AddCase(VectorVop3MoveAppliesFloatSourceModifiers);
|
||||||
AddCase(VectorIntegerOps);
|
AddCase(VectorIntegerOps);
|
||||||
AddCase(VectorFfbhI32NativeAndVop3OnGpu);
|
AddCase(VectorFfbhI32NativeAndVop3OnGpu);
|
||||||
|
AddCase(Vop1SdwaBfrevSourceSelectors);
|
||||||
AddCase(Vop1SdwaFfbhCapturedScalarLowWordSource);
|
AddCase(Vop1SdwaFfbhCapturedScalarLowWordSource);
|
||||||
AddCase(Vop1SdwaFfblCapturedHighWordSource);
|
AddCase(Vop1SdwaFfblCapturedHighWordSource);
|
||||||
AddCase(Vop1SdwaNotCapturedByte0Source);
|
AddCase(Vop1SdwaNotCapturedByte0Source);
|
||||||
@@ -37751,6 +37782,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
if (argc == 2 && std::strcmp(argv[1], "--sdwa-ffbh-only") == 0) {
|
if (argc == 2 && std::strcmp(argv[1], "--sdwa-ffbh-only") == 0) {
|
||||||
VulkanHarness vulkan;
|
VulkanHarness vulkan;
|
||||||
|
RunCase(&vulkan, Vop1SdwaBfrevSourceSelectors());
|
||||||
RunCase(&vulkan, Vop1SdwaFfbhCapturedScalarLowWordSource());
|
RunCase(&vulkan, Vop1SdwaFfbhCapturedScalarLowWordSource());
|
||||||
RunCase(&vulkan, VectorFfbhI32NativeAndVop3OnGpu());
|
RunCase(&vulkan, VectorFfbhI32NativeAndVop3OnGpu());
|
||||||
RunCase(&vulkan, Vop1SdwaFfblCapturedHighWordSource());
|
RunCase(&vulkan, Vop1SdwaFfblCapturedHighWordSource());
|
||||||
|
|||||||
@@ -3579,6 +3579,27 @@ void TestNewShaderRecompilerCapturedVop1SdwaByteConvert() {
|
|||||||
"V_CVT_F16_U16 accepted unimplemented SDWA byte sign extension");
|
"V_CVT_F16_U16 accepted unimplemented SDWA byte sign extension");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestNewShaderRecompilerVop1SdwaBfrev() {
|
||||||
|
using namespace ShaderRecompiler::Decoder;
|
||||||
|
const uint32_t captured[] = {0x7e0070f9u, 0x00040600u};
|
||||||
|
Instruction decoded;
|
||||||
|
DecodeInstruction(captured, 0, decoded);
|
||||||
|
Check(decoded.opcode == Opcode::V_BFREV_B32 && decoded.word_count == 2 &&
|
||||||
|
decoded.dst.kind == OperandKind::Vgpr && decoded.dst.reg == 0 &&
|
||||||
|
decoded.dst.sdwa_sel == 6 && decoded.src0.kind == OperandKind::Vgpr &&
|
||||||
|
decoded.src0.reg == 0 && decoded.src0.sdwa_sel == 4 &&
|
||||||
|
!decoded.src0.sdwa_sext,
|
||||||
|
"captured V_BFREV_B32 SDWA source metadata is incorrect");
|
||||||
|
for (const uint32_t modifier : {0x00070600u, 0x00140600u, 0x00240600u,
|
||||||
|
0x00042600u, 0x00044600u, 0x00040400u,
|
||||||
|
0x00041e00u}) {
|
||||||
|
const uint32_t invalid[] = {captured[0], modifier};
|
||||||
|
DecodeInstruction(invalid, 0, decoded);
|
||||||
|
Check(decoded.word_count == 2 && decoded.opcode == Opcode::UNSUPPORTED,
|
||||||
|
"V_BFREV_B32 SDWA accepted unsupported selectors or modifiers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TestNewShaderRecompilerVop1SdwaNotDestination() {
|
void TestNewShaderRecompilerVop1SdwaNotDestination() {
|
||||||
auto options = MakeCompileOptions(ShaderType::Pixel);
|
auto options = MakeCompileOptions(ShaderType::Pixel);
|
||||||
|
|
||||||
@@ -14546,6 +14567,7 @@ int main() {
|
|||||||
TestNewShaderRecompilerDsReadWrite2Translation();
|
TestNewShaderRecompilerDsReadWrite2Translation();
|
||||||
TestNewShaderRecompilerDsWideAndAtomicTranslation();
|
TestNewShaderRecompilerDsWideAndAtomicTranslation();
|
||||||
TestNewShaderRecompilerCapturedVop1SdwaByteConvert();
|
TestNewShaderRecompilerCapturedVop1SdwaByteConvert();
|
||||||
|
TestNewShaderRecompilerVop1SdwaBfrev();
|
||||||
TestNewShaderRecompilerVop1SdwaNotDestination();
|
TestNewShaderRecompilerVop1SdwaNotDestination();
|
||||||
TestNewShaderRecompilerScalarMemoryBindingDomains();
|
TestNewShaderRecompilerScalarMemoryBindingDomains();
|
||||||
// Opcode semantics and optimized SPIR-V are exercised by
|
// Opcode semantics and optimized SPIR-V are exercised by
|
||||||
|
|||||||
Reference in new issue
Block a user