Geometry shaders, step 2: read the merged ES+GS stage data #311

Open
opened 2026-11-26 03:40:30 +00:00 by github-bot · 1 comment
Owner

@⁠Revens2 on GitHub · 2026-11-24 23:29 UTC · original

Follow-up to #138, after #309 (step 1: the GS half reads the merged stage's SGPRs and stops at GS emit).

The merged stages keep their stage data in a layout native.rs does not read (see its module notes). Needed before any emission: the GS output signature rows and how the output records in LDS map onto them, the GS input layout (what the ES half writes per vertex), limits (max output vertices, output topology, instance count) and the LDS size. Read from the GS record and the ES record, with a synthetic fixture per field; add them to StageIo::Gs (today a unit variant). Status of what the runtime table at user data 0/1 holds, and whether the ES half reads it too, belongs here as well.

Not started.

**@⁠Revens2** on GitHub · 2026-11-24 23:29 UTC · [original](https://github.com/fxceless/victory-fork/issues/311) Follow-up to #138, after #309 (step 1: the GS half reads the merged stage's SGPRs and stops at GS emit). The merged stages keep their stage data in a layout native.rs does not read (see its module notes). Needed before any emission: the GS output signature rows and how the output records in LDS map onto them, the GS input layout (what the ES half writes per vertex), limits (max output vertices, output topology, instance count) and the LDS size. Read from the GS record and the ES record, with a synthetic fixture per field; add them to StageIo::Gs (today a unit variant). Status of what the runtime table at user data 0/1 holds, and whether the ES half reads it too, belongs here as well. Not started.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:40:30 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-24 23:47 UTC · original

There is a container-level source for some of these fields while the native records are being mapped. Microsoft's PSV layout puts the GS input primitive, output topology, stream mask and position flag at PSV0 payload offsets 4, 8, 12 and 16. For a declared runtime-info size of at least 36 bytes, offset 28 is the stage tag (geometry = 2), and offset 30 is the maximum vertex count (u16). XCL's restricted triangle-to-triangle-strip pairing reads the topology and limit from that part. Victory already has a reader for the outer ISG1 and OSG1 signature rows.

I checked those offsets against five original gs_6_0 fixtures generated with DXC 1.9.2609.5. All five passed dxv. Changing line to triangle input, line strip to point output, and max vertices from 8 to 12 changed the corresponding fields. ISG1 and OSG1 held distinct TEXCOORD indices and the expected two-component masks. Changing only [instance(1)] to [instance(3)] left the entire PSV0 identical. The standard DXIL entry metadata contained the changed instance count.

This supports testing a small outer-metadata reader independently of the native stages. Instance count in the native record, LDS size, the signature-to-LDS mapping, and the contents and ES use of the runtime table still need a source. I would keep #311 open for those fields and use compiler-produced ES+GS pairs with one declaration varied at a time to establish the native offsets. The checks above used original shaders and desktop DXIL. They exercised no console stage execution.

Source investigation and fixtures were prepared with Codex assistance.

**@⁠avt0m4t48** on GitHub · 2026-11-24 23:47 UTC · [original](https://github.com/fxceless/victory-fork/issues/311#issuecomment-7147805694) There is a container-level source for some of these fields while the native records are being mapped. Microsoft's [PSV layout](https://github.com/microsoft/DirectXShaderCompiler/blob/01b62ad47db7dee3dd33f90e7339cf9e860b3f93/include/dxc/DxilContainer/DxilPipelineStateValidation.h#L82-L155) puts the GS input primitive, output topology, stream mask and position flag at PSV0 payload offsets 4, 8, 12 and 16. For a declared runtime-info size of at least 36 bytes, offset 28 is the stage tag (geometry = 2), and offset 30 is the maximum vertex count (u16). [XCL's restricted triangle-to-triangle-strip pairing](https://github.com/xcl-dev/xcl/blob/20cf13022f764208384c610c2ae6a3f4eed201a2/crates/xcl/src/gpu/recomp/mod.rs#L270-L295) reads the topology and limit from that part. Victory already has a reader for the outer [ISG1 and OSG1 signature rows](https://github.com/fxceless/victory-fork/blob/2119b0e44c53aa9648307b0c5c73590290305b1f/crates/victory-shader/src/emit/mod.rs#L665-L700). I checked those offsets against five original `gs_6_0` fixtures generated with DXC 1.9.2609.5. All five passed `dxv`. Changing line to triangle input, line strip to point output, and max vertices from 8 to 12 changed the corresponding fields. ISG1 and OSG1 held distinct TEXCOORD indices and the expected two-component masks. Changing only `[instance(1)]` to `[instance(3)]` left the entire PSV0 identical. The standard DXIL entry metadata contained the changed instance count. This supports testing a small outer-metadata reader independently of the native stages. Instance count in the native record, LDS size, the signature-to-LDS mapping, and the contents and ES use of the runtime table still need a source. I would keep #311 open for those fields and use compiler-produced ES+GS pairs with one declaration varied at a time to establish the native offsets. The checks above used original shaders and desktop DXIL. They exercised no console stage execution. Source investigation and fixtures were prepared with Codex assistance.
This discussion has been locked. Commenting is limited to contributors.
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/fxceless--victory-fork#311
No description provided.