CLI: report shader worker initialization failures #1403

Open
github-bot wants to merge 1 commit from github-bot/gh-1403 into main AGit
Owner

@⁠Luizbc2 on GitHub · 2026-11-24 17:46 UTC · original
Luizbc2:fix/translate-worker-initialization → main · +40 −25 · 1 files · 1 commits · open

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

**@⁠Luizbc2** on GitHub · 2026-11-24 17:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1403) `Luizbc2:fix/translate-worker-initialization` → `main` · +40 −25 · 1 files · 1 commits · open ## 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. ```powershell $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. | <details> <summary>Synthetic fixture sources</summary> ```python # 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)) ``` ```rust // 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 } ``` </details> ## 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 #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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:33 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:25 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1403#issuecomment-7149536886) <!-- victory-triage v1 head=567e1345fb77021fd813e66bc66eff1c20350503 verdict=needs-rebase at=2026-11-25T01:25:46Z --> 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](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • apps/victory/src/translate.rs
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.
git fetch -u origin '+refs/pull/1403/head:github-bot/gh-1403'
git switch 'github-bot/gh-1403'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1403'
git switch 'github-bot/gh-1403'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1403'
git switch 'github-bot/gh-1403'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1403'
git switch 'main'
git merge --squash 'github-bot/gh-1403'
git switch 'main'
git merge --ff-only 'github-bot/gh-1403'
git switch 'main'
git merge 'github-bot/gh-1403'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1403
No description provided.