shader: translate gfx1013 mesh programs with run-time geometry for the startup runtime #1753

Open
opened 2026-11-24 18:10:50 +00:00 by denn0x · 4 comments
denn0x commented 2026-11-24 18:10:50 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-24T18:10:50Z.


Question

tools/mesh_entry_aot.py specializes a bounded gfx1013 mesh entry for desktop D3D12:

  • geometry words and the dispatch ABI are static inputs;
  • only forward control flow decided by static values is accepted;
  • the accepted exports are MSG_GS_ALLOC_REQ, prim, pos0 and param0;
  • #730 is extending it to several vertices and primitives within the PSV0 counts.

The startup runtime needs something different: a mesh program whose vertex and primitive counts, geometry reads and control flow depend on GPU data at run time. It has to be translated ahead of time to an HLSL or DXIL mesh shader, keyed like the pixel and vertex translations in tools/startup/gfx2hlsl.py.

Which gfx1013 mesh ABI has to be modelled for that? Specifically:

  • the entry registers;
  • the GS_ALLOC_REQ vertex and primitive counts taken from m0, as a run-time value;
  • the primitive export format;
  • position and parameter exports with an exec mask;
  • wave32 against wave64;
  • the payload or task input, if any.

Evidence so far

  • On main, the mesh path is verified only through static specialization: #491, #498, #606, #682, #1203 and #730.
  • The draw-path translator tools/startup/gfx2hlsl.py has vertex and pixel stages only.
  • Public references for the NGG export and allocation forms are the Mesa AMD common code (NGG lowering) and the LLVM AMDGPU backend (s_sendmsg and export encodings). The project has not checked how far gfx1013 matches them.
  • I have not established how the startup runtime would receive a console mesh pipeline, or which register metadata accompanies it. That is part of the question.

Completion condition

  1. Run-time counts. A source-built gfx1013 mesh program, assembled with the LLVM 15 chain like the existing mesh fixtures:

    • it reads its vertex and primitive counts from a buffer;
    • it emits GS_ALLOC_REQ with those counts in m0;
    • it exports positions, one parameter and triangle indices under an exec mask.

    The translator produces a mesh shader that draws it via DispatchMesh. Compare pixel by pixel with an independent CPU reference on WARP and one hardware adapter.

    Controls: a count of zero (nothing drawn); counts above the declared maximum (refused at translation, or clamped as documented); a swapped primitive index.

  2. Run-time control flow. The same program with a data-dependent branch and loop around the exports, with a control that flips the branch input.

  3. Wave width. The same program as wave64, on an adapter that runs 64-lane waves, or with a documented refusal otherwise.

  4. Refusals. Reported by instruction and form, as for the pixel stage, so a census over a local shader set can be posted as counts only.

Out of scope: amplification/task stages, and executing mesh draws from ExecuteIndirect (separate issue).

Required environment

  • Windows x64, LLVM 15 with gfx1013, DXC, WARP and a mesh-shader-capable GPU. Adapters without mesh shaders report a capability skip.
  • No game files.

Checklist

  • The task can be reproduced with public or source-built inputs.
  • I did not include game files, dumps, distribution links or credentials.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588359832 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1760). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-24T18:10:50Z. --- ### Question `tools/mesh_entry_aot.py` specializes a bounded gfx1013 mesh entry for desktop D3D12: - geometry words and the dispatch ABI are static inputs; - only forward control flow decided by static values is accepted; - the accepted exports are `MSG_GS_ALLOC_REQ`, `prim`, `pos0` and `param0`; - #730 is extending it to several vertices and primitives within the PSV0 counts. The startup runtime needs something different: a mesh program whose vertex and primitive counts, geometry reads and control flow depend on GPU data at run time. It has to be translated ahead of time to an HLSL or DXIL mesh shader, keyed like the pixel and vertex translations in `tools/startup/gfx2hlsl.py`. Which gfx1013 mesh ABI has to be modelled for that? Specifically: - the entry registers; - the `GS_ALLOC_REQ` vertex and primitive counts taken from `m0`, as a run-time value; - the primitive export format; - position and parameter exports with an exec mask; - wave32 against wave64; - the payload or task input, if any. ### Evidence so far - On `main`, the mesh path is verified only through static specialization: #491, #498, #606, #682, #1203 and #730. - The draw-path translator `tools/startup/gfx2hlsl.py` has vertex and pixel stages only. - Public references for the NGG export and allocation forms are the Mesa AMD common code (NGG lowering) and the LLVM AMDGPU backend (`s_sendmsg` and export encodings). The project has not checked how far gfx1013 matches them. - I have not established how the startup runtime would receive a console mesh pipeline, or which register metadata accompanies it. That is part of the question. ### Completion condition 1. **Run-time counts.** A source-built gfx1013 mesh program, assembled with the LLVM 15 chain like the existing mesh fixtures: - it reads its vertex and primitive counts from a buffer; - it emits `GS_ALLOC_REQ` with those counts in `m0`; - it exports positions, one parameter and triangle indices under an exec mask. The translator produces a mesh shader that draws it via `DispatchMesh`. Compare pixel by pixel with an independent CPU reference on WARP and one hardware adapter. Controls: a count of zero (nothing drawn); counts above the declared maximum (refused at translation, or clamped as documented); a swapped primitive index. 2. **Run-time control flow.** The same program with a data-dependent branch and loop around the exports, with a control that flips the branch input. 3. **Wave width.** The same program as wave64, on an adapter that runs 64-lane waves, or with a documented refusal otherwise. 4. **Refusals.** Reported by instruction and form, as for the pixel stage, so a census over a local shader set can be posted as counts only. Out of scope: amplification/task stages, and executing mesh draws from ExecuteIndirect (separate issue). ### Required environment - Windows x64, LLVM 15 with gfx1013, DXC, WARP and a mesh-shader-capable GPU. Adapters without mesh shaders report a capability skip. - No game files. ### Checklist - [x] The task can be reproduced with public or source-built inputs. - [x] I did not include game files, dumps, distribution links or credentials.
avt0m4t48 commented 2026-11-24 21:01:21 +00:00 (Migrated from github.com)
Author
Contributor

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


I have a source-built fixture for the runtime allocation-and-export slice. One gfx1013 mesh program reads its allocation and primitive data from buffer words, and the test verifies six inputs through the existing CPU model. I will submit the reusable fixture and its verification independently of runtime lowering.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7143313591 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1760#issuecomment-7143313591). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-24T20:17:27Z. --- I have a source-built fixture for the runtime allocation-and-export slice. One gfx1013 mesh program reads its allocation and primitive data from buffer words, and the test verifies six inputs through the existing CPU model. I will submit the reusable fixture and its verification independently of runtime lowering.
R0Y00 commented 2026-11-24 21:27:41 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T21:22:23Z.


The bounded runtime-geometry fixture in #1913 is on main at e4697f3a. I reran Release on the exact head: mesh_dynamic_aot_cpu plus both D3D12 draw backends passed, with zero skips. The translator enumerates bounded equality partitions for the two-wave64 triangular profile. This validates the source-built model and readback. Please keep the wider native runtime shader path and its binding cases in #1779 and this issue.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7144842924 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1760#issuecomment-7144842924). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T21:22:23Z. --- The bounded runtime-geometry fixture in #1913 is on main at e4697f3a. I reran Release on the exact head: mesh_dynamic_aot_cpu plus both D3D12 draw backends passed, with zero skips. The translator enumerates bounded equality partitions for the two-wave64 triangular profile. This validates the source-built model and readback. Please keep the wider native runtime shader path and its binding cases in #1779 and this issue.
R0Y00 commented 2026-11-24 22:01:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T21:40:52Z.


#1779 has merged. I ran the exact candidate and then reran after integrating current main with #1913. The combined Release run passed 7/7, including both multi-primitive GPU paths and both runtime-geometry draw paths, with zero skips. These are source-built pipeline checks. They establish multi-primitive native mesh lowering and its coexistence with the bounded runtime geometry profile. Wider console dispatch and binding remain tracked here.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7145248976 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1760#issuecomment-7145248976). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T21:40:52Z. --- #1779 has merged. I ran the exact candidate and then reran after integrating current main with #1913. The combined Release run passed 7/7, including both multi-primitive GPU paths and both runtime-geometry draw paths, with zero skips. These are source-built pipeline checks. They establish multi-primitive native mesh lowering and its coexistence with the bounded runtime geometry profile. Wider console dispatch and binding remain tracked here.
akimfomin commented 2026-11-25 02:02:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by akimfomin on 2026-11-25T01:45:20Z.


PortBridge used the bounded runtime geometry work in #1913 and #1779 to check one source of repeated code in #1760. The candidate shares identical emitted vertex and primitive exports while keeping every partition predicate and allocation count. Thanks to avt0m4t48 for the original geometry fixture.

On a source-built gfx1013 shader with 32 partitions and two distinct outputs, optimized DXIL went from 26,556 to 5,736 bytes. The CPU differential matched dispatch counts, attributes and indices over 65 inputs. On an RTX 4070 Ti SUPER with driver 32.0.16.1714, both variants matched every one of the 1,024 reference pixels for a triangle and again for a quad. A stale-pixel control produced the expected 528 mismatches. The D3D12 debug layer was unavailable. These are shader-size and correctness results on this fixture. Execution time remains unmeasured.

The patch, synthetic source and logs are pinned to 4c1b27dd. They cover the bounded runtime path used in #1760. If this case is useful, the portable verifier can be run as-is during review.

AI assistance: OpenAI Codex (GPT-6 family) assisted with the patch, independent fixture and verification.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149917446 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1760#issuecomment-7149917446). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-25T01:45:20Z. --- [PortBridge](https://github.com/akimfomin/PortBridge) used the bounded runtime geometry work in #1913 and #1779 to check one source of repeated code in #1760. The candidate shares identical emitted vertex and primitive exports while keeping every partition predicate and allocation count. Thanks to avt0m4t48 for the original geometry fixture. On a source-built gfx1013 shader with 32 partitions and two distinct outputs, optimized DXIL went from 26,556 to 5,736 bytes. The CPU differential matched dispatch counts, attributes and indices over 65 inputs. On an RTX 4070 Ti SUPER with driver `32.0.16.1714`, both variants matched every one of the 1,024 reference pixels for a triangle and again for a quad. A stale-pixel control produced the expected 528 mismatches. The D3D12 debug layer was unavailable. These are shader-size and correctness results on this fixture. Execution time remains unmeasured. The [patch, synthetic source and logs](https://github.com/akimfomin/PortBridge/blob/a3cf7bec540d5990e0ad3c1e36cf9c5a297f5ef5/research/rendering-night/xbox2windows-mesh-export-fold/README.md) are pinned to `4c1b27dd`. They cover the bounded runtime path used in #1760. If this case is useful, the portable verifier can be run as-is during review. AI assistance: OpenAI Codex (GPT-6 family) assisted with the patch, independent fixture and verification.
Sign in to join this conversation.
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#1753
No description provided.