Skip to content

CLI: report shader worker initialization failures - #1403

Open
Luizbc2 wants to merge 1 commit into
Marvisak:mainfrom
Luizbc2:fix/translate-worker-initialization
Open

Luizbc2 wants to merge 1 commit into
Marvisak:mainfrom
Luizbc2:fix/translate-worker-initialization

Conversation

@Luizbc2

@Luizbc2 Luizbc2 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Summary

When victory translate --validate or --pipelines passes its initial check but a worker fails to initialize its checker, that worker can silently skip the requested check. The command still exits successfully and prints a tally that looks complete.

Keep the initial checker for the first worker, initialize additional checkers as needed, and reuse them across input files. If initialization fails, return the worker number and underlying DXIL or D3D12 error before printing the final tally.

Reproduction

Windows 11 x64 (build 26200), Rust 1.98.1, base ffe310e. The fixture generates two no-op compute shaders and builds a stand-in DXIL validator that succeeds once and returns E_FAIL on later initialization attempts. Save the two sources below in a scratch directory and run from the repository root.

$fixture = 'C:\path\to\scratch'
cargo build -p victory --locked
python (Join-Path $fixture 'make-compute.py')
$env:VICTORY_DXIL = Join-Path $fixture 'validator.dll'
rustc --edition 2024 --crate-type cdylib (Join-Path $fixture 'validator.rs') -o $env:VICTORY_DXIL
$env:VICTORY_FIXTURE_MAX = '1'
.\target\debug\victory.exe translate (Join-Path $fixture 'compute-first.bin') --validate --jobs 2
$LASTEXITCODE
Build Result
ffe310e Emitted 2 compute shaders, reported 0 validated, and exited 0.
With this patch Exited 1 with starting shader worker 2 and DxcCreateInstance(validator) failed: 0x80004005. No final tally was printed.
Synthetic fixture sources
# make-compute.py
import struct
import zlib
from pathlib import Path

root = Path(__file__).resolve().parent


def compute_container(threads_x):
    code = struct.pack("<I", 0xBF810000)  # s_endpgm
    record = 0x68
    stage_data = record + 0x54
    code_at = stage_data + 0x34
    payload = bytearray(code_at)
    struct.pack_into("<Q", payload, 0, 6)
    for slot in (0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x48):
        struct.pack_into("<Q", payload, slot, 0xDEADBEEFDEADBEEF)
    struct.pack_into("<Q", payload, 0x60, record)
    struct.pack_into("<QQ", payload, record, code_at, len(code))
    struct.pack_into("<I", payload, record + 0x14, 1 << 5)
    struct.pack_into("<I", payload, record + 0x50, 1)
    struct.pack_into("<III", payload, stage_data + 0x28, threads_x, 1, 1)
    payload += code
    fssm = struct.pack("<4sIQ", b"FSSM", 0x101, len(payload)) + payload
    stream = zlib.compress(fssm)
    xbch = struct.pack("<4sIQQ", b"XBCH", 3, len(stream), len(fssm)) + stream
    dxil = bytes(0x18) + struct.pack("<4s5I", b"XDAT", 1, 0x24, 0x0D, 0x30, len(xbch)) + xbch
    part = struct.pack("<4sI", b"DXIL", len(dxil)) + dxil
    return struct.pack("<4s16xIIII", b"DXBC", 1, 0x24 + len(part), 1, 0x24) + part


(root / "compute-first.bin").write_bytes(compute_container(1) + compute_container(2))
(root / "compute-second.bin").write_bytes(compute_container(3) + compute_container(4))
// validator.rs
use std::ffi::c_void;
use std::sync::atomic::{AtomicUsize, Ordering};

static CREATED: AtomicUsize = AtomicUsize::new(0);

extern "system" fn release(_: *mut c_void) -> u32 {
    0
}

#[repr(C)]
struct Vtable {
    unused: [usize; 2],
    release: extern "system" fn(*mut c_void) -> u32,
}

static VTABLE: Vtable = Vtable { unused: [0; 2], release };

#[repr(C)]
struct Validator(&'static Vtable);

static VALIDATOR: Validator = Validator(&VTABLE);

#[unsafe(no_mangle)]
pub unsafe extern "system" fn DxcCreateInstance(
    _: *const c_void,
    _: *const c_void,
    out: *mut *const c_void,
) -> i32 {
    let call = CREATED.fetch_add(1, Ordering::SeqCst) + 1;
    eprintln!("fixture validator creation {call}");
    let allowed = std::env::var("VICTORY_FIXTURE_MAX")
        .unwrap().parse::<usize>().unwrap();
    if call > allowed {
        return 0x8000_4005_u32 as i32;
    }
    unsafe { *out = (&raw const VALIDATOR).cast() };
    0
}

Testing

  • With the real Windows SDK dxil.dll and VICTORY_WARP=1, ran both generated compute files with --validate --pipelines. Both --jobs 1 and --jobs 2 emitted 4 shaders, validated all 4, and created all 4 pipelines.
  • With the stand-in validator and two files containing two empty DXBC containers each, --jobs 2 initialized exactly two validators total across both files.
  • cargo test --workspace --locked --offline --no-fail-fast returned 341 passed, 6 ignored, and one pre-existing failure in v_med3_f32_matches_rdna2_with_nan on Intel Iris Xe (driver 31.0.101.5333). The same test fails on the base revision and passes with the shader change from Shaders: use DXIL IsNaN in med3 so Intel Xe does not fold fcmp uno #110. With that change temporarily applied, the workspace suite returned 342 passed and 6 ignored.
  • rustfmt --check for the changed file and git diff --check passed.

All shader inputs were generated for these tests. AI-assisted with Codex.

Return initialization errors for requested DXIL and D3D12 checks. Keep one set of checks per worker and reuse it across input files.

@DenRakEiw DenRakEiw 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.

Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory: 1 passed, 0 failed
  • cargo clippy -p victory --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean error reporting for shader worker initialization failures. Approving.

AI-assisted (Gemini 4 Neon).

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: apps/victory/src/translate.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

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.

3 participants