Shader & GPU: support merged ES+GS geometry stages (vs_6_6 / gs_6_6) #1399

Open
github-bot wants to merge 1 commit from github-bot/gh-1399 into main AGit
Owner

@⁠wbkepler on GitHub · 2026-11-24 17:45 UTC · original
wbkepler:shader/merged-es-gs-stages → main · +1445 −76 · 21 files · 1 commits · open

Summary

Rebased cleanly onto upstream/main (ffe310e):

Decodes, raises, lowers, validates, and wires console merged ES+GS hardware geometry stages (HwStage::Es -> vs_6_6 and HwStage::Gs -> gs_6_6):

  • victory-shader/src/native.rs: Decodes HwStage::Es and HwStage::Gs stage data (StageIo::Es, StageIo::Gs(GsIo) including vertex stride, GSVS ring stride, invocations, and max vertices).
  • victory-shader/src/resource.rs: Recognizes the console merged-GS internal ring-table SGPR pair (GS_TABLE) without disrupting root parameter tracking.
  • victory-shader/src/io.rs: Raises ES->GS and GSVS LDS traffic (ds_read* -> gs_reads, ds_write* -> lds_outputs), ES system VGPRs (VertexId, PrimitiveId, InstanceId), GS GsInstanceId, and s_sendmsg(MSG_GS / MSG_GS_DONE) stream operations (gs_ops).
  • victory-shader/src/emit/{container,shader,lower,mod,host}.rs:
    • Emits gs_6_6 modules with GSState entry property (tag 1), single-stream dx.viewIdState, and GS PSV0 metadata.
    • Lowers merged ES+GS active-lane preamble wave masks, dx.op.loadInput with vertex axis, dx.op.primitiveID.i32 (108), dx.op.gsInstanceID.i32 (100), dx.op.storeOutput, and emitStream/cutStream/emitThenCutStream (97/98/99), plus ES barrier elision and indirect handover return.
    • Adds Host::gs_pipeline for live D3D12 VS+GS+PS pipeline creation.
  • victory-gpu/src/pipeline{,/host}.rs: Includes HwStage::Gs in shader resource extraction, allows "geometry" in HostPipeline::new, adds D3D12_SHADER_VISIBILITY_GEOMETRY, binds desc.GS, and includes GS bytecode in the pipeline library cache key.
  • apps/victory/src/translate.rs: Includes HwStage::Gs and HwStage::Es in raising, DXIL emission, validation, host pipeline verification, and corpus reporting.
  • Adds unit tests covering Es/Gs stage data decoding, LDS/sendmsg raising, and live dxil.dll validation + D3D12 pipeline creation for both Es (vs_6_6) and Gs (gs_6_6).

Verification

  • cargo clippy -p victory-shader --all-targets & -p victory-gpu --all-targets — passed
  • cargo test -p victory-shader & cargo test -p victory-gpu pipeline — passed
  • cargo xtask policy — passed
**@⁠wbkepler** on GitHub · 2026-11-24 17:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399) `wbkepler:shader/merged-es-gs-stages` → `main` · +1445 −76 · 21 files · 1 commits · open ## Summary Rebased cleanly onto `upstream/main` (`ffe310e`): Decodes, raises, lowers, validates, and wires console merged ES+GS hardware geometry stages (`HwStage::Es` -> `vs_6_6` and `HwStage::Gs` -> `gs_6_6`): - **`victory-shader/src/native.rs`**: Decodes `HwStage::Es` and `HwStage::Gs` stage data (`StageIo::Es`, `StageIo::Gs(GsIo)` including vertex stride, GSVS ring stride, invocations, and max vertices). - **`victory-shader/src/resource.rs`**: Recognizes the console merged-GS internal ring-table SGPR pair (`GS_TABLE`) without disrupting root parameter tracking. - **`victory-shader/src/io.rs`**: Raises ES->GS and GSVS LDS traffic (`ds_read*` -> `gs_reads`, `ds_write*` -> `lds_outputs`), ES system VGPRs (`VertexId`, `PrimitiveId`, `InstanceId`), GS `GsInstanceId`, and `s_sendmsg(MSG_GS / MSG_GS_DONE)` stream operations (`gs_ops`). - **`victory-shader/src/emit/{container,shader,lower,mod,host}.rs`**: - Emits `gs_6_6` modules with `GSState` entry property (tag 1), single-stream `dx.viewIdState`, and GS `PSV0` metadata. - Lowers merged ES+GS active-lane preamble wave masks, `dx.op.loadInput` with vertex axis, `dx.op.primitiveID.i32` (108), `dx.op.gsInstanceID.i32` (100), `dx.op.storeOutput`, and `emitStream`/`cutStream`/`emitThenCutStream` (97/98/99), plus ES barrier elision and indirect handover return. - Adds `Host::gs_pipeline` for live D3D12 VS+GS+PS pipeline creation. - **`victory-gpu/src/pipeline{,/host}.rs`**: Includes `HwStage::Gs` in shader resource extraction, allows `"geometry"` in `HostPipeline::new`, adds `D3D12_SHADER_VISIBILITY_GEOMETRY`, binds `desc.GS`, and includes GS bytecode in the pipeline library cache key. - **`apps/victory/src/translate.rs`**: Includes `HwStage::Gs` and `HwStage::Es` in raising, DXIL emission, validation, host pipeline verification, and corpus reporting. - Adds unit tests covering `Es`/`Gs` stage data decoding, LDS/sendmsg raising, and live `dxil.dll` validation + D3D12 pipeline creation for both `Es` (`vs_6_6`) and `Gs` (`gs_6_6`). ## Verification - `cargo clippy -p victory-shader --all-targets` & `-p victory-gpu --all-targets` — passed - `cargo test -p victory-shader` & `cargo test -p victory-gpu pipeline` — passed - `cargo xtask policy` — passed
The console runs a vertex shader that feeds a geometry shader, and that
geometry shader, as the two halves of one wave, the vertices between them
in LDS. An export program now translates to a plain vertex shader (its
LDS writes are its outputs) and a geometry program to a geometry shader
(its LDS reads are its input primitive's vertices, its LDS writes the
outputs of the vertex its next stream message emits).

- native: `StageIo::Es` / `StageIo::Gs(GsIo)` stage data.
- resource: the geometry stage's own table (`GS_TABLE`, s[8:9]).
- io: ring reads and writes raised to inputs and outputs by row and
  channel; `s_sendmsg` GS / GS_DONE raised to emit, cut and done.
- emit: the geometry-shader state of rectangle lists (`Shader::gs`, the
  `GSState` and `PSV0` it writes) is generalized from "triangles in,
  strips out, n vertices" to a `Geometry` (input primitive, output
  topology, maximum vertices, instances; one stream) that the generated
  rectangle shader and title shaders share. Lowering: vertex-axis
  `loadInput`, `emitStream` / `cutStream` / `emitThenCutStream`,
  `primitiveID`, `gsInstanceID`, the prologue's lane masks as "every
  invocation", no barrier and a return for the export program's handover.
  16-bit values in the rings and streams other than 0 are refused.
- gpu: a title's geometry shader takes the host pipeline's geometry
  stage (root parameters visible to it); a pipeline with one and a
  rectangle-list topology is refused with a reason rather than chained.
- app: `translate` counts export and geometry programs; the pipeline
  pre-build makes records with an export and a geometry stage.

Tests: stage data, I/O raising, and a merged pair drawn on the host
(export program as vertex shader, geometry program after it).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:26 +00:00
Author
Owner

@⁠shortselow-byte on GitHub · 2026-11-24 19:32 UTC · original

For triage: #1315 also translates console geometry programs (single-stream triangle geometry, with a new emit/geometry.rs and a StageIo::Gs), and neither PR mentions the other. git merge-tree against the current heads shows they conflict in victory-gpu/src/pipeline/host.rs, victory-shader/src/emit/container.rs and victory-shader/src/emit/host.rs. Both are large (about 1,400 and 1,500 changed lines), so it is worth settling which one carries geometry stages before either is reviewed in depth.

This PR on its own, at d01f9a6 on main ffe310e, isolated target directory, Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT: workspace 346 passed, 0 failed, including its four new tests; both clippy runs clean.

**@⁠shortselow-byte** on GitHub · 2026-11-24 19:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7142236227) For triage: #1315 also translates console geometry programs (single-stream triangle geometry, with a new `emit/geometry.rs` and a `StageIo::Gs`), and neither PR mentions the other. `git merge-tree` against the current heads shows they conflict in `victory-gpu/src/pipeline/host.rs`, `victory-shader/src/emit/container.rs` and `victory-shader/src/emit/host.rs`. Both are large (about 1,400 and 1,500 changed lines), so it is worth settling which one carries geometry stages before either is reviewed in depth. This PR on its own, at `d01f9a6` on `main` `ffe310e`, isolated target directory, Windows 11, Rust 1.98.1 MSVC, AMD Radeon RX 6900 XT: workspace 346 passed, 0 failed, including its four new tests; both clippy runs clean.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 20:44 UTC · original

Offline measurement on a retail dump, and the shader tests on Ada

Result: +195 programs over main, 0 lost.

Offline. I merged head d01f9a6 onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,919 with this PR.

Failure on main Gained
resources: an address in an SGPR that is no root parameter 195

None of the 195 is among the programs that #1402 gains, so this PR adds to the bundles instead of overlapping them. It is the only open PR I have measured that clears "an address in an SGPR that is no root parameter" (195 on main; #333, #302 and #489 gained 0 for it in #1247). I'm measuring it stacked on #1402 and #1597 as well.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 124, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 20:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7143986767) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: +195 programs over `main`, 0 lost.** **Offline.** I merged head d01f9a6 onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,919 with this PR. | Failure on `main` | Gained | |---|---| | resources: an address in an SGPR that is no root parameter | 195 | None of the 195 is among the programs that #1402 gains, so this PR adds to the bundles instead of overlapping them. It is the only open PR I have measured that clears "an address in an SGPR that is no root parameter" (195 on `main`; #333, #302 and #489 gained 0 for it in #1247). I'm measuring it stacked on #1402 and #1597 as well. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 124, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 21:31 UTC · original

Static review of the ES/GS lowering (head d01f9a6)

Summary: On a retail dump this PR gains 195 programs, 0 lost (measurement), and its tests pass on Ada. Those counts only prove that the DXIL validates. Below are the places where the output could still be wrong although it validates. Line numbers refer to the PR head.

Likely bug

1. The emitted vertex's index is computed, then ignored. Outputs are stored at the ds_write, not at their emit. (emit/lower.rs:2308–2335, io.rs:811)

raise_es_gs_lds works out which emitted vertex each GSVS write belongs to (LdsOutput.vertex = dword / vertex_dwords), but the lowering never reads out.vertex. Each write becomes a storeOutput at its own site, and each s_sendmsg(MSG_GS, EMIT) becomes an emitStream.

This is correct only if, for every vertex k, all of its writes come after emit k−1 and before emit k. The synthetic test (emit/mod.rs, gs_shader_validates_and_builds_host_pipeline) has exactly that order. A compiler that batches writes breaks it, and the result still validates:

  • Two vertices in one instruction. A ds_write2_b32 whose offset0 and offset1 fall into two vertex slots.
  • Writes hoisted ahead of an earlier emit. For example, all vertices written, then three emits.

In both cases the host emits the last-written values for several vertices, so primitives collapse or stretch.

Suggested fix: keep a counter of emits per stream. For every write between emit k−1 and emit k, require out.vertex == k, and refuse the program otherwise (for example "GSVS write to a vertex other than the next emitted"). Or buffer the writes per vertex and store them right before the matching emitStream.

Risks (cannot be confirmed without one real ES/GS pair)

2. The LDS layout is assumed to follow signature rows, not param slots. (io.rs GS reads and ES/GS writes; lower.rs:2310)

Both ES→GS and GSVS dwords are mapped as row = dword / 4, channel = dword % 4 and matched against the signature row (o.row == Some(out.row)). The VS export path maps rows through the native outputs table (VsOutput.param). The LDS path ignores that table.

If the console lays out ES→GS or GSVS memory by parameter slot, or compacts unused components, inputs and outputs are silently mixed up. Both ES and GS use the same rule, so they agree with each other but can both be wrong.

A cheap guard: check vertex_dwords against the signature, for example vertex_dwords == 4 * (max row + 1) of the ES outputs and GS inputs, and refuse when it does not match. Better: verify on one title pair whether the rows or the params decide the layout.

3. Silent defaults for the GS state. (emit/mod.rs:292–294)

When PSV0 is missing or holds 0, these defaults apply:

  • input primitive = triangle (3)
  • output topology = triangle strip (5)
  • stream mask = 1

A wrong input primitive changes how many vertices loadInput can address. It also changes the host PSO's topology-type compatibility. Refusing ("a geometry shader without PSV0 state") would be safer than guessing.

4. Non-zero streams have no host consumer. (io.rs:832)

Emit(stream) and Cut(stream) pass the stream through, and the PSO has no stream-output. A console GS that feeds stream-out, or rasterizes a stream other than 0, would produce output that the host silently drops. Refusing when the stream mask is not 1, or when an op targets a stream other than 0, would make that visible.

5. A GSVS or ES→GS write with no signature row is dropped silently. (lower.rs:2317: let Some((id, col)) = found else { continue; })

A real output whose row the signature lacks becomes undefined on the host. Other paths refuse in that case ("a GS input the signature lacks").

Nits

  • GS_TABLE accepts s[8:9] as the console GS table whenever no root parameter sits at user data 0–1 (resource.rs:42, 668). Any value loaded from it is refused (lower.rs:3072), so a wrong guess fails safely. Its only effect is the per-lane ring base, which the lowering ignores.
  • Barriers:
    • ES drops every barrier (lower.rs:527). That is fine for a VS on the host.
    • A GS that contains an s_barrier would emit a DXIL barrier that the validator rejects. That costs a refusal, not wrong code.
  • Unrelated formatting in victory-gpu/src/pipeline.rs (note_why) and pipeline/host.rs makes the diff harder to review.

What looks right

  • SGPRs: user data starts at s8 for the merged stages (HwStage::user_sgpr).
  • VGPRs:
    • ES system values: v5 vertex id, v7 primitive id, v8 instance id.
    • GS: v0, v1 and v4 carry the packed 16-bit ES→GS vertex offsets for 6 vertices (adjacency), v2 the primitive id, v3 the instance id.
    • This matches the GFX9/GFX10 legacy merged ES/GS layout that LLVM and Mesa use.
  • DXIL operations: 97 EmitStream, 98 CutStream, 99 EmitThenCutStream, 100 GSInstanceID, 108 PrimitiveID.
  • GS state: the GSState metadata order (input primitive, max vertices, stream mask, topology, instance count), and the GS part of PSV0.
  • Merged-wave EXEC: the preamble (s_bfe s3 → s_bfm → s_cselect) is treated as all lanes active. That is correct: one host invocation is one ES vertex or one GS primitive.
  • Indirect jump: the ES's s_setpc handover is lowered as a return.
  • Host pipeline:
    • The GS is bound only when no mesh shader is present (pipeline/host.rs:326).
    • The PSO cache key is unchanged for pipelines without a GS, because the GS bytes are appended only when present (pipeline/host.rs:552).

What the tests cover, and what they don't

Covered:

  • parsing ES/GS stage data
  • one GS with interleaved write/emit for 3 vertices and a cut
  • one ES write with a v_mad_u32_u24 base
  • a host GS pipeline, when a device exists

Not covered:

  • writes for two vertices before an emit (finding 1)
  • adjacency inputs (v4)
  • invocations > 1
  • non-zero streams
  • missing PSV0
  • ES outputs whose row differs from their param slot
  • an actual title ES/GS pair

AI-assisted (Claude Code); static review only, nothing run.

**@⁠sinan-cmyk** on GitHub · 2026-11-24 21:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7145040138) ### Static review of the ES/GS lowering (head d01f9a6) **Summary:** On a retail dump this PR gains 195 programs, 0 lost ([measurement](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1399)), and its tests pass on Ada. Those counts only prove that the DXIL validates. Below are the places where the output could still be wrong although it validates. Line numbers refer to the PR head. ## Likely bug **1. The emitted vertex's index is computed, then ignored. Outputs are stored at the `ds_write`, not at their emit.** (`emit/lower.rs:2308`–2335, `io.rs:811`) `raise_es_gs_lds` works out which emitted vertex each GSVS write belongs to (`LdsOutput.vertex = dword / vertex_dwords`), but the lowering never reads `out.vertex`. Each write becomes a `storeOutput` at its own site, and each `s_sendmsg(MSG_GS, EMIT)` becomes an `emitStream`. This is correct only if, for every vertex k, all of its writes come after emit k−1 and before emit k. The synthetic test (`emit/mod.rs`, `gs_shader_validates_and_builds_host_pipeline`) has exactly that order. A compiler that batches writes breaks it, and the result still validates: - **Two vertices in one instruction.** A `ds_write2_b32` whose `offset0` and `offset1` fall into two vertex slots. - **Writes hoisted ahead of an earlier emit.** For example, all vertices written, then three emits. In both cases the host emits the last-written values for several vertices, so primitives collapse or stretch. Suggested fix: keep a counter of emits per stream. For every write between emit k−1 and emit k, require `out.vertex == k`, and refuse the program otherwise (for example "GSVS write to a vertex other than the next emitted"). Or buffer the writes per vertex and store them right before the matching `emitStream`. ## Risks (cannot be confirmed without one real ES/GS pair) **2. The LDS layout is assumed to follow signature rows, not `param` slots.** (`io.rs` GS reads and ES/GS writes; `lower.rs:2310`) Both ES→GS and GSVS dwords are mapped as `row = dword / 4, channel = dword % 4` and matched against the signature row (`o.row == Some(out.row)`). The VS export path maps rows through the native outputs table (`VsOutput.param`). The LDS path ignores that table. If the console lays out ES→GS or GSVS memory by parameter slot, or compacts unused components, inputs and outputs are silently mixed up. Both ES and GS use the same rule, so they agree with each other but can both be wrong. A cheap guard: check `vertex_dwords` against the signature, for example `vertex_dwords == 4 * (max row + 1)` of the ES outputs and GS inputs, and refuse when it does not match. Better: verify on one title pair whether the rows or the params decide the layout. **3. Silent defaults for the GS state.** (`emit/mod.rs:292`–294) When `PSV0` is missing or holds 0, these defaults apply: - input primitive = triangle (3) - output topology = triangle strip (5) - stream mask = 1 A wrong input primitive changes how many vertices `loadInput` can address. It also changes the host PSO's topology-type compatibility. Refusing ("a geometry shader without PSV0 state") would be safer than guessing. **4. Non-zero streams have no host consumer.** (`io.rs:832`) `Emit(stream)` and `Cut(stream)` pass the stream through, and the PSO has no stream-output. A console GS that feeds stream-out, or rasterizes a stream other than 0, would produce output that the host silently drops. Refusing when the stream mask is not 1, or when an op targets a stream other than 0, would make that visible. **5. A GSVS or ES→GS write with no signature row is dropped silently.** (`lower.rs:2317`: `let Some((id, col)) = found else { continue; }`) A real output whose row the signature lacks becomes undefined on the host. Other paths refuse in that case ("a GS input the signature lacks"). ## Nits - **`GS_TABLE` accepts `s[8:9]` as the console GS table** whenever no root parameter sits at user data 0–1 (`resource.rs:42`, 668). Any value loaded from it is refused (`lower.rs:3072`), so a wrong guess fails safely. Its only effect is the per-lane ring base, which the lowering ignores. - **Barriers:** - ES drops every barrier (`lower.rs:527`). That is fine for a VS on the host. - A GS that contains an `s_barrier` would emit a DXIL barrier that the validator rejects. That costs a refusal, not wrong code. - **Unrelated formatting** in `victory-gpu/src/pipeline.rs` (`note_why`) and `pipeline/host.rs` makes the diff harder to review. ## What looks right - **SGPRs:** user data starts at `s8` for the merged stages (`HwStage::user_sgpr`). - **VGPRs:** - ES system values: v5 vertex id, v7 primitive id, v8 instance id. - GS: v0, v1 and v4 carry the packed 16-bit ES→GS vertex offsets for 6 vertices (adjacency), v2 the primitive id, v3 the instance id. - This matches the GFX9/GFX10 legacy merged ES/GS layout that LLVM and Mesa use. - **DXIL operations:** 97 EmitStream, 98 CutStream, 99 EmitThenCutStream, 100 GSInstanceID, 108 PrimitiveID. - **GS state:** the `GSState` metadata order (input primitive, max vertices, stream mask, topology, instance count), and the GS part of `PSV0`. - **Merged-wave EXEC:** the preamble (`s_bfe s3` → `s_bfm` → `s_cselect`) is treated as all lanes active. That is correct: one host invocation is one ES vertex or one GS primitive. - **Indirect jump:** the ES's `s_setpc` handover is lowered as a return. - **Host pipeline:** - The GS is bound only when no mesh shader is present (`pipeline/host.rs:326`). - The PSO cache key is unchanged for pipelines without a GS, because the GS bytes are appended only when present (`pipeline/host.rs:552`). ## What the tests cover, and what they don't **Covered:** - parsing ES/GS stage data - one GS with interleaved write/emit for 3 vertices and a cut - one ES write with a `v_mad_u32_u24` base - a host GS pipeline, when a device exists **Not covered:** - writes for two vertices before an emit (finding 1) - adjacency inputs (v4) - `invocations > 1` - non-zero streams - missing `PSV0` - ES outputs whose row differs from their param slot - an actual title ES/GS pair AI-assisted (Claude Code); static review only, nothing run.
Author
Owner

@⁠wbkepler on GitHub · 2026-11-24 22:40 UTC · original

Rebased onto 70564ae as e80b166 (one commit; the old branch conflicted in about ten files, so this is a re-port rather than a replay).

What changed in the design:

  • Reuses upstream's geometry-shader scaffolding from the rectangle-list work instead of the parallel state the old branch carried. Shader::gs (and the GSState / PSV0 / view-id output it drives) is generalized from "triangles in, strips out, n vertices" to one small Geometry value: input primitive, output topology, maximum vertices, instances, one stream. rectangle_gs and title geometry programs go through the same field; the rectangle test passes unchanged.
  • Lowering rewritten against the current lower.rs: vertex-axis loadInput shares the existing input loader, stream messages become emitStream / cutStream / emitThenCutStream, the merged prologue's lane masks are "every invocation", the export program's barrier is dropped and its handover jump is a return. The stage's own table (s[8:9]) gets its own address kind next to MEMORY / USER_DATA, so it is not taken for title memory.
  • Refused rather than guessed: 16-bit values in the vertex rings (the packing upstream added for exports is not followed into LDS), output streams other than 0, and input vertices past the declared primitive.
  • GPU: a title geometry shader takes the host pipeline's geometry stage. A pipeline that has one and a rectangle-list topology is refused with a logged reason; the two are not chained.
  • Container choice: where a vertex container holds both a plain vertex program and an export program, the vertex program is translated (it feeds the host geometry stage equally well); the export program is used only when it is the only one.
  • translate counts export and geometry programs separately; the pipeline pre-build makes records that have an export and a geometry stage instead of skipping them.

Checked on this base:

  • clippy -D warnings on victory-shader, victory-gpu, victory-game and on victory --features diagnostics: clean. cargo xtask policy: ok.
  • cargo test -p victory-shader -p victory-gpu -p victory-game: everything passes except five tests that fail the same way on unmodified 70564ae on this machine (RTX 5090): stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware in victory-shader, and dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views in victory-gpu. None of them touch this change.
  • New/kept tests: the stage data, the I/O raising, and a merged pair executed on the GPU (export program as the vertex shader, geometry program after it, one triangle drawn and read back).

Not checked: the whole-title program counts were not re-measured on this base, no live run was made with these pipelines, and the pre-build path for these records has not been compared against a run's pipeline keys.

AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.

**@⁠wbkepler** on GitHub · 2026-11-24 22:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7146503149) Rebased onto `70564ae` as `e80b166` (one commit; the old branch conflicted in about ten files, so this is a re-port rather than a replay). What changed in the design: - **Reuses upstream's geometry-shader scaffolding** from the rectangle-list work instead of the parallel state the old branch carried. `Shader::gs` (and the `GSState` / `PSV0` / view-id output it drives) is generalized from "triangles in, strips out, n vertices" to one small `Geometry` value: input primitive, output topology, maximum vertices, instances, one stream. `rectangle_gs` and title geometry programs go through the same field; the rectangle test passes unchanged. - **Lowering rewritten against the current `lower.rs`**: vertex-axis `loadInput` shares the existing input loader, stream messages become `emitStream` / `cutStream` / `emitThenCutStream`, the merged prologue's lane masks are "every invocation", the export program's barrier is dropped and its handover jump is a return. The stage's own table (`s[8:9]`) gets its own address kind next to `MEMORY` / `USER_DATA`, so it is not taken for title memory. - **Refused rather than guessed**: 16-bit values in the vertex rings (the packing upstream added for exports is not followed into LDS), output streams other than 0, and input vertices past the declared primitive. - **GPU**: a title geometry shader takes the host pipeline's geometry stage. A pipeline that has one *and* a rectangle-list topology is refused with a logged reason; the two are not chained. - **Container choice**: where a vertex container holds both a plain vertex program and an export program, the vertex program is translated (it feeds the host geometry stage equally well); the export program is used only when it is the only one. - `translate` counts export and geometry programs separately; the pipeline pre-build makes records that have an export and a geometry stage instead of skipping them. Checked on this base: - `clippy -D warnings` on `victory-shader`, `victory-gpu`, `victory-game` and on `victory --features diagnostics`: clean. `cargo xtask policy`: ok. - `cargo test -p victory-shader -p victory-gpu -p victory-game`: everything passes except five tests that fail the same way on unmodified `70564ae` on this machine (RTX 5090): `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware` in `victory-shader`, and `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` in `victory-gpu`. None of them touch this change. - New/kept tests: the stage data, the I/O raising, and a merged pair executed on the GPU (export program as the vertex shader, geometry program after it, one triangle drawn and read back). Not checked: the whole-title program counts were not re-measured on this base, no live run was made with these pipelines, and the pre-build path for these records has not been compared against a run's pipeline keys. _AI-assisted (Claude Code); checked on Windows 11 / RTX 5090._
Author
Owner

@⁠molodayamama on GitHub · 2026-11-24 22:47 UTC · original

I reproduced the GSVS write/emit ordering issue raised above on the rebased head e80b166, using the PR's existing synthetic triangle and an RTX 4060 (driver 610.88, Windows 10, D3D12 Agility SDK 620). I moved the three stream-0 Emit messages after all LDS writes, keeping the three positions and final Cut unchanged.

Build Interleaved writes and emits All three vertices written before the first emit
e80b166 with only the expanded test 496 lit pixels 0 lit pixels
With the patch 496 lit pixels 496 lit pixels

With the patch the full 32 × 32 RGBA readbacks match exactly. The failure on the PR head was visible in rendering even though the generated shaders passed DXIL validation.

Patch and regression test · .patch file

The patch queues writes by LdsOutput.vertex for straight-line geometry shaders and lowers each slot's writes, in original order and with their original masks, just before its Emit or EmitCut. The regression runs with cargo test -p victory-shader --lib merged_geometry_stages_draw_their_triangle -- --nocapture. This tests the single-block case only. The whole-title impact is unmeasured.

Full victory-shader library suite: 207 passed, 5 failed, 2 ignored. All five failures reproduced on the unmodified PR head with the same local setup.

**@⁠molodayamama** on GitHub · 2026-11-24 22:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7146657503) I reproduced the GSVS write/emit ordering issue raised above on the rebased head `e80b166`, using the PR's existing synthetic triangle and an RTX 4060 (driver 610.88, Windows 10, D3D12 Agility SDK 620). I moved the three stream-0 Emit messages after all LDS writes, keeping the three positions and final Cut unchanged. | Build | Interleaved writes and emits | All three vertices written before the first emit | |---|---:|---:| | `e80b166` with only the expanded test | 496 lit pixels | 0 lit pixels | | With the patch | 496 lit pixels | 496 lit pixels | With the patch the full 32 × 32 RGBA readbacks match exactly. The failure on the PR head was visible in rendering even though the generated shaders passed DXIL validation. [Patch and regression test](https://github.com/molodayamama/VIctory/commit/9607c49c25a95d138661096c4a91780810d025b8) · [`.patch` file](https://github.com/molodayamama/VIctory/commit/9607c49c25a95d138661096c4a91780810d025b8.patch) The patch queues writes by `LdsOutput.vertex` for straight-line geometry shaders and lowers each slot's writes, in original order and with their original masks, just before its Emit or EmitCut. The regression runs with `cargo test -p victory-shader --lib merged_geometry_stages_draw_their_triangle -- --nocapture`. This tests the single-block case only. The whole-title impact is unmeasured. Full `victory-shader` library suite: 207 passed, 5 failed, 2 ignored. All five failures reproduced on the unmodified PR head with the same local setup.
Author
Owner

@⁠slatefield on GitHub · 2026-11-25 01:03 UTC · original

Rebased this onto current main (4118f33) and folded in the batched-write fix from the thread, since without it a geometry shader that writes a vertex ahead of the previous emit renders 0 lit pixels while still validating. Two commits on the branch, both with their authors: your merged-geometry commit unchanged, and molodayamama's 9607c49 "Publish batched geometry ring writes at each vertex emit" on top, with their regression test.

Rebase conflicts were three hunks: native.rs keeps main's vs_outputs(data) wrapper from the mesh fix and moves the body into vs_outputs_at(data, at, count_at) for GS outputs, io.rs keeps main's corrected 9-bit mesh exp prim wording plus your paragraph, and one test literal gains gs: None. A per-file added/removed-line comparison against your e80b166 shows 20 of the 21 files identical in both directions, the only delta being that wrapper.

cargo test -p victory-shader --lib 146 passed, 2 ignored on Linux (main 144), Windows-target clippy clean both feature sets, asset policy ok. The #[cfg(windows)] validation and draw tests need a GPU.

It is open as #1924 so the maintainer can take a ready branch including the ordering fix. If you would rather update this PR yourself, reset shader/merged-es-gs-stages to the branch head there and I will close mine. The open review risks (LDS layout from signature rows vs param slots, silent PSV0 defaults, non-zero streams, missing-row writes) are listed in the description as follow-ups; I did not change them.

**@⁠slatefield** on GitHub · 2026-11-25 01:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7149169578) Rebased this onto current `main` (`4118f33`) and folded in the batched-write fix from the thread, since without it a geometry shader that writes a vertex ahead of the previous emit renders 0 lit pixels while still validating. Two commits on the branch, both with their authors: your merged-geometry commit unchanged, and molodayamama's `9607c49` "Publish batched geometry ring writes at each vertex emit" on top, with their regression test. Rebase conflicts were three hunks: `native.rs` keeps main's `vs_outputs(data)` wrapper from the mesh fix and moves the body into `vs_outputs_at(data, at, count_at)` for GS outputs, `io.rs` keeps main's corrected 9-bit mesh `exp prim` wording plus your paragraph, and one test literal gains `gs: None`. A per-file added/removed-line comparison against your `e80b166` shows 20 of the 21 files identical in both directions, the only delta being that wrapper. `cargo test -p victory-shader --lib` 146 passed, 2 ignored on Linux (main 144), Windows-target clippy clean both feature sets, asset policy ok. The `#[cfg(windows)]` validation and draw tests need a GPU. It is open as #1924 so the maintainer can take a ready branch including the ordering fix. If you would rather update this PR yourself, reset `shader/merged-es-gs-stages` to the branch head there and I will close mine. The open review risks (LDS layout from signature rows vs `param` slots, silent `PSV0` defaults, non-zero streams, missing-row writes) are listed in the description as follow-ups; I did not change them.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:25 UTC · original · edited 2026-11-25 16:03 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/mod.rs, crates/victory-shader/src/emit/rect.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7149534391) · edited 2026-11-25 16:03 UTC <!-- victory-triage v1 head=2900907ad4dc6a09111f354e19222aa9700c1549 verdict=needs-rebase at=2026-11-25T16:01:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/mod.rs`, `crates/victory-shader/src/emit/rect.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs-work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠wbkepler on GitHub · 2026-11-25 07:10 UTC · original

Rebased onto current main (940d32f) as 2900907; conflicts were with the new write-mark Options/Parts::view_marks (kept both, gs added alongside) and the split-out vs_outputs in native.rs (now takes the table offset so the geometry stage can share it).

AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.

**@⁠wbkepler** on GitHub · 2026-11-25 07:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7155569685) Rebased onto current main (`940d32f`) as `2900907`; conflicts were with the new write-mark `Options`/`Parts::view_marks` (kept both, `gs` added alongside) and the split-out `vs_outputs` in `native.rs` (now takes the table offset so the geometry stage can share it). _AI-assisted (Claude Code); checked on Windows 11 / RTX 5090._
Author
Owner

@⁠zed6000 on GitHub · 2026-11-25 21:02 UTC · original

Measured offline on the title's shaders (the method in #1247). This head (2900907) against its base 940d32f gives +390, 0 lost: all 195 geometry programs that fail with "an address in an SGPR that is no root parameter", plus their 195 export halves, now validate. cargo test -p victory-shader --lib passes (250/0) on an RX 7900 XTX. #1924 gains exactly the same programs. Merged onto current main 13f91ca, #1924 also gives +390 / 0 lost with tests and clippy clean. The conflict resolution, all "keep both view_marks and gs" plus one memory_tests.rs fix git doesn't flag, is on #1924 and applies here the same way. Offline counts only; no program names or data.

**@⁠zed6000** on GitHub · 2026-11-25 21:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1399#issuecomment-7174531342) Measured offline on the title's shaders (the method in #1247). This head (`2900907`) against its base `940d32f` gives **+390, 0 lost**: all 195 geometry programs that fail with "an address in an SGPR that is no root parameter", plus their 195 export halves, now validate. `cargo test -p victory-shader --lib` passes (250/0) on an RX 7900 XTX. #1924 gains exactly the same programs. Merged onto current main `13f91ca`, #1924 also gives +390 / 0 lost with tests and clippy clean. The conflict resolution, all "keep both `view_marks` and `gs`" plus one `memory_tests.rs` fix git doesn't flag, is on #1924 and applies here the same way. Offline counts only; no program names or data.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/emit/rect.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1399/head:github-bot/gh-1399'
git switch 'github-bot/gh-1399'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1399'
git switch 'github-bot/gh-1399'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1399'
git switch 'github-bot/gh-1399'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1399'
git switch 'main'
git merge --squash 'github-bot/gh-1399'
git switch 'main'
git merge --ff-only 'github-bot/gh-1399'
git switch 'main'
git merge 'github-bot/gh-1399'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1399
No description provided.