Immediate sampler slots are kept apart by comparison mode (upstream 2286e03)

One constant used by a comparison and an ordinary sample became a
comparison sampler for both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-24 23:24:05 -06:00
1 parent 795d55eb73
commit 26a801e21a
2 files changed
+109 -24

No files matched your search

+92
View File
@@ -989,6 +989,98 @@ mod tests {
assert!(lower(unmarked).is_err());
}
#[test]
fn immediate_sampler_slots_distinguish_comparison_uses() {
let words = [
0xBE81_0380u32, // s_mov_b32 s1, 0
0xF40C_0000,
0xFA00_0000, // s_load_dwordx8 s[0:7], s[0:1], null
0xBE88_0380, // s_mov_b32 s8, 0
0xBE89_0380, // s_mov_b32 s9, 0
0xBE8A_0380, // s_mov_b32 s10, 0
0xBE8B_0380, // s_mov_b32 s11, 0
0x7E00_02F0, // v_mov_b32 v0, 0.5 (comparison reference)
0x7E02_02F0, // v_mov_b32 v1, 0.5 (u)
0x7E04_02F0, // v_mov_b32 v2, 0.5 (v)
0xBF8C_0070, // s_waitcnt vmcnt(0) lgkmcnt(0)
0xF080_0108,
0x0040_0301, // image_sample v3, v[1:2], s[0:7], s[8:11]
0xF0A0_0108,
0x0040_0400, // image_sample_c v4, v[0:2], s[0:7], s[8:11]
0xF0BC_0108,
0x0040_0500, // image_sample_c_lz v5, v[0:2], s[0:7], s[8:11]
0xF080_0108,
0x0040_0601, // image_sample v6, v[1:2], s[0:7], s[8:11]
0xBF8C_3F70, // s_waitcnt vmcnt(0)
0xF800_180F,
0x0605_0403, // exp mrt0, v3, v4, v5, v6 done vm
0xBF81_0000,
];
let native = NativeProgram {
stage: HwStage::Ps,
wave64: false,
vgprs: 7,
layout: vec![crate::native::RootParam {
root: RootType::Table,
table_offset_dwords: 0,
sgprs: 1,
base_register: 0,
user_data: 0,
slot: 0,
}],
used: vec![crate::native::UsedResource {
kind: crate::native::ResourceType::Srv,
root: RootType::Table,
table_offset_dwords: 0,
lower_bound: 0,
stride: 0,
dwords: 8,
user_data: 0,
slot: 0,
}],
io: StageIo::Ps {
inputs: vec![],
input_addr: 0,
db_shader_control: 0,
patches: vec![],
},
code: words.iter().flat_map(|w| w.to_le_bytes()).collect(),
};
let output = SigElement {
name: "SV_Target".into(),
index: 0,
kind: 16,
comp: 9,
interp: 0,
row: Some(0),
col: 0,
cols: 4,
usage: 15,
half: false,
};
let osg1 = container::signature(&[output], false);
let bytes = crate::dxbc::build(&[(FourCC::OSG1, &osg1)]);
let c = Container::parse(&bytes).unwrap();
let p = ir::build(&native.patched_code(), native.wave64, native.vgprs).unwrap();
let st = structure::structure(&p).unwrap();
let res = resource::track(&p, &native.layout, native.stage, Some(&st)).unwrap();
let io = io::raise(&p, &native).unwrap();
let out = emit(&c, &native, &p, &st, &io, &res).unwrap();
let sampler = StaticSampler::from_words([0; 4]);
let comparison = StaticSampler {
filter: sampler.filter | 0x80,
..sampler
};
assert_eq!(out.samplers, [[0; 4]; 2]);
assert_eq!(out.static_samplers, [sampler, comparison]);
#[cfg(windows)]
if let Some(path) = super::validator::Validator::default_path() {
let mut v = super::validator::Validator::load(Some(&path)).unwrap();
v.validate(&mut out.dxil.clone()).unwrap();
}
}
/// A wave64 compute program that writes only EXEC's high dword
/// (`s_mov_b32 exec_hi, 0`) before a vector instruction. The new mask was
/// opaque and keyed by the unchanged low dword, so building its lane bit