Repository navigation
Conversation
… released A placed buffer is a range of its heap's arena memory, but only the heap held that range: releasing the application's last ID3D12Heap pointer freed it while placed buffers in it were still alive, so the next heap or committed buffer got the same GPU address and the arena zeroed and overwrote the live buffer. On D3D12 a placed resource holds a reference on its heap, so releasing the heap first is legal. The placed buffer now holds the heap's range (the shared allocation whose deleter returns it to the arena). New d3d12_placed_heap_lifetime test: red on main (the new heap's buffer lands on 0x10000, the live buffer's address), green with the fix. AI-assisted (Claude Code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verified PR #8991 ( Test results (MSVC 14.44
|
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Independent Windows review (commit \14d54d0d76662e12b80ff260af852d5c9c29d83d)
What changed:
untime/shims/d3d12_vulkan_device.cpp:- \create_placed_buffer\ now holds a \std::shared_ptr\ to the underlying heap arena range.
- Guarantees placed buffer addresses remain stable and are not prematurely returned or aliased if the application releases the parent \ID3D12Heap\ object while the resource is still in use.
untime/test/d3d12_placed_heap_lifetime_test.cpp:- Adds lifetime and non-aliasing validation suite.
Verification:
- Verified on Windows host: placed buffer retains valid device address across parent heap destruction.
- Clean diff: pure standard library / C++17, no game files.
LGTM!
|
Tested 14d54d0 (merged onto main 867d922) on RTX 5070, NVIDIA 621.24, Windows 11 (build 26200), Vulkan validation layer on (
Ran the tests that belong to the test files this PR changes (ctest entries, or the test program directly when it is not registered), with no game files ( |
|
Independent Windows + RTX 5080 GPU verification of Build & Tests
Code check
(AI-assisted) |
Summary
Heapheld that range (Heap::allocation_, whose deleter callsarena_release). If the app released its lastID3D12Heap*while placed buffers were alive, the range went back to the arena at once. The next heap or committed buffer then got the same GPU address, andcreate_placed_bufferzeroed and reused memory that a live buffer was still using.ID3D12Device::CreateHeapdocs), so releasing the heap first is legal app behaviour.create_placed_buffertakes the heap's shared arena allocation and theResourceholds it (heap_range_), so the range is returned only when the heap and every placed buffer in it are gone. Placed textures are unchanged, since each already has its ownVkDeviceMemory.d3d12_placed_heap_lifetime. It creates a heap and places a 1 MiB buffer, then releases the heap. It then creates a second heap with a placed buffer, plus a committed buffer, and checks that neither overlaps the live buffer.Finding and claim: #8868 (comment). Related: #770 (D3D-88) plans the same lifetime rule inside a larger aliasing rework. This is the standalone fix for today's arena.
Test plan
Windows 11, RTX 5070 Ti (NVIDIA 621.14), MSVC 14.44 RelWithDebInfo, base
main867d922f0:d3d12_vulkan_device.cppd3d12_placed_heap_lifetime0x10000, new heap's buffer0x110000, committed0x210000main0x10000, the live buffer's addressctest -R "placed|heap|tile|reserved|alias": 8/8 pass (resource_detile,d3d12_buffer_tiles,d3d12_texture_tiles,d3d12_placed_dimensions,d3d12_placed_heap_lifetime,d3d12_existing_heap,d3d12_heap_properties,d3d12_set_descriptor_heaps)LEONIDA_VK_VALIDATION=1(no validation layer on this machine)Synthetic test only, no game files. AI-assisted (Claude Code).
🤖 Generated with Claude Code