Repository navigation
startup: accept the structured-to-raw descriptor conversion for vertex buffer stores - #2570
Conversation
…x buffer stores A vertex-stage buffer store through a descriptor modified before the store was refused outright. Captured vertex programs apply the conversion that compute stores already accept (R0Y00#2546): the stride field DW1[29:16] is extracted (s_bfe_u32 0xe0010), clamped to at least 1 (s_max_u32 with 1), NUM_RECORDS (DW2) is multiplied by it, OOB_SELECT (DW3[29:28]) is set to 3 and the stride is cleared. The vertex stage now recognizes the same word expressions and, when the store descriptor is marked modified, checks it with the compute helper: all four words must be the words of one descriptor load, either unchanged except for the stride clear (R0Y00#2320) or the full raw conversion. The store and manifest are those of the unmodified descriptor. Stores through an unmodified descriptor take the existing path unchanged. As in compute, a vertex-stage descriptor load through a pointer other than the untouched pair is tagged with the constant high word of a 32-bit table pointer, or otherwise with its own load, so the conversion cannot take NUM_RECORDS from one load and the stride from another. Graphics pipelines now keep the other_modified set too. Tests: startup_gfx2hlsl_buffer_store_check.py adds the captured clamped sequence, the unclamped one and the stride clear (same HLSL and manifest as the plain store), a stride taken from a second load through the same pointer (accepted), and refusals for a clamp of 2, NUM_RECORDS not scaled or scaled by a constant, OOB_SELECT 2, the stride not cleared, another bit field, and the stride or NUM_RECORDS of a second load after a pointer add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tedin7
left a comment
There was a problem hiding this comment.
Review of head dde87ee (comment only, no game run, Linux checks only).
Result: sound, no blocking findings.
- Change: the vertex-stage buffer store now accepts the same descriptor edits the compute store accepts (stride clear, structured-to-raw conversion) by calling
store_descriptor(..., stride0_ok=True, raw_conversion_ok=True)(tools/startup/gfx2hlsl.py,op_buffer_store_vs).raw_descriptor_aluand the load tag are extended fromcstocs/vs.other_modifiedis initialised inPipeline.__init__, so unproved descriptor writes still refuse. - Tests: the new cases in
tests/startup_gfx2hlsl_buffer_store_check.pycover the three accepted forms (HLSL and manifest equal to the plain store), a second load through the same untouched pointer, and 8 refusal controls. - Sibling check: the compute path and the vertex path now share the same helper; no other table needed an edit. No other open or merged PR covers this slice (searched
vertex buffer store descriptor conversion; #2069 is a different pointer-propagation item). - Scope: offline translation only; the docs state the runtime still refuses version 2 manifests. No startup claim is made, so none is judged here.
Commands run locally:
python3 tests/startup_gfx2hlsl_buffer_store_check.py-> all okpython3 tests/docs_links_check.py-> ok (488 links)python3 tests/bidi_controls_check.py-> okgit diff --check origin/main...HEAD-> clean- Mutation 1:
raw_conversion_ok=True->Falsein the vertex store call: the new test fails. - Mutation 2: drop
'vs'from theraw_descriptor_alucondition: 4 conversion tests fail. - Mutation 3: drop
'vs'from the load-tag condition: both "after a pointer add" refusal tests fail.
AI-assisted; commands listed were executed locally.
|
Win2025 WARP receipt for head 78a85ed after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
Post-merge audit of
|
| mutation | caught |
|---|---|
stride bitfield constant 0xe0010 → 0xe000f (s_bfe_u32) |
caught |
stride-clear mask 0xc000ffff → 0xc000fff0 |
caught |
OOB-clear mask 0xcfffffff → 0xcffffff0 |
caught |
OOB_SET constant 0x300000 → 0x300001 (s_or_b32) |
caught |
stride floor constant 1 → 0 (s_max_u32) |
caught |
byte_count source instruction s_mul_i32 → s_mul_u32 |
caught |
the compute load tag degrades (loaded = 5 … → loaded = 4) |
caught |
All seven are caught by the one fixture, which means the fixture assembles every one of these word expressions and
asserts the resulting classification rather than only the final verdict. The last row is the one I care most about: the
loaded distinction is what separates "a descriptor word read by one s_load" from "a descriptor word read by one
s_load and tagged with the compute load ordinal". Collapsing it would let a compute tag masquerade as a plain read,
and dropping it from the recognizer makes plain true for tagged words — the fixture notices.
One number worth recording
startup_gfx2hlsl_* is now 77 checks, all green on this commit. I run the whole family each round before touching
anything, so a survivor I report later cannot be a family-wide breakage I failed to notice.
Method note that applies to anyone patching this file
tools/startup/gfx2hlsl.py is CRLF. Two of my anchors missed on the first pass purely because of that (and one because I
had quoted the source line from memory rather than from the file) — a \n anchor never matches and the "anchor miss"
looks exactly like a mutation that was caught by nothing. Splice with the read-\r\n→\n, patch, write-back-\r\n
dance and print the anchor miss explicitly, as I do here.
AI-assisted; pure Python, Windows 11 build 26300, no DXC or GPU for the rows above.
What
No affected request translates end to end yet: all 32 now pass the store and stop at a later vertex-stage
instruction (
s_load with a register offset through ('resheap',)).op_buffer_store_vsrefused every vertex-stage buffer store whose descriptor was modified before the store(
buffer store through a modified descriptor). All refused local graphics requests of this kind (32: 19 baserequests and 13 render-target variants of the same programs) use one modification form, the clamped
structured-to-raw conversion that #2546 accepts for compute stores:
The vertex stage now recognizes the same word expressions (
raw_descriptor_alu) and, when the storedescriptor is marked modified, checks it with the compute helper (
store_descriptorwith the stride clear andthe raw conversion allowed). All four words must come from one descriptor load. The emitted store and the
manifest are those of the unmodified descriptor. Stores through an unmodified descriptor keep the existing path.
The stride clear alone (#2320) is accepted too, because the compute helper admits it; no captured vertex program
uses it, and it has its own positive case.
As in the compute stage (second commit of #2546), a descriptor load through a pointer other than the untouched
pair is now tagged with its own load in the vertex stage too, so the conversion cannot take NUM_RECORDS from one
load and the stride from another. Graphics pipelines now keep the
other_modifiedset, as compute pipelines do.Why it is correct
The store is the
offform (noidxen, nooffen): the address is base + soffset + immediate whatever thestride. The conversion only changes the range check (stride 0, NUM_RECORDS in bytes, raw OOB_SELECT), and the
translation does not model the range check for any vertex store. So the HLSL equals the plain store's, as in
compute. Field positions follow docs/pixel_mubuf_contract.md.
Tests
New cases in
startup_gfx2hlsl_buffer_store_check.py(source-built instruction words, decoded and checkedagainst the captured spelling):
manifest as the plain store. With the table high word set to 0 as captured programs do, a stride taken from a
second load through the same untouched pointer is accepted with the same HLSL.
buffer store through a modified descriptor: clamp of 2, NUM_RECORDSnot scaled, NUM_RECORDS scaled by a constant, OOB_SELECT 2, stride not cleared, another bit field
(0xe0011), and the stride or NUM_RECORDS taken from a second load after
s_add_u32on the table pointer.The last two pass (wrongly accepted) when the vertex-stage load tag is reverted, so they test that tag.
Local measurement (offline translation of the affected requests only, 4 workers): before, 32/32 refused at
buffer store through a modified descriptor; after, 0 refused there. All 32 now stop at a later instruction:s_load with a register offset through ('resheap',)(32). No translation completes yet.What stays unverified (AI-assisted change)
uavlines, so no translated vertexstore runs. Matching out-of-range behavior would need a UAV view sized to the converted byte count.
high word is a known constant (the captured pattern) share one tag, so equal loads still merge at joins.
Loads through a moved pointer or an unknown high word get a per-instruction tag: equal loads of those at
different instructions on two branch arms are no longer kept at the join (as in compute). The wider graphics
corpus was not re-measured.
uavline, as the unmodified vertex store already does.🤖 Generated with Claude Code