Faces move, ray tracing mostly off, intro video fix, picture fixes
- Faces: the face network's 16-bit values travel through integer views; they were read as floats and came back as zeros on NVIDIA. Port of fxceless/victory-fork pull request 927 (tippythetaidum): emit/halves.rs, lower.rs, descriptor/host.rs, draw.rs. - Ray tracing mostly off: scripts/rt_off_hashes.txt lists the 1,000 CS_RaytracingResolve and 34 traced-shadow shaders, skipped by play-nvidia.ps1 through VICTORY_SKIP_PIPELINES (-RayTracing keeps them). The structure builder cannot run on NVIDIA, so every ray missed and rooms went white depending on the view angle. The screen-probe and visibility traces keep running; skipping them left rainbow glitter. - Intro video flicker: linear one-level R8 video planes always record their copy (texture.rs), so frames of the ring no longer show out of order. - VICTORY_AMBIENT_MOST (ambient.rs), VICTORY_NAN_SCRUB (emit/lower.rs) and VICTORY_PIPELINE_WAIT_ONCE (pipeline/make.rs, on by default). - Off by default: VICTORY_CONSTANT_MARKS (port of fxceless pull request 1216), VICTORY_TARGET_VARIANTS (port of fxceless a35c557393), F9 frame capture (capture.rs). - play-nvidia.ps1: the speed set by default, -Quality for the slower set with fewer stretched bodies and less rainbow skin. README updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
3e5fb36392
commit
77e13a974a
27 files changed
+1868
-73
No files matched your search
@@ -181,6 +181,7 @@ fn build_cs(body: &[u32], threads: u32, lds_bytes: u32) -> HostShader {
|
||||
root_srvs: lowered.root_srvs,
|
||||
root_uavs: lowered.root_uavs,
|
||||
root_indexed_views: res.root_indexed_views,
|
||||
half_views: lowered.half_views,
|
||||
};
|
||||
|
||||
if let Ok(mut v) = validator::Validator::load(validator::Validator::default_path().as_deref()) {
|
||||
@@ -1918,6 +1919,7 @@ fn whole_wave_f64_sum_and_cvt_f32_f64() {
|
||||
root_srvs: lowered.root_srvs,
|
||||
root_uavs: lowered.root_uavs,
|
||||
root_indexed_views: Vec::new(),
|
||||
half_views: lowered.half_views,
|
||||
};
|
||||
if let Ok(mut v) = validator::Validator::load(validator::Validator::default_path().as_deref()) {
|
||||
let mut copy = shader.dxil.clone();
|
||||
@@ -2057,3 +2059,488 @@ fn rdna_forms_give_what_the_spelled_out_ones_give() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A program that moves a typed buffer's 16-bit channels
|
||||
/// (`buffer_load_format_d16_xyzw` from the table's first view,
|
||||
/// `buffer_store_format_d16_xyzw` to its second) names both places for the
|
||||
/// host (`HostShader::half_views`) and moves every pattern as it is through
|
||||
/// unsigned views: half floats, the not-a-number ones among them, and
|
||||
/// plain 16-bit integers (the title keeps both in such buffers; the
|
||||
/// network that moves its faces reads indices this way). A program that
|
||||
/// moves no halves names nothing.
|
||||
#[test]
|
||||
fn halves_go_through_a_table_as_they_are_and_name_their_views() {
|
||||
use super::host::Stride;
|
||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R16G16B16A16_UINT;
|
||||
/// MUBUF `op vdata, vaddr, s[srsrc:srsrc+3], 0 idxen`.
|
||||
const fn mubuf_idxen(op: u32, vdata: u8, vaddr: u8, srsrc: u8) -> [u32; 2] {
|
||||
[
|
||||
0x38 << 26 | op << 18 | 1 << 13,
|
||||
0x80 << 24 | ((srsrc as u32 >> 2) & 0x1F) << 16 | (vdata as u32) << 8 | vaddr as u32,
|
||||
]
|
||||
}
|
||||
const LOAD_D16_XYZW: u32 = 0x83;
|
||||
const STORE_D16_XYZW: u32 = 0x87;
|
||||
const THREADS: u32 = 32;
|
||||
// The table's second descriptor, 0x20 bytes on.
|
||||
let mut second = s_load_dwordx4(12, 4);
|
||||
second[1] |= 0x20;
|
||||
let mut words = vec![s_mov_b32(5, 0x80)];
|
||||
words.extend_from_slice(&s_load_dwordx4(8, 4));
|
||||
words.extend_from_slice(&second);
|
||||
// v[1:2] = first[thread] (four halves), second[thread] = v[1:2].
|
||||
words.extend_from_slice(&mubuf_idxen(LOAD_D16_XYZW, 1, 0, 8));
|
||||
words.extend_from_slice(&mubuf_idxen(STORE_D16_XYZW, 1, 0, 12));
|
||||
words.push(S_ENDPGM);
|
||||
let view = |kind: ResourceType, table_offset_dwords: u32| UsedResource {
|
||||
kind,
|
||||
root: RootType::Table,
|
||||
table_offset_dwords,
|
||||
lower_bound: table_offset_dwords / 8,
|
||||
stride: 4,
|
||||
dwords: 4,
|
||||
user_data: 4,
|
||||
slot: 1,
|
||||
};
|
||||
let native = NativeProgram {
|
||||
stage: HwStage::Cs,
|
||||
wave64: false,
|
||||
vgprs: 8,
|
||||
layout: vec![
|
||||
RootParam {
|
||||
root: RootType::Constants,
|
||||
table_offset_dwords: 0,
|
||||
sgprs: 4,
|
||||
base_register: 0,
|
||||
user_data: 0,
|
||||
slot: 0,
|
||||
},
|
||||
RootParam {
|
||||
root: RootType::Table,
|
||||
table_offset_dwords: 0,
|
||||
sgprs: 1,
|
||||
base_register: 0,
|
||||
user_data: 4,
|
||||
slot: 1,
|
||||
},
|
||||
],
|
||||
used: vec![view(ResourceType::Srv, 0), view(ResourceType::Uav, 8)],
|
||||
io: StageIo::Cs(ComputeIo {
|
||||
rsrc2: 5 << 1,
|
||||
threads: [THREADS, 1, 1],
|
||||
}),
|
||||
code: words.iter().flat_map(|w| w.to_le_bytes()).collect(),
|
||||
};
|
||||
let p = ir::build(&native.code, native.wave64, native.vgprs).expect("ir::build");
|
||||
let st = structure::structure(&p).expect("structure");
|
||||
let res =
|
||||
resource::track(&p, &native.layout, native.stage, Some(&st)).expect("resource::track");
|
||||
let io = io::raise(&p, &native).expect("io::raise");
|
||||
let lowered = lower::lower(&lower::Parts {
|
||||
native: &native,
|
||||
p: &p,
|
||||
st: &st,
|
||||
io: &io,
|
||||
res: &res,
|
||||
inputs: Vec::new(),
|
||||
outputs: Vec::new(),
|
||||
prims: Vec::new(),
|
||||
mesh_stride: 0,
|
||||
})
|
||||
.expect("lower");
|
||||
assert_eq!(lowered.half_views, [(1, 0), (1, 8)]);
|
||||
let shader = HostShader {
|
||||
stage: HwStage::Cs,
|
||||
dxil: lowered.dxil,
|
||||
user_data: lowered.user_data,
|
||||
samplers: lowered.samplers,
|
||||
static_samplers: Vec::new(),
|
||||
root_cbvs: lowered.root_cbvs,
|
||||
root_srvs: lowered.root_srvs,
|
||||
root_uavs: lowered.root_uavs,
|
||||
root_indexed_views: res.root_indexed_views,
|
||||
half_views: lowered.half_views,
|
||||
};
|
||||
if let Ok(mut v) = validator::Validator::load(validator::Validator::default_path().as_deref()) {
|
||||
let mut dxil = shader.dxil.clone();
|
||||
v.validate(&mut dxil).expect("DXIL validation failed");
|
||||
}
|
||||
// A raw store through the same table: no halves, nothing named.
|
||||
assert!(build_valu_cs(&[]).half_views.is_empty());
|
||||
|
||||
// Four halves a thread: numbers, both zeros, subnormals, infinities,
|
||||
// not-a-numbers of both signs, and integers past the largest number's
|
||||
// pattern, as indices are.
|
||||
const SPECIAL: [u16; 16] = [
|
||||
0x0000, 0x0001, 0x03ff, 0x0400, 0x3c00, 0x7bff, 0x7c00, 0x7c01, 0x7e00, 0x7fff, 0x8000,
|
||||
0x8001, 0xbc00, 0xfc00, 0xfc01, 0xffff,
|
||||
];
|
||||
let halves: Vec<u16> = (0..4 * THREADS as usize)
|
||||
.map(|i| match i {
|
||||
0..16 => SPECIAL[i],
|
||||
_ => (i as u16).wrapping_mul(0x0203).wrapping_add(0x7b00),
|
||||
})
|
||||
.collect();
|
||||
let data: Vec<u32> = halves
|
||||
.chunks(2)
|
||||
.map(|pair| u32::from(pair[0]) | u32::from(pair[1]) << 16)
|
||||
.collect();
|
||||
let _one = ONE_AT_A_TIME.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let mut ran = 0;
|
||||
for (label, warp) in [("hardware", false), ("warp", true)] {
|
||||
let Ok(host) = Host::new(warp) else {
|
||||
eprintln!("no SM 6.6 {label} device; skipped");
|
||||
continue;
|
||||
};
|
||||
let (root, pso) = host
|
||||
.compute_pipeline(&shader)
|
||||
.unwrap_or_else(|e| panic!("{label}: compute_pipeline failed: {e}"));
|
||||
let mut ud = vec![0u32; shader.user_data_dwords().max(1) as usize];
|
||||
for u in &shader.user_data {
|
||||
ud[u.index as usize] = match (u.root, u.slot) {
|
||||
(RootType::Table, 1) => 0,
|
||||
other => panic!("unexpected user data {other:?}"),
|
||||
};
|
||||
}
|
||||
let out = host
|
||||
.dispatch(
|
||||
&root,
|
||||
&pso,
|
||||
&Dispatch {
|
||||
roots: vec![(0, Root::Constants(ud))],
|
||||
views: &[
|
||||
View::Buffer {
|
||||
data: &data,
|
||||
stride: Stride::Format(DXGI_FORMAT_R16G16B16A16_UINT, 8),
|
||||
},
|
||||
View::HalfUintUav(THREADS),
|
||||
],
|
||||
samplers: &[],
|
||||
groups: [1, 1, 1],
|
||||
},
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("{label}: dispatch failed: {e}"));
|
||||
assert_eq!(
|
||||
out[0], data,
|
||||
"{label}: the halves stored are the halves loaded"
|
||||
);
|
||||
ran += 1;
|
||||
}
|
||||
assert!(ran > 0, "no SM 6.6 device available");
|
||||
}
|
||||
|
||||
/// The places a program that moves halves names are the descriptors it
|
||||
/// loads, not the start of the range their used-resource entry describes:
|
||||
/// with one entry for a range from dword 0, a load at byte 0x20 names
|
||||
/// dword 8 (a host view there in a 16-bit float format is the one shown
|
||||
/// as its unsigned twin). A descriptor picked at run time (the load's
|
||||
/// offset in an SGPR) names nothing and keeps the float path: which slot
|
||||
/// it reads, and in which format, is known only then.
|
||||
#[test]
|
||||
fn half_places_are_the_descriptors_the_program_loads() {
|
||||
/// MUBUF `op vdata, vaddr, s[srsrc:srsrc+3], 0 idxen`.
|
||||
const fn mubuf_idxen(op: u32, vdata: u8, vaddr: u8, srsrc: u8) -> [u32; 2] {
|
||||
[
|
||||
0x38 << 26 | op << 18 | 1 << 13,
|
||||
0x80 << 24 | ((srsrc as u32 >> 2) & 0x1F) << 16 | (vdata as u32) << 8 | vaddr as u32,
|
||||
]
|
||||
}
|
||||
const LOAD_D16_XYZW: u32 = 0x83;
|
||||
const STORE_D16_XYZW: u32 = 0x87;
|
||||
let lowered = |words: &[u32]| {
|
||||
let range = |kind: ResourceType, table_offset_dwords: u32| UsedResource {
|
||||
kind,
|
||||
root: RootType::Table,
|
||||
table_offset_dwords,
|
||||
lower_bound: table_offset_dwords / 8,
|
||||
stride: 4,
|
||||
dwords: 4,
|
||||
user_data: 4,
|
||||
slot: 1,
|
||||
};
|
||||
let native = NativeProgram {
|
||||
stage: HwStage::Cs,
|
||||
wave64: false,
|
||||
vgprs: 8,
|
||||
layout: vec![
|
||||
RootParam {
|
||||
root: RootType::Constants,
|
||||
table_offset_dwords: 0,
|
||||
sgprs: 4,
|
||||
base_register: 0,
|
||||
user_data: 0,
|
||||
slot: 0,
|
||||
},
|
||||
RootParam {
|
||||
root: RootType::Table,
|
||||
table_offset_dwords: 0,
|
||||
sgprs: 1,
|
||||
base_register: 0,
|
||||
user_data: 4,
|
||||
slot: 1,
|
||||
},
|
||||
],
|
||||
// One entry for a range of views from dword 0, one at 16.
|
||||
used: vec![range(ResourceType::Srv, 0), range(ResourceType::Uav, 16)],
|
||||
io: StageIo::Cs(ComputeIo {
|
||||
rsrc2: 5 << 1,
|
||||
threads: [32, 1, 1],
|
||||
}),
|
||||
code: words.iter().flat_map(|w| w.to_le_bytes()).collect(),
|
||||
};
|
||||
let p = ir::build(&native.code, native.wave64, native.vgprs).expect("ir::build");
|
||||
let st = structure::structure(&p).expect("structure");
|
||||
let res =
|
||||
resource::track(&p, &native.layout, native.stage, Some(&st)).expect("resource::track");
|
||||
let io = io::raise(&p, &native).expect("io::raise");
|
||||
lower::lower(&lower::Parts {
|
||||
native: &native,
|
||||
p: &p,
|
||||
st: &st,
|
||||
io: &io,
|
||||
res: &res,
|
||||
inputs: Vec::new(),
|
||||
outputs: Vec::new(),
|
||||
prims: Vec::new(),
|
||||
mesh_stride: 0,
|
||||
})
|
||||
.expect("lower")
|
||||
};
|
||||
// `s_load_dwordx4 s[dst:dst+3], s[4:5], offset` (soffset null), or with
|
||||
// the offset in `soffset` instead.
|
||||
let at = |dst: u8, offset: u32| {
|
||||
let mut w = s_load_dwordx4(dst, 4);
|
||||
w[1] |= offset;
|
||||
w
|
||||
};
|
||||
let picked = |dst: u8, soffset: u8| {
|
||||
let mut w = s_load_dwordx4(dst, 4);
|
||||
w[1] = u32::from(soffset) << 25;
|
||||
w
|
||||
};
|
||||
let mut fixed = vec![s_mov_b32(5, 0x80)];
|
||||
fixed.extend_from_slice(&at(8, 0x20));
|
||||
fixed.extend_from_slice(&at(12, 0x40));
|
||||
fixed.extend_from_slice(&mubuf_idxen(LOAD_D16_XYZW, 1, 0, 8));
|
||||
fixed.extend_from_slice(&mubuf_idxen(STORE_D16_XYZW, 1, 0, 12));
|
||||
fixed.push(S_ENDPGM);
|
||||
assert_eq!(lowered(&fixed).half_views, [(1, 8), (1, 16)]);
|
||||
// The load's offset in s20, from the first lane's thread index
|
||||
// (`v_readfirstlane_b32 s20, v0`): picked at run time. The pick may land
|
||||
// on the store's place too, so no place of that table is named: the d16
|
||||
// accesses there take the float path, as before half views.
|
||||
let mut runtime = vec![s_mov_b32(5, 0x80), vop1(0x02, 20, vgpr(0))];
|
||||
runtime.extend_from_slice(&picked(8, 20));
|
||||
runtime.extend_from_slice(&at(12, 0x40));
|
||||
runtime.extend_from_slice(&mubuf_idxen(LOAD_D16_XYZW, 1, 0, 8));
|
||||
runtime.extend_from_slice(&mubuf_idxen(STORE_D16_XYZW, 1, 0, 12));
|
||||
runtime.push(S_ENDPGM);
|
||||
assert!(lowered(&runtime).half_views.is_empty());
|
||||
}
|
||||
|
||||
/// A format load of whole dwords (`buffer_load_format_x`, not d16) whose
|
||||
/// result the program only reads one half of as a half float
|
||||
/// (`v_cvt_f32_f16`) is moving 16-bit integers: the head program reads the
|
||||
/// face network's output so, from an `R16_UINT` view. It names its view for
|
||||
/// the host and loads the integer: 0x3c00 comes through as 1.0. Used as a
|
||||
/// whole float instead (`v_add_f32`), the load stays a float load and names
|
||||
/// nothing; so does a load of halves beside a load of the same view read as
|
||||
/// a whole float (a view of numbers the program also picks one half float
|
||||
/// out of, as hundreds of the title's pixel programs do).
|
||||
#[test]
|
||||
fn a_format_load_read_as_halves_loads_the_integer() {
|
||||
use super::host::Stride;
|
||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R16_UINT;
|
||||
/// MUBUF `op vdata, vaddr, s[srsrc:srsrc+3], 0 idxen`.
|
||||
const fn mubuf_idxen(op: u32, vdata: u8, vaddr: u8, srsrc: u8) -> [u32; 2] {
|
||||
[
|
||||
0x38 << 26 | op << 18 | 1 << 13,
|
||||
0x80 << 24 | ((srsrc as u32 >> 2) & 0x1F) << 16 | (vdata as u32) << 8 | vaddr as u32,
|
||||
]
|
||||
}
|
||||
const LOAD_FORMAT_X: u32 = 0x00;
|
||||
const V_CVT_F32_F16: u16 = 0x0B;
|
||||
const V_ADD_F32: u8 = 0x03;
|
||||
let lowered = |body: &[u32]| {
|
||||
let view = |kind: ResourceType, table_offset_dwords: u32, stride: u32| UsedResource {
|
||||
kind,
|
||||
root: RootType::Table,
|
||||
table_offset_dwords,
|
||||
lower_bound: table_offset_dwords / 8,
|
||||
stride,
|
||||
dwords: 4,
|
||||
user_data: 4,
|
||||
slot: 1,
|
||||
};
|
||||
let mut second = s_load_dwordx4(12, 4);
|
||||
second[1] |= 0x20;
|
||||
let mut words = vec![s_mov_b32(5, 0x80)];
|
||||
words.extend_from_slice(&s_load_dwordx4(8, 4));
|
||||
words.extend_from_slice(&second);
|
||||
// `body` leaves v2, stored raw.
|
||||
words.extend_from_slice(body);
|
||||
words.extend_from_slice(&buffer_store_dword(2, 12, 0));
|
||||
words.push(S_ENDPGM);
|
||||
let native = NativeProgram {
|
||||
stage: HwStage::Cs,
|
||||
wave64: false,
|
||||
vgprs: 8,
|
||||
layout: vec![
|
||||
RootParam {
|
||||
root: RootType::Constants,
|
||||
table_offset_dwords: 0,
|
||||
sgprs: 4,
|
||||
base_register: 0,
|
||||
user_data: 0,
|
||||
slot: 0,
|
||||
},
|
||||
RootParam {
|
||||
root: RootType::Table,
|
||||
table_offset_dwords: 0,
|
||||
sgprs: 1,
|
||||
base_register: 0,
|
||||
user_data: 4,
|
||||
slot: 1,
|
||||
},
|
||||
],
|
||||
used: vec![view(ResourceType::Srv, 0, 4), view(ResourceType::Uav, 8, 0)],
|
||||
io: StageIo::Cs(ComputeIo {
|
||||
rsrc2: 5 << 1,
|
||||
threads: [1, 1, 1],
|
||||
}),
|
||||
code: words.iter().flat_map(|w| w.to_le_bytes()).collect(),
|
||||
};
|
||||
let p = ir::build(&native.code, native.wave64, native.vgprs).expect("ir::build");
|
||||
let st = structure::structure(&p).expect("structure");
|
||||
let res =
|
||||
resource::track(&p, &native.layout, native.stage, Some(&st)).expect("resource::track");
|
||||
let io = io::raise(&p, &native).expect("io::raise");
|
||||
let l = lower::lower(&lower::Parts {
|
||||
native: &native,
|
||||
p: &p,
|
||||
st: &st,
|
||||
io: &io,
|
||||
res: &res,
|
||||
inputs: Vec::new(),
|
||||
outputs: Vec::new(),
|
||||
prims: Vec::new(),
|
||||
mesh_stride: 0,
|
||||
})
|
||||
.expect("lower");
|
||||
HostShader {
|
||||
stage: HwStage::Cs,
|
||||
dxil: l.dxil,
|
||||
user_data: l.user_data,
|
||||
samplers: l.samplers,
|
||||
static_samplers: Vec::new(),
|
||||
root_cbvs: l.root_cbvs,
|
||||
root_srvs: l.root_srvs,
|
||||
root_uavs: l.root_uavs,
|
||||
root_indexed_views: res.root_indexed_views,
|
||||
half_views: l.half_views,
|
||||
}
|
||||
};
|
||||
// v1 = first[v0] (one channel).
|
||||
let load = mubuf_idxen(LOAD_FORMAT_X, 1, 0, 8);
|
||||
let half = vop1(V_CVT_F32_F16, 2, vgpr(1));
|
||||
let as_halves = lowered(&[&load[..], &[half]].concat());
|
||||
assert_eq!(as_halves.half_views, [(1, 0)]);
|
||||
let as_float = lowered(&[&load[..], &[vop2(V_ADD_F32, 2, vgpr(1), 1)]].concat());
|
||||
assert!(as_float.half_views.is_empty());
|
||||
// v3 = first[v0] too, read as a whole float: v2 = half(v1) + v3.
|
||||
let mut beside = load.to_vec();
|
||||
beside.extend_from_slice(&mubuf_idxen(LOAD_FORMAT_X, 3, 0, 8));
|
||||
beside.push(half);
|
||||
beside.push(vop2(V_ADD_F32, 2, vgpr(3), 2));
|
||||
assert!(lowered(&beside).half_views.is_empty());
|
||||
// Behind a branch, as the head program has it: where the lanes meet
|
||||
// again the loaded value goes on through a phi, and a later write of
|
||||
// v1 under EXEC reads it only to keep it in the lanes it leaves alone.
|
||||
const SAVE_EXEC: u32 = 0xBE90_037E; // s_mov_b32 s16, exec_lo
|
||||
const ONLY_LANE_0: u32 = 0x7DA4_0080; // v_cmpx_eq_u32 exec_lo, 0, v0
|
||||
const SKIP_3: u32 = 0xBF88_0003; // s_cbranch_execz over the next 3 words
|
||||
const RESTORE_EXEC: u32 = 0xBEFE_0310; // s_mov_b32 exec_lo, s16
|
||||
let zero = vop1(0x01, 2, 128); // v_mov_b32 v2, 0
|
||||
let rewrite = vop1(0x01, 1, 128); // v_mov_b32 v1, 0
|
||||
let branched = lowered(
|
||||
&[
|
||||
&[zero, SAVE_EXEC, ONLY_LANE_0, SKIP_3][..],
|
||||
&load,
|
||||
&[
|
||||
half,
|
||||
RESTORE_EXEC,
|
||||
SAVE_EXEC,
|
||||
ONLY_LANE_0,
|
||||
rewrite,
|
||||
RESTORE_EXEC,
|
||||
],
|
||||
]
|
||||
.concat(),
|
||||
);
|
||||
assert_eq!(branched.half_views, [(1, 0)]);
|
||||
// A d16 load names its place where it is the only access there...
|
||||
const LOAD_FORMAT_D16_X: u32 = 0x80;
|
||||
let d16 = mubuf_idxen(LOAD_FORMAT_D16_X, 1, 0, 8);
|
||||
let d16_alone = lowered(&[&d16[..], &[half]].concat());
|
||||
assert_eq!(d16_alone.half_views, [(1, 0)]);
|
||||
// ...and not beside a whole float read through the same place, which
|
||||
// would see the unsigned twin: v2 = half(d16 v1) + v3.
|
||||
let mut d16_beside = d16.to_vec();
|
||||
d16_beside.extend_from_slice(&mubuf_idxen(LOAD_FORMAT_X, 3, 0, 8));
|
||||
d16_beside.push(half);
|
||||
d16_beside.push(vop2(V_ADD_F32, 2, vgpr(3), 2));
|
||||
assert!(lowered(&d16_beside).half_views.is_empty());
|
||||
if let Ok(mut v) = validator::Validator::load(validator::Validator::default_path().as_deref()) {
|
||||
for shader in [&as_halves, &branched, &d16_alone] {
|
||||
let mut dxil = shader.dxil.clone();
|
||||
v.validate(&mut dxil).expect("DXIL validation failed");
|
||||
}
|
||||
}
|
||||
// Element 0 of an R16_UINT buffer holds the half 1.0 (0x3c00).
|
||||
let data = [0x0000_3c00u32, 0];
|
||||
let _one = ONE_AT_A_TIME.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let mut ran = 0;
|
||||
for (label, warp) in [("hardware", false), ("warp", true)] {
|
||||
let Ok(host) = Host::new(warp) else {
|
||||
eprintln!("no SM 6.6 {label} device; skipped");
|
||||
continue;
|
||||
};
|
||||
for (name, shader) in [("straight", &as_halves), ("branched", &branched)] {
|
||||
let (root, pso) = host
|
||||
.compute_pipeline(shader)
|
||||
.unwrap_or_else(|e| panic!("{label}: compute_pipeline failed: {e}"));
|
||||
let mut ud = vec![0u32; shader.user_data_dwords().max(1) as usize];
|
||||
for u in &shader.user_data {
|
||||
ud[u.index as usize] = match (u.root, u.slot) {
|
||||
(RootType::Table, 1) => 0,
|
||||
other => panic!("unexpected user data {other:?}"),
|
||||
};
|
||||
}
|
||||
let out = host
|
||||
.dispatch(
|
||||
&root,
|
||||
&pso,
|
||||
&Dispatch {
|
||||
roots: vec![(0, Root::Constants(ud))],
|
||||
views: &[
|
||||
View::Buffer {
|
||||
data: &data,
|
||||
stride: Stride::Format(DXGI_FORMAT_R16_UINT, 2),
|
||||
},
|
||||
View::RawUav(1),
|
||||
],
|
||||
samplers: &[],
|
||||
groups: [1, 1, 1],
|
||||
},
|
||||
)
|
||||
.unwrap_or_else(|e| panic!("{label}: dispatch failed: {e}"));
|
||||
assert_eq!(
|
||||
out[0][0],
|
||||
1.0f32.to_bits(),
|
||||
"{label}, {name}: the half read as an integer's bits"
|
||||
);
|
||||
}
|
||||
ran += 1;
|
||||
}
|
||||
assert!(ran > 0, "no SM 6.6 device available");
|
||||
}
|
||||
Reference in new issue
Block a user