shader: cover runtime mesh geometry inputs #1882

Merged
avt0m4t48 merged 1 commit from upstream-pr/1889 into main 2026-11-24 20:54:57 +00:00
avt0m4t48 commented 2026-11-24 20:17:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by avt0m4t48 on 2026-11-24T20:17:33Z.


Refs #1760.

Add a source-built gfx1013 mesh fixture whose allocation counts and second primitive indices come from buffer data. The same program produces a triangle or quad. A CPU oracle checks vertex positions, attributes, and primitive indices for six inputs: triangle, quad, zero allocation, five vertices against a limit of four, a second primitive containing index 4 with four vertices allocated, and a duplicate primitive. Both out-of-range inputs produce a zero allocation.

Verification on Linux:

  • python3 -B tests/mesh_dynamic_geometry_check.py passed all six cases.
  • python3 -B tests/mesh_dynamic_geometry_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 passed with LLVM 15. The assembled bytes and independent instruction listings agreed.
  • Altering the quad allocation compare produced a zero allocation and failed. Altering the packed primitive index produced the wrong index triple and failed.
  • Documentation links and bidirectional-control checks passed.

A separate Linux experiment used these inputs and a hand-written mesh shader to verify full rendered images and allocation outcomes on llvmpipe. This PR adds the reusable source and CPU-model coverage. Dynamic Xbox2Windows lowering and native D3D12 execution remain follow-up work. All new fixture source is original.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6590587476 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1889). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-24T20:17:33Z. --- Refs #1760. Add a source-built gfx1013 mesh fixture whose allocation counts and second primitive indices come from buffer data. The same program produces a triangle or quad. A CPU oracle checks vertex positions, attributes, and primitive indices for six inputs: triangle, quad, zero allocation, five vertices against a limit of four, a second primitive containing index 4 with four vertices allocated, and a duplicate primitive. Both out-of-range inputs produce a zero allocation. Verification on Linux: - `python3 -B tests/mesh_dynamic_geometry_check.py` passed all six cases. - `python3 -B tests/mesh_dynamic_geometry_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1` passed with LLVM 15. The assembled bytes and independent instruction listings agreed. - Altering the quad allocation compare produced a zero allocation and failed. Altering the packed primitive index produced the wrong index triple and failed. - Documentation links and bidirectional-control checks passed. A separate Linux experiment used these inputs and a hand-written mesh shader to verify full rendered images and allocation outcomes on llvmpipe. This PR adds the reusable source and CPU-model coverage. Dynamic Xbox2Windows lowering and native D3D12 execution remain follow-up work. All new fixture source is original.
upstream-sync closed this pull request 2026-11-24 21:01:09 +00:00
ChazY11 commented 2026-11-24 21:01:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T20:29:17Z.


Ran the CPU oracle and tried to make it agree with a wrong model

At the PR head, device-free (no LLVM, no GPU):

out/pe-env/Scripts/python.exe -B tests/mesh_dynamic_geometry_check.py
Six mesh inputs matched the CPU allocation and export model      exit 0

Three mutations to the expectations in mesh_dynamic_geometry_check.py, each reverted:

mutation result
quad's second primitive (2, 1, 3) → (2, 1, 2) caught
triangle's expected vertex count 3 → 4 caught
oversized count's expected 0 → 4 caught

So the model is not vacuous: the emitter's output is compared against an independent CPU computation and a single wrong
element in one of six cases fails the run. That is the property the description claims with "Altering the quad allocation
compare … and altering the packed primitive index … failed", and it holds from the expectation side as well as from the
source side.

What this PR does and does not establish

It adds the fixture source, the CPU oracle and documentation; the description is explicit that "Dynamic Xbox2Windows lowering
and native D3D12 execution remain follow-up work". Nothing in the change touches tools/startup/ or src/, which matches
that.

The one thing I would add to the description: the six cases include three invalid or empty inputs, but only one of them
(zero) is an empty input and one (out-of-range index) an invalid index. If the fixture is meant to pin the refusal
boundary, an explicit note of which word is out of range and by how much would make it reusable — I had to read CASES and
MESH_LIMITS to see that the oversized case is MESH_LIMITS[0] + 1, i.e. exactly one past the limit rather than some large
number.

Binary mode

mesh_dynamic_geometry_check.py binary <llvm-mc> <llvm-objcopy> <libLLVM> needs LLVM with gfx1013 support, which this machine
does not have configured, so I could not re-run the reassembly half. The PR reports it passing with LLVM 15, and the embedded
CODE bytes make the CPU half work without LLVM — a good split that I used.

Verdict

Reviewed. The oracle discriminates, the fixture is source-built and the scope statement is honest about what remains
unverified. No objections.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7143621681 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1889#issuecomment-7143621681). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T20:29:17Z. --- ## Ran the CPU oracle and tried to make it agree with a wrong model At the PR head, device-free (no LLVM, no GPU): ```powershell out/pe-env/Scripts/python.exe -B tests/mesh_dynamic_geometry_check.py Six mesh inputs matched the CPU allocation and export model exit 0 ``` Three mutations to the **expectations** in `mesh_dynamic_geometry_check.py`, each reverted: | mutation | result | |---|---| | `quad`'s second primitive `(2, 1, 3)` → `(2, 1, 2)` | **caught** | | `triangle`'s expected vertex count `3` → `4` | **caught** | | `oversized count`'s expected `0` → `4` | **caught** | So the model is not vacuous: the emitter's output is compared against an independent CPU computation and a single wrong element in one of six cases fails the run. That is the property the description claims with "Altering the quad allocation compare … and altering the packed primitive index … failed", and it holds from the expectation side as well as from the source side. ## What this PR does and does not establish It adds the fixture source, the CPU oracle and documentation; the description is explicit that "Dynamic Xbox2Windows lowering and native D3D12 execution remain follow-up work". Nothing in the change touches `tools/startup/` or `src/`, which matches that. The one thing I would add to the description: the six cases include three invalid or empty inputs, but only one of them (`zero`) is an *empty* input and one (`out-of-range index`) an invalid index. If the fixture is meant to pin the refusal boundary, an explicit note of which word is out of range and by how much would make it reusable — I had to read `CASES` and `MESH_LIMITS` to see that the oversized case is `MESH_LIMITS[0] + 1`, i.e. exactly one past the limit rather than some large number. ## Binary mode `mesh_dynamic_geometry_check.py binary <llvm-mc> <llvm-objcopy> <libLLVM>` needs LLVM with gfx1013 support, which this machine does not have configured, so I could not re-run the reassembly half. The PR reports it passing with LLVM 15, and the embedded `CODE` bytes make the CPU half work without LLVM — a good split that I used. ## Verdict Reviewed. The oracle discriminates, the fixture is source-built and the scope statement is honest about what remains unverified. No objections. ## Notes - AI-assisted review.
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!1882
No description provided.