Shaders: emit a merged ES+GS pair as a vertex and a geometry shader (#313) #381
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!381
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-381"
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:12 UTC · original
Revens2:fix/issue-313→main· +2506 −25 · 16 files · 8 commits · openStep 4 of #138, for #313. Stacked on #373 (#312), itself on #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
translate_merged_gsnow returns two host shaders (MergedShaders): a vertex shader and a geometry shader, instead of stopping atGS emit. Newemit/gs.rsholds the plan and its notes.TEXCOORD<row>register (32-bit integers, dwordk= rowk / 4, channelk % 4). The rewrite is of the machine code:ds_write_b32..b128becomes theexp param<row>of the same size,s_barrieras_nop, thes_setpc_b64handover ans_endpgm.loadInputof that signature; its own LDS writes/reads go to a private array at the offset from the first record written; the k-thGS_EMITcopies record k to the output signature (storeOutput) and callsemitStream;GS_CUTiscutStream; the runtime-table scalar load reads 0. The array andmaxvertexcountcome from the emit count of the code.merged::limits,handoff::own_accesses, anOverrideshook inemit_program_withandShader.geometrycarry this;VsI/O raising also accepts the ES stage.victory translatekeeps counting those on thegeometryline.Tested
cargo build --workspace --locked,cargo test --workspace --locked --no-fail-fast -- --test-threads=4: all green (243 passed in victory-shader, 0 failed).Not tested / assumed (none read from the stage data or checked on a title program)
4 * row + colis that channel of the output with that register, records back to back; the written range must be exactly one record per emit or the program is refused.non verifie.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:44 UTC · original
Review findings handled in 1c4de71 (with tests on synthetic programs):
s_sendmsghalt: a haltingGS_EMIT/GS_CUTis refused (a halting GS_EMIT or GS_CUT); the lowering handleds_sendmsgonly, so it would have been dropped silently.OSG1says they are written (checked on the read-write mask of every row).MergedShaders::vertexis nowHwStage::Vs(the geometry oneGs).more than one field read from the runtime table). That the one field is the output base, and is used as nothing else, is an assumption on a title program that nothing here checks; it stays in the list of what is assumed.cargo test -p victory-shader --lib --locked: 251 passed, 0 failed.@Revens2 on GitHub · 2026-11-25 07:10 UTC · original
Rebased on main (
a26859f), stacked on #373; head nowdc33623. Main's new valu test buildsPartswithout thegsfield this PR adds, sogs: Noneis added in that test (folded into the last commit).cargo build --workspace --lockedok;cargo test -p victory-shader -p victory-gpu --locked: 137 + 256 passed, 0 failed. 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:12 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.dc33623ℹ️ 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.
@ -4819,2 +4942,4 @@Ok(())}Fields::Sopp { .. } if name == "s_sendmsg" && self.x.gs.is_some() => {self.gs_message(inst, (b, i))@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:21 UTC · original
s_sendmsghaltgeometry messagesmerged::message_ofandGsPlanrecognize boths_sendmsgands_sendmsghalt, so a halt-formGS_EMITorGS_CUTis counted and assigned in the plan. This dispatch only callsgs_messagefors_sendmsg; the halt form falls through as a no-op, leaving the returned shader with a reserved vertex or cut that it never emits. Handle both opcodes, including their halt behavior, or refuse the halt form.Useful? React with 👍 / 👎.
@ -4359,0 +4461,4 @@("storeOutput.i32", bits)};let args = [self.s.m.i32(id as u32), self.s.m.i32(0), self.s.m.i8(k), value];self.s.op(self.cur, name, Attr::NoUnwind, void, 5, &args);@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:21 UTC · original
When the GS writes outputs through this
GS_EMITpath, the elements parsed fromOSG1haveusage = 0, and thesestoreOutputcalls never update the corresponding usage bits. Unlike the normal output lowering path, the resulting geometry signature is serialized as if none of those components were used, so it does not describe the values the shader stores and can mislead downstream stage linkage. Mark each component as it is stored.Useful? React with 👍 / 👎.
@ -5462,0 +5594,4 @@};for k in 0..dwords {let zero = self.s.m.i32(0);self.write(inst, Reg::S(code + k), zero, None);@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:21 UTC · original
Every scalar load traced to
RUNTIME_TABLEreaches this branch without checking its address offset, and every result dword is replaced with zero. Rewriting the GS output array makes its output-base load irrelevant, but a GS that reads another runtime-table field will now use zero in its calculations or control flow and produce different geometry. Restrict this substitution to the identified output-base load or preserve other table reads.Useful? React with 👍 / 👎.
@ -0,0 +364,4 @@let Some(Operand::Vector { reg: d, .. }) = *dst else {return Err(unsupported("an LDS read without a destination"));};let byte = lin.add.wrapping_add(u32::from(*offset0) | u32::from(*offset1) << 8);@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:21 UTC · original
Evalpreserves the multiplier for an input-vertex offset, but this mapping computes the record dword using only the additive part and the DS instruction offset. A read using a scale other than the expected byte scale is therefore accepted as the same vertex/dword, then replaced byloadInputfor a different component. Validate the multiplier before constructing theVertexRead, or account for it when resolving the record address.Useful? React with 👍 / 👎.
@ -0,0 +166,4 @@outputs,},code,..merged.es.clone()@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:21 UTC · original
..merged.es.clone()preservesstage = HwStage::Es;emit_program_withcopies that intoHostShader.stageeven though the emitted DXIL is a vertex shader. Consumers that dispatch on this field, as the existing translator host check does, will treat the returnedvertexshader as a non-vertex stage. Keep the ES stage for machine-code and root-data mapping, but set the returned host shader's stage toVs.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.