Repository navigation
Conversation
|
Independent Windows + GPU test of Setup: Windows 11 x64, MSVC 19.44.35220 (
AI-assisted review/test. |
tupacfan04
left a comment
There was a problem hiding this comment.
Build/test at head cceaf38d: d3d12_placed_inherit_test 1/1 Passed with validation; the host loop did exercise WARP here (Microsoft Basic Render Driver appeared via EnumAdapters1), so the WARP claim is not a gap on this system. No product defect found in the zero-init/aliasing logic.
Coverage gap: no test sets D3D12_HEAP_FLAG_CREATE_NOT_ZEROED. The heap descriptor at runtime/test/d3d12_placed_inherit_test.cpp:48-53 never sets it and both CreateHeap calls use it, so the new branch at runtime/shims/d3d12_vulkan_device.cpp:2597-2598 is untested. A regression that always zeroes the heap, or fails to skip zeroing under the flag, would still pass. Add a test analogous to step 2 on a CREATE_NOT_ZEROED heap reusing stale bytes.
Synthetic only; no game files. AI-assisted (OpenCode).
create_placed_buffer zeroed the arena range under every new placed buffer, so a
buffer placed over another one wiped the data that one held (and any the GPU had
written or was reading there). D3D12 writes nothing when it places a resource:
buffers inherit data in any state ("Memory Aliasing and Data Inheritance"), and
the heap is zeroed once, at creation, unless it has CREATE_NOT_ZEROED.
The Heap constructor now zeroes its arena range (not with CREATE_NOT_ZEROED), and
create_placed_buffer writes nothing. d3d12_placed_inherit_test checks both: it
fails on main (the overlapped buffer reads 0) and passes here.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… bytes Review on ItsNotRexed#7559: no test set D3D12_HEAP_FLAG_CREATE_NOT_ZEROED, so the Heap constructor's flag branch was untested. check_not_zeroed (Vulkan-backed device only: D3D12 leaves such a heap's bytes undefined, while our arena hands a released range to the next heap that fits) fills a heap, releases it, makes a NOT_ZEROED heap over the same range (checked by its VA) that must read the stale pattern, then a normal heap over it again that must read zero. Fails if Heap always zeroes (the NOT_ZEROED heap reads 0x00) or never zeroes (the normal heap reads the pattern); passes with the change. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cceaf38 to
a74b941
Compare
|
Thanks @tupacfan04 — fair catch.
Mutation check: always zeroing the heap fails step 2 ("a CREATE_NOT_ZEROED heap's byte 0 reads 0x00, the range held 0x01"), and never zeroing fails the existing step 3 and the new step. With the fix it passes 3/3 runs (clang-cl + xwin build under Wine 11.20, RTX 5080, NVIDIA 615.78.08). I didn't complete a full ctest run on this head, so a Windows run of cc @shayderrr |
|
Tested Ran AI-assisted. |
Claimed in the coordination issue: #7231 (comment) (a new D3D-layer item, found and claimed there).
What and why
Resource::create_placed_buffer(runtime/shims/d3d12_vulkan_device.cpp:1971on main) zeroed the arena range under every new placed buffer ("a fresh place reads as zeroed"). Every overlapping placed buffer therefore wiped the data in the bytes it covered: data the CPU had written through another buffer's mapping, and data the GPU had written or was still reading (the memset is an immediate CPU write into the arena). TheHeapconstructor (:2581-2593) took an arena range that can still hold an earlier resource's bytes and never cleared it, so only that memset made a fresh placed buffer read zero.D3D12 does it the other way round. A heap is zeroed when it is created unless it has
D3D12_HEAP_FLAG_CREATE_NOT_ZEROED, and creating a placed resource writes nothing. Memory Aliasing and Data Inheritance says that for buffers "the resource transition state is not important and all states are 'compatible'". So a buffer placed over bytes another buffer holds reads them, and that buffer keeps them. Engines that place buffers over each other (transient or frame-graph aliasing, or upload rings placed again over the same heap) lose that data onmain.The change
Heap::Heapzeroes its arena range through the arena's host mapping, unless the heap hasCREATE_NOT_ZEROED.create_placed_bufferwrites nothing; its comment says why.docs/d3d12_vulkan.md: theCreateHeapbullet says the same.A fresh placed buffer still reads zero, because its heap was zeroed, so the existing check in
d3d12_vulkan_device_test("A placed buffer reads as zeroed through the copy path") still holds. Placed textures are unaffected: they keep their own image memory.Tests
New
runtime/test/d3d12_placed_inherit_test.cpp(ctestd3d12_placed_inherit, skips with 77 without the standalone device). It is CPU only and uses no shaders or game data. It runs the same checks on the Vulkan-backed device and, on Windows but not under Wine, on every host D3D12 adapter:main8575d36: fails at step 2:after placing B and C, A's byte 0 reads 0x00, it held 0x01.Heapmemset: step 3 fails. That shows step 3 guards the heap zeroing.Full suite: Windows cross build (clang-cl + xwin,
-DLEONIDA_SDL3_FETCH=ON -DLEONIDA_REQUIRE_VULKAN=ON -DLEONIDA_VULKAN_HEADERS_FETCH=ON, RelWithDebInfo) under Wine 11.20 on Linux, NVIDIA GeForce RTX 5080, driver 615.78.08. Command:ctest -C RelWithDebInfo --output-on-failure -j1 --timeout 300.main: 17 failed of 267.main, with the same output: Wine-host comparisons such asd3d12_heap_properties/d3d12_residencyagainst vkd3d, andd3d12_vulkan_deviceat its known line 6564 (TEST-1649, d3d12_vulkan_device: check PC CreateReservedResource2 behind the Xbox proxy, not through slot 78 #7125).main's extra failure isvk_pipeline_check_cli, which passed on this branch.d3d12_placed_inheritis the added test.Overlaps
Heap. Whichever lands second needs a small rebase. With d3d12: a heap reserves its arena range when a buffer first needs it, not at CreateHeap #6257, the zeroing moves to where the range is reserved.AI-assisted (Claude Code).
cc @shayderrr
🤖 Generated with Claude Code