Typed buffer loads of 16-bit channels pack two per register; skipped devices say why (upstream c430b1d, 100de0e)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
75cfb234e5
commit
4e3e0654bf
5 files changed
+128
-24
No files matched your search
@@ -219,9 +219,12 @@ fn run_cases_on(
|
||||
let _one = ONE_AT_A_TIME.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let mut ran = 0;
|
||||
for &(label, warp) in devices {
|
||||
let Ok(host) = Host::new(warp) else {
|
||||
eprintln!("no SM 6.6 {label} device; skipped");
|
||||
continue;
|
||||
let host = match Host::new(warp) {
|
||||
Ok(host) => host,
|
||||
Err(e) => {
|
||||
eprintln!("no SM 6.6 {label} device ({e}); skipped");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let (root, pso) = host
|
||||
.compute_pipeline(shader)
|
||||
@@ -320,6 +323,51 @@ fn f16_to_f32(bits: u16) -> f32 {
|
||||
f32::from_bits(f32_bits)
|
||||
}
|
||||
|
||||
/// MTBUF `op vdata, off, s[srsrc:srsrc+3], 0 format:format` (at byte 0).
|
||||
const fn mtbuf(op: u8, vdata: u8, srsrc: u8, format: u8) -> [u32; 2] {
|
||||
[
|
||||
0x3A << 26 | (format as u32 & 0x7F) << 19 | (op as u32 & 7) << 16,
|
||||
0x80 << 24
|
||||
| (op as u32 >> 3 & 1) << 21
|
||||
| (srsrc as u32 >> 2 & 0x1F) << 16
|
||||
| (vdata as u32) << 8,
|
||||
]
|
||||
}
|
||||
|
||||
/// Stores `v1` to the buffer, then reads it back into `v0` with the tbuffer
|
||||
/// load `op` in buffer format `format`.
|
||||
fn tbuffer_load_of_v1(op: u8, format: u8) -> HostShader {
|
||||
let mut body = buffer_store_dword(1, 8, 0).to_vec();
|
||||
body.extend(mtbuf(op, 0, 8, format));
|
||||
build_valu_cs(&body)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tbuffer_d16_loads_pack_two_channels_per_dword() {
|
||||
// tbuffer_load_format_d16_x and tbuffer_load_format_d16_xy.
|
||||
let (x, xy) = (8, 9);
|
||||
// (opcode, format, dword stored, dword loaded)
|
||||
let cases: &[(u8, u8, u32, u32)] = &[
|
||||
// 16_16_FLOAT: the f16 pair (1.0, 2.0) as it was stored.
|
||||
(xy, 29, 0x4000_3C00, 0x4000_3C00),
|
||||
// 16_16_UINT: the 16-bit integers as they were stored.
|
||||
(xy, 27, 0xBEEF_1234, 0xBEEF_1234),
|
||||
// 16_16_UNORM: 0.0 and 1.0, as f16.
|
||||
(xy, 23, 0xFFFF_0000, 0x3C00_0000),
|
||||
// 16_FLOAT, one channel: the high half is 0.
|
||||
(x, 13, 0x4000_3C00, 0x0000_3C00),
|
||||
];
|
||||
for &(op, format, stored, want) in cases {
|
||||
let shader = tbuffer_load_of_v1(op, format);
|
||||
run_cases(&shader, &[[stored, 0, 0, 0]], |backend, _, _, got| {
|
||||
assert_eq!(
|
||||
got, want,
|
||||
"{backend}: d16 opcode {op} format {format} of {stored:#010x} = {got:#010x}, want {want:#010x}",
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normalized_buffer_formats_load_their_ends_exactly() {
|
||||
// tbuffer_load_format_x.
|
||||
|
||||
Reference in new issue
Block a user