startup: check every field of a buffer memory SRV #1670
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1677"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T16:56:46Z.
Refs #1149.
Change
src/startup_stubs/memory_srv_buffer.hvalidates and resolves buffer memory SRVs for device slot 70.supports_buffer_memory_srvchecks the buffer description and the view (rawR32_TYPELESS, structured with a stride that is a multiple of 4 up to 2048, or typed) against the buffer width.resolve_buffer_srv_descturns a title address inside a live buffer into a view with an adjustedFirstElementand checks bounds and raw 16-byte alignment.typed_buffer_format_bytesalso gives the element stride that translated draws bind (d3d12_draw.inl).Two tests reach the header:
startup_memory_srv_bufferis device-free and calls the three functions directly;startup_address_buffer_srv_*runs the resolve path on a device, with valid addresses only.24 of 34 single-point mutants of the header left the device-free check passing (table below). Among them were every buffer description field except the deny flag, exact-fit bounds, 32-bit truncation of the width and of the resolved first element, and five typed element-size mutants. A wrong element size there also gives translated draws the wrong stride.
This PR adds hand-worked cases to
tests/startup_memory_srv_buffer_check.cppand does not change any existing case:R32_TYPELESS, 4 samples, quality 1, layout UNKNOWN, alignment 4 KiB: each refused(3,2,1,0), flag bit 2 on a typed and on a raw view: each refusedraw_view(0, 256)and R8typed_view(0, 1024)on 1024 bytes accepted;(1, 256),(256, 1)and R8 1025 refusedsupports_buffer_memory_srv+0x10(252 elements left):raw_view(4, 248)gives FirstElement 8, NumElements 248;raw_view(4, 249)refused+0x20, stride 16 (62 left): FirstElement 63 refused(1, 4)at offset 12 gives FirstElement 4; at offset 16 refused0x100000400:raw_view(0x40000000, 0x40)accepted,0x101refused0x200000000, width 8 GiB: address+4 GiBwith FirstElement 0x10 gives0x100000010; FirstElement0x100000000at the base is keptThree negative controls are registered with
WILL_FAILnext to the existing test:startup_memory_srv_buffer_height_controlresource height 2startup_memory_srv_buffer_exact-fit_controlraw exact fit,typed R8 exact fit,raw resolve exact fitstartup_memory_srv_buffer_first-32_controltyped R8 resolve 4 GiB in,typed R8 resolve 64-bit first elementThe change also corrects the check's top comment and the CMake comment, which said the check covers acceleration-structure views (the header refuses them). It adds two sentences and the control command to the "Buffer memory SRVs (device slot 70)" section of
docs/startup-runtime.md. The header itself is not changed.Mutation probe
I applied each mutation to the header alone, rebuilt
startup_memory_srv_buffer_check, ran it, then reverted. None of this is committed.Height == 1droppedDepthOrArraySize == 1droppedMipLevels == 1droppedFormat == UNKNOWNdroppedLayout == ROW_MAJORdroppedViewDimension == BUFFERdroppedNumElements == 0accepted> 2048to>= 2048% 4to% 2R11G11B10_FLOATmoved to the 8-byte groupR10G10B10A2_UINTdropped (returns 0)NumElements <=to<!buffer_title_basedroppedFirstElement > availdroppedNumElements >to>=Not pinned:
!buffer_title_baseguard inresolve_buffer_srv_desc. The only caller (device_memory_srv) passes the title memory of a buffer thatexisting_memory_bufferhas already found at the address, so the guard cannot be reached from it.Width > 0(a zero width leaves no element for a view with NumElements > 0),FirstElement <=to<in supports,address < base(the offset wraps and failsoffset >= width), andoffset >=to>in resolve.Verification
Commit
cd4ea26aonmainc864f138,devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260 (Visual Studio), Windows SDK 10.0.26100.0. No GPU is used.tests/docs_links_check.py(16 files, 350 links),tests/bidi_controls_check.pyandgit diff --checkpassed.Checklist
AI-assisted (Claude Code).