mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 20:28:38 +00:00
d3d12_xs: fence slot 12 returns the address of a live completed value
The retail executable calls fence slot 12, one past ID3D12Fence1, as (value, descriptor, flags) and reads the return as a pointer to the fence's 64-bit completed value: it compares it with ~0 and subtracts the value it waits for. The proxy refused it with E_NOTIMPL, which the title then dereferenced. Each fence now gets a mirror on its first slot 12 call. A wait-thread callback reads the real fence's completed value into it and re-arms SetEventOnCompletion(value + 1), so it follows every completion without another call; slot 12 and the CPU Signal refresh it at once, under a lock. After device removal it holds ~0 and nothing is re-armed. The release of the proxy unregisters the wait before the real fence goes. The descriptor's code pointer is not called. Tests: xs_proxy_mock_test (mock fences now keep a completed value and arm one event) and queue_proxy_test (a real queue signal reaches the mirror). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -389,13 +389,30 @@ int check_slots(const Backend& b) {
|
||||
}
|
||||
}
|
||||
|
||||
// The refused tail: every slot from the end of the public chain to the end of the table.
|
||||
// Fence slot 12 (value, descriptor, flags): the address of the completed value, which follows a queue's
|
||||
// signal without another call (a wait on the real fence refreshes it).
|
||||
{
|
||||
before = fhits(12);
|
||||
const auto* completed = reinterpret_cast<const volatile UINT64*>(raw_call(fence.p, 12, 9, 0, 0));
|
||||
EXPECT(completed && *completed == fence->GetCompletedValue() && fhits(12) == before + 1);
|
||||
EXPECT(SUCCEEDED(queue->Signal(fence.p, 9)));
|
||||
bool seen = false;
|
||||
for (int i = 0; i < 5000 && !seen; ++i) {
|
||||
seen = *completed == 9;
|
||||
if (!seen) Sleep(1);
|
||||
}
|
||||
EXPECT(seen);
|
||||
EXPECT(raw_call(fence.p, 12, 9, 0, 0) == reinterpret_cast<std::uint64_t>(completed));
|
||||
}
|
||||
|
||||
// The refused tail: every slot from the end of the public chain to the end of the table, but fence slot 12.
|
||||
for (unsigned slot = 19; slot < xs::queue_proxy_table_size(); ++slot) {
|
||||
before = qhits(slot);
|
||||
EXPECT(as_hr(call_slot(queue.p, slot)) == E_NOTIMPL);
|
||||
EXPECT(qhits(slot) == before + 1 && xs::queue_slot_first_call_seen(slot));
|
||||
}
|
||||
for (unsigned slot = fence_slots; slot < xs::fence_proxy_table_size(); ++slot) {
|
||||
if (slot == 12) continue;
|
||||
before = fhits(slot);
|
||||
EXPECT(as_hr(call_slot(fence.p, slot)) == E_NOTIMPL);
|
||||
EXPECT(fhits(slot) == before + 1 && xs::fence_slot_first_call_seen(slot));
|
||||
@ -406,7 +423,8 @@ int check_slots(const Backend& b) {
|
||||
EXPECT(xs::command_object_proxy_ref_count(queue.p) == 1 && xs::command_object_proxy_ref_count(fence.p) == 1);
|
||||
}
|
||||
EXPECT(xs::device_proxy_ref_count(device) == device_refs); // every queue and fence gave its reference back
|
||||
std::printf("%s: every public queue and fence slot forwarded and counted; tail refused\n", label);
|
||||
std::printf("%s: every public queue and fence slot forwarded and counted; fence slot 12 follows a queue "
|
||||
"signal; tail refused\n", label);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user