GPU: say which part of a refused mesh pipeline the driver refuses #436

Open
sennecools wants to merge 1 commit from upstream-pr/436 into main
sennecools commented 2026-11-25 00:49:16 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by sennecools on 2026-11-25T00:49:16Z.


Without the debug layer the driver refuses a mesh pipeline with only E_INVALIDARG, which says nothing about the cause.

When a mesh pipeline is refused, it is now made again, outside the pipeline library, with one part of its description after another made neutral:

  1. the blend state and sample mask;
  2. the rasterizer state;
  3. the depth and stencil state (depth off);
  4. the target formats, depth format and sample count;
  5. without its pixel shader.

Each step keeps the earlier ones. The "host mesh pipeline refused" warning names the first part whose neutral form the driver accepts, and also gives the root parameter and static sampler counts and the state text. Only refused pipelines pay for the extra attempts; nothing changes for pipelines that are accepted.

Testing:

  • new test a_refused_mesh_pipeline_names_the_part_refused: breaks each part on purpose and checks the name, and checks a pixel shader that reads an input the mesh shader does not write. It skips without mesh shader support or without the PC dxc.exe, like the library test;
  • cargo test -p victory-gpu --features victory-gpu/diagnostics on WARP: 120 passed (the mesh tests ran);
  • clippy -D warnings clean, asset policy ok;
  • not tried in a game run: this change only adds diagnostics.

AI-assisted.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6594543366 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/436). Originally posted by [sennecools](https://github.com/sennecools) on 2026-11-25T00:49:16Z. --- Without the debug layer the driver refuses a mesh pipeline with only E_INVALIDARG, which says nothing about the cause. When a mesh pipeline is refused, it is now made again, outside the pipeline library, with one part of its description after another made neutral: 1. the blend state and sample mask; 2. the rasterizer state; 3. the depth and stencil state (depth off); 4. the target formats, depth format and sample count; 5. without its pixel shader. Each step keeps the earlier ones. The "host mesh pipeline refused" warning names the first part whose neutral form the driver accepts, and also gives the root parameter and static sampler counts and the state text. Only refused pipelines pay for the extra attempts; nothing changes for pipelines that are accepted. Testing: - new test `a_refused_mesh_pipeline_names_the_part_refused`: breaks each part on purpose and checks the name, and checks a pixel shader that reads an input the mesh shader does not write. It skips without mesh shader support or without the PC dxc.exe, like the library test; - `cargo test -p victory-gpu --features victory-gpu/diagnostics` on WARP: 120 passed (the mesh tests ran); - clippy -D warnings clean, asset policy ok; - not tried in a game run: this change only adds diagnostics. AI-assisted.
chatgpt-codex-connector[bot commented 2026-11-25 01:11:49 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:52:58Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f1d56b6eb

ℹ️ 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:6049875600 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/436#pullrequestreview-6049875600). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:52:58Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `0f1d56b6eb` <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 01:12:05 +00:00 (Migrated from github.com)

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


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-25T00:53:00.252282Z 0f1d56b PR opened
ℹ️ 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:7148916471 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/436#issuecomment-7148916471). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:49:28Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"0f1d56b6eb982dc10ec3d695ea8f4ca15ff3a2f2","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-25T00:53:00.252282Z">2026-11-25T00:53:00.252282Z</relative-time> | `0f1d56b` | PR opened | <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>
chatgpt-codex-connector[bot commented 2026-11-25 01:12:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:52:58Z.

Code review location: crates/victory-gpu/src/pipeline/host.rs; line 854

@@ -778,13 +794,74 @@ fn mesh_pipeline(
         pPipelineStateSubobjectStream: (&raw mut stream).cast(),
     };
     let device = device.cast::<ID3D12Device2>()?;
-    super::library::pipeline(
-        name,
-        // SAFETY: the stream holds whole subobjects pointing at live data.
-        |library, name| unsafe { library.LoadPipeline(name, &desc) },
-        // SAFETY: as above.
-        || unsafe { device.CreatePipelineState(&desc) },
-    )
+    // SAFETY: the stream holds whole subobjects pointing at live data.
+    let create = || unsafe { device.CreatePipelineState(&desc) };
+    match name {
+        Some(name) => super::library::pipeline(
+            name,
+            // SAFETY: as above.
+            |library, name| unsafe { library.LoadPipeline(name, &desc) },
+            create,
+        ),
+        None => create(),
+    }
+}
+
+/// Which part of a refused mesh pipeline's description the driver refuses:
+/// it is made again (outside the library) with one part after another made
+/// neutral, and the part whose neutral form is first accepted is named.
+/// Each step keeps the ones before it, so the part named is one the
+/// pipeline needs changed once those before it are neutral too.
+fn mesh_refusal(
+    device: &ID3D12Device,
+    root: &ID3D12RootSignature,
+    ms: D3D12_SHADER_BYTECODE,
+    ps: D3D12_SHADER_BYTECODE,
+    g: &GraphicsState,
+) -> &'static str {
+    let neutral = GraphicsState::default();
+    let mut s = GraphicsState {
+        blend: g.blend,
+        sample_mask: g.sample_mask,
+        rasterizer: g.rasterizer,
+        depth: g.depth,
+        targets: g.targets,
+        depth_format: g.depth_format,
+        samples: g.samples,
+        ..GraphicsState::default()
+    };
+    let accepted = |s: &GraphicsState, ps| mesh_pipeline(device, root, ms, ps, s, None).is_ok();
+    s.blend = neutral.blend;
+    s.sample_mask = neutral.sample_mask;
+    if accepted(&s, ps) {
+        return "the blend state or sample mask";
+    }
+    s.rasterizer = neutral.rasterizer;
+    if accepted(&s, ps) {
+        return "the rasterizer state";
+    }
+    // Off rather than D3D12's default, which tests depth: valid with any
+    // depth format, and with none (the next step).
+    s.depth = D3D12_DEPTH_STENCIL_DESC {
+        DepthEnable: false.into(),
+        ..neutral.depth
+    };
+    if accepted(&s, ps) {
+        return "the depth and stencil state";
+    }
+    s.targets = D3D12_RT_FORMAT_ARRAY::default();
+    s.targets.NumRenderTargets = 1;
+    s.targets.RTFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;

P2 Badge Match neutral target formats to the pixel-output types

For a pipeline with a valid uint pixel output and R32_UINT RTV that is refused because samples.Count == 0, this probe fixes the sample count but introduces a new PS-output/RTV type mismatch by replacing the RTV with UNORM. That attempt still fails, while removing the otherwise-valid PS succeeds, so the warning incorrectly identifies the pixel shader/linkage instead of the sample-count/format state. Select neutral RTV formats compatible with the PS output signature, as target_format in crates/victory-shader/src/emit/host.rs does, and extend the sample-count test case to cover an integer-output PS.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:fxceless/victory-fork:review-comment:4688698508 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/436#discussion_r4688698508). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:52:58Z. **Code review location:** `crates/victory-gpu/src/pipeline/host.rs`; line 854 ~~~~diff @@ -778,13 +794,74 @@ fn mesh_pipeline( pPipelineStateSubobjectStream: (&raw mut stream).cast(), }; let device = device.cast::<ID3D12Device2>()?; - super::library::pipeline( - name, - // SAFETY: the stream holds whole subobjects pointing at live data. - |library, name| unsafe { library.LoadPipeline(name, &desc) }, - // SAFETY: as above. - || unsafe { device.CreatePipelineState(&desc) }, - ) + // SAFETY: the stream holds whole subobjects pointing at live data. + let create = || unsafe { device.CreatePipelineState(&desc) }; + match name { + Some(name) => super::library::pipeline( + name, + // SAFETY: as above. + |library, name| unsafe { library.LoadPipeline(name, &desc) }, + create, + ), + None => create(), + } +} + +/// Which part of a refused mesh pipeline's description the driver refuses: +/// it is made again (outside the library) with one part after another made +/// neutral, and the part whose neutral form is first accepted is named. +/// Each step keeps the ones before it, so the part named is one the +/// pipeline needs changed once those before it are neutral too. +fn mesh_refusal( + device: &ID3D12Device, + root: &ID3D12RootSignature, + ms: D3D12_SHADER_BYTECODE, + ps: D3D12_SHADER_BYTECODE, + g: &GraphicsState, +) -> &'static str { + let neutral = GraphicsState::default(); + let mut s = GraphicsState { + blend: g.blend, + sample_mask: g.sample_mask, + rasterizer: g.rasterizer, + depth: g.depth, + targets: g.targets, + depth_format: g.depth_format, + samples: g.samples, + ..GraphicsState::default() + }; + let accepted = |s: &GraphicsState, ps| mesh_pipeline(device, root, ms, ps, s, None).is_ok(); + s.blend = neutral.blend; + s.sample_mask = neutral.sample_mask; + if accepted(&s, ps) { + return "the blend state or sample mask"; + } + s.rasterizer = neutral.rasterizer; + if accepted(&s, ps) { + return "the rasterizer state"; + } + // Off rather than D3D12's default, which tests depth: valid with any + // depth format, and with none (the next step). + s.depth = D3D12_DEPTH_STENCIL_DESC { + DepthEnable: false.into(), + ..neutral.depth + }; + if accepted(&s, ps) { + return "the depth and stencil state"; + } + s.targets = D3D12_RT_FORMAT_ARRAY::default(); + s.targets.NumRenderTargets = 1; + s.targets.RTFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Match neutral target formats to the pixel-output types** For a pipeline with a valid `uint` pixel output and `R32_UINT` RTV that is refused because `samples.Count == 0`, this probe fixes the sample count but introduces a new PS-output/RTV type mismatch by replacing the RTV with UNORM. That attempt still fails, while removing the otherwise-valid PS succeeds, so the warning incorrectly identifies the pixel shader/linkage instead of the sample-count/format state. Select neutral RTV formats compatible with the PS output signature, as `target_format` in `crates/victory-shader/src/emit/host.rs` does, and extend the sample-count test case to cover an integer-output PS. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
sennecools commented 2026-11-25 02:09:33 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by sennecools on 2026-11-25T02:05:27Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:fxceless/victory-fork:review:6050552362 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/436#pullrequestreview-6050552362). Originally posted by [sennecools](https://github.com/sennecools) on 2026-11-25T02:05:27Z. **Review:** COMMENTED --- _No description provided._
sennecools commented 2026-11-25 02:10:15 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by sennecools on 2026-11-25T02:05:27Z.

Code review location: crates/victory-gpu/src/pipeline/host.rs; line 854

@@ -778,13 +794,74 @@ fn mesh_pipeline(
         pPipelineStateSubobjectStream: (&raw mut stream).cast(),
     };
     let device = device.cast::<ID3D12Device2>()?;
-    super::library::pipeline(
-        name,
-        // SAFETY: the stream holds whole subobjects pointing at live data.
-        |library, name| unsafe { library.LoadPipeline(name, &desc) },
-        // SAFETY: as above.
-        || unsafe { device.CreatePipelineState(&desc) },
-    )
+    // SAFETY: the stream holds whole subobjects pointing at live data.
+    let create = || unsafe { device.CreatePipelineState(&desc) };
+    match name {
+        Some(name) => super::library::pipeline(
+            name,
+            // SAFETY: as above.
+            |library, name| unsafe { library.LoadPipeline(name, &desc) },
+            create,
+        ),
+        None => create(),
+    }
+}
+
+/// Which part of a refused mesh pipeline's description the driver refuses:
+/// it is made again (outside the library) with one part after another made
+/// neutral, and the part whose neutral form is first accepted is named.
+/// Each step keeps the ones before it, so the part named is one the
+/// pipeline needs changed once those before it are neutral too.
+fn mesh_refusal(
+    device: &ID3D12Device,
+    root: &ID3D12RootSignature,
+    ms: D3D12_SHADER_BYTECODE,
+    ps: D3D12_SHADER_BYTECODE,
+    g: &GraphicsState,
+) -> &'static str {
+    let neutral = GraphicsState::default();
+    let mut s = GraphicsState {
+        blend: g.blend,
+        sample_mask: g.sample_mask,
+        rasterizer: g.rasterizer,
+        depth: g.depth,
+        targets: g.targets,
+        depth_format: g.depth_format,
+        samples: g.samples,
+        ..GraphicsState::default()
+    };
+    let accepted = |s: &GraphicsState, ps| mesh_pipeline(device, root, ms, ps, s, None).is_ok();
+    s.blend = neutral.blend;
+    s.sample_mask = neutral.sample_mask;
+    if accepted(&s, ps) {
+        return "the blend state or sample mask";
+    }
+    s.rasterizer = neutral.rasterizer;
+    if accepted(&s, ps) {
+        return "the rasterizer state";
+    }
+    // Off rather than D3D12's default, which tests depth: valid with any
+    // depth format, and with none (the next step).
+    s.depth = D3D12_DEPTH_STENCIL_DESC {
+        DepthEnable: false.into(),
+        ..neutral.depth
+    };
+    if accepted(&s, ps) {
+        return "the depth and stencil state";
+    }
+    s.targets = D3D12_RT_FORMAT_ARRAY::default();
+    s.targets.NumRenderTargets = 1;
+    s.targets.RTFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;

Thanks for the review. I checked this: D3D12 does not refuse a pipeline whose pixel output type differs from the render target type (the result is undefined values, not an invalid pipeline). A pixel shader with an integer output and the neutral UNORM target is accepted (checked on WARP), so a pipeline refused only for its sample count is still reported as the target formats, depth format or sample count. No change needed.

AI-assisted.

<!-- greyfinch-sync:fxceless/victory-fork:review-comment:4689276278 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/436#discussion_r4689276278). Originally posted by [sennecools](https://github.com/sennecools) on 2026-11-25T02:05:27Z. **Code review location:** `crates/victory-gpu/src/pipeline/host.rs`; line 854 ~~~~diff @@ -778,13 +794,74 @@ fn mesh_pipeline( pPipelineStateSubobjectStream: (&raw mut stream).cast(), }; let device = device.cast::<ID3D12Device2>()?; - super::library::pipeline( - name, - // SAFETY: the stream holds whole subobjects pointing at live data. - |library, name| unsafe { library.LoadPipeline(name, &desc) }, - // SAFETY: as above. - || unsafe { device.CreatePipelineState(&desc) }, - ) + // SAFETY: the stream holds whole subobjects pointing at live data. + let create = || unsafe { device.CreatePipelineState(&desc) }; + match name { + Some(name) => super::library::pipeline( + name, + // SAFETY: as above. + |library, name| unsafe { library.LoadPipeline(name, &desc) }, + create, + ), + None => create(), + } +} + +/// Which part of a refused mesh pipeline's description the driver refuses: +/// it is made again (outside the library) with one part after another made +/// neutral, and the part whose neutral form is first accepted is named. +/// Each step keeps the ones before it, so the part named is one the +/// pipeline needs changed once those before it are neutral too. +fn mesh_refusal( + device: &ID3D12Device, + root: &ID3D12RootSignature, + ms: D3D12_SHADER_BYTECODE, + ps: D3D12_SHADER_BYTECODE, + g: &GraphicsState, +) -> &'static str { + let neutral = GraphicsState::default(); + let mut s = GraphicsState { + blend: g.blend, + sample_mask: g.sample_mask, + rasterizer: g.rasterizer, + depth: g.depth, + targets: g.targets, + depth_format: g.depth_format, + samples: g.samples, + ..GraphicsState::default() + }; + let accepted = |s: &GraphicsState, ps| mesh_pipeline(device, root, ms, ps, s, None).is_ok(); + s.blend = neutral.blend; + s.sample_mask = neutral.sample_mask; + if accepted(&s, ps) { + return "the blend state or sample mask"; + } + s.rasterizer = neutral.rasterizer; + if accepted(&s, ps) { + return "the rasterizer state"; + } + // Off rather than D3D12's default, which tests depth: valid with any + // depth format, and with none (the next step). + s.depth = D3D12_DEPTH_STENCIL_DESC { + DepthEnable: false.into(), + ..neutral.depth + }; + if accepted(&s, ps) { + return "the depth and stencil state"; + } + s.targets = D3D12_RT_FORMAT_ARRAY::default(); + s.targets.NumRenderTargets = 1; + s.targets.RTFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; ~~~~ --- Thanks for the review. I checked this: D3D12 does not refuse a pipeline whose pixel output type differs from the render target type (the result is undefined values, not an invalid pipeline). A pixel shader with an integer output and the neutral UNORM target is accepted (checked on WARP), so a pipeline refused only for its sample count is still reported as the target formats, depth format or sample count. No change needed. AI-assisted.
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/436:upstream-pr/436'
git switch 'upstream-pr/436'

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