shader: decode the SHARED_LIMIT and PRIVATE_LIMIT inline constants

Co-authored-by: Senaxx <michelbeld@gmail.com>
This commit is contained in:
nmzikandSenaxx committed 2026-10-26 06:35:17 +01:00
1 parent 3c62269751
commit 025d1f7edf
4 files changed
+37 -11

No files matched your search

@@ -258,7 +258,9 @@ void DecodeScalarSource(uint32_t code, uint32_t pc, Operand& operand) {
case 126u: operand.kind = OperandKind::ExecLo; return; case 126u: operand.kind = OperandKind::ExecLo; return;
case 127u: operand.kind = OperandKind::ExecHi; return; case 127u: operand.kind = OperandKind::ExecHi; return;
case 235u: operand.kind = OperandKind::SharedBase; return; case 235u: operand.kind = OperandKind::SharedBase; return;
case 236u: operand.kind = OperandKind::SharedLimit; return;
case 237u: operand.kind = OperandKind::PrivateBase; return; case 237u: operand.kind = OperandKind::PrivateBase; return;
case 238u: operand.kind = OperandKind::PrivateLimit; return;
case 239u: operand.kind = OperandKind::PopsExitingWaveId; return; case 239u: operand.kind = OperandKind::PopsExitingWaveId; return;
case 248u: case 248u:
operand.kind = OperandKind::FloatInlineConstant; operand.kind = OperandKind::FloatInlineConstant;
@@ -459,7 +461,9 @@ std::string OperandToString(const Operand& operand) {
case OperandKind::M0: text = "m0"; break; case OperandKind::M0: text = "m0"; break;
case OperandKind::PopsExitingWaveId: text = "pops_exiting_wave_id"; break; case OperandKind::PopsExitingWaveId: text = "pops_exiting_wave_id"; break;
case OperandKind::SharedBase: text = "shared_base"; break; case OperandKind::SharedBase: text = "shared_base"; break;
case OperandKind::SharedLimit: text = "shared_limit"; break;
case OperandKind::PrivateBase: text = "private_base"; break; case OperandKind::PrivateBase: text = "private_base"; break;
case OperandKind::PrivateLimit: text = "private_limit"; break;
case OperandKind::Null: text = "null"; break; case OperandKind::Null: text = "null"; break;
default: text = "unknown"; break; default: text = "unknown"; break;
} }
@@ -766,7 +766,9 @@ enum class OperandKind {
M0, M0,
PopsExitingWaveId, PopsExitingWaveId,
SharedBase, SharedBase,
SharedLimit,
PrivateBase, PrivateBase,
PrivateLimit,
Null, Null,
Vgpr, Vgpr,
}; };
@@ -138,6 +138,8 @@ IR::U32 Translator::ReadRawU32(const Decoder::Operand& operand) {
case Decoder::OperandKind::SharedBase: case Decoder::OperandKind::SharedBase:
case Decoder::OperandKind::PrivateBase: case Decoder::OperandKind::PrivateBase:
case Decoder::OperandKind::PopsExitingWaveId: return IR::U32(IR::Value(0u)); case Decoder::OperandKind::PopsExitingWaveId: return IR::U32(IR::Value(0u));
case Decoder::OperandKind::SharedLimit:
case Decoder::OperandKind::PrivateLimit: return IR::U32(IR::Value(0xffffffffu));
case Decoder::OperandKind::Sgpr: case Decoder::OperandKind::Sgpr:
return ir.GetScalarReg(static_cast<IR::ScalarReg>(operand.reg)); return ir.GetScalarReg(static_cast<IR::ScalarReg>(operand.reg));
case Decoder::OperandKind::Vgpr: case Decoder::OperandKind::Vgpr:
@@ -471,17 +473,17 @@ IR::U32 Translator::ReadU32(const Decoder::Operand& operand) {
} }
std::array<IR::U32, 2> Translator::ReadU32Pair(const Decoder::Operand& operand) { std::array<IR::U32, 2> Translator::ReadU32Pair(const Decoder::Operand& operand) {
if (operand.kind == Decoder::OperandKind::PrivateBase || // Each aperture limit is its base plus 0xffffffff.
operand.kind == Decoder::OperandKind::SharedBase) { switch (operand.kind) {
return {IR::U32(IR::Value(0u)), IR::U32(IR::Value( case Decoder::OperandKind::SharedBase:
operand.kind == Decoder::OperandKind::PrivateBase ? Decoder::PrivateApertureHigh case Decoder::OperandKind::SharedLimit:
: Decoder::SharedApertureHigh))}; return {ReadRawU32(operand), IR::U32(IR::Value(Decoder::SharedApertureHigh))};
} case Decoder::OperandKind::PrivateBase:
if (operand.kind == Decoder::OperandKind::ExecLo) { case Decoder::OperandKind::PrivateLimit:
return {ir.GetExecLo(), ir.GetExecHi()}; return {ReadRawU32(operand), IR::U32(IR::Value(Decoder::PrivateApertureHigh))};
} case Decoder::OperandKind::ExecLo: return {ir.GetExecLo(), ir.GetExecHi()};
if (operand.kind == Decoder::OperandKind::VccLo) { case Decoder::OperandKind::VccLo: return {ir.GetVccLo(), ir.GetVccHi()};
return {ir.GetVccLo(), ir.GetVccHi()}; default: break;
} }
if (operand.kind == Decoder::OperandKind::FloatInlineConstant) { if (operand.kind == Decoder::OperandKind::FloatInlineConstant) {
const auto bits = const auto bits =
+18
View File
@@ -22872,6 +22872,23 @@ TestCase Rdna2ScalarOpcodes() {
O::S_SLEEP, O::V_MOV_B32, O::BUFFER_STORE_DWORD, O::S_ENDPGM}}; O::S_SLEEP, O::V_MOV_B32, O::BUFFER_STORE_DWORD, O::S_ENDPGM}};
} }
TestCase ScalarApertureLimits() {
using O = ShaderOpcode;
std::vector<u32> code;
code.push_back(EncodeSop1(0x04, 20, 236));
AppendStoreSgprPair(&code, 20, 0);
code.push_back(EncodeSop1(0x04, 20, 238));
AppendStoreSgprPair(&code, 20, 2);
AppendEnd(&code);
return {"ScalarApertureLimits",
code,
{},
{0xffffffffu, 0x80000000u, 0xffffffffu, 0x70000000u},
{O::S_MOV_B64, O::V_MOV_B32, O::BUFFER_STORE_DWORD, O::S_ENDPGM}};
}
TestCase ScalarTrapDisabledFallsThroughExactRaw() { TestCase ScalarTrapDisabledFallsThroughExactRaw() {
using O = ShaderOpcode; using O = ShaderOpcode;
@@ -44346,6 +44363,7 @@ std::vector<TestCase> MakeCases() {
AddCase(ExactPushConstantExtent); AddCase(ExactPushConstantExtent);
AddCase(ScalarShiftCountsMaskLowBits); AddCase(ScalarShiftCountsMaskLowBits);
AddCase(Rdna2ScalarOpcodes); AddCase(Rdna2ScalarOpcodes);
AddCase(ScalarApertureLimits);
AddCase(ScalarTrapDisabledFallsThroughExactRaw); AddCase(ScalarTrapDisabledFallsThroughExactRaw);
AddCase(ScalarWaitcntDepctrCapturedVmVsrc); AddCase(ScalarWaitcntDepctrCapturedVmVsrc);
AddCase(ScalarExtendedArithmetic); AddCase(ScalarExtendedArithmetic);