diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 22:03:00 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-25 22:03:00 -0500 |
| commit | b3e541b224e1d0bb691d8b4b5cc719eeea7c7dd7 (patch) | |
| tree | 53e0bbdcace9b8f7b83a550c07d402e03942828e /runtime/test | |
| parent | 7b1fe62850f69bc3ad0b3176aea8dda8168867ea (diff) | |
d3d12_xs: drop the null-RTV marks of a descriptor heap when it is released
The null-view marks (#1504, by ubiquitarianism) are kept by the real CPU
handle. They were moved by descriptor copies and cleared by a view made
with a resource, but never dropped when the heap went away, so an RTV heap
made later at the same address inherited stale marks and its clears were
skipped. The heap proxy now records an RTV heap's real CPU range and
heap_release drops the marks in it. The barrier conversion keeps no state
across calls, so it needs nothing here.
xs_proxy_mock_test: an RTV heap's marked view is skipped while the heap
lives and cleared after it is released; a mark outside it stays; a second
heap at the same address starts unmarked and marks again. docs/d3d12_vulkan.md
says so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test')
| -rw-r--r-- | runtime/test/xs_proxy_mock_test.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index 453be7cca..cb350820e 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp | |||
| @@ -5107,6 +5107,40 @@ int check_console_null_barrier_and_clear() { | |||
| 5107 | EXPECT(real->calls[48] == 5 && real->args[48][0] == rtv_copy + kMockDescriptorInc); | 5107 | EXPECT(real->calls[48] == 5 && real->args[48][0] == rtv_copy + kMockDescriptorInc); |
| 5108 | EXPECT(!real->list_error && hr_of(raw(list, 9)) == S_OK); | 5108 | EXPECT(!real->list_error && hr_of(raw(list, 9)) == S_OK); |
| 5109 | 5109 | ||
| 5110 | // Releasing an RTV heap drops the marks in its real range, so a heap made later at the same address starts | ||
| 5111 | // unmarked; a mark outside that range stays. | ||
| 5112 | g_heap_hook.next_ptr = nullptr; // a plain PC heap even if a descriptor-heap hook is registered: real handles | ||
| 5113 | D3D12_DESCRIPTOR_HEAP_DESC rtv_heap_desc{}; | ||
| 5114 | rtv_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; | ||
| 5115 | rtv_heap_desc.NumDescriptors = 4; | ||
| 5116 | const IID heap_iid = __uuidof(ID3D12DescriptorHeap); | ||
| 5117 | void* rtv_heap = nullptr; | ||
| 5118 | EXPECT(SUCCEEDED(hr_of(raw(device, 14, word(&rtv_heap_desc), word(&heap_iid), word(&rtv_heap))))); | ||
| 5119 | EXPECT(rtv_heap && xs::is_heap_proxy(rtv_heap) && raw(rtv_heap, 9) == kMockHeapCpuStart); | ||
| 5120 | const SIZE_T in_heap = kMockHeapCpuStart + 2 * kMockDescriptorInc; | ||
| 5121 | raw(device, 20, 0, 0, in_heap); | ||
| 5122 | const unsigned clears = real->calls[48]; | ||
| 5123 | raw(list, 52, in_heap, word(color), 0, 0); | ||
| 5124 | EXPECT(real->calls[48] == clears); // marked while the heap lives: skipped | ||
| 5125 | EXPECT(raw(rtv_heap, 2) == 0); | ||
| 5126 | raw(list, 52, in_heap, word(color), 0, 0); | ||
| 5127 | EXPECT(real->calls[48] == clears + 1 && real->args[48][0] == in_heap); // the mark went with the heap | ||
| 5128 | real->list_error = false; // the mock list still takes its own view there as invalid | ||
| 5129 | raw(list, 52, rtv_none, word(color), 0, 0); | ||
| 5130 | EXPECT(real->calls[48] == clears + 1); // outside the released heap: still skipped | ||
| 5131 | // A second RTV heap at the same address: the view made there with a resource is cleared, and a view made with | ||
| 5132 | // no resource is marked again for as long as that heap lives. | ||
| 5133 | void* rtv_heap2 = nullptr; | ||
| 5134 | EXPECT(SUCCEEDED(hr_of(raw(device, 14, word(&rtv_heap_desc), word(&heap_iid), word(&rtv_heap2))))); | ||
| 5135 | raw(device, 20, word(resource_a), 0, in_heap); | ||
| 5136 | raw(list, 52, in_heap, word(color), 0, 0); | ||
| 5137 | EXPECT(real->calls[48] == clears + 2 && !real->list_error); | ||
| 5138 | raw(device, 20, 0, 0, in_heap); | ||
| 5139 | raw(list, 52, in_heap, word(color), 0, 0); | ||
| 5140 | EXPECT(real->calls[48] == clears + 2); | ||
| 5141 | EXPECT(raw(rtv_heap2, 2) == 0); | ||
| 5142 | EXPECT(!real->list_error && hr_of(raw(list, 9)) == S_OK); | ||
| 5143 | |||
| 5110 | // The marks are the device's own: another device's clear at a handle marked on the first is forwarded (its mock | 5144 | // The marks are the device's own: another device's clear at a handle marked on the first is forwarded (its mock |
| 5111 | // list then takes the view as invalid, which is what that device was told). | 5145 | // list then takes the view as invalid, which is what that device was told). |
| 5112 | Mock* other_mock = nullptr; | 5146 | Mock* other_mock = nullptr; |