diff --git a/CHANGELOG.md b/CHANGELOG.md index de50e2e..d04484e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Guest execution uses original, purpose-built test programs. Commercial Xbox game remains unsupported. ### Added +- Review follow-up on the proposed `victory-shader` import (#394): `translate_native` now reports immediate samplers as static samplers (a sampled texel read 0 on the GPU before), BetterXen's GPU tests use a host that `VICTORY_WARP` cannot redirect, the double-precision probes take run-time operands and were rerun (same result), and a per-file provenance review records that the crate was developed against one commercial title's shaders. **The import is not approved; a maintainer decision is required** (`docs/research/victory-shader-provenance.md`). Earlier statements that the crate had nothing game-specific are withdrawn. - Fixed the two wave-operation failures the vendored victory-shader tests showed under D3DMetal (`docs/research/shader-wave-semantics.md`). Device capabilities were measured with a new original D3D12 host (`workloads/d3d12-wave-probe`): shader model 6.6, wave operations, waves exactly 32 lanes, no double-precision shader operations. One failure was a wrong test precondition (a 64-lane lowering run on the 32-lane device); the test now checks the device width and asserts the recompiler's refusal. The other was unsupported double-precision operations: shaders compiled from original HLSL by Microsoft's DXC that use a `double` ran without writing anything, while float wave operations worked. The recompiler's one native-double site (`active_f64_sum`) now builds the console's balanced sum tree with its existing integer fp64 add and no longer declares doubles. Local results on one Apple M4 under CrossOver 26.3, not independently reproduced: the whole suite passes (229 passed, 3 ignored; the vendored original had 2 failures); 24 new GPU cases compare full 64-bit sums with a CPU model of the tree; both regression tests fail against the original lowering. Cost not measured; tree-order fidelity relies on the recompiler's own recognizer. - Added `scripts/hybrid/run-shader-gpu-tests.sh`, which cross-builds the vendored `victory-shader` test executable for Windows and runs it under CrossOver through `betterxen-hybrid run` (supervision, memory guard, stall detection, JSON record), either BetterXen's seven tests or the whole upstream suite. It takes both the runner and the test executable from the messages of the cargo invocations that built them, and stops if a build fails (review fix: an earlier version piped cargo into the parser, so a failed build exited 0 and ran a stale executable, and it assumed the runner was under `target/`). `scripts/hybrid/test-run-shader-gpu-tests.sh` is a stubbed regression test for both. It needs the runner from #384 and #388. Verified on the Apple M4 with CrossOver 26.3: fixtures pass; the whole suite shows the known failures; there is no fallback to a guessed path. Not independently reviewed. - Integrated skakwy's `victory-shader` (GFX10/RDNA 2 machine code to DXIL SM 6.6 recompiler, about 43,500 lines of Rust) as `crates/victory-shader`, with provenance in its `UPSTREAM.md`, the Mesa notice preserved and 19 lines of lint-only edits to upstream files. Added `translate_native` and tests that translate BetterXen's own gfx1030 fixtures to DXIL and, on Windows targets, run them on the GPU through D3D12. Local results on one Apple M4 with CrossOver 26.3 (D3DMetal), not independently reproduced: 177 upstream CPU-side tests pass on macOS; all 6 fixtures with expected words matched the manifest on the GPU, with a negative control; the GPU tests fail without D3D12 instead of skipping; the full upstream suite under CrossOver has 224 passed, 2 failed, 3 ignored. DXIL validation by `dxil.dll` was not run. The native RDNA-to-Metal compiler is unchanged. See `docs/research/victory-shader-integration.md`. diff --git a/crates/victory-shader/UPSTREAM.md b/crates/victory-shader/UPSTREAM.md index 37c6836..12ac8f7 100644 --- a/crates/victory-shader/UPSTREAM.md +++ b/crates/victory-shader/UPSTREAM.md @@ -1,5 +1,7 @@ # Upstream provenance: victory-shader +**Not approved for merge.** This crate was developed against one commercial title's shaders; the per-file review and the open maintainer decision are in `docs/research/victory-shader-provenance.md`. + | | | | --- | --- | | Source | , directory `crates/victory-shader/` (Cargo.toml and `src/`) | @@ -25,9 +27,10 @@ Changes to upstream files (19 lines, nothing functional) and files BetterXen add - `src/emit/lower.rs` (`active_f64_sum`, about 90 lines): the whole-wave f64 sum no longer emits a native `double` wave operation (`makeDouble`, `waveActiveOp.f64`, `splitDouble`); it builds the console's balanced tree over the lanes with the crate's own integer `add_f64`, reading partner runs through `waveReadLaneAt` and a ballot for lanes that are not present, and no longer sets the doubles feature flag. Why: D3DMetal reports no double-precision shader operations and a shader that uses a `double` ran without writing anything (docs/research/shader-wave-semantics.md). - `src/emit/bitcode.rs`: two `#[allow(dead_code)]` for the double type, now never constructed. -- `src/emit/host.rs`: `Host::wave_lane_count_max()` (test host only). +- `src/emit/host.rs`: `Host::wave_lane_count_max()` and `Host::hardware()` (test host only; `hardware()` ignores `VICTORY_WARP`). +- `src/emit/mod.rs`: the static-sampler construction is factored into `static_samplers()` so `translate_native` reports immediate samplers. - `src/emit/wave64_tests.rs`: `a_sum_of_halves_where_lanes_have_left_is_the_consoles_tree_bit_for_bit` checks the device's wave width and, on a device narrower than 64 lanes, asserts the recompiler's refusal instead of running a 64-lane lowering. ## Not carried -The upstream repository's other crates (`victory-gpu`, `victory-loader`, `victory-hle`, ...), which are tied to one console title and its runtime, and `mac/`, `tools/`. The shader inputs the upstream project was built for are not included; BetterXen validates this crate only with its own synthetic fixtures (see `docs/research/` for the validation record). +The upstream repository's other crates (`victory-gpu`, `victory-loader`, `victory-hle`, ...), which are tied to one console title and its runtime, and `mac/`, `tools/`. No shader binaries or dumps of the title the upstream project targets are included, but comments and behaviour in this crate refer to that title's shaders; BetterXen validates this crate only with its own synthetic fixtures (see `docs/research/` for the validation record). diff --git a/crates/victory-shader/src/emit/betterxen.rs b/crates/victory-shader/src/emit/betterxen.rs index 66b1823..372c768 100644 --- a/crates/victory-shader/src/emit/betterxen.rs +++ b/crates/victory-shader/src/emit/betterxen.rs @@ -38,8 +38,8 @@ pub fn translate_native(native: &NativeProgram) -> Result NativeProgram { + let s_mov_lit = |dst: u8, lit: u32| [0xBE80_03FF | (dst as u32) << 16, lit]; + let smem = |op: u32, dst: u32, base: u32, off: u32| [0x3D << 26 | op << 18 | dst << 6 | base >> 1, 125 << 25 | off]; + let mut w: Vec = Vec::new(); + w.push(0xBE80_0300 | 2 << 16); // s_mov_b32 s2, s0 (table address) + w.push(0xBE80_0380 | 3 << 16); // s_mov_b32 s3, 0 + w.extend(smem(0x03, 8, 2, 0)); // s_load_dwordx8 s[8:15]: the texture SRV + w.extend(smem(0x02, 20, 2, 32)); // s_load_dwordx4 s[20:23]: the UAV + w.push(0x7E00_02F0 | 2 << 17); // v_mov_b32 v2, 0.5 + w.push(0x7E00_02F0 | 3 << 17); // v_mov_b32 v3, 0.5 + for (i, word) in [0x0000_0092u32, 0x00C0_0000, 0x1850_0000, 0].into_iter().enumerate() { + w.extend(s_mov_lit(16 + i as u8, word)); // s[16:19]: the sampler, as constants + } + // image_sample_lz v4, v[2:3], s[8:15], s[16:19] dmask:0x1 dim:2D + w.extend([0x3C << 26 | 0x21 << 18 | 1 << 8 | 1 << 3, (16u32 >> 2) << 21 | (8u32 >> 2) << 16 | 4 << 8 | 2]); + w.extend([0x38 << 26 | 0x1C << 18, 0x80 << 24 | (20u32 >> 2) << 16 | 4 << 8]); // buffer_store_dword v4 + w.push(0xBF81_0000); // s_endpgm + let used = |kind, table_offset_dwords, dwords| UsedResource { + kind, + root: RootType::Table, + table_offset_dwords, + lower_bound: 0, + stride: 0, + dwords, + user_data: 0, + slot: 0, + }; + NativeProgram { + stage: HwStage::Cs, + wave64: false, + vgprs: 8, + layout: vec![RootParam { + root: RootType::Table, + table_offset_dwords: 0, + sgprs: 1, + base_register: 0, + user_data: 0, + slot: 0, + }], + used: vec![used(ResourceType::Srv, 0, 8), used(ResourceType::Uav, 8, 4)], + io: StageIo::Cs(ComputeIo { rsrc2: 1 << 1, threads: [1, 1, 1] }), + code: w.iter().flat_map(|x| x.to_le_bytes()).collect(), + } +} + +#[test] +fn translate_native_reports_immediate_samplers_as_static_samplers() { + let shader = translate_native(&immediate_sampler_program()).expect("translate"); + assert_eq!(shader.samplers.len(), 1, "the program has one immediate sampler"); + assert_eq!(shader.static_samplers.len(), 1, "the host builds s0 from this list"); +} + +#[cfg(windows)] +#[test] +fn immediate_sampler_samples_the_texture_on_the_gpu() { + use crate::emit::host::{Dispatch, Host, Root, View}; + let _one = crate::emit::valu_tests::ONE_AT_A_TIME.lock().unwrap_or_else(|e| e.into_inner()); + let host = Host::hardware().expect("no SM 6.6 D3D12 hardware device: not verified"); + let shader = translate_native(&immediate_sampler_program()).expect("translate"); + let (root, pso) = host.compute_pipeline(&shader).expect("compute pipeline"); + let ud = vec![0u32; shader.user_data_dwords().max(1) as usize]; + let texels = [[0.25f32, 0.5, 0.75, 1.0]]; + let out = host + .dispatch( + &root, + &pso, + &Dispatch { + roots: vec![(0, Root::Constants(ud))], + views: &[View::Texture(1, 1, &texels), View::RawUav(1)], + samplers: &[], + groups: [1, 1, 1], + }, + ) + .expect("dispatch"); + assert_eq!(out[0][0], 0.25f32.to_bits(), "red of the only texel"); + eprintln!("betterxen: the immediate-sampler program sampled the texture on the GPU"); +} + +#[test] +fn static_samplers_keep_the_comparison_filter_flag() { + let words = [0x0000_0092u32, 0x00C0_0000, 0x1850_0000, 0]; + let list = super::static_samplers(&[words, words], 0b10); + assert_eq!(list.len(), 2); + assert_eq!(list[0].filter & 0x80, 0, "sampler 0 is not a comparison sampler"); + assert_ne!(list[1].filter & 0x80, 0, "sampler 1 is"); +} diff --git a/crates/victory-shader/src/emit/host.rs b/crates/victory-shader/src/emit/host.rs index be3b502..84628e7 100644 --- a/crates/victory-shader/src/emit/host.rs +++ b/crates/victory-shader/src/emit/host.rs @@ -103,6 +103,17 @@ impl Host { /// The default adapter, or WARP with `warp` (or `VICTORY_WARP=1`). pub fn new(warp: bool) -> Result { let warp = warp || std::env::var("VICTORY_WARP").is_ok_and(|v| v == "1"); + Self::create(warp) + } + + /// The default hardware adapter, whatever `VICTORY_WARP` says; an error when the default + /// device is the software adapter. BetterXen addition: a test that reports GPU verification + /// must not be redirectable to WARP by the environment. + pub fn hardware() -> Result { + Self::create(false) + } + + fn create(warp: bool) -> Result { // SAFETY: plain D3D12/DXGI calls with valid out pointers. unsafe { // `VICTORY_D3D12_DEBUG`: the debug layer, whose messages a diff --git a/crates/victory-shader/src/emit/mod.rs b/crates/victory-shader/src/emit/mod.rs index a838f93..db37b9e 100644 --- a/crates/victory-shader/src/emit/mod.rs +++ b/crates/victory-shader/src/emit/mod.rs @@ -646,18 +646,7 @@ fn emit_program( stage: native.stage, dxil: l.dxil, user_data: l.user_data, - static_samplers: l - .samplers - .iter() - .enumerate() - .map(|(n, &w)| { - let mut s = StaticSampler::from_words(w); - if l.cmp_samplers >> n & 1 != 0 { - s.filter |= 0x80; - } - s - }) - .collect(), + static_samplers: static_samplers(&l.samplers, l.cmp_samplers), samplers: l.samplers, root_cbvs: l.root_cbvs, root_srvs: l.root_srvs, @@ -667,6 +656,23 @@ fn emit_program( Ok((shader, wave_size)) } +/// The static sampler descriptions for the immediate samplers a shader uses (`s` at position +/// n); bit n of `cmp` marks a sampler used for comparisons. BetterXen change: factored out so +/// `translate_native` builds the same list as the container path. +fn static_samplers(samplers: &[[u32; 4]], cmp: u64) -> Vec { + samplers + .iter() + .enumerate() + .map(|(n, &w)| { + let mut s = StaticSampler::from_words(w); + if cmp >> n & 1 != 0 { + s.filter |= 0x80; + } + s + }) + .collect() +} + /// The rows of an `ISG1`/`OSG1` part. fn signature(part: &[u8]) -> Result, ShaderError> { use crate::dxbc::u32_at; diff --git a/crates/victory-shader/src/emit/wave64_tests.rs b/crates/victory-shader/src/emit/wave64_tests.rs index 05d7f70..4f2647c 100644 --- a/crates/victory-shader/src/emit/wave64_tests.rs +++ b/crates/victory-shader/src/emit/wave64_tests.rs @@ -242,7 +242,7 @@ fn a_sum_of_halves_where_lanes_have_left_is_the_consoles_tree_bit_for_bit() { // this program ("a wave sum of 16-bit floats where not every lane runs"): the test then // asserts that refusal, which is the correct behaviour, rather than reporting a failure // or silently skipping. - if let Some(w) = Host::new(false).ok().and_then(|h| h.wave_lane_count_max()).filter(|&w| w < 64) { + if let Some(w) = Host::hardware().ok().and_then(|h| h.wave_lane_count_max()).filter(|&w| w < 64) { let refused = lowered_on(&native, &p, &HashSet::new(), w); assert!( matches!(&refused, Err(ShaderError::Unsupported { what, .. }) if what.contains("16-bit floats where not every lane runs")), diff --git a/docs/README.md b/docs/README.md index cac8c10..727f08c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -68,6 +68,7 @@ checkpoints retain their original evidence scope. - [Public sources](research/sources.md), [RDNA 2 notes](research/rdna2.md), and [Xbox GPU evidence](research/xbox-gpu.md) — Specifications, evidence scope, and unknown console behavior. - [Shader inputs](research/shader-containers.md) and [risk register](risk-register.md) — Input provenance and unresolved engineering risks. +- [victory-shader provenance review](research/victory-shader-provenance.md) — Per-file licence and origin record for the proposed import; not approved, maintainer decision pending. - [victory-shader integration](research/victory-shader-integration.md) — The vendored GFX10-to-DXIL recompiler, how BetterXen's fixtures run through it on the GPU under CrossOver, and what is not verified. - [Shader wave-semantics investigation](research/shader-wave-semantics.md) — Why two upstream wave tests failed under D3DMetal: device capabilities, independent probes, the fix and its limits. - [Texture format inventory](research/texture-formats.md) — Formats and layouts by stage (decode, layout, native upload, sampling, guest), their public specifications, unknowns and ranked follow-ups. diff --git a/docs/research/component-reuse-matrix.md b/docs/research/component-reuse-matrix.md index e71b57d..cb3a528 100644 --- a/docs/research/component-reuse-matrix.md +++ b/docs/research/component-reuse-matrix.md @@ -14,6 +14,7 @@ Companion to the [upstream registry](upstream-registry.md); same evidence limits | Direct3D 12 to Vulkan | VKD3D-Proton | **Evaluate**; blocked on a Vulkan 1.3 provider | Depends on MoltenVK feature coverage, unknown. | | Vulkan on Metal | MoltenVK | **Evaluate** | Apache-2.0 (compatible with GPLv3). Subset of Vulkan; coverage vs consumers unknown. | | Shader compiler / runtime | VIctory, VIctory-macOS | **Rejected for reuse** | Built for a specific commercial game's Xbox Series build whose provenance is not established as authorized. Ideas only. | +| GFX10 to DXIL recompiler | victory-mac `crates/victory-shader` (VIctory family) | **Not approved: maintainer decision pending** (the rejection above stands until then) | PR #394 proposes vendoring it. The [per-file review](victory-shader-provenance.md) finds GPL-3.0 licensing but development against one commercial title's shaders; read plainly, the engineering rules exclude it. | | Project discovery | PortWatch VI | Reference only | Editorial tracker; not engineering evidence; nothing imported. | | x86-64 decode and ARM64 translation, runtime, gfx1030 compiler, Metal backend | BetterXen native implementation | **Preserved, paused** | Reuse only where hybrid needs it and it shows a demonstrated advantage; not forced into the architecture. | | Test and diagnostics methodology | BetterXen existing audits, benchmark harness, claims registry | **Reuse** | Existing evidence classes, claims audit and benchmark gating apply to hybrid work (Phase 1 onward). | diff --git a/docs/research/shader-wave-semantics.md b/docs/research/shader-wave-semantics.md index caa7824..46151f3 100644 --- a/docs/research/shader-wave-semantics.md +++ b/docs/research/shader-wave-semantics.md @@ -37,15 +37,18 @@ Observed: a Wave32 program with 4 launched threads, each contributing 1.25, shou | --- | --- | --- | | `lanes4`: wave size and lane index, 4 threads | `0x2000`..`0x2003` (wave of 32) | exactly that | | `sum_f32_4`: `WaveActiveSum(1.25f)`, 4 threads | `0x40a00000` in every lane | exactly that | -| `add_f64_4`: a plain `double` add (no wave operation) | low `0x00000000`, high `0x40000000` | **every dword still `0xDEADBEEF`: the shader wrote nothing** | -| `sum_f64_4`: `WaveActiveSum` over a `double` | low `0x00000000`, high `0x40140000` | **every dword still `0xDEADBEEF`: the shader wrote nothing** | +| `add_f32_4`: control, run-time load, float add, store | `0x40000000`, `0` per thread | exactly that | +| `add_f64_4`: a `double` add of run-time operands (DXIL contains `fadd fast double`) | low `0x00000000`, high `0x40000000` | **every dword still `0xDEADBEEF`: the shader wrote nothing** | +| `sum_f64_4`: `WaveActiveSum` over a run-time `double` (DXIL `waveActiveOp.f64`) | low `0x00000000`, high `0x40140000` | **every dword still `0xDEADBEEF`: the shader wrote nothing** | + +An earlier version of `add_f64_4` used constant operands: the compiler folded the addition to `splitDouble(2.0)` with no `fadd` (reviewer finding by atesahmet0, confirmed with `dxc -dumpbin`), so it did not show a double *addition* failing. The probes above take their operands from the buffer at run time and were rerun; the result is the same. So wave operations, wave width and partial waves are fine on this device. Any shader that uses a `double` runs without effect: pipeline creation succeeds, the dispatch completes, and nothing is stored. That matches the capability record (`DoublePrecisionFloatShaderOps = 0`; Metal has no fp64). Upstream's test harness zero-fills its output buffer, which is why it saw `0` instead of the sentinel. **Conclusion:** the failure comes from unsupported double-precision operations in the backend, combined with the recompiler emitting a native `double` in one place (`active_f64_sum`) while using integer emulation everywhere else. It is not a mistranslation of the wave operation and not a wave-semantics problem. **Fix (recompiler, `active_f64_sum`):** the existing integer fp64 add (`add_f64`, checked upstream against the CPU's doubles) is reused to build the console's sum, which is the balanced tree over the lanes in their order. Each lane adds its partner run's partial sum, read through `waveReadLaneAt` from the first lane of that run that is present (found with a ballot, as `half_sum_present` already does for 16-bit sums), `+0.0` where none is, which is what a lane outside EXEC adds on the console. No `double` type is emitted and the doubles feature flag is no longer set. The same code covers the console wave64 on two host waves of 32 (an integer add for the last step). **Validation** (M4, CrossOver 26.3, default backend; one machine, not independently reproduced): -- Whole suite under CrossOver: **229 passed, 0 failed, 3 ignored** (was 224 passed, 2 failed). macOS: 179 + new tests pass (`cargo test -p victory-shader`). +- Whole suite under CrossOver: **232 passed, 0 failed, 3 ignored** (229 before the review's sampler tests) (was 224 passed, 2 failed). macOS: 179 + new tests pass (`cargo test -p victory-shader`). - New test `f64_wave_sums_match_the_cpu_tree_bit_for_bit`: 24 cases (1, 4, 20 and 32 launched threads; six values including ones that round: 0.1, 123456.789, a value one ulp above 1.0, -3.75e10, 1e-300), comparing all 64 bits with a CPU model of the balanced tree using the CPU's own f64 additions and `+0.0` for lanes that are not launched. All 24 match. The model is independent of the recompiler. - Negative controls: against the **original** lowering this GPU test fails (`got 0x0000000000000000, want 0x3ff4000000000000`) and the new `the_f64_wave_sum_is_lowered_without_native_doubles` test (the container's feature word must declare wave operations but not doubles) fails too; both pass with the fix. diff --git a/docs/research/upstream-registry.md b/docs/research/upstream-registry.md index fc02510..85b99c8 100644 --- a/docs/research/upstream-registry.md +++ b/docs/research/upstream-registry.md @@ -15,6 +15,10 @@ Reviewed 2026-11-25. Every entry is **evidence class D** (non-normative official | VIctory-macOS | [pragyaangaur/VIctory-macOS](https://github.com/pragyaangaur/VIctory-macOS) | `485b230ef596` | GPL-3.0 (GitHub) | Discovery reference only | A macOS port of VIctory using Rosetta, CrossOver Wine and D3DMetal per its README (also noted in [portwatch-native-macos.md](portwatch-native-macos.md)). Same input concern. Its test and "works" claims are self-reported and not verified here. The repository has no parent fork, so the "canonical upstream" is VIctory. | | PortWatch VI | [portwatch-vi.xyz](https://portwatch-vi.xyz/), [4lwayz/portwatch-vi](https://github.com/4lwayz/portwatch-vi) | `ed00263cc0c9` | NOASSERTION | Project discovery reference | A tracker of community efforts; progress figures are editorial, with self-reported claims labelled. Not engineering evidence; flagged and ignored queues are not endorsed. | +## victory-shader import under review + +`skakwy/victory-mac` `crates/victory-shader` at `22b3f8e45a59` is proposed for vendoring in PR #394. **Not approved.** See the [per-file provenance and licence review](victory-shader-provenance.md); the provenance decision below stands until a maintainer changes it. + ## Additional candidates found by search (not reviewed) Found by GitHub search on 2026-11-25. Only repository metadata was read; none was evaluated, installed or run, and none is a recommendation. Licenses are what GitHub reported. diff --git a/docs/research/victory-shader-integration.md b/docs/research/victory-shader-integration.md index 480dac7..5b8c513 100644 --- a/docs/research/victory-shader-integration.md +++ b/docs/research/victory-shader-integration.md @@ -1,6 +1,6 @@ # victory-shader integration (GFX10 to DXIL recompiler) -Evidence: classes noted per row. Everything ran on one machine (Apple M4, 24 GiB, macOS 27.0, CrossOver 26.3.0.39832, bottle `betterxen-test`, default backend) and has **not been independently reproduced**. No game, console title or leaked material was used. +Evidence: classes noted per row. Everything ran on one machine (Apple M4, 24 GiB, macOS 27.0, CrossOver 26.3.0.39832, bottle `betterxen-test`, default backend) and has **not been independently reproduced**. BetterXen's runs used no game files or leaked material. **The vendored code itself was developed against one commercial title's shaders** and is not approved for merge: see [victory-shader-provenance.md](victory-shader-provenance.md). ## What was integrated diff --git a/docs/research/victory-shader-provenance.md b/docs/research/victory-shader-provenance.md new file mode 100644 index 0000000..1951877 --- /dev/null +++ b/docs/research/victory-shader-provenance.md @@ -0,0 +1,66 @@ +# victory-shader: per-file provenance and licence review + +**Status: NOT APPROVED. A maintainer decision is required before PR #394 can merge.** This is the review the engineering rules require for VIctory-family code. It records facts; it does not grant approval, and its author is the person who proposed the import, so it is not an independent review. + +Upstream: , revision `22b3f8e45a59f7d11fef7718988c58d0b3f1d0f9`. Method: every tracked file of `crates/victory-shader/` at that revision; authors from `git shortlog`; licence from the repository `LICENSE` and a search of each file for other notices; title references by searching for shader names of the form `module:CS_Name` and the words title, titles, game, games. The search finds references, not every dependence: a file without one may still have been developed against the same title. + +## Findings + +1. **Licence:** GPL-3.0, compatible with BetterXen's GPL-3.0-or-later. One third-party notice (Mesa-derived opcode names, MIT, Valve) in `src/gfx10/opcodes.rs`, kept. Some comments cite Mesa behaviour and LLVM definitions. skakwy and the VIctory-macOS maintainer authorized reuse of their own contributions (relayed by the maintainer); other authors' lines rest on the repository licence. +2. **The crate was developed against one commercial title's shaders.** 17 of 36 files refer to "the title" or "the game"; comments describe that title's programs, layouts and structures, and four places cite its shaders by name (`wave64_tests.rs`, `wave.rs`, `own_bits.rs`). The upstream project's stated purpose is to run that title's Xbox Series build; this registry and PortWatch record that build as leaked. +3. **What is not in the crate:** a search found no shader binaries, shader dumps, game assets, keys or decryption code. The references are in comments, test descriptions and handling of shader constructs. +4. **Earlier statements that were wrong:** the integration record and PR descriptions said the crate had nothing game-specific. That claim came from searching only for the game's and publisher's names. It is withdrawn. + +## How this meets the engineering rules (`AGENTS.md`) + +| Rule | Assessment | +| --- | --- | +| "Projects whose stated purpose depends on leaked or unauthorized builds ... are discovery references at documentation level; adopt nothing from them without a per-file provenance and license review recorded in the registry." | This file is that record. Recording it does not by itself approve adoption. | +| "Game-specific, asset-specific and decryption-related code is never adopted." | Handling written for and documented against one title's shaders is present in at least some files. Whether that makes a file "game-specific code" is the decision to make; it is a general GFX10 recompiler in structure, with title-driven behaviour inside it. | +| "Provenance first: exclude anything derived from leaked proprietary material or unauthorized software." | Layouts "as observed in shipped titles" (`native.rs`) and behaviour tuned to the title's programs are plausibly derived from that material. | +| "Never copy, port, translate or adapt source from emulator projects built for leaked or unauthorized material." | Read plainly, this applies to this import. Author permission does not change it. | + +**Reviewer's recommendation to the maintainer:** under the rules as written, do not merge the import. Either decline it (keep the crate as a documentation-level reference; BetterXen's own fixtures, probes and findings stand on their own), or change the rule explicitly in `AGENTS.md` with the legal question considered, and then decide file by file. This is not legal advice. + +## Per-file record + +| File (under `crates/victory-shader/`) | Lines | Upstream authors (commits) | Licence and third-party notes | Shader names of a title | Lines saying title/game | +| --- | --- | --- | --- | --- | --- | +| `Cargo.toml` | 40 | Marvis (2), fxceless (1) | GPL-3.0 (repository licence) | - | - | +| `src/bvh.rs` | 696 | fxceless (2) | GPL-3.0 (repository licence) | - | 5 | +| `src/dxbc.rs` | 181 | Marvis (2) | GPL-3.0 (repository licence) | - | - | +| `src/dxil.rs` | 211 | Marvis (1) | GPL-3.0 (repository licence); cites LLVM | - | - | +| `src/emit/bitcode.rs` | 1240 | Marvis (3), fxceless (2), Lyrnc (1) +2 more | GPL-3.0 (repository licence); cites LLVM | - | - | +| `src/emit/bitcode/census.rs` | 174 | fxceless (1) | GPL-3.0 (repository licence) | - | - | +| `src/emit/bitcode/opt.rs` | 2140 | armin (1), fxceless (1) | GPL-3.0 (repository licence) | - | 1 | +| `src/emit/container.rs` | 419 | Duff (1), Marvis (1), fxceless (1) +1 more | GPL-3.0 (repository licence) | - | - | +| `src/emit/diff_tests.rs` | 1287 | Marvis (3), fxceless (1) | GPL-3.0 (repository licence) | - | 5 | +| `src/emit/f64.rs` | 409 | skakwy (1) | GPL-3.0 (repository licence) | - | - | +| `src/emit/host.rs` | 1472 | fxceless (3), Marvis (1), skakwy (1) | GPL-3.0 (repository licence) | - | - | +| `src/emit/intersect.rs` | 557 | fxceless (1) | GPL-3.0 (repository licence) | - | 12 | +| `src/emit/intersect_tests.rs` | 690 | fxceless (1) | GPL-3.0 (repository licence) | - | 15 | +| `src/emit/lower.rs` | 12268 | Marvis (21), skakwy (9), fxceless (6) +23 more | GPL-3.0 (repository licence); comment cites Mesa behaviour; cites LLVM | - | 18 | +| `src/emit/mod.rs` | 1755 | Marvis (7), fxceless (6), skakwy (4) +8 more | GPL-3.0 (repository licence) | - | 16 | +| `src/emit/own_bits.rs` | 914 | fxceless (1) | GPL-3.0 (repository licence) | 1 | 3 | +| `src/emit/rect.rs` | 484 | fxceless (2) | GPL-3.0 (repository licence) | - | 2 | +| `src/emit/sampler.rs` | 125 | Marvis (1) | GPL-3.0 (repository licence) | - | 1 | +| `src/emit/shader.rs` | 908 | fxceless (4), Claude (1), Duff (1) +4 more | GPL-3.0 (repository licence) | - | 8 | +| `src/emit/threading.rs` | 218 | fxceless (1) | GPL-3.0 (repository licence) | - | - | +| `src/emit/validator.rs` | 221 | Marvis (1), lameloball2813-ui (1) | GPL-3.0 (repository licence) | - | - | +| `src/emit/valu_tests.rs` | 1624 | Marvis (6), r4. (5), fxceless (4) +6 more | GPL-3.0 (repository licence) | - | - | +| `src/emit/waterfall_tests.rs` | 435 | r4. (3), Marvis (1), Noname0202 (1) +1 more | GPL-3.0 (repository licence) | - | - | +| `src/emit/wave.rs` | 1228 | fxceless (3), skakwy (2), AscilCH (1) +1 more | GPL-3.0 (repository licence) | 1 | - | +| `src/emit/wave64_tests.rs` | 532 | fxceless (1), triippywhale (1) | GPL-3.0 (repository licence) | 2 | - | +| `src/gfx10/fields.rs` | 815 | Marvis (1), fxceless (1) | GPL-3.0 (repository licence) | - | - | +| `src/gfx10/mod.rs` | 496 | Marvis (3), tedin7 (1) | GPL-3.0 (repository licence) | - | - | +| `src/gfx10/opcodes.rs` | 1333 | Duff (1), Marvis (1) | GPL-3.0 (repository licence); Mesa-derived, MIT (Valve), notice in header; cites LLVM | - | - | +| `src/gfx10/sp3.rs` | 784 | Marvis (1) | GPL-3.0 (repository licence) | - | - | +| `src/io.rs` | 826 | Marvis (1), fxceless (1), local (1) | GPL-3.0 (repository licence) | - | - | +| `src/ir.rs` | 1791 | fxceless (4), Marvis (2), Yaekai (1) +1 more | GPL-3.0 (repository licence) | - | 1 | +| `src/lib.rs` | 38 | Marvis (3), fxceless (1) | GPL-3.0 (repository licence); cites LLVM | - | - | +| `src/native.rs` | 1103 | Marvis (4), fxceless (1), local (1) | GPL-3.0 (repository licence) | - | 1 | +| `src/resource.rs` | 3848 | Claude (3), fxceless (3), Marvis (2) +2 more | GPL-3.0 (repository licence); cites LLVM | - | 10 | +| `src/spill.rs` | 380 | fxceless (2) | GPL-3.0 (repository licence) | - | 1 | +| `src/structure.rs` | 1899 | Marvis (2), fxceless (2), DexNom (1) +2 more | GPL-3.0 (repository licence) | - | - | + +BetterXen's additions (`src/emit/betterxen.rs`, `src/emit/betterxen_tests.rs`, `Cargo.toml`, `UPSTREAM.md`) are original, GPL-3.0-or-later. Functional edits to upstream files are listed in `crates/victory-shader/UPSTREAM.md`. diff --git a/workloads/d3d12-wave-probe/hlsl/add_f32_4.hlsl b/workloads/d3d12-wave-probe/hlsl/add_f32_4.hlsl new file mode 100644 index 0000000..661a036 --- /dev/null +++ b/workloads/d3d12-wave-probe/hlsl/add_f32_4.hlsl @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Control for add_f64_4: the same run-time load, add and store in single precision. If this writes +// and the double version does not, the load/store path is not the cause. +// Expected (by hand): word 0 = 2.0f (0x40000000), word 1 = 0 for each of the 4 threads. +RWByteAddressBuffer o : register(u0); +[numthreads(4, 1, 1)] +void main(uint t : SV_GroupIndex) { + uint z = o.Load(t * 8) ^ 0xDEADBEEF; + float s = asfloat(z ^ 0x3FA00000) + asfloat(z ^ 0x3F400000); // 1.25 + 0.75 + o.Store2(t * 8, uint2(asuint(s), z)); +} diff --git a/workloads/d3d12-wave-probe/hlsl/add_f64_4.hlsl b/workloads/d3d12-wave-probe/hlsl/add_f64_4.hlsl index 75ffab7..170dddd 100644 --- a/workloads/d3d12-wave-probe/hlsl/add_f64_4.hlsl +++ b/workloads/d3d12-wave-probe/hlsl/add_f64_4.hlsl @@ -1,11 +1,16 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// No wave operation: a plain double addition 1.25 + 0.75 = 2.0 (0x4000000000000000), to separate -// "doubles unsupported" from "wave operations on doubles unsupported". -// Expected (by hand): low word 0x00000000, high word 0x40000000. +// No wave operation: a double addition 1.25 + 0.75 = 2.0 (0x4000000000000000) whose operands are +// only known at run time, so the compiler cannot fold it. The host fills the buffer with +// 0xDEADBEEF; `z` is therefore 0 when the shader runs, but not at compile time. The compiled DXIL +// must contain `fadd ... double` (check with `dxc -dumpbin`). Separates "doubles unsupported" from +// "wave operations on doubles unsupported". +// Expected (by hand): low word 0x00000000, high word 0x40000000 for each of the 4 threads. RWByteAddressBuffer o : register(u0); [numthreads(4, 1, 1)] void main(uint t : SV_GroupIndex) { - double a = 1.25, b = 0.75 + (double)(t - t); + uint z = o.Load(t * 8) ^ 0xDEADBEEF; + double a = asdouble(z, z ^ 0x3FF40000); // 1.25 + double b = asdouble(z, z ^ 0x3FE80000); // 0.75 double s = a + b; uint lo, hi; asuint(s, lo, hi); diff --git a/workloads/d3d12-wave-probe/hlsl/sum_f64_4.hlsl b/workloads/d3d12-wave-probe/hlsl/sum_f64_4.hlsl index bf49e30..44d3642 100644 --- a/workloads/d3d12-wave-probe/hlsl/sum_f64_4.hlsl +++ b/workloads/d3d12-wave-probe/hlsl/sum_f64_4.hlsl @@ -1,11 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-or-later -// Expected (by hand): 4 threads each add the double 1.25; the sum is 5.0, whose bit pattern is -// 0x4014000000000000, so each lane stores low word 0x00000000 and high word 0x40140000. +// A wave sum over a double that is only known at run time (see add_f64_4.hlsl). +// Expected (by hand): 4 threads each add 1.25, sum 5.0 = 0x4014000000000000, so each stores low +// word 0x00000000 and high word 0x40140000. // The device reports DoublePrecisionFloatShaderOps = 0; this probe shows what actually happens. RWByteAddressBuffer o : register(u0); [numthreads(4, 1, 1)] void main(uint t : SV_GroupIndex) { - double s = WaveActiveSum(1.25); + uint z = o.Load(t * 8) ^ 0xDEADBEEF; + double s = WaveActiveSum(asdouble(z, z ^ 0x3FF40000)); uint lo, hi; asuint(s, lo, hi); o.Store2(t * 8, uint2(lo, hi));