mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
shader: took fixes from PR 427
- apply c8f34f9's ResourceTracking portability fix
- complete V_CMP_LT_U64 and S_FLBIT_I32_B32 support
- add the sceAmprCommandBufferWaitOnAddress NID from f625a47
- add decoder and compute tests for both shader operations
Co-authored-by: Mac <me@itsmemac.com>
This commit is contained in:
@@ -12960,6 +12960,36 @@ TestCase ScalarFlbitI32B64Gpu() {
|
||||
O::BUFFER_STORE_DWORD, O::S_ENDPGM}};
|
||||
}
|
||||
|
||||
TestCase ScalarFlbitI32B32Gpu() {
|
||||
using O = ShaderOpcode;
|
||||
|
||||
std::vector<u32> code;
|
||||
AppendSMovLiteral(&code, 0, 0x00000000u);
|
||||
code.push_back(EncodeSop1(0x15, 20, 0));
|
||||
|
||||
AppendSMovLiteral(&code, 0, 0x0000ccccu);
|
||||
code.push_back(EncodeSop1(0x15, 21, 0));
|
||||
|
||||
AppendSMovLiteral(&code, 0, 0x80000000u);
|
||||
code.push_back(EncodeSop1(0x15, 22, 0));
|
||||
|
||||
AppendSMovLiteral(&code, 0, 0x7fffffffu);
|
||||
code.push_back(EncodeSop1(0x15, 23, 0));
|
||||
|
||||
AppendStoreSgpr(&code, 20, 0);
|
||||
AppendStoreSgpr(&code, 21, 1);
|
||||
AppendStoreSgpr(&code, 22, 2);
|
||||
AppendStoreSgpr(&code, 23, 3);
|
||||
AppendEnd(&code);
|
||||
|
||||
return {"ScalarFlbitI32B32Gpu",
|
||||
code,
|
||||
{},
|
||||
{0xffffffffu, 16, 0, 1},
|
||||
{O::S_MOV_B32, O::S_FLBIT_I32_B32, O::V_MOV_B32,
|
||||
O::BUFFER_STORE_DWORD, O::S_ENDPGM}};
|
||||
}
|
||||
|
||||
TestCase ScalarSaveExecOps() {
|
||||
using O = ShaderOpcode;
|
||||
|
||||
@@ -16091,6 +16121,36 @@ TestCase VectorVop3CompareGtU64OnGpu() {
|
||||
return test;
|
||||
}
|
||||
|
||||
TestCase VectorVopcCompareLtU64OnGpu() {
|
||||
using O = ShaderOpcode;
|
||||
|
||||
std::vector<u32> code;
|
||||
AppendVMovU32(&code, 0, 5);
|
||||
AppendVMovU32(&code, 1, 0);
|
||||
AppendVMovU32(&code, 2, 1);
|
||||
|
||||
AppendSMovLiteral(&code, 4, 4);
|
||||
AppendSMovLiteral(&code, 5, 0);
|
||||
code.push_back(EncodeVopc(0xe1, 4, 0));
|
||||
code.push_back(EncodeVop2(0x01, 3, InlineU32(0), 2));
|
||||
AppendStoreVgpr(&code, 3, 0);
|
||||
|
||||
AppendSMovLiteral(&code, 4, 6);
|
||||
code.push_back(EncodeVopc(0xe1, 4, 0));
|
||||
code.push_back(EncodeVop2(0x01, 4, InlineU32(0), 2));
|
||||
AppendStoreVgpr(&code, 4, 1);
|
||||
AppendEnd(&code);
|
||||
|
||||
TestCase test{"VectorVopcCompareLtU64OnGpu",
|
||||
code,
|
||||
{},
|
||||
{1, 0},
|
||||
{O::V_MOV_B32, O::S_MOV_B32, O::V_CMP_LT_U64,
|
||||
O::V_CNDMASK_B32, O::BUFFER_STORE_DWORD, O::S_ENDPGM}};
|
||||
test.decoded_counts = {{"V_CMP_LT_U64 vcc_lo, s4, v0", 2}};
|
||||
return test;
|
||||
}
|
||||
|
||||
TestCase VectorVop3CompareEqI64OnGpu() {
|
||||
using O = ShaderOpcode;
|
||||
|
||||
@@ -21148,6 +21208,7 @@ std::vector<TestCase> MakeCases() {
|
||||
AddCase(ScalarMovB32SpecialAliases);
|
||||
AddCase(ScalarQuadmaskB64);
|
||||
AddCase(ScalarFlbitI32B64Gpu);
|
||||
AddCase(ScalarFlbitI32B32Gpu);
|
||||
AddCase(ScalarSaveExecOps);
|
||||
AddCase(ScalarOrn2SaveexecUsesSourceOrNotExec);
|
||||
AddCase(ScalarGetpcWritesNextInstructionPc);
|
||||
@@ -21238,6 +21299,7 @@ std::vector<TestCase> MakeCases() {
|
||||
AddCase(VectorVop3CompareEqI64OnGpu);
|
||||
AddCase(VectorVop3CompareEqU64OnGpu);
|
||||
AddCase(VectorVop3CompareGtU64OnGpu);
|
||||
AddCase(VectorVopcCompareLtU64OnGpu);
|
||||
AddCase(VectorVop3CompareNeU64OnGpu);
|
||||
AddCase(VectorVopcCmpxNeU64CapturedExecMask);
|
||||
AddCase(VectorVop3CmpxNeI64CapturedExecMask);
|
||||
|
||||
@@ -3969,6 +3969,37 @@ void TestNewShaderDecoderArchitecture() {
|
||||
cmp_eq_u64.src1.kind == OperandKind::VccLo,
|
||||
"decoder rejected the captured VOP3 V_CMP_EQ_U64 instruction");
|
||||
|
||||
const uint32_t completed_pr_opcodes[] = {
|
||||
EncodeSop1(0x15, 0, 1), // s_flbit_i32_b32 s0, s1
|
||||
EncodeVopc(0xe1, 128, 0), // v_cmp_lt_u64 vcc, 0, v[0:1]
|
||||
EncodeSopp(0x01, 0),
|
||||
};
|
||||
Instruction flbit_i32_b32;
|
||||
ShaderRecompiler::Decoder::DecodeInstruction(completed_pr_opcodes, 0u,
|
||||
flbit_i32_b32);
|
||||
Instruction cmp_lt_u64;
|
||||
ShaderRecompiler::Decoder::DecodeInstruction(completed_pr_opcodes, 1u,
|
||||
cmp_lt_u64);
|
||||
Check(flbit_i32_b32.family == Family::SOP1 &&
|
||||
flbit_i32_b32.opcode == Opcode::S_FLBIT_I32_B32 &&
|
||||
flbit_i32_b32.dst.kind == OperandKind::Sgpr &&
|
||||
flbit_i32_b32.dst.reg == 0u &&
|
||||
flbit_i32_b32.src0.kind == OperandKind::Sgpr &&
|
||||
flbit_i32_b32.src0.reg == 1u &&
|
||||
cmp_lt_u64.family == Family::VOPC &&
|
||||
cmp_lt_u64.opcode == Opcode::V_CMP_LT_U64 &&
|
||||
cmp_lt_u64.dst.kind == OperandKind::VccLo,
|
||||
"decoder rejected completed PR #427 scalar/vector opcodes");
|
||||
|
||||
const auto completed_options = MakeCompileOptions(ShaderType::Compute);
|
||||
const auto completed_result =
|
||||
ShaderRecompiler::Recompile(completed_pr_opcodes, completed_options);
|
||||
Check(Common::ContainsStr(completed_result.decoded_dump,
|
||||
"S_FLBIT_I32_B32 s0, s1") &&
|
||||
Common::ContainsStr(completed_result.decoded_dump,
|
||||
"V_CMP_LT_U64 vcc_lo, 0, v0"),
|
||||
"completed PR #427 opcodes were absent from the decoded shader");
|
||||
|
||||
const uint32_t ffbh_i32_code[] = {0x7e1c770eu};
|
||||
Instruction ffbh_i32;
|
||||
ShaderRecompiler::Decoder::DecodeInstruction(ffbh_i32_code, 0u, ffbh_i32);
|
||||
|
||||
Reference in New Issue
Block a user