Skip to content

translate --pipelines: driver reasons for refusals, and --only <stages> (#2537) - #2562

Open
oni-swr wants to merge 3 commits into
Marvisak:mainfrom
oni-swr:t3/victory-2537-d3d12-debug-pipelines
Open

oni-swr wants to merge 3 commits into
Marvisak:mainfrom
oni-swr:t3/victory-2537-d3d12-debug-pipelines

Conversation

@oni-swr

@oni-swr oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

What

Fixes #2537.

  • VICTORY_D3D12_DEBUG now reaches the device translate --pipelines creates (emit::host::Host::new), in a diagnostics build and before the first device of the process (so also before the census's initial probe). A refused root signature or pipeline then reads <error>; debug layer: id N: <message>; ... instead of a bare error code. Gating matches victory-gpu (diagnostics feature, 0 is off).
  • Hosts of one adapter share one device and one ID3D12InfoQueue (see the note on the issue), so with the layer on, creation and the read of its messages run one at a time under a process-wide lock; shader translation stays parallel. Without the layer nothing is serialized.
  • translate --pipelines --only vs,ps,cs,ms makes pipelines for the listed stages only; every stage is still emitted and validated. It requires --pipelines and conflicts with --cache. Documented in the README usage and the VICTORY_D3D12_DEBUG row.

Orthogonal to #2456 (adapter selection): no adapter logic touched. Expect a trivial textual overlap in emit/host.rs Host::new and the README usage lines.

Tests (software adapter only, no GPU, no title data)

  • tests/debug_layer.rs (own process, layer on): a non-shader refused on WARP names the layer's reason; 8 hosts on the same device refusing concurrently each keep their message (fails without the lock — checked).
  • tests/debug_layer_off.rs: same refusal without the layer is the bare error.
  • Unit tests for the stage filter.
  • cargo test -p victory, -p xtask repository_passes_policy, cargo clippy -p victory-shader -p victory --all-targets clean. cargo test -p victory-shader --features host,diagnostics on WARP: 3 hardware-behavior tests fail (a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out), identically on unmodified main.

Not measured: census performance with the layer on.

AI disclosure: written by Claude Code (Claude Sonnet 5.5).

🤖 Generated with Claude Code

…s> (Marvisak#2537)

VICTORY_D3D12_DEBUG now reaches the device `emit::host::Host` creates (in a
diagnostics build, before the first device of the process), and a refused
root signature or pipeline carries the debug layer's messages instead of a bare
error code.

Hosts of one adapter share one device and one ID3D12InfoQueue, so with the
layer on, creation and the read of its messages are one at a time (shader
translation stays parallel); without it nothing is serialized.

`translate --pipelines --only vs,ps,cs,ms` makes pipelines for the listed
stages only; every stage is still emitted and validated.

Tests: synthetic refusals on WARP (a non-shader), also from 8 hosts at once;
the same refusal without the layer; the stage filter.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate (recommending a look, not an approval). Thanks for the rebase and the follow-up. In crates/victory-shader/src/emit/host.rs, create_device now enables the debug layer once per process (enable_debug_layer, diagnostics builds, VICTORY_D3D12_DEBUG not 0) and warns once if it is unavailable; Host::made wraps root-signature and pipeline creation so that, when the device has an ID3D12InfoQueue, creation is serialised under CREATION and a refusal carries the layer's messages. Without the layer the cast fails and nothing is serialised. translate --pipelines --only vs,ps,cs,ms (apps/victory/src/translate.rs, wanted) limits pipeline creation by stage, and clap enforces requires = "pipelines" / conflicts_with = "cache". I checked that victory-gpu only reaches this module through Host::from_device (no second EnableDebugLayer in the game process). It merges cleanly and CI check is passing.

Minor: in the game process with the layer on, fuses_fmad goes through made once at start-up and clears the device's stored messages at that point. Overlaps #2560 (same issue #2537), which currently conflicts with main.


Generated by Claude Code

…-2562

# Conflicts:
#	apps/victory/src/main.rs
#	crates/victory-shader/src/emit/host.rs
@KainanP

KainanP commented Nov 25, 2026

Copy link
Copy Markdown

Compared with #2560 on an RTX 4060 and WARP. This machine has no debug layer, so the reasons themselves are unverified. There are no regressions with the switch on or off (also 0ec4c483 on f3578e38). Recommended, with one ask: warn when the layer is missing. #2537 (comment) (AI-assisted)

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Author

Merged upstream main (f3578e3) into the existing fork branch and pushed 0ec4c48 as a fast-forward. GitHub reports this head mergeable and up to date with main.

The earlier EnableDebugLayer suggestion is addressed. A process-wide Once now guards setup before the shader host creates its first device. The merge preserves upstream's shared WARP device and locking, and root-signature and pipeline refusals still capture debug-layer messages.

Local checks passed on the updated head:

  • All three debug-layer integration tests on WARP, including concurrent refusals with the layer on and the original error with the layer off.
  • A synthetic compute dispatch on WARP with DXIL validation confirmed using the Windows SDK dxil.dll.
  • The victory tests, repository asset-policy test, and workspace Clippy with default and all features.

AI disclosure: Claude Code (Claude Sonnet 5.5) authored the original PR. Claude Code (Claude Opus 5.5) resolved the merge and implemented the one-time initialization. Codex (gpt-6.2-sol) verified the update, ran the final checks, and pushed it.

@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown
Author

@KainanP Thanks for flagging this. ad66ddf now warns once per process if VICTORY_D3D12_DEBUG requests the layer and it is unavailable. The warning points to Graphics Tools in Windows Optional Features. Pipeline checks continue without debug-layer messages.

On WARP, the existing debug-layer tests passed with the layer available and with it disabled. I temporarily simulated an unavailable layer and verified that concurrent pipeline creation and draws still completed, with one warning when requested and zero with VICTORY_D3D12_DEBUG=0. Synthetic DXIL validation with the Windows SDK dxil.dll, the repository asset-policy test, and shader-library Clippy also passed.

AI disclosure: Codex (gpt-6.2-sol) implemented and verified this follow-up.

@reboot0000-cmd

Copy link
Copy Markdown

Verified on the host this exists for: every refusal now names the driver's reason — 396 of 396.

Windows 10 IoT Enterprise LTSC 2021 (19044.7846) with Graphics Tools installed, RTX 4090 (WaveLaneCount 32..32), validator DXC 1.8.2502.8, --features diagnostics, VICTORY_D3D12_DEBUG=1, translate --validate --pipelines --list --only cs over the whole archive (26,503 containers, 26,084 programs). The two comparisons above could not observe this because those machines have no debug layer; this one does.

count
compute pipelines refused in this run 396
refusal lines carrying a debug-layer message 397 lines over 396 distinct programs
of those programs, ones already known as refusals from a layer-less run on this same host 396 of 396
programs the layer text reached that the control did not refuse 0

One program is recorded twice (two containers, same program), which is why 397 lines describe 396 programs. Every one of them is the same message id:

pipeline: The parameter is incorrect.; debug layer: id 622: ID3D12Device::CreateComputeShader:
Shader wants wave lane count of 64 but maximum wave lane count for device is 32.

That is the whole of #2220's complaint resolved at source: the bare E_INVALIDARG these runs used to emit now arrives with the sentence that explains it, and the offset set is identical to the layer-less census I ran on this machine this afternoon — so nothing was refused that wasn't before, and nothing was missed. The PR does what our issue asked, on the host class that motivated it.

Two things to flag about the tests, both about Windows 10 rather than the change.

cargo test -p victory-shader --features diagnostics --test debug_layer reports ok. 0 passed — silently, because the file is gated on all(windows, feature = "host", feature = "diagnostics") and one of the two was missing. It reads as a pass. With --features host,diagnostics:

no debug layer on this machine; skipped
no debug layer on this machine; skipped
test a_refused_pipeline_names_the_debug_layers_reason ... ok
test hosts_sharing_a_device_keep_their_messages ... ok
test result: ok. 2 passed; 0 failed   (finished in 0.02s)

test a_refused_pipeline_carries_no_debug_layer_text ... FAILED
  WARP: "the device supports SM 0x62 only"

This machine has the layer (System32\d3D12SDKLayers.dll present), so the skip message points at the wrong cause. What actually happens is earlier: Host::new needs a shader-model 6.6 device, and on Windows 10 a test binary runs on the in-box runtime — the app-local Agility opt-in from #463 lives in the victory executable, not in cargo test outputs — so the device creation fails at 6.2 and host() returns None. The negative-control test has no skip path and fails outright for the same reason.

Concretely, if useful:

  • separate the two skip reasons in the message — "debug layer not installed" versus "no shader-model 6.6 device (on Windows 10 the test binary has no Agility opt-in)". Right now a Windows 10 tester is told to install a feature they already installed, and then sees two green tests that examined nothing.
  • the failure and the skip are the same root cause as the link-args issue on GPU: load an app-local D3D12 Agility SDK runtime when present #463, which is worth knowing while both are open.

Cost, so nobody is surprised: the layer is not free. This compute-only run took 47 minutes; the same archive with all stages and no layer took 26 on this host, so the scopes differ and it isn't a clean ratio, but the direction is clear — and the machine was only about three logical cores busy for most of it, so the extra time is waiting on the single process-wide ID3D12InfoQueue, not translating. That's inherent to draining one queue from eight workers, and it's what your second test exists to keep correct. Worth one sentence in the docs: expect a census with the layer to run several times slower and near-serial, and run it with --only cs when refusals are the question.

One setup note that cost me a wasted run: in our measurement the layer only became reachable once D3D12SDKLayers.dll was staged next to the app-local runtime. With only D3D12\D3D12Core.dll present, the new code printed VICTORY_D3D12_DEBUG requested the D3D12 debug layer, but it is unavailable. Install Graphics Tools… on a machine that has it; the same binary with D3D12\D3D12SDKLayers.dll alongside D3D12Core.dll printed no warning and produced the 396 messages above. Whether the System32 copy is consulted at all when the Agility runtime is loaded, I did not test — but if the warning also mentioned staging D3D12SDKLayers.dll beside D3D12Core.dll it would have saved me an hour.

Counts and driver text only; no game files.

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed ad66ddf5fc1d5b86d1c9b5f5238ed117be588464 (merged cleanly onto 63bcca43 and verified clean co-merge with #1767) on Windows 11 with Graphics Tools debug layer active.

Enabling VICTORY_D3D12_DEBUG once per process before device creation, warning once when Graphics Tools are absent, wiring --only <stages> cleanly through Clap (requires = "pipelines", conflicts_with = "cache"), and reporting debug-layer refusal reasons directly in translate --pipelines all work cleanly.

Non-blocking follow-up notes:

  • drain_messages (crates/victory-shader/src/emit/host.rs:108-132) iterates GetNumStoredMessages() while indexing GetMessage (which uses the retrieval-filtered count); switching the loop bound to GetNumStoredMessagesAllowedByRetrievalFilter() matches the API contract.
  • Host::made clears the device-wide ID3D12InfoQueue even on Host::from_device (caller-owned devices) and on successful creations; scoping queue clearing to census-owned hosts preserves external diagnostics.
  • VICTORY_PAIRS currently still builds paired graphics/mesh pipelines under --only cs (worth documenting in --help / README or gating on wanted), and debug_layer.rs's concurrent WARP test currently runs serialized by WARP_LOCK with identical refusal messages.

Verification

  • xtask policy (192 files ok), cargo clippy (default & --all-features) clean.
  • With Windows Graphics Tools active: debug_layer 2/2 passed (unskipped), debug_layer_off 1/1 passed (both host and host,diagnostics), victory translate::tests 3/3 passed (4/4 co-merged with #1767), and invalid CLI flag combinations (--only cs without --pipelines, --only bogus, --only cs --cache) rejected as expected.

@Victorzinn704 Victorzinn704 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent run with Windows Graphics Tools installed. With the shader-crate changes from ad66ddf5fc1 applied to main 63bcca43c6a0, both WARP debug-layer tests ran and passed, including the shared-device test. The debug-off test passed as well. On an RTX 5060 Ti (616.92), the rejected compute-shader case reported D3D12 message 322 (CREATECOMPUTESHADER_INVALIDSHADERBYTECODE), with the encoded-size mismatch in the text.

I also tested the inline feature guard below. The ordinary build avoids a COM interface query for each creation through Host::made. The debug-on and debug-off tests passed with the guard applied. Clippy passed with host and with host,diagnostics.

AI-assisted. These were local runs with synthetic shaders.

/// the layer they run in parallel. Callers take [`WARP_LOCK`] (if at all)
/// before this, never after.
fn made<T>(&self, make: impl FnOnce() -> windows::core::Result<T>) -> Result<T, String> {
let Ok(queue) = self.device.cast::<ID3D12InfoQueue>() else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Host::made can go straight to the create call when diagnostics is absent. This avoids attempting QueryInterface for ID3D12InfoQueue on every creation in the ordinary build.

Suggested change
let Ok(queue) = self.device.cast::<ID3D12InfoQueue>() else {
if !cfg!(feature = "diagnostics") {
return make().map_err(err);
}
let Ok(queue) = self.device.cast::<ID3D12InfoQueue>() else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

translate --pipelines: VICTORY_D3D12_DEBUG never reaches the device it creates, so pipeline refusals carry no driver reason

6 participants