Shaders: read a geometry shader's limits from its container's PSV0 (#311) #385

Open
0xkn0wh3r3 wants to merge 2 commits from upstream-pr/385 into main
0xkn0wh3r3 commented 2026-11-25 00:14:15 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by 0xkn0wh3r3 on 2026-11-25T00:14:15Z.


Refs #311. This covers the container-level fields. The fields that need the native records stay open there.

The title's containers carry the standard PSV0 part next to ISG1/OSG1 (runtime info version 3, with the shader stage tagged). For a geometry shader, PSV0 holds the input primitive, the output topology, the stream mask, whether SV_Position is written and the vertex maximum. Those are some of the stage limits #311 asks for, in a documented layout. This adds psv::geometry, which reads them, and a shader-info line that lists them per container and in the totals.

It touches none of #309's files, so it applies with or without that PR.

Checked

  • One synthetic fixture per field, including the values D3D refuses (unknown primitives, list topologies, an empty or 5th stream, a vertex maximum of 0 or above 1024), and parts that are truncated, from another stage or too old to name a stage.
  • A round trip through the emitter's own PSV0 writer (the built-in rectangle GS).
  • Two PSV0 parts written by DXC are kept in the tests, signature tables included: triangle strips out on one stream, and points out on two streams.
  • A part that holds only the runtime info, and a declared size past the end of the data (up to u32::MAX), which is refused without a panic. Also the text shader-info prints for a geometry shader.
  • I broke the reader on purpose nine ways: the stage and vertex maximum read from the offsets in the earlier comment, the input and output fields swapped, the position byte one off, no limit on the stream mask, a patch count one off, the version-0 size check dropped, a wrong vertex count for triangles with adjacency, and the 1024 limit one off. A test failed every time.
  • shader-info on a container whose output topology was corrupted to a line list: it is listed under geometry unreadable with the reason, not dropped.
  • 13 gs_6_0 shaders built with DXC (Windows SDK 10.0.26100), varying one declaration at a time: point, line, triangle, both adjacency inputs and 4-point patch input; point, line strip and triangle strip output; maximums of 3, 12 and 170; no position; two streams. Each reads back as declared. [instance(3)] reads the same as [instance(1)], which matches the earlier comment that the instance count is not in PSV0.
  • The title's own containers: shader-info finds 15 in the executable, and none of them reads as geometry or fails to read. I dumped 10 of them by hand: each carries PSV0 with 52 bytes of runtime info, and the stage byte at info +0x18 is 1 for the vertex shader and 0 for the pixel shaders.
  • cargo clippy in both CI configurations, and cargo test --workspace: 507 passed.

A note on offsets: counted from the start of the runtime info, the stage is at 0x18 and the vertex maximum at 0x1a. The 28 and 30 in the earlier comment count from the start of the part, which begins with the 4-byte runtime-info size.

Not checked

  • The title's 195 GS containers, because I don't have the game's data files. With them, victory shader-info --verbose <game dir> lists what each one declares.

Still open in #311

The instance count, the LDS size, the output record layout in LDS, and the runtime table. They need the merged stage's native records.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6594124621 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/385). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T00:14:15Z. --- Refs #311. This covers the container-level fields. The fields that need the native records stay open there. The title's containers carry the standard `PSV0` part next to `ISG1`/`OSG1` (runtime info version 3, with the shader stage tagged). For a geometry shader, `PSV0` holds the input primitive, the output topology, the stream mask, whether `SV_Position` is written and the vertex maximum. Those are some of the stage limits #311 asks for, in a documented layout. This adds `psv::geometry`, which reads them, and a `shader-info` line that lists them per container and in the totals. It touches none of #309's files, so it applies with or without that PR. ### Checked - One synthetic fixture per field, including the values D3D refuses (unknown primitives, list topologies, an empty or 5th stream, a vertex maximum of 0 or above 1024), and parts that are truncated, from another stage or too old to name a stage. - A round trip through the emitter's own `PSV0` writer (the built-in rectangle GS). - Two `PSV0` parts written by DXC are kept in the tests, signature tables included: triangle strips out on one stream, and points out on two streams. - A part that holds only the runtime info, and a declared size past the end of the data (up to `u32::MAX`), which is refused without a panic. Also the text `shader-info` prints for a geometry shader. - I broke the reader on purpose nine ways: the stage and vertex maximum read from the offsets in the earlier comment, the input and output fields swapped, the position byte one off, no limit on the stream mask, a patch count one off, the version-0 size check dropped, a wrong vertex count for triangles with adjacency, and the 1024 limit one off. A test failed every time. - `shader-info` on a container whose output topology was corrupted to a line list: it is listed under `geometry unreadable` with the reason, not dropped. - 13 `gs_6_0` shaders built with DXC (Windows SDK 10.0.26100), varying one declaration at a time: point, line, triangle, both adjacency inputs and 4-point patch input; point, line strip and triangle strip output; maximums of 3, 12 and 170; no position; two streams. Each reads back as declared. `[instance(3)]` reads the same as `[instance(1)]`, which matches the earlier comment that the instance count is not in `PSV0`. - The title's own containers: `shader-info` finds 15 in the executable, and none of them reads as geometry or fails to read. I dumped 10 of them by hand: each carries `PSV0` with 52 bytes of runtime info, and the stage byte at info +0x18 is 1 for the vertex shader and 0 for the pixel shaders. - `cargo clippy` in both CI configurations, and `cargo test --workspace`: 507 passed. A note on offsets: counted from the start of the runtime info, the stage is at 0x18 and the vertex maximum at 0x1a. The 28 and 30 in the earlier comment count from the start of the part, which begins with the 4-byte runtime-info size. ### Not checked - The title's 195 GS containers, because I don't have the game's data files. With them, `victory shader-info --verbose <game dir>` lists what each one declares. ### Still open in #311 The instance count, the LDS size, the output record layout in LDS, and the runtime table. They need the merged stage's native records.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/385:upstream-pr/385'
git switch 'upstream-pr/385'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/385'
git switch 'upstream-pr/385'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/385'
git switch 'upstream-pr/385'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/385'
git switch 'main'
git merge --squash 'upstream-pr/385'
git switch 'main'
git merge --ff-only 'upstream-pr/385'
git switch 'main'
git merge 'upstream-pr/385'
git push origin 'main'
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
fxceless/victory-fork!385
No description provided.