diff options
| author | DevilNine <102010568+DevilNine@users.noreply.github.com> | 2026-11-23 14:46:12 -0300 |
|---|---|---|
| committer | Mumogg <104529023+Mumogg@users.noreply.github.com> | 2026-11-24 03:52:41 -0600 |
| commit | bbae96de2a46e472c5e8627829d17c648b06366e (patch) | |
| tree | 7cd02c19ef7009dced9ea8f9337dba25a7c37f0a /runtime/test/allocator_proxy_test.cpp | |
| parent | 1bd72a87ada80475d2a51f9eda359906d9962a3f (diff) | |
d3d12_xs: handle ID3D12CommandAllocator slot 9 (SetAllocatorCallbackX) on allocator proxy
(cherry picked from commit e29e9899809347a730fd57a14532a22fe0ee7231)
Diffstat (limited to 'runtime/test/allocator_proxy_test.cpp')
| -rw-r--r-- | runtime/test/allocator_proxy_test.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/runtime/test/allocator_proxy_test.cpp b/runtime/test/allocator_proxy_test.cpp index 5f89366f5..b48b224b7 100644 --- a/runtime/test/allocator_proxy_test.cpp +++ b/runtime/test/allocator_proxy_test.cpp | |||
| @@ -58,11 +58,13 @@ using SlotFn = std::uint64_t(WINAPI*)(void*, std::uint64_t, std::uint64_t, std:: | |||
| 58 | std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, | 58 | std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, |
| 59 | std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t); | 59 | std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t); |
| 60 | 60 | ||
| 61 | // A call through slot `slot` with all words zero, the way a title calls a console method the PC interface lacks. | 61 | // A call through slot `slot` with up to four explicit words (rest zero), the way a title calls a console method the PC |
| 62 | HRESULT call_slot(void* object, unsigned slot) { | 62 | // interface lacks. |
| 63 | HRESULT call_slot(void* object, unsigned slot, std::uint64_t a1 = 0, std::uint64_t a2 = 0, std::uint64_t a3 = 0, | ||
| 64 | std::uint64_t a4 = 0) { | ||
| 63 | void** vtable = *reinterpret_cast<void***>(object); | 65 | void** vtable = *reinterpret_cast<void***>(object); |
| 64 | return static_cast<HRESULT>(static_cast<std::uint32_t>( | 66 | return static_cast<HRESULT>(static_cast<std::uint32_t>( |
| 65 | reinterpret_cast<SlotFn>(vtable[slot])(object, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); | 67 | reinterpret_cast<SlotFn>(vtable[slot])(object, a1, a2, a3, a4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); |
| 66 | } | 68 | } |
| 67 | 69 | ||
| 68 | ULONG_PTR g_fault_address = 0; | 70 | ULONG_PTR g_fault_address = 0; |
| @@ -182,10 +184,24 @@ int check_proxy(const Backend& b, ID3D12CommandAllocator* allocator) { | |||
| 182 | back->Release(); | 184 | back->Release(); |
| 183 | EXPECT(SUCCEEDED(allocator->SetPrivateDataInterface(key, nullptr))); | 185 | EXPECT(SUCCEEDED(allocator->SetPrivateDataInterface(key, nullptr))); |
| 184 | 186 | ||
| 185 | // The refused tail: every slot past the public chain, up to the table end, is E_NOTIMPL and counted. | 187 | // Console slot 9 (SetAllocatorCallbackX): records callback/context on the proxy and returns S_OK. |
| 186 | const unsigned table = xs::allocator_proxy_table_size(); | 188 | const unsigned table = xs::allocator_proxy_table_size(); |
| 187 | EXPECT(table == 64); | 189 | EXPECT(table == 64); |
| 188 | for (unsigned slot = 9; slot < table; ++slot) { | 190 | { |
| 191 | EXPECT(xs::allocator_proxy_callback(allocator) == 0 && xs::allocator_proxy_callback_context(allocator) == 0); | ||
| 192 | constexpr std::uintptr_t fake_cb = 0x11223344u; | ||
| 193 | constexpr std::uintptr_t fake_ctx = 0x55667788u; | ||
| 194 | const std::uint64_t before = xs::allocator_slot_hits(9); | ||
| 195 | EXPECT(call_slot(allocator, 9, fake_cb, fake_ctx, 0, 0x99aabbccu) == S_OK); | ||
| 196 | EXPECT(xs::allocator_slot_hits(9) == before + 1 && xs::allocator_slot_first_call_seen(9)); | ||
| 197 | EXPECT(xs::allocator_proxy_callback(allocator) == fake_cb && | ||
| 198 | xs::allocator_proxy_callback_context(allocator) == fake_ctx); | ||
| 199 | EXPECT(call_slot(allocator, 9, 0, 0) == S_OK); | ||
| 200 | EXPECT(xs::allocator_proxy_callback(allocator) == 0 && xs::allocator_proxy_callback_context(allocator) == 0); | ||
| 201 | } | ||
| 202 | |||
| 203 | // The refused tail: every slot past slot 9, up to the table end, is E_NOTIMPL and counted. | ||
| 204 | for (unsigned slot = 10; slot < table; ++slot) { | ||
| 189 | const std::uint64_t before = xs::allocator_slot_hits(slot); | 205 | const std::uint64_t before = xs::allocator_slot_hits(slot); |
| 190 | EXPECT(call_slot(allocator, slot) == E_NOTIMPL); | 206 | EXPECT(call_slot(allocator, slot) == E_NOTIMPL); |
| 191 | EXPECT(xs::allocator_slot_hits(slot) == before + 1 && xs::allocator_slot_first_call_seen(slot)); | 207 | EXPECT(xs::allocator_slot_hits(slot) == before + 1 && xs::allocator_slot_first_call_seen(slot)); |
| @@ -201,8 +217,9 @@ int check_proxy(const Backend& b, ID3D12CommandAllocator* allocator) { | |||
| 201 | EXPECT(g_fault_address == reinterpret_cast<ULONG_PTR>(&vtable[slot])); | 217 | EXPECT(g_fault_address == reinterpret_cast<ULONG_PTR>(&vtable[slot])); |
| 202 | EXPECT(xs::allocator_table_overruns() == before + 1); | 218 | EXPECT(xs::allocator_table_overruns() == before + 1); |
| 203 | } | 219 | } |
| 204 | std::printf("%s: allocator proxy: 9 public slots forwarded, slots 9-%u refused, the guard region names a read " | 220 | std::printf("%s: allocator proxy: 9 public slots forwarded, slot 9 SetAllocatorCallbackX handled, slots 10-%u " |
| 205 | "past the table; QueryInterface/GetDevice/private data keep the proxy identity\n", label, table - 1); | 221 | "refused, the guard region names a read past the table; QueryInterface/GetDevice/private data keep " |
| 222 | "the proxy identity\n", label, table - 1); | ||
| 206 | return 0; | 223 | return 0; |
| 207 | } | 224 | } |
| 208 | 225 | ||