mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
perf(recompiler): load the written-page slot before the CAS
note_bda_write ran a device-scope compare-exchange on every probe, also when the slot already held the page. The table lives in host-visible memory, so each BDA store paid an atomic across PCIe, and nearly every store hits a page an earlier store noted. Load the slot first and only compare-exchange when it does not hold the page. The slots probed, the pages recorded and the overflow report are unchanged. DOOM (PPSA99666) presents through a compute kernel that stores about two million pixels through raw pointers per frame: 248 ms per dispatch before, 8.1 ms after, on an RTX 5070 Ti. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -153,10 +153,16 @@ static std::uint32_t DefineBdaNoteWrite(SpirvEmitterState& state) {
|
||||
state.module.AddFunction(spv::OpBranchConditional, searching, body, merge);
|
||||
EmitLabel(state, body);
|
||||
const auto slot = binary(spv::OpIAdd, u32, constant(BdaAbi::WrittenSlotsWord), binary(spv::OpBitwiseAnd, u32, binary(spv::OpIAdd, u32, hash, probe), constant(BdaAbi::WrittenPageSlots - 1u)));
|
||||
const auto previous = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpAtomicCompareExchange, u32, previous, BdaWord(state, state.faultBufferVariable, slot), scope, relaxed, relaxed, page, constant(0u));
|
||||
const auto taken = binary(spv::OpLogicalOr, boolean, binary(spv::OpIEqual, boolean, previous, constant(0u)), binary(spv::OpIEqual, boolean, previous, page));
|
||||
state.module.AddFunction(spv::OpStore, done, taken);
|
||||
const auto current = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpAtomicLoad, u32, current, BdaWord(state, state.faultBufferVariable, slot), scope, relaxed);
|
||||
const auto held = binary(spv::OpIEqual, boolean, current, page);
|
||||
state.module.AddFunction(spv::OpStore, done, held);
|
||||
EmitIfCondition(state, Unary(state, spv::OpLogicalNot, boolean, held), [&] {
|
||||
const auto previous = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpAtomicCompareExchange, u32, previous, BdaWord(state, state.faultBufferVariable, slot), scope, relaxed, relaxed, page, constant(0u));
|
||||
const auto taken = binary(spv::OpLogicalOr, boolean, binary(spv::OpIEqual, boolean, previous, constant(0u)), binary(spv::OpIEqual, boolean, previous, page));
|
||||
state.module.AddFunction(spv::OpStore, done, taken);
|
||||
});
|
||||
state.module.AddFunction(spv::OpBranch, continuation);
|
||||
EmitLabel(state, continuation);
|
||||
state.module.AddFunction(spv::OpStore, counter, binary(spv::OpIAdd, u32, probe, constant(1u)));
|
||||
|
||||
Reference in New Issue
Block a user