Shaders, GPU: translate single-stream triangle geometry programs #1315
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1315
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1315"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@r4tedx on GitHub · 2026-11-24 17:21 UTC · original
r4tedx:shader/geometry-programs→main· +1476 −113 · 13 files · 7 commits · openConsole geometry programs are refused today: their GS-to-VS ring addresses look like SGPRs that are no root parameter, and the native stage data of a geometry record was never read. As fiestorra measured on #293, no open PR reaches them. This translates the single-stream triangle case.
What it does
native: reads uncompressed FSSM entries (XDAT kind0x0c; the geometry containers use them) and a geometry record's copy VS and GS-to-VS ring layout (StageIo::Gs).geometry(new): one host GS invocation per console invocation. It follows the LDS offsets of the input vertices packed in v0/v1, the private slice of the ring the invocation writes, and thes_sendmsgemit/cut messages, then uses the copy VS to map each ring dword to the export target and component it ends up in.resource::track_io).victory-gpu: host graphics pipelines take a geometry stage (refused together with a mesh stage).Limits (refused, not guessed):
GS_OP_EMIT_CUT(0x32), no control flow in the GS body, nothing past the copy VS's stream predicate;A geometry record whose copy VS or stage data does not parse keeps no stage I/O, and its container's other programs are unaffected. The same goes for an uncompressed entry that is not a valid FSSM, which is skipped as before. The copy record at stage data
+0x34and the ring sizes at+0x27c..+0x28care not documented anywhere I know of. Two internal checks hold on all 195 geometry programs (vertex_dwords × max_vertices == invocation_dwords, and PSV0's max vertex count equal to+0x284), and they are the evidence for that layout.Tests
emit::geometry_tests::geometry_vertices_match_reference_drawtranslates a console GS and draws with it, on the hardware adapter and on WARP. It compares the result with the same operation as an HLSL GS compiled by the Windows SDK'sdxc.exe(the test skips without the SDK, and says so).geometry_parameters_match_reference_drawdoes the same for the parameter-export path: input row 1 (TEXCOORD0.xy) goes through ring dwords 4-5, which the copy VS exports asparam0(output table → signature row 1), and the PS writes it into green and blue. On an RTX 5070 and on WARP, both draws equal the reference image (44 of 256 pixels covered). Also tested:raisegivespos0plus a two-channelparam0from all six input dwords, component order and constants in the copy export, refusal of untraced reads and exports and of a ring store to an emitted vertex, and the parse fallbacks innative.940d32f(head0d45a59); CI passes. Both CIcargo clippycommands with-D warningsare clean locally. Local tests on this head are WARP only, because after a hard PC crash no test here runs on the hardware GPU for now. Geometry andnativetests: 23 passed, and both reference draws match on WARP. Thevictory-shaderlibrary on WARP, one thread: 254 passed. 2 failed insynthetic_tests, and those fail the same way on main underVICTORY_WARP=1(hardware-only checks). Earlier, on6ddbdfc,cargo test --workspace --lockedpassed on an RTX 5070 and withVICTORY_WARP=1(350 passed).victory translate --validate, CPU plus dxil.dll, no title launch, no pipelines. It covers 642 containers from the title's shader archive that an earlier build refused, 195 of them geometry programs. Counts only: on main940d32fall 195 geometry programs stop atan address in an SGPR that is no root parameter(offset0x44). With0d45a59all 195 translate and validate, and nothing that validates on main stops validating.GS_VoxelizeGeneric_<h>was paired with theVS_VoxelizeGeneric_<h>containers of the same technique hash (13 hashes, 195 of each). Their container holds both the ES and the VS payload, and the translation takes the VS. Within a hash, the VS were grouped by output signature and the GS by input signature, and one VS + GS (+ stub PS) pipeline was created per pair of groups. In 12 hashes there is one group of each, and the pipeline is created. Hash912dfba0has two of each (2 and 33 members): the size-matched pairs (2 with 2, 33 with 33) link, and so does 33 VS with 2 GS, but the 2 VS with the 33 GS is refused by D3D12. I can't tell from the archive which VS the title pairs with which GS. If the pairs follow the group sizes, every one links.Where it already runs: the fork's tester tree
r4tedx/VIctoryintegration/testerscarries the first two commits since update 8 (d45ea23). The third commit is the follow-up from that tree's review. c4k3ss was about to start a geometry-stage path (#293); this is it, and review or measurements are welcome.Overlap: main's rectangle-list GS (
683ad7a, from #1020) is reused for the DXIL GS state; a pipeline with both a geometry stage and rectangle lists is refused. #1924 (a rebase of #1399) and #877 reach the same 195 programs. The comparison is in #1315. Please take one, not both.AI-assisted
🤖 Generated with Claude Code
@KainanP on GitHub · 2026-11-24 17:52 UTC · original
Tested
6ddbdfcon an RTX 4060 Laptop (driver 32.0.16.1047, Windows 11 26200) and WARP.VICTORY_WARP=1 cargo test --workspace --locked: 350 passed, 0 failed, 6 ignored.cargo test --workspace --locked:victory-shader --libdied withSTATUS_ACCESS_VIOLATIONafter 218 passing tests.It is intermittent and only in parallel:
cargo test -p victory-shader --lib --lockedon the RTXmainffe310e, default threads--test-threads=1geometry_vertices_match_reference_drawandgeometry_parameters_match_reference_drawgeometry_testsCause:
reference_drawinemit/geometry_tests.rsdoes not takevalu_tests::ONE_AT_A_TIME, whose comment already says two GPU tests at once can end the test process with an access violation, and which the other GPU test modules take. The draw then races with them. Taking the lock fixes it here:The title-side numbers of the PR (195 geometry programs) are untouched by this; it only affects the test run. I have no game copy, so I did not run
victory translate.Tested and written with the help of an AI (Claude Code).
@ryotdev on GitHub · 2026-11-24 20:25 UTC · original
I found a copy-shader case on
f74eab0where the generated geometry exports can run for lanes the shader disabled. Prependings_mov_b32 exec_lo, 0to the synthetic copy ingeometry_part()still returnsStreams. The same happens withexec_hi. Both writes change which lanes should export, but the emitted stream has no predicate for that change.Fix and regression test on your exact head. It reports the unsupported EXEC write at its instruction offset. A control that writes zero to ordinary register
s20still translates.AI-assisted review. The new test failed before the change and passed after it. The Linux CPU shader library suite passed 103 tests with one ignored. I haven't measured whether a retail draw uses this case.
@Marvisak on GitHub · 2026-11-25 01:22 UTC · original · edited 2026-11-26 00:25 UTC
Automated triage for the maintainers.
Needs work: it would now break the file-size policy on
main. The head is unchanged and still merges without conflicts. However,mainhas growncrates/victory-shader/src/emit/lower.rsto 520,563 bytes, and with this PR merged it would be 526,553 bytes. That is over the 524,288-byte limitcargo xtask policyenforces (MAX_FILE_SIZEinxtask/src/policy.rs), so CI fails after the merge even though it passed on the PR's own base. Please move this PR's additions tolower.rs(the geometry-stage lowering, about 140 lines) into a submodule such asemit/lower/geometry.rs, or intogeometry.rs, so the merged file stays under the limit with some margin. #1271 and #1540 also add to this file.The substance is as judged before. The ring-address tracing in
geometry.rsand the exemption inresource.rs::track_ioare narrow. The refusals cover streams other than 0,EMIT_CUT, ring stores after EMIT, and EXEC writes in the copy shader. The synthetic reference draws compare the output with a dxc-compiled GS. An independent corpus count (+195 validated, nothing lost, every other refusal unchanged) matches the author's.Two smaller points from brainbudt's review, which the author acknowledged:
HostPipeline::rectangles(victory-gpu/src/pipeline/host.rs) is true for every geometry stage, not only for the generated rectangle GS, and the specific GS refusal reason can be lost on the fallback path. Please fix the first while you are in the code.The choice between this PR and #1924 is still open for the maintainers. Push the split and this will be reviewed again.
CI: passing on the PR's own base (it would fail the policy check once merged with current
main).Generated by Claude Code
@fiestorra on GitHub · 2026-11-25 04:11 UTC · original
One family, one instruction: 196 geometry programs that all stop at offset
0x44on an address in an SGPRCensus over a local 1.0.2.1 archive (26,503 containers,
victory translate --validate --list --jobs 10onmain940d32fplus #2016 and #2027), looking at the "an address in an SGPR that is no root parameter" refusals, which are 196 programs:Gs, no other stageGS_VoxelizeGeneric_*, one family0x44, the same instruction in every oneTwo things fall out of that, and the second is the useful one for the work in this issue:
0x44, seventeen dwords in). So the first thing these programs do is compute an address in an SGPR that the translator will not take, and the rest of the program is never reached. Making geometry shaders translate without addressing that instruction will move 196 programs from "resources: an address in an SGPR that is no root parameter" to the same message, one line later in the log.The code that refuses them is
crates/victory-shader/src/resource.rs::why_no_base, and the branch is the one that answers "an address in an SGPR that is no root parameter" — the value's base is a shader input SGPR rather than a root parameter.#710(closed) and#139are the neighbours of this ground: reading through an address the console spilled somewhere, versus an address that arrives as input.What I have not done: read the instruction at
0x44, or checked whether the family is single-stream triangles (which would put it under this issue's scope) or something else. Both are cheap with a--disasmpass over the pack and I did not run it; I would rather report the shape I measured than guess at the instruction.If it helps whoever is on #877/#1924: the number to watch is that 196, and one program of the family is enough to iterate on, since they all stop in the same place.
No game data is involved: counts, stage letters, program names and an offset.
Written with an AI assistant.
@fiestorra on GitHub · 2026-11-25 04:36 UTC · original
The address is not an instruction: it is SGPR 2, which has no producer — all 195 of them
I said in the comment above that reading the instruction at
0x44was cheap with a--disasmpass. Two things to correct and one to add.Correction, my invocation. My first attempt reported
containers found 0, which was my ownStart-Processsplitting the path on its spaces, not the tool:victory shader-info <pack>does read this pack (26,503 containers, all with a DXIL part).Correction, the method.
--disasmover the whole pack is the wrong tool for one family: the dump passes 1 GB before reachingGS_VoxelizeGenericand I stopped it there. It would tell me the instruction eventually, at the cost of a gigabyte of game-derived text on disk to answer a question a print answers.What answers it instead, and it is the useful part: a two-line probe at the refusal site in
resource.rs::why_no_base— printing the SGPR index and the defining instruction of the value that is refused — run over the same census:All 195 refusals are the same value: SGPR 2, and it has no defining instruction. That is not "an instruction we cannot lower" — it is an incoming register. In a geometry shader the SGPRs on entry are whatever the host set before invoking it, so the program is taking a memory base straight out of an input register and the address analysis refuses it because that base is not a root parameter in the layout we build for the stage.
That fits the offset too:
0x44is early because there is nothing to compute — the first thing the program does with that register is use it as an address.So the question for this issue is not "which instruction should we lower" but "what does SGPR 2 hold for a
GS_VoxelizeGenericprogram", which the container's stage data answers (the same placems_io/vs_ioread their input layouts from). If it is the primitive's vertex-data pointer, the fix is a layout entry for the geometry stage — a much smaller thing than addressing support, and it would move all 195 at once.I have not gone further than that: reading the GS input layout is the next step and it needs the native stage data for that container, which is where I stopped.
No game data is involved: an SGPR index, an instruction-name lookup and counts.
Written with an AI assistant.
@r4tedx on GitHub · 2026-11-25 04:42 UTC · original
Rebased onto main
940d32f, head0d45a59, and CI passes there. Main moved in two ways this had to fit:range::build, so this addsNativeProgram::translation_code: the patched code, or for a GS the code one host invocation runs, with its EXEC set-up as a no-op.683ad7a), and the console GS now uses it (Shader::gs, same entry state and PSV fields). A pipeline with both a geometry stage and rectangle lists is refused; rectangle lists keep main's generated GS.@KainanP your diagnosis of the parallel crash was right. The lock is
f74eab0, still in. Thank you for the A/B table.@ryotdev reproduced on the rebased head: your test fails without the change and passes with it (WARP). It's taken as
5d307cdunder your authorship, with the test's program now built throughtranslation_code.@fiestorra yes. Offline count on
0d45a59: CPU plus dxil.dll, no title launch, local copy. All 195GS_VoxelizeGeneric_*programs in my set validate. On main they stop at0x44withan address in an SGPR that is no root parameter. That instruction is the start of the GS-to-VS ring address:s[8:9](the high half masked to0xff), thens_load_dword +0xb8, then a shift by 8, plus the wave offset ins2, plus lane × stride. c4k3ss read it the same way on #293.geometry.rstraces it and exempts exactly those steps from root-parameter tracking. My set has 195 of the family, yours 196, and I can't check the one I don't have.Compared with the other two geometry efforts. Same 642 containers, same command (
victory translate --validate --list, CPU plus dxil.dll), each branch's own build:940d32f0d45a591aa7225VS_*Transform*_VfxVBuffer*vertex programs (Flags must match usageon main), which is independent of geometry828f825ffe310e, so not a fair comparison until it is rebasedSo the counts tie. The difference is in what each refuses rather than guesses. #1924's own description lists four open risks from its review thread. Here is how this PR handles each:
paramslots: here each ring dword's export target and component come from the copy VS's own code (itsds_readoffsets,exptargets and its output table), not from the signature.[1, 0], EMIT and CUT on stream 0 only, noEMIT_CUT).a geometry output missing from the copy exports,a geometry output signature row).It also refuses a ring store to a vertex already emitted and an EXEC write in the copy (ryotdev's). It covers the write batching that #1924's second commit fixes, with a test (
ring_writes_batched_before_the_emits_stay_with_their_vertex). That needed no code change here, because each EMIT reads its vertex's slots by their offset in the invocation's ring.For #1924, whose description says its Windows GPU tests had not run: I ran
emit::tests::merged_geometry_stages_draw_their_triangleat1aa7225on WARP (VICTORY_WARP=1, one thread). It passes, with 496 lit pixels both interleaved and batched. That's WARP only, not hardware.My suggestion to the maintainers: take one of the two, not both. If #1924 is the one, I can port these refusals onto it. Its 20 vertex programs are worth taking either way.
Tests on
0d45a59. Local runs are WARP only today: after a hard PC crash, no test here runs on the hardware GPU until it is understood.nativetests: 23 passed. Both reference draws equal the dxc-compiled GS on WARP (44 of 256 pixels), including the param0 path.victory-shaderlibrary on WARP, one thread: 254 passed. Two failed:synthetic_tests::gathers_at_a_level_match_the_hardwareandpermutes_read_the_lane_named_and_zero_from_lanes_left_out. They fail the same way on main940d32funderVICTORY_WARP=1, because they are hardware-only checks.victory-gpuwas not run locally, because its host takes the default adapter. CI covers it.The title was used only for the offline counts above (counts and reasons only); none of the tests use it.
AI-assisted
@r4tedx on GitHub · 2026-11-25 06:07 UTC · original
The two reference draws on
0d45a59ran with the D3D12 debug layer enabled, on WARP. It was the first time on this PC: the layer was installed today.victory-shader's test host never enabled the debug layer, so I ran the two tests with a local diagnostic patch, not part of this PR. WithVICTORY_D3D12_DEBUG=1the patch enables the layer before the device is created, then reads the device's info queue after each draw. The info queue was present and held 0 messages after every draw, of any severity. The translated GS, withpos0only and with theparam0export, drew the same image as the dxc-compiled reference both times (44 of 256 pixels).This was WARP only; the hardware GPU here is off-limits for tests for now. GPU-based validation was not turned on. The title was not used in these tests.
If a debug-layer switch for the shader tests' host is wanted upstream, I can open it as a small separate PR.
AI-assisted
@r4tedx on GitHub · 2026-11-25 06:44 UTC · original
@fiestorra a follow-up to "my set has 195, yours 196".
A full-archive list of main
940d32f(26,503 containers,victory translate --validate --list, CPU plus dxil.dll, local copy) has exactly 195GS_VoxelizeGeneric_*programs, each refused at0x44. The 196th match in a line count is the list's own summary block:195 resources: an address in an SGPR that is no root parameter (e.g. …@0xbdcce29 GS_VoxelizeGeneric_f406ea93_Wrapped Gs at 0x44). That's the same summary-block effect you described on #878. So the family is 195, and all 195 validate with this PR.The title was used only for that offline list (counts, names and offsets).
AI-assisted
@brainbudt on GitHub · 2026-11-25 20:29 UTC · original
Independently verified
0d45a59and its clean merge onto13f91ca. No merge blockers found for single-stream triangles.1.9.2609.5): all 8 geometry tests passed; both translated shaders validated and matched the complete DXC reference images pixel for pixel (44/256 pixels covered). Repeating both draws with all three vertices written before the firstEMITalso matched. (Synthetic fixtures only; no physical GPU or retail assets.)cargo check --workspace --target x86_64-pc-windows-msvc --testspassed.Two small follow-ups (non-blocking):
HostPipeline::rectangles(crates/victory-gpu/src/pipeline/host.rs:697) is currently set totruefor every translated GS rather than only the synthesized rectangle shader.EMIT), the fallback path surfaces a generic SGPR error instead of preserving the specific GS refusal reason.@r4tedx on GitHub · 2026-11-25 20:32 UTC · original
@brainbudt thanks for the independent run on
0d45a59and the merge onto13f91ca.HostPipeline::rectangles: confirmed. Atcrates/victory-gpu/src/pipeline/host.rs:697it is!gs.is_empty(), so it is also true for a translated GS. Today that should not reach a rectangle draw: a translated GS on a rectangle-list pipeline is refused (host.rs:616), and the console topology type is part of the pipeline's key (GraphicsState::describe). Butcompletes_rectangles(draw.rs:1425) checks the draw's topology against the bound pipeline's flag, so the flag should mean what its doc says. I'll set it only for the synthesizedrectangle_gscase in a follow-up commit on this branch.EMIT), and keep the specific reason if it is being lost.Both after the current queue on this PC drains. I'll post the head and test counts here when they are done.
AI-assisted
@BaggyALPHA on GitHub · 2026-11-25 21:03 UTC · original
Offline corpus measurement: this clears the whole
an address in an SGPR that is no root parameterbucket — 195 programs recovered, none lost.Merged onto
main13f91ca(clean merge), rebuilt, and run over the shipped shader archive with the same method and validator as the census on #1481:translate <archive> --list --validate --jobs 6, official DXC archivedxil.dll(1.8), release build, RTX 3080 / Windows 11 26300.address in an SGPR that is no root parametermain13f91caEvery other refusal is byte-identical to
main: the 748 compute entry-point rejections, the 71 mesh output-budget ones, and the emit tail (13 / 8 / 5 / 1 / 1 / 1) all unchanged. So the 195 are recovered and nothing is traded for them.The mechanism matches @kotekompotek's decode of that bucket: all 195 are one geometry program family failing at the same instruction, and the tracker refusal is only the first wall — on
mainthe census contains noGsprograms at all (12,051Ps, 8,765Ms, 2,658Cs, 2,191Vs, 0Gs). With this PR 195Gsappear, emit and validate, and the DXIL line itself changes to "vertex, geometry and pixel". That is a stage path arriving, not a tracker being loosened.Worth stating for whoever triages the cluster: on current
mainthis bucket is the second-largest translator-side gap after the 748 (#1065), and of the pull requests that quote its refusal string this is the one that actually moves it — I measured #2387, #2546, #2154 and #2295 the same way earlier today and none of them changes any count (results).Not measured here: host pipeline creation (the census makes none,
0 pipelinesin both rows), anything at runtime, and whether the geometry output is correct — this says the programs translate and validate, not that they draw the right thing. Counts and validator strings only, no program names, hashes or paths.AI-assisted (Claude Code); both rows from the runs described.
@r4tedx on GitHub · 2026-11-25 21:04 UTC · original
@BaggyALPHA thank you. An independent count on current
mainwith the archive validator is what this PR lacked. Your +195, 0 lost, with every other refusal unchanged, matches our own offline count of the same programs: local title data, CPU only, counts only.On what isn't measured, you're right. The PR's own evidence for correct output is the synthetic reference draws in
emit/geometry_tests.rs: hand-assembled programs checked against a dxc-compiled reference geometry shader by rasterized coverage, on WARP and under the D3D12 debug layer with 0 messages. None of that comes from the title. The open question for the maintainers is still the one in the triage: this PR or #1924, which covers the same 195.AI-assisted
@Venom2054 on GitHub · 2026-11-26 15:04 UTC · original
Tested
0d45a59on a physical RTX 5070 Ti. I used the vertex, geometry and pixel program IDs recorded together in each effect pass to check which pairs the title declares. This resolves the pairing question for technique912dfba0in the PR description.Host::geometry_pipeline. Windows DXIL validation passed for the 195 vertex, 195 geometry and 294 pixel containers used here.emit::geometry_testsmatched their DXC reference on hardware and WARP, with 44 of 256 pixels covered in each case.These are offline pipeline-creation results for the title combinations. Pixel readback was measured on the two synthetic draws only.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.