From dde87eecd41d1737d7b7ff9c629386d1535958aa Mon Sep 17 00:00:00 2001 From: NiiRoZz Date: Wed, 25 Nov 2026 22:16:14 +0100 Subject: [PATCH] startup: accept the structured-to-raw descriptor conversion for vertex 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 (#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 (#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 --- docs/experiments.md | 2 + tests/startup_gfx2hlsl_buffer_store_check.py | 64 ++++++++++++++++++++ tools/startup/gfx2hlsl.py | 14 +++-- 3 files changed, 74 insertions(+), 6 deletions(-) diff --git a/docs/experiments.md b/docs/experiments.md index 4bc8162986..6d4f4bc444 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -264,6 +264,8 @@ to check RGBA8 texel and alpha values, rebinding, and a mismatched 2D view on ha `tools/startup/gfx2hlsl.py` lowers vertex-stage `buffer_store_dword`, `dwordx2`, `dwordx3` and `dwordx4` in the `off` form to `RWByteAddressBuffer.Store*`. The descriptor must come from a root-table slot, and the manifest becomes version 2 with a `uav table ` line. This is offline only: the shipped runtime refuses version 2 manifests, so no store runs in a game. Refused forms: `glc`, `slc`, `offen`, `idxen`, pixel stage, a descriptor also used for a load, a descriptor whose base was changed, and an immediate or inline offset that is not a multiple of four. A register offset is rounded down to a multiple of four. +The descriptor modifications that compute buffer stores accept are accepted here too, with the same checks: the stride clear of DW1 and the structured-to-raw conversion (stride DW1[29:16] extracted, optionally clamped to at least 1, DW2 NUM_RECORDS scaled by it, DW3 OOB_SELECT set to 3, stride cleared), all four words from one descriptor load. The store and manifest are those of the unmodified descriptor. In the vertex stage, as in compute, a 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 mix words of two loads. Any other modification stays refused. As for compute, matching out-of-range behavior would need a UAV view sized to the converted byte count; the runtime binds no vertex-stage UAV yet. + ```powershell ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_buffer_store$' --output-on-failure ``` diff --git a/tests/startup_gfx2hlsl_buffer_store_check.py b/tests/startup_gfx2hlsl_buffer_store_check.py index c689fc5cc3..38c427ceb5 100644 --- a/tests/startup_gfx2hlsl_buffer_store_check.py +++ b/tests/startup_gfx2hlsl_buffer_store_check.py @@ -46,6 +46,15 @@ def v_mov(vdst, inline): return struct.pack('