Shaders: merged ES+GS stage reads its SGPRs, stops at "GS emit" (#138, step 1) #309

Open
Revens2 wants to merge 2 commits from upstream-pr/309 into main
Revens2 commented 2026-11-24 23:29:06 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-24T23:29:06Z.


Step 1 of #138 (the 195 an address in an SGPR that is no root parameter failures are one merged ES+GS shader). This does not translate geometry shaders. It makes the GS half read the merged stage's SGPRs, so that failure stops hiding what is left, and it stops cleanly at a named error instead.

What is in it

  • StageIo::Gs: the GS record is now tagged (its stage data is still not read), and io::raise accepts it: no exports, and the first two user-data dwords (s8, s9 of the merged stage) are Input::RuntimeTable, the pointer the issue found at user data 0/1, when the root layout puts nothing there.
  • Resource tracking: through resource::track_merged (the merged layout of both halves), in a geometry program a load through that pair is traced to a new resource::RUNTIME_TABLE address (with the load's offset) instead of failing. It applies to the geometry stage only and only to dwords the merged layout leaves free; any other unbound SGPR pair, the same load in other stages, and a geometry program tracked on its own with plain track or emit::translate fail as before. A pointer whose high half was overwritten is refused.
  • merged::pair_es_gs: pairs the ES program (vertex container) with the GS program (geometry container): ES and GS stages, same wave size, one meaning per user-data dword (the halves share the SGPRs; both halves' ranges of one table pointer are kept), merged root layout. emit::translate_merged_gs(es, gs) runs a pair through tracing and I/O raising.
  • emit::emit refuses a geometry program with GS_EMIT ("GS emit"); emit::translate now takes a geometry container that far too (it used to say the container had no vertex, pixel, compute or mesh program).
  • victory translate: geometry programs are counted on their own geometry line (programs, resources traced, I/O raised, stopped at GS emit) and no longer appear in the failure list. The ES half they pair with is not in their container, so the line says user data 0 and 1 are taken as free (an assumption, not a pairing).

Tested

  • New unit tests on synthetic GCN programs and containers (13): the runtime-table load in a geometry program, the same load in VS/PS/MS/ES still failing, the layout taking precedence, other SGPR pairs and an overwritten high half still failing, geometry I/O raising, ES+GS pairing and its refusals (swapped stages, wave size, conflicting user data), and synthetic containers going through translate and translate_merged_gs to GS emit.
  • cargo build --workspace --locked, cargo test --workspace --locked -- --test-threads=4: 511 passed, 0 failed, 7 ignored (Windows, this branch on current main, after the review fixes).

Not tested

  • victory translate over the title: not run, so the 195 moving from the failure list to the geometry line is expected, not measured. Those programs may stop earlier on something else (structurisation, an instruction the translator lacks); that would show as a new failure reason.
  • That s8/s9 is the runtime table's pointer is the issue's static analysis, not checked against the console runtime; its contents are not modeled.
  • No run in game: nothing the pipeline binds changes (the host still has no geometry path beyond the rectangle one).

Still to do (not in this PR)

  • Read the merged stage data (output signature, LDS layout of the records the ES half hands over).
  • The ES half and the ES to GS handoff through LDS (s_barrier, s_setpc_b64), GS input vertices.
  • Output records in LDS and GS_EMIT / GS_CUT / GS_DONE as DXIL stream emits; LDS in general.
  • A geometry-stage pipeline path: a pairing/cache key that carries both the ES and the GS container, the host pipeline with a translated geometry shader.

Follow-up issues, one per step: #311 (stage data), #312 (ES half and LDS handoff), #313 (GS output and GS_EMIT / GS_CUT), #314 (pipeline path). #138 stays open.

AI use
Written with Claude Code (Claude Sonnet 5.5). The tests are synthetic programs; no title shaders or game files were read.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593522027 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-24T23:29:06Z. --- Step 1 of #138 (the 195 `an address in an SGPR that is no root parameter` failures are one merged ES+GS shader). This does not translate geometry shaders. It makes the GS half read the merged stage's SGPRs, so that failure stops hiding what is left, and it stops cleanly at a named error instead. **What is in it** - `StageIo::Gs`: the GS record is now tagged (its stage data is still not read), and `io::raise` accepts it: no exports, and the first two user-data dwords (s8, s9 of the merged stage) are `Input::RuntimeTable`, the pointer the issue found at user data 0/1, when the root layout puts nothing there. - Resource tracking: through `resource::track_merged` (the merged layout of both halves), in a geometry program a load through that pair is traced to a new `resource::RUNTIME_TABLE` address (with the load's offset) instead of failing. It applies to the geometry stage only and only to dwords the merged layout leaves free; any other unbound SGPR pair, the same load in other stages, and a geometry program tracked on its own with plain `track` or `emit::translate` fail as before. A pointer whose high half was overwritten is refused. - `merged::pair_es_gs`: pairs the ES program (vertex container) with the GS program (geometry container): ES and GS stages, same wave size, one meaning per user-data dword (the halves share the SGPRs; both halves' ranges of one table pointer are kept), merged root layout. `emit::translate_merged_gs(es, gs)` runs a pair through tracing and I/O raising. - `emit::emit` refuses a geometry program with `GS_EMIT` ("GS emit"); `emit::translate` now takes a geometry container that far too (it used to say the container had no vertex, pixel, compute or mesh program). - `victory translate`: geometry programs are counted on their own `geometry` line (programs, resources traced, I/O raised, stopped at GS emit) and no longer appear in the failure list. The ES half they pair with is not in their container, so the line says user data 0 and 1 are taken as free (an assumption, not a pairing). **Tested** - New unit tests on synthetic GCN programs and containers (13): the runtime-table load in a geometry program, the same load in VS/PS/MS/ES still failing, the layout taking precedence, other SGPR pairs and an overwritten high half still failing, geometry I/O raising, ES+GS pairing and its refusals (swapped stages, wave size, conflicting user data), and synthetic containers going through `translate` and `translate_merged_gs` to `GS emit`. - `cargo build --workspace --locked`, `cargo test --workspace --locked -- --test-threads=4`: 511 passed, 0 failed, 7 ignored (Windows, this branch on current `main`, after the review fixes). **Not tested** - `victory translate` over the title: not run, so the 195 moving from the failure list to the `geometry` line is expected, not measured. Those programs may stop earlier on something else (structurisation, an instruction the translator lacks); that would show as a new failure reason. - That s8/s9 is the runtime table's pointer is the issue's static analysis, not checked against the console runtime; its contents are not modeled. - No run in game: nothing the pipeline binds changes (the host still has no geometry path beyond the rectangle one). **Still to do (not in this PR)** - Read the merged stage data (output signature, LDS layout of the records the ES half hands over). - The ES half and the ES to GS handoff through LDS (`s_barrier`, `s_setpc_b64`), GS input vertices. - Output records in LDS and `GS_EMIT` / `GS_CUT` / `GS_DONE` as DXIL stream emits; LDS in general. - A geometry-stage pipeline path: a pairing/cache key that carries both the ES and the GS container, the host pipeline with a translated geometry shader. Follow-up issues, one per step: #311 (stage data), #312 (ES half and LDS handoff), #313 (GS output and `GS_EMIT` / `GS_CUT`), #314 (pipeline path). #138 stays open. **AI use** Written with Claude Code (Claude Sonnet 5.5). The tests are synthetic programs; no title shaders or game files were read.
chatgpt-codex-connector[bot commented 2026-11-25 00:09:45 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:33:09Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ad26761f2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

<!-- greyfinch-sync:fxceless/victory-fork:review:6049109976 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#pullrequestreview-6049109976). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:33:09Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `5ad26761f2` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". 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". </details>
chatgpt-codex-connector[bot commented 2026-11-25 00:10:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:29:20Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T09:39:51.428622Z 90ec93b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147456714 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#issuecomment-7147456714). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:29:20Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"90ec93bef615698d59c5e633e72f0ad97dfb1532","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T09:39:51.428622Z">2026-11-25T09:39:51.428622Z</relative-time> | `90ec93b` | Manual request | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Revens2 commented 2026-11-25 00:10:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-24T23:45:57Z.


Both review findings fixed in the new commit on this branch.

  • Shared table pointer (merged.rs): pair_es_gs now keeps both halves' ranges when they list the same descriptor-table root parameter (same user data, SGPR count and root slot) with a different table offset or base register. A different root parameter or type on the same dword is still a conflict. New test: the_same_table_pointer_with_other_ranges_in_each_half_is_one_parameter.
  • Runtime table inference (resource.rs): it is made only through resource::track_merged, i.e. with the merged layout of a pair (translate_merged_gs), no longer by plain track. A geometry container on its own (emit::translate) fails again with "an address in an SGPR that is no root parameter", since its ES half could own those dwords. victory translate cannot pair containers, so it still tracks geometry programs with track_merged, and its geometry line now says the ES half is unpaired and user data 0 and 1 are taken as free. New tests: the_runtime_table_needs_the_merged_layout, a_geometry_container_alone_does_not_trace.

Tested: cargo build --workspace --locked, cargo test --workspace --locked -- --test-threads=4: 511 passed, 0 failed, 7 ignored (Windows). Not run in game, not measured over the title.

Written with Claude Code (Claude Sonnet 5.5).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147769660 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#issuecomment-7147769660). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-24T23:45:57Z. --- Both review findings fixed in the new commit on this branch. - **Shared table pointer (`merged.rs`)**: `pair_es_gs` now keeps both halves' ranges when they list the same descriptor-table root parameter (same user data, SGPR count and root slot) with a different table offset or base register. A different root parameter or type on the same dword is still a conflict. New test: `the_same_table_pointer_with_other_ranges_in_each_half_is_one_parameter`. - **Runtime table inference (`resource.rs`)**: it is made only through `resource::track_merged`, i.e. with the merged layout of a pair (`translate_merged_gs`), no longer by plain `track`. A geometry container on its own (`emit::translate`) fails again with "an address in an SGPR that is no root parameter", since its ES half could own those dwords. `victory translate` cannot pair containers, so it still tracks geometry programs with `track_merged`, and its geometry line now says the ES half is unpaired and user data 0 and 1 are taken as free. New tests: `the_runtime_table_needs_the_merged_layout`, `a_geometry_container_alone_does_not_trace`. Tested: `cargo build --workspace --locked`, `cargo test --workspace --locked -- --test-threads=4`: 511 passed, 0 failed, 7 ignored (Windows). Not run in game, not measured over the title. Written with Claude Code (Claude Sonnet 5.5).
chatgpt-codex-connector[bot commented 2026-11-25 00:10:13 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:33:09Z.

Code review location: crates/victory-shader/src/merged.rs; line 79

@@ -0,0 +1,156 @@
+//! The merged ES+GS stage (a geometry shader), step 1 of its support.
+//!
+//! The console links two programs into one hardware stage when it creates a
+//! pipeline with a geometry shader: the ES program, which sits in the vertex
+//! container next to the ordinary VS, and the GS program, which is all the
+//! geometry container holds. Both run on the same wave, so they share one
+//! SGPR file: eight system SGPRs first, then the user data of the root
+//! signature ([`HwStage::user_sgpr`]).
+//!
+//! What this step knows, from the title's programs as the issue on this
+//! (fork issue 138) writes it down (static analysis, not a run):
+//!
+//! * The GS half loads from a pointer in user data 0 and 1 (s8 and s9) that
+//!   is no root parameter: the console runtime's own table. [`RUNTIME_TABLE`]
+//!   names it; resource tracking takes the pair as that table when the root
+//!   layout puts nothing there, and [`crate::io::Input::RuntimeTable`] names
+//!   the two dwords.
+//! * A root parameter is the same in both halves: [`pair_es_gs`] merges the
+//!   two layouts and refuses programs that disagree about a user-data dword.
+//!
+//! What it does not do yet: translate the stage. The ES half hands its
+//! records over through LDS, the GS half reads them from there and writes
+//! its output vertices there too, with `s_sendmsg` GS_EMIT, GS_CUT and
+//! GS_DONE; none of that is modeled. Emission refuses a geometry program with
+//! [`crate::emit::GS_EMIT`].
+
+use crate::ShaderError::{self, Malformed};
+use crate::native::{HwStage, NativeProgram, RootParam};
+
+/// The first user-data dword of the runtime table pointer: it takes dwords 0
+/// (low half) and 1 (high half) of the merged stage's user data.
+pub const RUNTIME_TABLE: u8 = 0;
+
+/// An ES program and the GS program it is linked with.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct MergedGs {
+    pub es: NativeProgram,
+    pub gs: NativeProgram,
+    /// The root parameters of the merged stage: those of either half, by user
+    /// data (a parameter both halves list is in it once).
+    pub layout: Vec<RootParam>,
+}
+
+impl MergedGs {
+    /// The GS program as the merged stage runs it: the code of the GS half
+    /// with the root layout of both halves, which is what its user SGPRs
+    /// hold.
+    pub fn program(&self) -> NativeProgram {
+        NativeProgram {
+            layout: self.layout.clone(),
+            ..self.gs.clone()
+        }
+    }
+}
+
+/// Pairs an ES program with the GS program of the same pipeline.
+///
+/// Fails when the programs are not an ES and a GS, run at different wave
+/// sizes, or disagree about what a user-data dword holds (the two halves
+/// share the SGPRs, so a dword has one meaning).
+pub fn pair_es_gs(es: NativeProgram, gs: NativeProgram) -> Result<MergedGs, ShaderError> {
+    if es.stage != HwStage::Es {
+        return Err(Malformed("the vertex half of a merged stage is not an ES program"));
+    }
+    if gs.stage != HwStage::Gs {
+        return Err(Malformed("the geometry half of a merged stage is not a GS program"));
+    }
+    if es.wave64 != gs.wave64 {
+        return Err(Malformed("ES and GS programs run at different wave sizes"));
+    }
+    let mut layout = es.layout.clone();
+    for g in &gs.layout {
+        let overlaps = |e: &RootParam| {
+            let end = |p: &RootParam| u32::from(p.user_data) + p.sgprs;
+            u32::from(e.user_data) < end(g) && u32::from(g.user_data) < end(e)
+        };
+        match layout.iter().find(|e| overlaps(e)) {
+            Some(e) if e == g => {}
+            Some(_) => return Err(Malformed("ES and GS programs disagree about a user-data dword")),

P2 Badge Allow shared table pointers with distinct range mappings

When ES and GS use different ranges of the same descriptor-table root parameter, their RootParams overlap at the same user-data pointer but can differ in table_offset_dwords or base_register. Since a RootParam can encode a table range, this branch rejects a valid pair as a dword conflict, so translate_merged_gs never reaches resource tracking or GS_EMIT. Treat entries for the same table pointer as compatible while retaining both range mappings.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:fxceless/victory-fork:review-comment:4688013999 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#discussion_r4688013999). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:33:09Z. **Code review location:** `crates/victory-shader/src/merged.rs`; line 79 ~~~~diff @@ -0,0 +1,156 @@ +//! The merged ES+GS stage (a geometry shader), step 1 of its support. +//! +//! The console links two programs into one hardware stage when it creates a +//! pipeline with a geometry shader: the ES program, which sits in the vertex +//! container next to the ordinary VS, and the GS program, which is all the +//! geometry container holds. Both run on the same wave, so they share one +//! SGPR file: eight system SGPRs first, then the user data of the root +//! signature ([`HwStage::user_sgpr`]). +//! +//! What this step knows, from the title's programs as the issue on this +//! (fork issue 138) writes it down (static analysis, not a run): +//! +//! * The GS half loads from a pointer in user data 0 and 1 (s8 and s9) that +//! is no root parameter: the console runtime's own table. [`RUNTIME_TABLE`] +//! names it; resource tracking takes the pair as that table when the root +//! layout puts nothing there, and [`crate::io::Input::RuntimeTable`] names +//! the two dwords. +//! * A root parameter is the same in both halves: [`pair_es_gs`] merges the +//! two layouts and refuses programs that disagree about a user-data dword. +//! +//! What it does not do yet: translate the stage. The ES half hands its +//! records over through LDS, the GS half reads them from there and writes +//! its output vertices there too, with `s_sendmsg` GS_EMIT, GS_CUT and +//! GS_DONE; none of that is modeled. Emission refuses a geometry program with +//! [`crate::emit::GS_EMIT`]. + +use crate::ShaderError::{self, Malformed}; +use crate::native::{HwStage, NativeProgram, RootParam}; + +/// The first user-data dword of the runtime table pointer: it takes dwords 0 +/// (low half) and 1 (high half) of the merged stage's user data. +pub const RUNTIME_TABLE: u8 = 0; + +/// An ES program and the GS program it is linked with. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct MergedGs { + pub es: NativeProgram, + pub gs: NativeProgram, + /// The root parameters of the merged stage: those of either half, by user + /// data (a parameter both halves list is in it once). + pub layout: Vec<RootParam>, +} + +impl MergedGs { + /// The GS program as the merged stage runs it: the code of the GS half + /// with the root layout of both halves, which is what its user SGPRs + /// hold. + pub fn program(&self) -> NativeProgram { + NativeProgram { + layout: self.layout.clone(), + ..self.gs.clone() + } + } +} + +/// Pairs an ES program with the GS program of the same pipeline. +/// +/// Fails when the programs are not an ES and a GS, run at different wave +/// sizes, or disagree about what a user-data dword holds (the two halves +/// share the SGPRs, so a dword has one meaning). +pub fn pair_es_gs(es: NativeProgram, gs: NativeProgram) -> Result<MergedGs, ShaderError> { + if es.stage != HwStage::Es { + return Err(Malformed("the vertex half of a merged stage is not an ES program")); + } + if gs.stage != HwStage::Gs { + return Err(Malformed("the geometry half of a merged stage is not a GS program")); + } + if es.wave64 != gs.wave64 { + return Err(Malformed("ES and GS programs run at different wave sizes")); + } + let mut layout = es.layout.clone(); + for g in &gs.layout { + let overlaps = |e: &RootParam| { + let end = |p: &RootParam| u32::from(p.user_data) + p.sgprs; + u32::from(e.user_data) < end(g) && u32::from(g.user_data) < end(e) + }; + match layout.iter().find(|e| overlaps(e)) { + Some(e) if e == g => {} + Some(_) => return Err(Malformed("ES and GS programs disagree about a user-data dword")), ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Allow shared table pointers with distinct range mappings** When ES and GS use different ranges of the same descriptor-table root parameter, their `RootParam`s overlap at the same user-data pointer but can differ in `table_offset_dwords` or `base_register`. Since a `RootParam` can encode a table range, this branch rejects a valid pair as a dword conflict, so `translate_merged_gs` never reaches resource tracking or `GS_EMIT`. Treat entries for the same table pointer as compatible while retaining both range mappings. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 00:10:13 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:33:09Z.

Code review location: crates/victory-shader/src/resource.rs; line 600

@@ -582,6 +589,17 @@ impl<'a> Tracer<'a> {
         })
     }
 
+    /// Whether `reg` is the low half of the console runtime's table pointer
+    /// ([`RUNTIME_TABLE`]): the first two user-data dwords of a geometry
+    /// program, when the root layout puts no parameter on either.
+    fn runtime_table(&self, reg: Reg) -> bool {
+        let first = self.stage.user_sgpr(crate::merged::RUNTIME_TABLE);
+        self.stage == HwStage::Gs
+            && reg == Reg::S(first)
+            && self.param_of(reg).is_none()
+            && self.param_of(Reg::S(first + 1)).is_none()

P2 Badge Consult the merged layout before classifying a runtime-table load

If the ES half owns user-data dword 0 or 1 but the GS record omits that parameter, this check sees both dwords as free and classifies an s_load through s8:s9 as a runtime-table access. The batch path in apps/victory/src/translate.rs::translate_programs calls resource::track with the GS-only p.layout, so it can report those root-parameter reads as successfully traced; only translate_merged_gs supplies the union. Use the merged layout for this inference, or avoid making it for an unpaired GS.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:fxceless/victory-fork:review-comment:4688014007 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#discussion_r4688014007). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:33:09Z. **Code review location:** `crates/victory-shader/src/resource.rs`; line 600 ~~~~diff @@ -582,6 +589,17 @@ impl<'a> Tracer<'a> { }) } + /// Whether `reg` is the low half of the console runtime's table pointer + /// ([`RUNTIME_TABLE`]): the first two user-data dwords of a geometry + /// program, when the root layout puts no parameter on either. + fn runtime_table(&self, reg: Reg) -> bool { + let first = self.stage.user_sgpr(crate::merged::RUNTIME_TABLE); + self.stage == HwStage::Gs + && reg == Reg::S(first) + && self.param_of(reg).is_none() + && self.param_of(Reg::S(first + 1)).is_none() ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Consult the merged layout before classifying a runtime-table load** If the ES half owns user-data dword 0 or 1 but the GS record omits that parameter, this check sees both dwords as free and classifies an `s_load` through `s8:s9` as a runtime-table access. The batch path in `apps/victory/src/translate.rs::translate_programs` calls `resource::track` with the GS-only `p.layout`, so it can report those root-parameter reads as successfully traced; only `translate_merged_gs` supplies the union. Use the merged layout for this inference, or avoid making it for an unpaired GS. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Revens2 commented 2026-11-25 08:08:57 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-25T07:10:09Z.


Rebased on main (a26859f), head now 90ec93b. One conflict (the doc comment of translate), resolved by keeping both texts. The two commits and the review fixes are unchanged in meaning. cargo build --workspace --locked ok; cargo test -p victory-shader -p victory-gpu --locked: 137 + 230 passed, 0 failed. Ready for another review pass.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7155562971 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#issuecomment-7155562971). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-25T07:10:09Z. --- Rebased on main (a26859f), head now 90ec93b. One conflict (the doc comment of `translate`), resolved by keeping both texts. The two commits and the review fixes are unchanged in meaning. `cargo build --workspace --locked` ok; `cargo test -p victory-shader -p victory-gpu --locked`: 137 + 230 passed, 0 failed. Ready for another review pass.
chatgpt-codex-connector[bot commented 2026-11-25 10:10:51 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T09:39:49Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90ec93bef6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

<!-- greyfinch-sync:fxceless/victory-fork:review:6055131431 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#pullrequestreview-6055131431). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T09:39:49Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `90ec93bef6` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". 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". </details>
Revens2 commented 2026-11-25 10:11:12 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-25T09:35:18Z.


@codex review (head rebased on origin/main; earlier findings were addressed before the rebase)

<!-- greyfinch-sync:fxceless/victory-fork:comment:7158532722 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#issuecomment-7158532722). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-25T09:35:18Z. --- @codex review (head rebased on origin/main; earlier findings were addressed before the rebase)
chatgpt-codex-connector[bot commented 2026-11-25 10:11:18 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T09:39:49Z.

Code review location: crates/victory-shader/src/io.rs; line 316

@@ -302,6 +306,21 @@ pub fn raise(p: &Program, native: &NativeProgram) -> Result<Io, ShaderError> {
             ];
             (loaded, &[][..], &ms.outputs[..])
         }
+        // The GS half of a merged ES+GS stage: no exports (its output goes
+        // through LDS, not modeled yet); the runtime table pointer is the one
+        // input known. The root layout wins where it covers those dwords.
+        (StageIo::Gs, HwStage::Gs) => {
+            let first = native.stage.user_sgpr(crate::merged::RUNTIME_TABLE);
+            let taken = native.layout.iter().any(|p| {
+                let at = u32::from(native.stage.user_sgpr(p.user_data));
+                at < u32::from(first) + 2 && u32::from(first) < at + p.sgprs

P2 Badge Check geometry root-range arithmetic before adding

For a malformed GS FSSM entry with user_data = 0 and sgprs near u32::MAX, native_programs preserves the raw sgprs, so this end calculation can overflow: overflow-checking builds panic, while wrapping builds can mark s8:s9 as free and report them as RuntimeTable inputs instead of rejecting the layout. Use a checked or bounded end here and in merged::pair_es_gs, which makes the same calculation.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:fxceless/victory-fork:review-comment:4692983289 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#discussion_r4692983289). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T09:39:49Z. **Code review location:** `crates/victory-shader/src/io.rs`; line 316 ~~~~diff @@ -302,6 +306,21 @@ pub fn raise(p: &Program, native: &NativeProgram) -> Result<Io, ShaderError> { ]; (loaded, &[][..], &ms.outputs[..]) } + // The GS half of a merged ES+GS stage: no exports (its output goes + // through LDS, not modeled yet); the runtime table pointer is the one + // input known. The root layout wins where it covers those dwords. + (StageIo::Gs, HwStage::Gs) => { + let first = native.stage.user_sgpr(crate::merged::RUNTIME_TABLE); + let taken = native.layout.iter().any(|p| { + let at = u32::from(native.stage.user_sgpr(p.user_data)); + at < u32::from(first) + 2 && u32::from(first) < at + p.sgprs ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Check geometry root-range arithmetic before adding** For a malformed GS FSSM entry with `user_data = 0` and `sgprs` near `u32::MAX`, `native_programs` preserves the raw `sgprs`, so this end calculation can overflow: overflow-checking builds panic, while wrapping builds can mark s8:s9 as free and report them as `RuntimeTable` inputs instead of rejecting the layout. Use a checked or bounded end here and in `merged::pair_es_gs`, which makes the same calculation. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
slauko commented 2026-11-26 11:05:32 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by slauko on 2026-11-26T10:44:39Z.


A number for step 1, from a Wine run of the title (RTX 3080 Ti, vkd3d-proton ec20719, uiliannn's line):

victory translate --list over the pack names every refusal. Of 228 refused containers, 196 are the title's voxelization geometry shaders, all refused at the same place:

shaders.rpf@0xbd7b8e3 GS_VoxelizeGeneric_b300ca2e_Wrapped #d82a0a5a22471c77 ~b8bb2fac Gs at 0x44
    resources: an address in an SGPR that is no root parameter

(the rest: 29 FidelityFX containers with no DXIL part (SM5 or older), one shadow-mask compute program with a lane mask holding lanes elsewhere read as data.)

What those 196 cost a run: the pipeline library has no pipeline whose stage set includes one of them, so every draw that binds such a pipeline is dropped — in the cell, 340 to 350 of ~5,000 draws a frame (dropped ... without a host pipeline), and 1,017 pipelines bound once that never get made. That is the title's voxelized (traced-shadow/GI) work, so nothing that would show on screen as geometry; it is the lighting side.

If step 1 makes the stage read its SGPRs, that alone would put ~1,000 pipelines and ~350 draws a frame back into the run here. Not a speed claim — the draws are missing, so they would cost frame time — but a picture claim.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7189775936 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/309#issuecomment-7189775936). Originally posted by [slauko](https://github.com/slauko) on 2026-11-26T10:44:39Z. --- A number for step 1, from a Wine run of the title (RTX 3080 Ti, vkd3d-proton `ec20719`, uiliannn's line): `victory translate --list` over the pack names every refusal. Of 228 refused containers, **196 are the title's voxelization geometry shaders**, all refused at the same place: ``` shaders.rpf@0xbd7b8e3 GS_VoxelizeGeneric_b300ca2e_Wrapped #d82a0a5a22471c77 ~b8bb2fac Gs at 0x44 resources: an address in an SGPR that is no root parameter ``` (the rest: 29 FidelityFX containers with `no DXIL part (SM5 or older)`, one shadow-mask compute program with `a lane mask holding lanes elsewhere read as data`.) What those 196 cost a run: the pipeline library has no pipeline whose stage set includes one of them, so every draw that binds such a pipeline is dropped — in the cell, **340 to 350 of ~5,000 draws a frame** (`dropped ... without a host pipeline`), and 1,017 pipelines bound once that never get made. That is the title's voxelized (traced-shadow/GI) work, so nothing that would show on screen as geometry; it is the lighting side. If step 1 makes the stage read its SGPRs, that alone would put ~1,000 pipelines and ~350 draws a frame back into the run here. Not a speed claim — the draws are missing, so they would *cost* frame time — but a picture claim.
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/309:upstream-pr/309'
git switch 'upstream-pr/309'

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/309'
git switch 'upstream-pr/309'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/309'
git switch 'upstream-pr/309'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/309'
git switch 'main'
git merge --squash 'upstream-pr/309'
git switch 'main'
git merge --ff-only 'upstream-pr/309'
git switch 'main'
git merge 'upstream-pr/309'
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!309
No description provided.