GPU: host pipelines with a geometry stage from the merged ES+GS pair (#314) #400
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!400
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-400"
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?
@Revens2 on GitHub · 2026-11-25 00:25 UTC · original
Revens2:fix/issue-314→main· +3057 −34 · 21 files · 10 commits · openStep 5 of #138, for #314. Stacked on #381 (#313), itself on #373 (#312), #367 (#311) and #309: the diff here includes theirs until they merge; the commit of this step is the last one. Base is
mainbecause the stacked branches are not in this repository.What is in it
pipeline::merged_pairtranslates the two containers together (emit::translate_merged_gs) into a vertex and a geometry shader, each aShaderwith its translation made; the pair is kept by the two containers' hashes, so two pipelines sharing a GS container with different ES containers are two pairs (in memory only, translated again at each start).HostPipeline::newtakesgeometrystages: vertex, geometry (root parameters with geometry visibility, same user-data / root-view handling as the other stages) and pixel; the GS bytecode goes in the PSO. Stages are found by visibility rather than by position. The library name of such a pipeline is its own (graphics geometry).syntheticfeature with the synthetic containers its tests use, for the victory-gpu test.Tested
HostPipeline::newon a synthetic ES+GS pair and a pixel container gives a three-stage host pipeline (vertex, geometry, pixel), the pair's translation is shared, a non-triangle topology and a missing vertex container are refused. Runs on the host GPU (skipped without one).cargo build --workspace --locked,cargo test --workspace --locked --no-fail-fast -- --test-threads=4: 536 passed, 0 failed, 7 ignored (Windows).Not tested / assumed
victory translatestill counts geometry programs on their own line: the ES half a GS pairs with lives in another container, only known from a title pipeline at run time, so the batch tool cannot measure the pair path.non verifiein this PR (see the comment below if a run was made).AI use
Written with Claude Code (Claude Sonnet 5.5). The tests are synthetic programs; no title shaders or game files were read.
🤖 Generated with Claude Code
@Revens2 on GitHub · 2026-11-25 00:36 UTC · original
In-game run of the stacked head (release build, one session of about 9 minutes, the usual script to the lit cell scene): 0
ERROR, 0 device removed, 4 fps at ~4,900 draws a frame like the runs before it, and no pipeline with a geometry stage was created (nogeometry stage translatednordoes not translateline, no geometry shader seen), so the new path was not exercised in game. That matches #138: the title'sGS_VoxelizeGeneric_*programs are not on a path this scene reaches.The 195 failing programs:
non verifie.victory translatereads the title's shader files, which I did not do, and it cannot pair an ES half with its GS half (the pair is only known from a title pipeline at run time), so it would not measure this path anyway.@Revens2 on GitHub · 2026-11-25 00:44 UTC · original
Review findings: the three on the geometry emission (
s_sendmsghalt, half-precision outputs, runtime table loads) are handled in #381 (1c4de71) and merged into this branch; see the comment there. The fourth, on the user-data block:UserData::index), so the vertex and geometry halves of a pair do not necessarily use the same index for the same dword, and one shared block could have one stage overwrite the other's values. Each stage keeps its own block, as every other stage does. A pair whose two blocks and other root parameters exceed the 64 DWORD limit fails at root signature creation (logged ashost root signature refused) and its draws are dropped; I did not measure how close a title's pairs get, as none was created in the run.Workspace tests on the head (
cargo test --workspace --locked --no-fail-fast -- --test-threads=4): 539 passed, 0 failed, 7 ignored.@JRamos1993 on GitHub · 2026-11-25 04:28 UTC · original
Offline check of this head (
64f781d) against the title's 195 geometry programs: the pair path stops at six small gaps. With them closed, every geometry container pairs, translates and validates, and makes a host pipeline. The patch is at the end, on top of this branch.Setup:
victory translate --validate --listover the title's shader pack with this branch.emit::translate_merged_gson the ES and GS containers (dumped on my machine withVICTORY_DUMP_MATCH, not shared) and validates both outputs withdxil.dll.What this head does with them. The batch tool runs the ES record step and the GS resource step:
ES record: an LDS access of the ES half other than a record write. The instruction isds_write2_b64in every one; 190 also have oneds_write_b64.resources: an address with an untracked high half, at the runtime table. The high half is the table's high half masked withs_and_b32 …, 0xff(a 40-bit address), andhigh_halfdoes not accept that mask.main.Past those, inside
translate_merged_gs(found with the harness, in this order):vertex_readsfinds none, because the title computes the offsets differently from the model:(v0 << 2) & (0xffff << 2)(shift first, then mask), and vertex 2 the same on v1;v_lshlrev_b32of v0 withsrc1_sel:WORD_1, whose shift amount (2) is in an SGPR set bys_mov_b32;ds_read2_b32andds_read_b32.own_accessesrefuses the GS half'sds_write2_b32andds_read2_b32on its output records.s_bfe_i32 s0, s3, <count field>,s_bfm_b64 exec, s0, 0,s_cmp_eq_u32 s0, 64,s_cselect_b64 exec, -1, exec. The lowering stops there with "an opaque lane mask".xyz) and the program writes 12 bytes of it. So the records end one dword beforeemits × record_dwords, andplanrefuses them.The patch:
handoff: oneelements()helper for single and paired LDS accesses (offsets scaled by the element size, ×64 forst64).es_record,vertex_readsandown_accessesuse it.Eval: also followss_mov_b32constants, SDWA word selects (only withdst_sel:DWORDand no sext, neg or abs), andv_and_b32with0xffff << nof an input scaled by2^n.emit::gs:es_as_vertex_shaderwrites oneexpper write instruction. Both elements of a paired write must fall in one record row, which holds for all 195.drop_thread_masksturns the twoexecwrites of the prologue intos_nop. A host invocation is one vertex or one primitive, so it is a thread that runs. It runs inmerged_halves, before anything numbers the instructions:s_nopis dropped from the IR, and the handoff's sites must match the lowering's.planaccepts records that end at the last row's signature columns, and nothing else short of the full array.lower::gs_ds: handles every element of a site; each stored element takes its data from its own operand.resource::high_half: acceptss_and_b32of the expected high half with a mask of low bits (0xffor wider).Results with the patch:
victory translate --validatevalidates 25,370, the same as before, and loses none that validate onmain. Failing programs go from 714 to 324: the 390 ES and GS lines are gone. The summary readsgeometry 195 programs: 195 resources traced, 195 I/O raised, 195 stopped at GS emit.victory_shader::synthetic::pixel_container(). This is the calla_geometry_pipeline_is_made_from_the_pair_of_containersmakes.HostPipeline::newgives 195 vertex+geometry+pixel pipelines; D3D12 refused 0.cargo test --workspace --locked --no-fail-fast -- --test-threads=4gives 546 passed, 0 failed, 7 ignored.cargo clippy -p victory-shader --all-targets --locked -- -D warningsis clean, with and without--all-features.Not tested:
Patch on
64f781d(git apply)AI use: Claude Code with Claude Opus 5.5 ran the pack, wrote the harness and the patch, ran the tests and wrote this. The unit tests use synthetic programs. The title's shaders were only read on my machine.
@Revens2 on GitHub · 2026-11-25 04:39 UTC · original
Thank you, JRamos1993: this is exactly the check this PR lacked. I read each point against the code, applied the patch (it applied cleanly on the previous head), and made two corrections to it. The branch is rebased on the current
mainand pushed (head10f4c02).Point by point
ds_write2_b64in the LDS (all 195 ES halves): fixed.handoff::elements()gives one or two elements per access (offsets scaled by the element size, x64 forst64);es_recordstores both, andes_as_vertex_shadermakes oneexpper write instruction, refusing a pair that spans two record rows. Unit tests: a paired write is two stores at one site, and one export of both elements.0xffmask on the table's high half (GS resources): fixed.high_halfacceptss_and_b32with a mask of the low bits at least0xff. A mask of0x7for0xff00is still refused (tested).src1_sel:WORD_1), constants throughs_mov_b32, paired reads.0xFFFF * muloverflows once the shift passes 16, and from a shift of 17 the mask no longer keeps a whole half, so the rewrite is not valid there. It now holds only for shifts of 1 to 16 (new test, shifts 17 and 31 give no vertex read).clamporomodis not evaluated (the patch checkedneg,abs,sextanddst_selonly).own_accesses: fixed, each element has its own site entry;lower::gs_dstakes each element's data from its own operand. Test onds_write2_b32andds_read2_b32.drop_thread_masksturns the twoexecwrites of the entry block intos_nop, before anything numbers the instructions. This rests on a host invocation being one vertex or one primitive, which is a thread that runs. I tested it on a synthetic prologue only (the others_cselectstays); whether every real prologue has this exact shape:non verifie.planaccepts records that end at the last row's signature columns, and nothing else short of the full array (tested both ways).Your numbers. The 195 programs, the 11,229 pairs and the 195 host pipelines are yours: I did not read the title's shaders, so I did not reproduce them (
non verifieon my side). All tests here use synthetic GCN programs.Checks on the new head.
cargo build --workspace --lockedandcargo test --workspace --locked --no-fail-fast -- --test-threads=4: 561 passed, 0 failed, 9 ignored. The rebase needed two small fixes: one conflict in thegs.rstests (both sets kept) and a newvalu_tests.rstest that neededgs: NoneinParts. No game run for this update: the earlier run of this stack never created a geometry pipeline, and nothing here changes a path that scene reaches.Codex finding "Share the merged-stage user-data block": decision kept, now with a measurement. The two halves keep one block each, because each translated half numbers its user-data dwords itself, so one shared block could have one stage overwrite the other's values. The risk was the 64 DWORD root-signature limit. Your run answers it:
HostPipeline::newmade 195 vertex+geometry+pixel pipelines and D3D12 refused none (that is a measurement of yours, on the title's own pairs, with the root parameters of the pair path). I did not measure it myself. If a pair is ever refused, the log sayshost root signature refused, and I will reopen this then, probably by sharing the block between the two halves.Not tested (same as your list): the title's real ES/GS pairs, a draw with these shaders, and what the geometry looks like on screen.
AI use: Claude Code with Claude Sonnet 5.5 checked the points, adapted the patch, rebased and ran the tests. The patch itself is JRamos1993's (credited as co-author on the commit).
@JRamos1993 on GitHub · 2026-11-25 05:43 UTC · original
Your head
10f4c02checked on the title's programs: same results as my patch, and the two corrections change nothing for these programs. Same machine and method as above:victory translate --validate --list):main310c6eb, and each one's DXIL is byte-identical tomain's (local DXIL hash on each validated line).geometry 195 programs: 195 resources traced, 195 I/O raised, 195 stopped at GS emit.64f781d) and this head, for all 195 pairs.Your two restrictions (shifts 1–16, SDWA without clamp or omod) don't touch the title's idioms: its offsets shift by 2, and its SDWA shift has neither.
AI use: Claude Code with Claude Opus 5.5 ran the checks and wrote this. Nothing from the title is in it.
@Revens2 on GitHub · 2026-11-25 07:10 UTC · original
Rebased on main (
a26859f), stacked on #381; head now77b24c1. Conflict in the test module ofemit/gs.rs(two tests added at the same spot), resolved by keeping both; the earlier "rebase fix" test commit is now part of #381. Tree is identical to the previous head apart from the main changes.cargo build --workspace --lockedok;cargo test --workspace --locked -- --test-threads=4: 584 passed, 0 failed, 10 ignored (one earlier run of the same command had avictory-gpulib failure while the machine was loaded; two reruns passed, cause not identified). No game run. Ready for another review pass.@Revens2 on GitHub · 2026-11-25 09:35 UTC · original
@codex review (head rebased on origin/main; earlier findings were addressed before the rebase)
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 09:35 UTC · original
Codex Review: Something went wrong. Try again later by commenting “@codex review”.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:25 UTC · original · edited 2026-11-25 09:35 UTC
Codex Review Summary: ❌ Failed
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.77b24c1ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@ -4359,0 +4468,4 @@let p = self.s.m.element(c, arr, index);let bits = self.s.m.load(c, p);let (name, value) = if e.comp == 9 {("storeOutput.f32", self.as_float(bits))@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:33 UTC · original
When the geometry output signature marks an element as 16-bit (
e.half), this path still reads a full record dword and forwards its raw bits through a 32-bit output operation. Unlike the regular export path, it never unpacks or widens the half value, so GS varyings or positions from such signatures are corrupted; reject these outputs or convert them before storing.Useful? React with 👍 / 👎.
@ -4818,6 +4953,9 @@ impl<'a> Lower<'a> {.op(self.cur, "barrier", Attr::NoDuplicate, void, 80, &[mode]);Ok(())}Fields::Sopp { .. } if name == "s_sendmsg" && self.x.gs.is_some() => {@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:33 UTC · original
When a GS uses
s_sendmsghaltforGS_EMITorGS_CUT, planning recognizes the message and assigns it an output record, but this dispatch handles onlys_sendmsg. The halting instruction falls through as a no-op, so the translated shader omits the emission or cut while still declaring the vertex maximum; handle both opcodes or refuse the halting form.Useful? React with 👍 / 👎.
@ -5459,6 +5597,19 @@ impl<'a> Lower<'a> {unreachable!()};let name = inst.name();if self.scalar.get(&site).is_some_and(|a| a.param == RUNTIME_TABLE) {@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:33 UTC · original
Whenever a GS reads the runtime table, this branch replaces every scalar destination with zero without checking the load offset or proving that the value is used only as the relocatable LDS base. If a table field also feeds an output value, condition, or other computation, the pair is still accepted but silently produces results based on zero; limit this substitution to proven base-only uses or refuse other accesses.
Useful? React with 👍 / 👎.
@ -367,3 +383,4 @@(None, None) => return refuse("no vertex or mesh shader", shaders),};let mut stages = vec![first];stages.extend(merged.as_ref().map(|m| (&m.1, D3D12_SHADER_VISIBILITY_GEOMETRY)));@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:33 UTC · original
The ES and GS halves share one user-data layout, but adding the translated GS here sends it through the per-stage root-parameter construction, which allocates a second root-constants block for the same registers. If those duplicated constants plus the other parameters exceed D3D12's 64-DWORD root-signature limit, serialization fails and
HostPipeline::newdrops every draw for that pair; share the merged block or otherwise keep it within the limit.Useful? React with 👍 / 👎.
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.Merge
Merge the changes and update on Forgejo.