shader: lower and draw the null export target (Part of #1723) #2604

Closed
lambirou wants to merge 3 commits from upstream-pr/2612 into main
lambirou commented 2026-11-25 23:20:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-25T23:20:32Z.


Problem

exp null, off, off, off, off done vm is a pixel shader that only discards: the null target writes no channel, while vm still kills the lanes outside the entry execution mask. The startup translator refused it as export target null, and a stage whose only export was null was classified as other.

This PR revives the two commits from the closed #2026 by @tedin7 and adds the missing draw coverage. #2026 was closed only to keep the Windows queue short; its branch is unchanged.

Change

  • tools/startup/gfx2hlsl.py: accept the null target, keep the vm discard, add no SV_Target or write mask, and classify a null-only stage as a pixel stage. A null export with a source operand, a compressed mask or an en: field stays refused.
  • tests/startup_gfx2hlsl_export_null_check.py: the source-built translation, classification and refusal controls from #2026.
  • tests/startup_gfx2hlsl_export_null_draw_check.py: compile a colour export followed by exp null with DXC ps_6_0, draw 4x4 pixels through offscreen_check --startup-pixel-words, and compare all 64 words with the four constants. The negative control writes mrt0 = 0 from the null site and must produce pixel mismatch.
  • CMakeLists.txt and docs/experiments.md: register the pure check plus startup_gfx2hlsl_export_null_draw_{warp,hardware} and document the scope.

Verification

python -B tests/startup_gfx2hlsl_export_null_check.py
all ok

python -B tests/startup_gfx2hlsl_export_null_draw_check.py draw <dxc> <offscreen_check> warp
backend=warp ... adapter=Microsoft Basic Render Driver ...
null export draw: 16 pixels match; the writing-null control differs

python -B tests/startup_gfx2hlsl_export_null_draw_check.py draw <dxc> <offscreen_check> hardware
backend=hardware ... adapter=AMD Radeon RX 9060 XT driver=32.0.32029.2010 ...
null export draw: 16 pixels match; the writing-null control differs

The hardware case ran on Windows 11 build 26300 with the D3D12 debug layer unavailable. tests/docs_links_check.py passes (19 files, 498 links), tests/bidi_controls_check.py passes, and git diff --check is clean.

Evidence

Every instruction is built from the documented EXP encoding; no archive bytes, game files, dumps or private logs are used. The pure check covers the null-only translation, null before and after mrt0, the vm discard outside entry EXEC, the three refusal shapes and the pixel/vertex classification controls.

Follow-up

  • The draw covers the mixed null-plus-colour case, where the no-op is observable; a null-only stage has no pixels to read back.
  • If @tedin7 prefers, #2026 can be reopened and this draw commit cherry-picked; the first two commits here preserve his authorship.

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.

AI-assisted: the translation and first checks are @tedin7's; the draw fixture and this description were prepared with a Codex subagent and reviewed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6615783283 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2612). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-25T23:20:32Z. --- ## Problem `exp null, off, off, off, off done vm` is a pixel shader that only discards: the null target writes no channel, while `vm` still kills the lanes outside the entry execution mask. The startup translator refused it as `export target null`, and a stage whose only export was null was classified as `other`. This PR revives the two commits from the closed #2026 by @tedin7 and adds the missing draw coverage. #2026 was closed only to keep the Windows queue short; its branch is unchanged. ## Change - `tools/startup/gfx2hlsl.py`: accept the null target, keep the `vm` discard, add no `SV_Target` or write mask, and classify a null-only stage as a pixel stage. A null export with a source operand, a compressed mask or an `en:` field stays refused. - `tests/startup_gfx2hlsl_export_null_check.py`: the source-built translation, classification and refusal controls from #2026. - `tests/startup_gfx2hlsl_export_null_draw_check.py`: compile a colour export followed by `exp null` with DXC `ps_6_0`, draw 4x4 pixels through `offscreen_check --startup-pixel-words`, and compare all 64 words with the four constants. The negative control writes `mrt0 = 0` from the null site and must produce `pixel mismatch`. - `CMakeLists.txt` and `docs/experiments.md`: register the pure check plus `startup_gfx2hlsl_export_null_draw_{warp,hardware}` and document the scope. ## Verification ```text python -B tests/startup_gfx2hlsl_export_null_check.py all ok python -B tests/startup_gfx2hlsl_export_null_draw_check.py draw <dxc> <offscreen_check> warp backend=warp ... adapter=Microsoft Basic Render Driver ... null export draw: 16 pixels match; the writing-null control differs python -B tests/startup_gfx2hlsl_export_null_draw_check.py draw <dxc> <offscreen_check> hardware backend=hardware ... adapter=AMD Radeon RX 9060 XT driver=32.0.32029.2010 ... null export draw: 16 pixels match; the writing-null control differs ``` The hardware case ran on Windows 11 build 26300 with the D3D12 debug layer unavailable. `tests/docs_links_check.py` passes (19 files, 498 links), `tests/bidi_controls_check.py` passes, and `git diff --check` is clean. ## Evidence Every instruction is built from the documented EXP encoding; no archive bytes, game files, dumps or private logs are used. The pure check covers the null-only translation, null before and after `mrt0`, the `vm` discard outside entry EXEC, the three refusal shapes and the pixel/vertex classification controls. ## Follow-up - The draw covers the mixed null-plus-colour case, where the no-op is observable; a null-only stage has no pixels to read back. - If @tedin7 prefers, #2026 can be reopened and this draw commit cherry-picked; the first two commits here preserve his authorship. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted: the translation and first checks are @tedin7's; the draw fixture and this description were prepared with a Codex subagent and reviewed locally.
upstream-sync closed this pull request 2026-11-26 00:00:58 +00:00
lambirou commented 2026-11-26 00:01:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-25T23:22:28Z.


@tedin7 this PR revives the two commits from your closed #2026 and adds the draw fixture discussed there (7ee0b6d7). Your authorship is preserved on both commits.

If you prefer to reopen #2026 instead, I can close this PR and hand the draw commit over; otherwise this is the combined branch ready for review. CI is running on 7ee0b6d7.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7177472608 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2612#issuecomment-7177472608). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-25T23:22:28Z. --- @tedin7 this PR revives the two commits from your closed #2026 and adds the draw fixture discussed there (`7ee0b6d7`). Your authorship is preserved on both commits. If you prefer to reopen #2026 instead, I can close this PR and hand the draw commit over; otherwise this is the combined branch ready for review. CI is running on `7ee0b6d7`.
lambirou commented 2026-11-26 00:01:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-25T23:24:57Z.


#2026 was reopened and merged at 23:22 UTC (merge commit 66026a39). Its merge includes the draw fixture from 7ee0b6d7 and the documentation update, with Co-authored-by: Roland Edi.

This PR is now a duplicate of the merged #2026, so I am closing it. The useful draw coverage is already on main; no further change is needed here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7177528963 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2612#issuecomment-7177528963). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-25T23:24:57Z. --- #2026 was reopened and merged at 23:22 UTC (merge commit `66026a39`). Its merge includes the draw fixture from `7ee0b6d7` and the documentation update, with `Co-authored-by: Roland Edi`. This PR is now a duplicate of the merged #2026, so I am closing it. The useful draw coverage is already on `main`; no further change is needed here.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2604
No description provided.