Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion core/libs/prx/libSceAgcDriver/tests/ShaderModeRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,29 @@ void verifyRecompilePropagation() {

}

void verifyDebugIdentityRegisters() {
constexpr std::uint32_t endProgram = 0xbf810000u;
const auto read = [](std::uint32_t hardwareRegister, std::uint32_t offset, std::uint32_t size) {
return 0xb9140000u | ((size - 1u) << 11u) | (offset << 6u) | hardwareRegister;
};
for (const std::uint32_t hardwareRegister : {23u, 24u}) {
const std::array<std::uint32_t, 2> code{read(hardwareRegister, 18u, 2u), endProgram};
expectRegister(translate(code, std::nullopt), 20u, 0u);
const std::array<std::uint32_t, 2> whole{read(hardwareRegister, 0u, 32u), endProgram};
expectRegister(translate(whole, std::nullopt), 20u, 0u);
const std::array<std::uint32_t, 2> pastRegister{read(hardwareRegister, 31u, 2u), endProgram};
expectRejected(pastRegister, std::nullopt, "past the 32-bit register", 0);
}
const std::array<std::uint32_t, 2> other{read(4u, 0u, 8u), endProgram};
expectRejected(other, std::nullopt, "only the MODE round, denormal and status fields are modeled", 0);
}

int main() {
struct Check {
const char* name;
void (*run)();
};
constexpr std::array<Check, 23> checks{{
constexpr std::array<Check, 24> checks{{
{"encodings", verifyEncodings}, {"reads", verifyReads}, {"dynamicWrites", verifyDynamicWrites},
{"partialOverwrite", verifyDynamicWriteSurvivesPartialOverwrite}, {"immediateWrites", verifyImmediateWrites},
{"denormalImmediateWrites", verifyDenormalImmediateWrites}, {"roundInstruction", verifyRoundInstruction},
Expand All @@ -497,6 +514,7 @@ int main() {
{"loop", verifyRoundingInLoop}, {"propagation", verifyRecompilePropagation}, {"denormalAfterRounding", verifyDenormalReadsAfterRoundingWrites},
{"outputModifierRounding", verifyOutputModifierRounding},
{"statusBitfields", verifyStatusBitfieldReads},
{"debugIdentityRegisters", verifyDebugIdentityRegisters},
}};
int failures = 0;
for (const auto& check : checks) {
Expand Down
14 changes: 12 additions & 2 deletions core/shader/recompiler/Translation/src/ScalarInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,21 @@ bool TranslationContext::emitScalar(const RdnaInstruction& inst) {
return true;
}
case RdnaOpcode::SGetregB32: {
constexpr std::uint32_t HwId1 = 23u;
constexpr std::uint32_t HwId2 = 24u;
const std::uint32_t field = inst.source0.value;
const std::uint32_t offset = (field >> 6u) & 0x1fu;
const std::uint32_t size = ((field >> 11u) & 0x1fu) + 1u;
if ((field & 0x3fu) != 1u || (offset + size > 10u && (offset != 23u || size != 1u))) {
throw std::runtime_error("s_getreg_b32 at pc " + std::to_string(inst.programCounter) + " reads hardware register " + std::to_string(field & 0x3fu) + " bits " + std::to_string(offset) + ".." + std::to_string(offset + size - 1u) + ": only the MODE round, denormal and status fields are modeled");
const std::uint32_t hardwareRegister = field & 0x3fu;
if (hardwareRegister == HwId1 || hardwareRegister == HwId2) {
if (offset + size > 32u) {
throw std::runtime_error("s_getreg_b32 at pc " + std::to_string(inst.programCounter) + " reads hardware register " + std::to_string(hardwareRegister) + " bits " + std::to_string(offset) + ".." + std::to_string(offset + size - 1u) + ": past the 32-bit register");
}
writeRawU32(inst.destination, IrU32(ir.Constant(0u)));
return true;
}
if (hardwareRegister != 1u || (offset + size > 10u && (offset != 23u || size != 1u))) {
throw std::runtime_error("s_getreg_b32 at pc " + std::to_string(inst.programCounter) + " reads hardware register " + std::to_string(hardwareRegister) + " bits " + std::to_string(offset) + ".." + std::to_string(offset + size - 1u) + ": only the MODE round, denormal and status fields are modeled");
}
const std::uint32_t mask = ((1u << size) - 1u) << offset;
if ((rounding.unknown & mask) != 0u) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# shader

## add Functional

- [s_getreg_b32 through HW_ID1 and HW_ID2](../../../core/shader/recompiler/Translation/src/ScalarInstructions.cpp) now answers a read of hardware registers 23 (`HW_ID1`) and 24 (`HW_ID2`) with zero for any field instead of throwing. The RDNA3 instruction set reference lists both as read-only, debug-only registers whose contents are not predictable, which is what makes a fixed answer legitimate, and the host exposes no shader-engine, WGP or wave identity to report: every wave therefore reports engine 0, SIMD 0, wave 0 and VMID 0. The fields these registers carry (wave, SIMD, WGP, SA and SE ids in `HW_ID1`; queue, pipe, ME, state, WG and VM ids in `HW_ID2`) are not compared against console hardware, so a title that distributes work per shader engine sees a single-engine GPU. Every other read-only register (`STATUS`, `TRAPSTS`, `HW_ID`, `GPR_ALLOC`, `LDS_ALLOC`, `IB_STS`, `TBA`, `TMA`, `FLAT_SCR`, `XNACK_MASK`) still throws, and so does a field that runs past the 32-bit register.
Loading