Skip to content

startup: add a compute stage to gfx2hlsl with the offen buffer store - #2182

Merged
R0Y00 merged 5 commits into
R0Y00:mainfrom
NiiRoZz:startup/gfx2hlsl-compute-stage
Nov 25, 2026
Merged

R0Y00 merged 5 commits into
R0Y00:mainfrom
NiiRoZz:startup/gfx2hlsl-compute-stage

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Change

This adds a compute stage to the startup translator, tools/startup/gfx2hlsl.py. It lowers one compute
store form. Refs #1412.

What it adds

gfx2hlsl.ComputePipeline(cs_code, root_blob, rsrc2, group) translates one gfx1013 compute program. It
uses the same root, resource and entry-constant model as the graphics stages.

Entry registers:

Output:

  • A cs HLSL main with [numthreads].
  • A version 2 manifest with stage cs, group X Y Z, ud/udsrc/srv lines in the existing format,
    and uav <slot> table <param> <byte offset>.

Store lowering:

  • One store form is lowered: buffer_store_dword/x2/x3/x4 in the offen form. The address is a
    per-lane byte VGPR plus the scalar offset and the immediate. The descriptor must sit at a fixed
    root-table offset, and the target is a RWByteAddressBuffer.
  • All four descriptor words must still be the words the s_load returned.
  • Refused:
    • the off and idxen forms, and glc/slc/dlc;
    • an immediate offset that is not a multiple of 4;
    • a moved, overwritten or modified descriptor word;
    • a descriptor that is also loaded.

New compute-only refusals:

  • A scalar instruction (or v_readlane/v_readfirstlane/v_writelane) inside a block that
    s_cbranch_execz skips. The wave runs such a block when any lane is active. The one-lane model would
    skip it for an inactive lane and lose the scalar result.
  • An image_sample with implicit LOD. A compute lane has no derivatives. The _l/_lz forms are kept.

Shared change (affects graphics too):

  • A modification of a descriptor word (s_and_b32 s18, s18, …) was recorded under the key of the
    load's first descriptor. It is now recorded under the descriptor the word belongs to: load offset
    plus 4 * (dword & ~3).
  • Only idxen loads consult that set.
  • Before and after, I translated every graphics request in a local shader cache in memory: 925 requests,
    123 of which translate. The HLSL and manifest hashes and the refusal texts were identical, so no
    graphics output moved.
  • Graphics stages keep the unknown-op refusal text for buffer stores (buffer_store_dwordx3), so
    refusal census buckets do not move.

Not in this change

Open design question: which tool is the runtime compute translator?

On #1412 the maintainer described the first slot-67 fixture: "A useful first slot 67 fixture would bind
explicit group dimensions, a read buffer and a writable resource, then verify nonzero GPU output plus a
dropped-dispatch or swapped-binding control." This change follows that description.

The compute lowerings merged so far live in compute_store_aot, and #2022 item A is being added there.
compute_store_aot takes its bindings from the caller (table_reg, descriptor_offset, …), and #1994's
records do the same. gfx2hlsl derives them from the root signature and already feeds the runtime shader
cache, which is why the stage is added here and reuses compute_store_aot only for the
COMPUTE_PGM_RSRC2 decode.

If the runtime compute translator should instead be compute_store_aot, made to serve requests, this
stage should move there; please say so.

Overlapping work

Known gaps shared with the graphics stages, not changed here

  • In graphics stages, a scalar write inside an execz-skipped block has the same per-lane problem. It is
    refused only for compute in this change.
  • s_cbranch_vccz/vccnz and s_cbranch_execnz loops are also evaluated per lane while the wave
    evaluates them per wave. Scalar state updated inside a loop that lanes leave at different times can
    differ.
  • An idxen load still checks only the first register of its descriptor operand. An overwritten later
    word is not seen there.

AI-assisted (Claude Code).

Verification

Commit 0236bbcb (on 65f8ef9d). Windows 11 build 26300, MSVC Release, offscreen_check built in the
worktree, DXC 10.0.26100.0, debug layer enabled.

. .\tools\dev.ps1
cmake --preset release
cmake --build --preset release --target offscreen_check
ctest --preset release --no-tests=error -R '^startup_gfx2hlsl_compute_' -V
python -B tests/startup_gfx2hlsl_compute_check.py
python -B tests/startup_gfx2hlsl_compute_check.py binary llvm-mc   # LLVM 15.0.7
Test WARP 10.0.26100.10068 RTX 5090, driver 32.0.16.2135
startup_gfx2hlsl_compute_{warp,hardware}: cases A (3x2x2 groups), B (4x1x3), C (1x5x1) 320/320 words each 320/320 words each
control swapped-axes (case A) rejected, 128 mismatches, first at word 48 same
control dropped-store (case A) rejected, 288 mismatches, first at word 0 same
control b-offset (case B without its immediate offset) rejected, 242 mismatches, first at word 0 same
control c-unpredicated (case C without the exec predicate) rejected, 30 mismatches, first at word 46 same
  • ctest: 11/11 passed, 0 skipped. The hardware variants return 77 without a GPU; that path was not
    exercised here because a GPU was present.

  • Debug layer: 0 errors and 0 warnings in every run.

  • Each control is pinned in CMake by PASS_REGULAR_EXPRESSION "control <name>: rejected at word=[0-9]+ ".

  • Pure-Python controls pass. Each of these reviewed inputs was accepted before and is now refused:

    • a constant move into descriptor dword 2 (s_mov_b32 s18, 0);
    • s_or_b32 s17, s17, 0x40000;
    • s_and_b32 s18, s18, 0xffff;
    • s_mov_b32 s18, 4 between two stores;
    • a scalar add in an execz-skipped block, with exec set by a plain move and in the s_and_saveexec_b32
      form;
    • an implicit-LOD image_sample;
    • offset:6.

    The modification is recorded under byte 16 of the x8 load, not byte 0. An image_sample_lz still
    translates. The graphics refusal text is unchanged.

  • The binary mode reassembles the three programs and every spliced control instruction with llvm-mc 15.

  • 52 other pure-Python checks pass: all tests/startup_gfx2hlsl_*_check.py and startup_translator,
    plus compute_entry_layout, startup_flat_param, startup_buffer_address, startup_smem_address,
    startup_stream_fetch, startup_sampler_heap, startup_inline_sampler, docs_links and
    bidi_controls.

  • git diff --check is clean.

  • Not run: the full ctest suite, CI, FXC (the runtime cache's compiler) on compute output.

Evidence and follow-up

  • Fixtures: three source-built gfx1013 programs in tests/startup_gfx2hlsl_compute_check.py, with
    their llvm-mc source and recorded words. They contain no retail bytes. MIT.
    • Case A: all group-ID axes and v0-v2, group size 2x3x4, one-word store.
    • Case B: X and Z only, so Z is s8; v0-v1; group size 5x2x1; two-word store at immediate offset 8.
    • Case C: Y only; v0; group size 8x1x1; a four-word store from every lane, then a three-word store under
      an exec mask set from a compare.
  • What the GPU run does not exercise: the fixture runs on a plain D3D12 device with the runner's own
    root signature (root SRV t0, root UAV u0, 16 root constants at b0). These match the translation's r0,
    u0 and entry cbuffer by register. The manifest's srv/uav table lines and the descriptor fetch
    from the table are not exercised on the GPU
    ; they are checked only as text.
  • Assumptions, not measurements:
    • out-of-range stores (a future runtime would have to size the UAV view to the descriptor's range);
    • rounding the run-time part of a misaligned address down;
    • a raw descriptor with no stride or swizzle;
    • s4 as the start of the root parameters.
  • Request side (local observation, a hypothesis until its own PR): the local branch
    compute/slot67-requests publishes slot-67 requests (.cs code, .root, and a 28-byte state block .sa).
    A local run produced 2,689 of them.
    • The entry facts were located there, not decoded from any public source:
      • thread group size X/Y in .sa dword 3 (low and high 16 bits), Z in dword 4 (low 16 bits);
      • COMPUTE_PGM_RSRC2 in dword 6.
    • Across the 2,689 requests:
      • every group size is within the numthreads limits;
      • user SGPR counts run from 4 to 14;
      • 91 set TG_SIZE_EN, which this stage refuses.
    • Wiring load_request for .cs into ComputePipeline is the piece after both PRs land.
  • The s4 placement checked against those sizes:
    • The roots of the 743 compute pipelines in the captured frame end at s5 to s12 under s4 placement
      (4 + parameter SGPRs + heap pointers). That lies inside the observed user SGPR range of 4 to 14, so
      the refusal "root needs more SGPRs than USER_SGPR" is not expected to fire for them.
    • I did not compare each pipeline's own USER_SGPR with its own root.
    • That refusal can only catch a root placed too far. It cannot detect a wrong start register.
  • Next steps:
  • Reproduce: ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_compute_' -V. The new section
    is "Compute stage in the startup translator" in docs/experiments.md.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

🤖 Generated with Claude Code

NiiRoZz and others added 2 commits November 25, 2026 04:04
ComputePipeline translates one gfx1013 compute program with the root and
resource model of the graphics stages. COMPUTE_PGM_RSRC2 and the thread
group size come from the caller and follow compute_store_aot's entry layout
(R0Y00#1608): root parameters from s4, one SGPR per enabled group-ID axis after
the user SGPRs, and v0-v2 as SV_GroupThreadID. TG_SIZE_EN stays refused, and
a numeric read of a user SGPR the root does not place is refused.

The output is a cs HLSL main with numthreads and a version 2 manifest
(stage cs, group, uav <slot> table <param> <offset>). The one store lowered
is buffer_store_dword[x2-4] in the offen form through a fixed root-table
descriptor, to a RWByteAddressBuffer.

The fixture translates two source-built programs (all axes; X and Z only),
compiles them with DXC and dispatches them on a plain D3D12 device, comparing
all 320 words. Swapped group axes and a dropped store must mismatch.

Refs R0Y00#1412

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- Store descriptor: all four words must still be the words the s_load
  returned. A moved, overwritten or modified word refuses the store. A
  modification is now recorded for the descriptor the word belongs to
  (load offset + 4 * (dword & ~3)), not for the load's first descriptor.
  Translating every locally cached graphics request gave identical output.
- Compute: a scalar instruction inside a block s_cbranch_execz skips is
  refused. The wave runs that block when any lane is active.
- Compute: an implicit-LOD image_sample is refused instead of sampling
  level 0.
- An immediate store offset that is not a multiple of 4 is refused. The
  run-time part is rounded down as in R0Y00#2059.
- Graphics stages keep the unknown-op refusal text for buffer stores.
- Root parameters from s4 are documented as an inference, not as R0Y00#1608.
- Fixture: case C stores x4 and, under a compare-set exec, x3. New
  controls drop case B's immediate offset and case C's exec predicate.

Refs R0Y00#1412

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 0236bbc (comment only, no approval).

Scope read: tools/startup/gfx2hlsl.py (cs entry, execz guard, buffer_store_dword*), tests/startup_gfx2hlsl_compute_check.py, CMakeLists.txt, windows.yml, AGENTS.md, docs/experiments.md.

Commands executed locally (Linux):

  • python3 -B tests/startup_gfx2hlsl_compute_check.py -> "compute entry, numthreads, manifest, offen store forms and the store, descriptor, execz and sample refusals pass"
  • python3 tests/startup_gfx2hlsl_compute_check.py binary llvm-mc-15 -> not runnable here (llvm-mc-15 not installed); covered by the Linux CI job, which is green.
  • python3 tests/docs_links_check.py -> 402 links OK; python3 tests/bidi_controls_check.py -> OK; git diff --check origin/main...HEAD -> clean.
  • Mutation: changed the store alignment mask 0xfffffffcu to 0xfffffff8u in op_buffer_store_dword. The Linux controls fail (exact-line assertion on the emitted a = (...) & 0xfffffffcu;). Reverted with git checkout -- ..

Windows (Win2025 node, x2w_pipe.py win2025 2182 --scope direct --regex startup_gfx2hlsl_compute --force):

  • Debug phase: 11/11 ctest passed (compute_controls, compute_warp, compute_hardware, and the 4 controls swapped-axes / dropped-store / b-offset / c-unpredicated on both adapters). The real D3D12 readback against the CPU reference is therefore exercised and the 4 controls are rejected as intended.
  • Release phase did not complete: the first attempt and the retry both died in sccache ("existing connection was forcibly closed") while compiling d3d12_xs_device.cpp. That is a node cache failure, not a PR failure; I do not count it as evidence either way. GitHub "Build and test on Windows" was still pending when I looked.

Findings:

  • P1: none. P2: none.
  • nit 1 (gfx2hlsl.py, setup_compute_entry): user SGPR base s4 is an inference, and it is documented as one in the comment and in docs/experiments.md. Good; keep the refusal of reads of s0-s3 until real evidence exists.
  • nit 2 (gfx2hlsl.py, op_buffer_store_dword): rounding the run-time address down to 4 bytes and ignoring num_records/stride are stated assumptions, not measured. The comment says so. Consider one control that stores past the range so the future runtime change cannot go unnoticed.
  • nit 3 (tests): on Linux the mutation is killed by an exact HLSL line check, which is brittle against harmless HLSL formatting changes. The behavioural kill happens only in the Windows WARP/hardware tests (controls cover axes, dropped store, b-offset, unpredicated C). That is fine, but note the Linux job alone does not prove the arithmetic.
  • windows.yml: the new check is added both to the binary matrix (with llvm-mc-15) and to the direct list, next to sibling gfx2hlsl checks. Consistent. AGENTS.md: one line added in the same order as the siblings. Consistent. CMake: controls registered per adapter with SKIP_RETURN_CODE 77 and PASS_REGULAR_EXPRESSION, matching the mad/swap siblings.
  • Clean-room: no external code or names; title is neutral; PR is mergeable.

AI-assisted; commands listed were executed locally.

A store whose immediate offset puts it past the descriptor's range still
translates to a plain RWByteAddressBuffer Store with no range check, and the
manifest carries no size: num_records and stride are not read, and dropping
such a store is left to a runtime that sizes the view. The control pins that
stated behaviour, so changing the policy has to update it (review nit on
R0Y00#2182).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@NiiRoZz

NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Added 94b042b for nit 2: a pure-Python control that pins today's translation of a store past the descriptor's range (offset:4092 → a = (v4 + 4092) & 0xfffffffcu; then a plain u0.Store, no range check, manifest unchanged), so a later runtime change to range handling cannot go unnoticed. It is a text control rather than a GPU case because the fixture binds a root UAV, which has no bounds checking, so an out-of-range store has no defined GPU result to pin. Controls, binary mode against llvm-mc 15 and the 11 compute ctests pass on that head.

AI-assisted (Claude Code).

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 94b042bac51961db9be4fd5218b3ab0eb92d9c01 (previous review was on 0236bbcb). Scope: compute stage in tools/startup/gfx2hlsl.py, new tests/startup_gfx2hlsl_compute_check.py, CMake/CI/docs wiring.

Status: mergeable, CI green on this head (Linux checks, gfx1013 fixtures, Windows build and test; /O2 and chart jobs skipped). Title and body are neutral. No external or clean-room concerns seen in the diff.

Commands executed locally in a worktree of the head:

  • git diff --stat origin/main...HEAD: 6 files, +652/-4
  • python3 tests/startup_gfx2hlsl_compute_check.py: pass ("Self-test passed.")
  • python3 tests/docs_links_check.py: pass (18 files, 402 links)
  • python3 tests/bidi_controls_check.py: pass (1465 files)
  • git diff --check origin/main...HEAD: clean

Mutations (each reverted with git checkout -- .):

  1. Disabled the s_cbranch_execz skipped-block guard in translate(): killed (test fails: expected refusal naming s_add_u32 inside a block s_cbranch_execz skips).
  2. Dropped the & 0xfffffffcu dword rounding in op_buffer_store_dword: killed (test pins the emitted a = (v4 + 0) & 0xfffffffcu;).
  3. Removed the desc_key(first) in self.pipe.modified clause in the store's descriptor check: survived.

Findings:

  • P1: none.
  • P2: none.
  • nit (tools/startup/gfx2hlsl.py, op_buffer_store_dword, the desc_key(first) in self.pipe.modified clause): mutation 3 survives. The per-word self.sym comparison already catches a modified word because the writer now tags it ('modified',), so the clause looks redundant. Either add a case where only pipe.modified carries the mark, or drop the clause.
  • nit (op_buffer_store_dword): the out-of-range store is deliberately unguarded and the comment and the new pinning test say so. It stays an assumption until a runtime sizes the UAV view. Fine to keep as documented.
  • nit (setup_entry): the compute root start at s4 is an inference. The code comment and docs/experiments.md say so honestly, and unplaced user SGPRs are refused on read. Good.

Not run: Win2025 WARP. The compute store is not yet covered by a GPU readback in this PR, which is acceptable for a translator-only slice, but a WARP readback of the offen store versus a CPU reference should come before the follow-up that binds the UAV.

Verdict: no blocking issues on this head; the earlier review points look addressed.

AI-assisted; commands listed were executed locally.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combined tree with current main (including #2139) passed the compute buffer-store comparison and all four mutations on both WARP and RTX 4060 Laptop. I found one scope leak in that combination: a source-built CS Stage with a table SRV and image_load v4, v[0:1], s[16:23] dim:SQ_RSRC_IMG_2D dmask:0x3 d16 emits pack16_d16(..., ud0) and udsrc 0 d16unorm16 0. ComputePipeline.manifest does not emit the d16srv bound-view requirement, and the CS path has no equivalent per-view validation. Please update against #2139 and explicitly refuse D16 loads in CS for this buffer-store slice. Add that synthetic case as a refusal control. Supporting D16 compute textures can follow when the compute consumer validates the effective SRV format.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 0a523d0 (comment only, no approval). Earlier reviews covered 0236bbc and 94b042b.

Scope: git diff --stat origin/main...HEAD is 6 files (gfx2hlsl.py, the compute check, CMakeLists.txt, windows.yml, AGENTS.md, docs/experiments.md). The new part since the last review is the "refuse unvalidated compute D16 loads" change in image() plus the D16 SRV format sets.

Commands executed locally (Linux):

  • python3 -B tests/startup_gfx2hlsl_compute_check.py -> pass
  • python3 -B tests/startup_image_sample_l_check.py -> FAIL: AttributeError: 'Stage' object has no attribute 'kind' (tools/startup/gfx2hlsl.py:1803, from tests/startup_image_sample_l_check.py:205 bare.image(...))
  • all tests/startup_gfx2hlsl_*_check.py and tests/startup_*gfx*check.py -> pass (the failure above is outside that glob)
  • python3 tests/docs_links_check.py -> 407 links OK; python3 tests/bidi_controls_check.py -> OK; git diff --check origin/main...HEAD -> clean
  • Mutation: replaced self.kind == 'cs' and 'd16' in mods with False and 'd16' in mods. The compute check fails ("accepted, expected a refusal naming 'compute d16 image load requires validated SRV formats'"), so the new refusal is guarded. Reverted with git checkout -- ..
  • CI: "Run platform-independent Python checks on Linux" is red on this head. The log shows the same traceback, in tests/startup_image_sample_l_check.py. The Windows jobs were still pending when I looked.

Findings:

  • P1: none.
  • P2 (tools/startup/gfx2hlsl.py:1803): image() now reads self.kind unconditionally. Stage instances created without kind (the bare Stage in tests/startup_image_sample_l_check.py:205 and its address-count control) raise AttributeError before any other check, so an existing test fails and the Linux CI job is red. Fix: set a default kind on Stage (or getattr(self, 'kind', None)), or have that test set bare.kind = 'ps' like startup_gfx2hlsl_refusals_check.py:37 does. A class-level default is safer, since other callers could build a Stage the same way.
  • nit (tests): the D16 refusal is covered for the unvalidated case. Add one control that a validated SRV format in D16_EXACT_SRV_FORMATS still lowers on cs, so the allowlist cannot be emptied unnoticed.
  • Earlier nits (user SGPR base s4 is an inference, store alignment/num_records assumptions, the Linux kill is an exact-line check) still stand and are documented in the code and docs.

Windows: I did not run x2w_pipe.py win2025 on this head. The Linux job is already red, and the earlier Win2025 debug result (11/11) was for 0236bbc. It needs a rerun after the P2 fix.

Verdict: not ready until the P2 is fixed and CI is green.

AI-assisted; commands listed were executed locally.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed 0a523d0. The integration explicitly refuses a D16 load in compute until that consumer validates the bound SRV, and the new control checks that refusal. Compute buffer-store controls, graphics D16 tests, and the offline producer test pass. The combined branch's three 320-word GPU comparisons and four mutations ran on WARP and RTX 4060 Laptop before this narrow guard. This lands the standalone compute translator only. Runtime binding and the real application Dispatch remain separate.

… D16 guard

The compute D16 guard added in 0a523d0 reads self.kind at the top of
Stage.image. Checks that build a bare Stage to reach the operand-only
refusals (tests/startup_image_sample_l_check.py and others) have no kind,
so the Linux Python job failed with AttributeError. Read kind with a
default; the guard is unchanged for a compute stage.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@NiiRoZz

NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

The Linux Python job failed on 0a523d0: tests/startup_image_sample_l_check.py builds a bare Stage (Stage.__new__) to reach the operand-only refusals, and the new compute D16 guard at the top of Stage.image reads self.kind, which a bare stage does not have (AttributeError: 'Stage' object has no attribute 'kind').

Pushed a one-line follow-up on top of your commit: the guard reads getattr(self, 'kind', None), so it is unchanged for a compute stage and bare stages reach their refusals again. Locally the 16 pure-Python checks that build a bare stage, plus startup_gfx2hlsl_compute_check.py and startup_translator_check.py, pass on that head.

AI-assisted (Claude Code).

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 5633dcd (PR #2182).

Delta since my last review (0a523d0): one line, tools/startup/gfx2hlsl.py:1803, self.kind == 'cs' became getattr(self, 'kind', None) == 'cs'. This addresses the earlier P2 (bare Stage without kind raised AttributeError before the image refusals).

Commands executed locally (Linux):

  • python3 -B tests/startup_image_sample_l_check.py -> pass (was FAIL on 0a523d0)
  • python3 -B tests/startup_gfx2hlsl_compute_check.py -> pass
  • all tests/startup_*gfx*check.py and tests/startup_image*check.py -> pass, no failures
  • python3 tests/docs_links_check.py -> 18 files, 407 links OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean
  • Mutation: replaced the guard with False and 'd16' in mods. The compute check fails ("accepted, expected a refusal naming 'compute d16 image load requires validated SRV formats'"), so the refusal is guarded. Reverted with git checkout -- ..
  • CI on this head: "Run platform-independent Python checks on Linux" pass, "Assemble and translate gfx1013 fixtures" pass, "Build and test on Windows" pass. The /O2 job and the chart job are skipped. PR is mergeable, title is neutral.

Findings:

  • P1: none.
  • P2: none. The previous P2 is fixed.
  • nit (tests, carried over): add one control that a format in D16_EXACT_SRV_FORMATS still lowers on cs, so the allowlist cannot be emptied unnoticed.
  • Earlier nits (user SGPR base s4 is an inference, store alignment/num_records assumptions, the Linux kill is an exact-line check) still stand and are documented in the code and docs.

Windows: I did not run x2w_pipe.py win2025. The change since the last Win2025 run is a one-line Python default with no HLSL output change, and the Windows CI job is green. The maintainer's Draft -> Ready gate still needs its own WARP run on the final head.

Verdict: no blocking findings from this review.

AI-assisted; commands listed were executed locally.

@R0Y00
R0Y00 merged commit 77521c4 into R0Y00:main Nov 25, 2026
5 checks passed
rasptum added a commit to rasptum/Xbox2Windows that referenced this pull request Nov 25, 2026
ComputePipeline (R0Y00#2182) maps buffer descriptors to u indices in self.uavs
and declares them itself; the inherited common() and manifest() read
stored_images() as pixel-stage image entries, which a compute program
cannot have. startup_gfx2hlsl_compute_check.py fails without this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R0Y00 pushed a commit that referenced this pull request Nov 25, 2026
* startup: lower pixel-stage image_store to a typed UAV store

gfx2hlsl refused image_store in every stage (#1996 item F). In a pixel stage,
image_store with dim:SQ_RSRC_IMG_2D and dmask:0xf now becomes
w<n>[uint2(x, y)] = asfloat(uint4(data)) on a RWTexture2D<float4> at its
own u register, under the lane's exec bit, and the manifest becomes version 2 with
"uav <index> tex2d table <table> <offset>".

Semantics: MIMG opcode 0x08 (LLVM AMDGPU MIMGInstructions.td, IMAGE_STORE
defined through MIMG_Store): VDATA is the source, VADDR the integer texel
address (x, y for dim 2D), SRSRC the image descriptor, and the DMASK
channels are written in order from consecutive VDATA registers. Mesa ACO
(visit_image_store) emits the same form with DMASK from the write mask.
A typed UAV store writes every channel, so only DMASK 0xf is exact; a
partial mask, other dimensions, d16, a16, tfe, lwe, r128, unorm,
image_store_mip, a store outside a pixel stage and a load and store of the
same image are refused by name. glc, slc and dlc are accepted.

The translated graphics path does not bind UAVs yet: d3d12_draw.inl logs
and does not use a translation whose manifest has a uav line, instead of
rejecting it as an invalid sampler-heap line.

startup_pixel_image_store_check.py decodes the hand-assembled program with
disasm_rdna2, checks the translation, the refusals, and that the program is
refused again with the lowering removed. The draw stores four values at
texel (1, 2) of a 4x4 image through offscreen_check --startup-image-store,
reads all 16 texels back, and checks that deleting the store or exchanging
x and y is detected.

Refs #1996

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* startup: check the image_store dmask guard itself

The two encoded partial-mask controls only asserted that image_store was
refused. The decoder sizes VDATA from the mask (v[4:6], v4), so with the
dmask guard disabled the data-register check still refused them and the
controls passed. Each now asserts the dmask reason, and a new control calls
the handler with v[4:7] and dmask 0x7, which only the mask guard can
refuse; another passes dmask 0xf with three data registers and asserts the
data reason. With the guard replaced by `if False:` the check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* startup: give Pipeline.uavs a class default instead of a __dict__ fallback

Pipelines that tests assemble without __init__ store to no image. A class
attribute of None now says so; the first store creates the instance's own
map.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: rewrap the pixel-stage image store bullet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* startup: refuse malformed image_store dmask text by name

int(masks[0], 0) raised ValueError on mask text that is not an integer;
it is now an Unsupported refusal ("not an integer"), with a control.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* startup: check the image_store exec guard

Two variants put v_cmpx_eq_u32 before the store so exec is not known at
translation time. The controls assert that the emitted store is guarded
by the lane's exec bit, and the draw mode reads the image back: with the
lane on the texel is written, with every lane off it keeps its starting
value, and the exec-off shader with the guard removed must write it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* startup: keep compute buffer UAVs out of the pixel-stage image list

ComputePipeline (#2182) maps buffer descriptors to u indices in self.uavs
and declares them itself; the inherited common() and manifest() read
stored_images() as pixel-stage image entries, which a compute program
cannot have. startup_gfx2hlsl_compute_check.py fails without this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* startup: name the texel_mismatch line in the image store controls

The controls printed the first stderr line as the reason, which on a
machine with several adapters is an adapter notice. They now print the
texel_mismatch report they already assert on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* startup: check that a compute program lists no pixel-stage image stores

The compute stage's buffer stores live in self.uavs (descriptor key -> u
index), which the shared common() and manifest() must not read as
#2155's image stores. The control asserts stored_images() is empty
before any output is built, then no RWTexture2D declaration, the
`x2w-manifest 2` / `stage cs` header and the single kind-less uav line.
With ComputePipeline.stored_images removed it fails at that assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: rasptum <348594691+rasptum@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants