Skip to content

startup: translate slot 57 mesh requests with a depth-only pixel stage - #2606

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
NiiRoZz:startup/gfx2hlsl-mesh57-depth-only-pixel
Nov 26, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
NiiRoZz:startup/gfx2hlsl-mesh57-depth-only-pixel

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Part of #2413 (item T5, the null-export half; #2520 covered the no-pixel-stage half).

What changed

A slot 57 request whose pixel stage exports only to the null target (exp null off, off, off, off done vm) passed the role check since #2421 but was then refused with slot 57 mesh with a depth-only pixel stage is not covered. That refusal is removed, so the pair goes through the existing pair path:

  • Stage.export writes nothing for the null target. The vm flag still emits the existing if (!(exec & 1)) discard; when EXEC was narrowed, so an alpha test keeps its kill. This is the same two-line hunk as the open shader: lower export target null in gfx2hlsl (Part of #1723) #2026 (first commit of this branch, byte-identical, so it drops out if shader: lower export target null in gfx2hlsl (Part of #1723) #2026 merges first). classify_decoded is not changed here.
  • translate_mesh57 no longer raises for a null-only pixel stage. The role check is unchanged: a null export mixed with any other non-colour export is still refused.
  • No new output form. hlsl_ps already emits void main(PSIn i) with no SV_Target when the stage has no colour export, and manifest() already writes an empty targets line. The manifest keeps that line instead of ps none, because the pixel stage still decides coverage (discard) and must be bound.

Why it is not handled like the no-pixel case (#2520): all 29 measured depth-only pixel stages read a texture and write EXEC before the null export, and 2 of them also store to an image. Dropping the stage would lose the kill (depth written for pixels that are discarded) and the stores.

Tests

Windows 11, Python 3.13, at this branch's head:

python -B tests/startup_mesh57_depth_only_check.py      -> ok
python -B tests/startup_mesh57_skeleton_check.py        -> ok
python -B tests/startup_gfx2hlsl_watch_check.py         -> startup_gfx2hlsl_watch_check passed
python -B tests/startup_translator_check.py             -> startup translator checks: 0 failed
python -B tests/docs_links_check.py                     -> Checked 19 Markdown files and 503 links.

tests/startup_mesh57_depth_only_check.py (new, pure Python, registered in CMakeLists.txt, AGENTS.md and the platform-independent workflow job) pairs the accepted mesh fixture with hand-built pixel words: v_interp_mov_f32, v_cmp_gt_f32 vcc, 0.5, v0, s_andn2_b64 exec, exec, vcc, exp null done vm, s_endpgm. It checks the decode, that the pair translates, that the pixel HLSL has no SV_Target and keeps the discard, and that the manifest ends in an empty targets line and has no ps none. Controls: the same stage without the EXEC narrowing has no discard; a null export followed by a position export is still refused with the incompatible-export message. With the translator change reverted the check exits 1.

Two existing assertions that expected the old refusal were updated to the new outcome: the skeleton check's depth-only case now expects ok, and the watch check's synthetic null-export pair now reaches the mesh shape check, with the same refusal as its synthetic colour pair.

Local observation (not reproducible from the repository)

29 locally requested slot 57 pairs stopped first at the depth-only refusal.

first refusal before after
slot 57 mesh with a depth-only pixel stage is not covered 29 0
slot 57 mesh: a branch enters or crosses a group-memory exchange 0 24
slot 57 mesh: a loop outside the group-memory exchanges is not covered 0 3
slot 57 mesh group-index exchange: instruction N of the accepted shape (s_mov_b64) is absent 0 2
translated 0 0

All 29 now stop in the mesh stage, at refusals that already exist; none translates. Shapes of the 29 pixel stages: 31 to 437 instructions; each reads a texture (image_sample or image_load) and writes EXEC before its null export; 24 have the single null export as the instruction before s_endpgm; 2 contain an image store. The common form interpolates two attributes, samples one texture channel (dmask:0x8), compares and narrows EXEC.

DXC (Windows SDK 10.0.26100) compiled the new fixture pair as ms_6_5 and ps_6_0 locally. Nothing was drawn.

Measured versus hypothesis

  • Measured: the first-refusal counts above; the fixture translation, its discard and manifest; DXC compiles the fixture pair.
  • Probe, not the request path: running only the 29 pixel stages through the pixel translator in a hand-built pipeline object (each with its request's root signature) gives 27 s_load with a register offset through the resource heap, 1 sampler from a descriptor, 1 image_store modifier a16. These are expected to be the next pixel-side refusals once the mesh stages pass, but the request path never reached them.
  • Hypothesis: that an empty targets line is what a future slot 57 runtime loader needs to create a pipeline with zero render targets and a depth view. No runtime code reads slot 57 results yet.

Not verified

  • No draw: the depth-only fixture is not rasterised or compared against a CPU reference, and no depth buffer is read back.
  • No request among the 29 translates end to end; they stop in the mesh stage first. Their pixel-stage refusals are only probed (see above).
  • The runtime does not load .ms57 / .ps57 results (issue item R1), so these draws are not submitted. Zero-RTV plus depth translated draws are the subject of the open startup: allow MRT, depth, and depth-only targets in translated ExecuteIndirect #2417.

🤖 Generated with Claude Code

NiiRoZz and others added 2 commits November 26, 2026 00:11
The null target carries no channel; its only effect is the vm discard
emitted before it. Same change as the open R0Y00#2026, so a rebase onto it
drops this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e (Part of R0Y00#2413)

A pixel stage whose only export is the null target was refused with
'slot 57 mesh with a depth-only pixel stage is not covered'. It now
translates with the pair: the pixel stage has no SV_Target, keeps the vm
discard of an alpha test, and the manifest has an empty targets line.

Co-Authored-By: Claude Opus 5.5 <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 94fed37 against origin/main (comment only).

Code: the diff is small and consistent with the description.

  • tools/startup/gfx2hlsl.py Stage.export: the null target returns after the existing vm discard, so an alpha-test kill is kept and no render-target write is emitted.
  • translate_mesh57: the null-only refusal is removed; the role check for a null export mixed with another non-colour export is unchanged.
  • Sibling checks: the two assertions that expected the old refusal were updated to the new outcome and nothing else changed in them.

Linux commands run on the exact head:

  • python3 -B tests/startup_mesh57_depth_only_check.py -> ok
  • python3 -B tests/startup_mesh57_skeleton_check.py -> ok
  • python3 -B tests/startup_gfx2hlsl_watch_check.py -> passed
  • python3 -B tests/startup_translator_check.py -> 0 failed
  • python3 tests/docs_links_check.py -> ok; python3 tests/bidi_controls_check.py -> ok; git diff --check origin/main...HEAD -> clean
  • Mutation 1: restore tools/startup/gfx2hlsl.py from origin/main -> the new depth-only check exits 1.
  • Mutation 2: disable the null early return in Stage.export -> the new depth-only check exits 1.

Findings: no code defect found. The new test guards the behavior (discard kept, no SV_Target, empty targets line, mixed null+position still refused).

Not covered by this review:

  • No Windows run was done by this review (no Win2025 receipt for this head).
  • The PR is framed as startup progress (29 locally requested pairs, first-refusal counts). That observation cannot be reproduced from the repository and was not verified here; the DXC compile result is the author's own.
  • Because of that framing, the merge decision stays with MasterDomino or @R0Y00, who can check the startup claim on the game. This review does not merge it.
  • .github/workflows/windows.yml has a one-line change registering the new test; it should be exercised by this PR's own CI run.

AI-assisted; commands listed were executed locally.

@roansystemlabs

Copy link
Copy Markdown
Contributor

Thanks for #2606. As agreed in #2413, I'm building the source-built depth-only draw on top of it, and I checked the translator half first. Everything below was run on your head 94fed370 and on a local merge of it with current main 66026a39 (#2026 merged at 23:22Z; the merge has no conflicts). Windows 11, Python 3.12 venv, DXC from the Windows SDK 10.0.26100.0.

What works

  • The null-only pair translates as you describe: the vm discard is kept, there is no SV_Target, and the manifest ends in an empty targets line.
  • The existing manifest reader is happy with it: pending_keys keeps the pair pending with only .ms57.cso, or with a truncated .ps57.cso, and reports it done once both are complete.
  • The CI run on this head is green.
  • Our depth draw on top of it (the pair drawn twice into a D32 target cleared to 1.0, depth test LESS, compared with the CPU rasteriser) passes on an NVIDIA GeForce RTX 3070 (driver 621.01) and on WARP, debug layer on, debug_errors=0 debug_warnings=0, no skips, at your head and on the merge with main. I'll open it once the first question below is settled, because its refusal controls depend on the answer.

Questions

To reproduce, save this as null_mix.py and run python -B null_mix.py from the repository root. It uses only MESH and request from tests/startup_mesh57_skeleton_check.py. python -B null_mix.py dxc compiles with DXC instead of writing sources only.

import os, sys, tempfile
sys.path.insert(0, 'tests')
import startup_mesh57_skeleton_check as S
if sys.argv[1:] != ['dxc']:
    os.environ['X2W_FXC'] = ''  # sources and manifest only
PRE = ['c8020002', '7c2200f0']  # v_interp_mov_f32 v0, p0, attr0.x; v_cmpx_lt_f32 0.5, v0
NULL, END = ['f8001890', '00000000'], ['bf810000']  # exp null off, off, off, off done vm; s_endpgm
for label, words in (
        ('mrt0 before null', PRE + ['f800000f', '00000000'] + NULL + END),
        ('null done, then mrt0 done', ['f8000890', '00000000', 'f800080f', '00000000'] + END),
        ('mrtz before null', ['f8000081', '00000000'] + NULL + END),
        ('param0 before null', PRE + ['f800020f', '00000000'] + NULL + END),
        ('pos0 before null', PRE + ['f80000cf', '00000000'] + NULL + END),
        ('null with channel x', ['f8001891', '00000000'] + END)):
    with tempfile.TemporaryDirectory() as tmp:
        key, result = S.request(tmp, S.MESH, words)
        print('%-26s %-60s %s' % (label, result, sorted(n.split('.', 1)[1] for n in os.listdir(tmp) if not n.startswith('req_'))))
  1. Colour next to the null export. exp mrt0 v0, v0, v0, v0 before exp null off, off, off, off done vm translates (ok, targets 0, SV_Target in the pixel HLSL), and so does exp null … done followed by exp mrt0 … done. With DXC both publish .ms57.cso and .ps57.cso. At cece3a36 both stopped at export target null. In tracking: fixed mesh pipelines (device slot 57) requested at run time, 0 of 298 translated; checklist of claimable items #2413 R0Y00 asked to keep the mixed colour/null refusal for this narrow profile. Since shader: lower export target null in gfx2hlsl (Part of #1723) #2026 deliberately draws a null export after mrt0 in the general pixel path, would the refusal belong in translate_mesh57 only, for example refusing a slot 57 pixel stage that has a null export next to any other export?
  2. Depth next to the null export. exp mrtz v0, off, off, off before the null export, with the entry EXEC, also translates (SV_Depth, empty targets). The description says a null export mixed with any other non-colour export is still refused; is mrtz meant to be the exception? (mrtz after a v_cmpx is still refused by the existing MRTZ rule.)
  3. param0 next to the null export, after merging main. At your head this is refused with slot 57 pixel stage has an incompatible export or termination. On the merge with main it translates, because shader: lower export target null in gfx2hlsl (Part of #1723) #2026 makes classify_decoded return ps for a stage with a null export. Without DXC the result is ok and .ps57.hlsl assigns o.param0 inside void main(PSIn i), where o is not declared. With DXC it stops at dxc ps: error: use of undeclared identifier 'o' and leaves the two .hlsl files next to the .fail, instead of the named refusal. pos0 next to the null export is still refused by name. So this appears only after a rebase on main.
  4. A null export that carries a channel. exp null v0, off, off, off done vm translates and the channel is dropped. The null target writes nothing anyway, so this may well be intended; I'm only asking because shader: lower export target null in gfx2hlsl (Part of #1723) #2026 keeps a partial compressed enable mask on a null export refused.

Not covered: source-built programs only, no captured requests, nothing loaded at runtime (R1 does not exist yet).

AI-assisted.

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

@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.

Keep T5 scoped to a slot-57 pixel stage whose only export target is null. The existing general pixel behavior from #2026 can keep its mixed-export forms. I reran the proposed controls on the rebased 1f41b562: the pure depth-only check passes, but each of mrt0 + null, mrtz + null and param0 + null returns ok in manifest-only mode. Please enforce the narrower shape in translate_mesh57 before HLSL publication. Include the inverse export order and confirm mixed forms leave no manifest. For the null-only case, keep the VM discard and the real pixel stage with zero color targets. The D32 sentinel comparison and discard-removal mutant described above are the right independent evidence.

… of R0Y00#2413)

The slot 57 depth-only profile is a pixel stage whose only export target is
null. A null export before or after an mrt0, mrtz or param0 export passed the
role check and was published; it is now refused in translate_mesh57 before any
source or manifest is written. The general pixel path keeps its mixed forms.

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

NiiRoZz commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Pushed 8bd527a8 on top of 1f41b562.

Reproduction. At 1f41b562 in manifest-only mode (X2W_FXC=), all six mixed forms returned ok and wrote .ms57.hlsl, .ps57.hlsl and .ms57.txt: mrt0 + null, mrtz + null, param0 + null and the inverse orders null + mrt0, null + mrtz, null + param0.

Narrower shape. translate_mesh57 now refuses a slot 57 pixel stage that has a null export next to any other export target, with slot 57 pixel stage mixes the null export with another export. The check runs after the existing role check and before any source, bytecode or manifest is written. Stage.export and classify_decoded are unchanged, so the general pixel path from #2026 keeps its mixed forms. null + pos0 still gets the existing incompatible export or termination message.

Inverse order, no manifest. tests/startup_mesh57_depth_only_check.py covers the three forms in both orders (six cases). Each case checks the decoded export order, the exact refusal, and that the directory holds only the req_* inputs and <key>.fail: no .hlsl and no .ms57.txt. With the new check disabled, the test fails on all six cases (12 failed assertions).

Null-only. Unchanged and still asserted: the vm discard is kept, the pixel stage has no SV_Target, and the manifest ends in an empty targets line without ps none.

D32 sentinel and discard-removal mutant. I left this out of the PR on purpose: @roansystemlabs is building the source-built depth-only draw on top of this branch, as agreed in #2413, and I do not want to duplicate it. For reference, a local draw of the alpha-test pair into a D32 target cleared to 1.0 (zero render targets, depth test LESS) matched its reference on WARP and on one hardware adapter, and the same draw with the discard line removed from the generated pixel source failed with 115 depth mismatches. If you would rather have that fixture in this PR, say so and I will push it as a separate commit.

Commands at 8bd527a8 (Windows 11):

python -B tests/startup_mesh57_depth_only_check.py   -> ok
python -B tests/startup_mesh57_skeleton_check.py     -> ok
python -B tests/startup_translator_check.py          -> startup translator checks: 0 failed

Not verified:

  • No captured request translates end to end; they still stop in the mesh stage.
  • The runtime does not load slot 57 results, so nothing is drawn through the guest path.
  • A null export carrying a channel is unchanged and still accepted.

🤖 Generated with Claude Code

R0Y00 commented Nov 26, 2026

Copy link
Copy Markdown
Owner

I retested 8bd527a8 on Windows. The six mixed-export cases now refuse before publication, and the null-only, skeleton, watch and translator checks all pass. This addresses the export-shape finding. @roansystemlabs, please publish your existing D32 draw fixture on this head, or link an exact-head run with the discard-removal mutant if the branch is already ready. That will let us verify the actual depth distinction on the revised candidate.

@roansystemlabs

Copy link
Copy Markdown
Contributor

Thanks. Here is the D32 draw fixture on your exact head 8bd527a8: #2680 (one commit, 120eef54, tests and docs only, no translator change).

ctest --preset release --no-tests=error -j 1 -R '^startup_mesh57_skeleton' -V at 8bd527a8 + 120eef54, Windows 11, Release, MSVC 14.44, DXC 10.0.26100.0: 9/9 passed. That includes the offline check, which now expects your exact refusal (slot 57 pixel stage mixes the null export with another export) for a colour export before the null export of the drawn stage; the other mixed forms are left to your startup_mesh57_depth_only_check.py. startup_mesh57_depth_only, startup_gfx2hlsl_watch and startup_gfx2hlsl_export_null{,_draw_warp,_draw_hardware} pass too.

startup_mesh57_skeleton_depth_hardware ran on an NVIDIA GeForce RTX 3070 (10de:2484, driver 32.0.16.2101). startup_mesh57_skeleton_depth_warp ran on the Microsoft Basic Render Driver (1414:008c, 10.0.26100.9818). Both had the debug layer enabled, debug_errors=0 debug_warnings=0, and no skips. The pair is drawn twice into a D32 target cleared to 1.0, depth test LESS. 259 pixels are covered: 181 keep a written depth and 78 keep the sentinel only because of the discard. Against the CPU reference the result is depth_mismatches=0, and colour stays cleared. In-test controls: a reference without the depth writes gives 181 mismatches, and the same mesh with a null export that does not discard gives 134.

Translator mutants at the same head, each reverted:

  • Discard removed (vm ignored for null in Stage.export): the baseline draw fails with depth_mismatches=134 on both adapters, and the offline check and startup_mesh57_depth_only fail.
  • No depth written (an unconditional discard; for null): the baseline fails with 181 on both, and the same two checks fail.

Not covered: source-built programs only, no captured request, nothing loaded at runtime (R1). The binary (llvm-mc) mode was not run here.

AI-assisted.

@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.

I reran the offline depth-only, mesh-skeleton and watcher controls at your exact head plus the test-only #2680 commit. WARP and RTX 4060 Laptop each matched all 1,024 D32 pixels and kept color cleared with zero debug warnings. Both adapters detected 181 depth mismatches against a no-write reference and 134 when the discard was removed. The six mixed export forms still refuse before publication. This resolves the T5 scope review. The fixture can follow as its own PR.

@R0Y00
R0Y00 merged commit d26cbc5 into R0Y00:main Nov 26, 2026
5 checks passed
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.

4 participants