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

Open
github-bot wants to merge 2 commits from github-bot/gh-385 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 00:14 UTC · original
0xkn0wh3r3:shaders/gs-psv0-info → main · +473 −0 · 4 files · 2 commits · open

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.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 00:14 UTC · [original](https://github.com/fxceless/victory-fork/pull/385) `0xkn0wh3r3:shaders/gs-psv0-info` → `main` · +473 −0 · 4 files · 2 commits · open 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.
The title's containers carry the standard PSV0 part (runtime info version
3, stage tagged). For a geometry shader it holds the input primitive, the
output topology, the stream mask, whether SV_Position is written and the
vertex maximum, the stage limits the merged ES+GS native stage data also
encodes in a layout not read yet. psv::geometry reads them, checked
against the range D3D allows, with one synthetic fixture per field and a
round trip through the emitter's own PSV0 writer.

shader-info lists the geometry limits per container and in its totals, so
the title's GS containers can be checked in one command.

Not covered, still open in #311: the instance count (not in PSV0), the
LDS size, the output record layout in LDS and the runtime table, which
need the native records.
Two PSV0 parts written by DXC (Windows SDK 10.0.26100, gs_6_0), signature
tables included, now read in the tests: triangle strips out on one stream,
and points out on two. Also covered: a part holding the runtime info alone,
a declared size past the data (up to u32::MAX) refused without a panic, and
the text shader-info prints for a geometry shader.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:42:14 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-385'
git switch 'github-bot/gh-385'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-385'
git switch 'github-bot/gh-385'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-385'
git switch 'main'
git merge --squash 'github-bot/gh-385'
git switch 'main'
git merge --ff-only 'github-bot/gh-385'
git switch 'main'
git merge 'github-bot/gh-385'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.