nak: Add a nak_qmd_size_B() query

Also add a #define NAK_QMD_ALIGN_B for alignments.  The alignment is
always 256B and there's no evidence of that changing.

Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Backport-to: 25.2
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36995>
This commit is contained in:
Faith Ekstrand
2025-08-25 17:04:36 -04:00
committed by Marge Bot
parent 8e93a763a3
commit 02ef6a5158
3 changed files with 28 additions and 0 deletions
+1
View File
@@ -65,6 +65,7 @@ _nak_bindings_rs = rust.bindgen(
'--allowlist-type', 'nak_.*',
'--allowlist-type', 'nouveau_ws_.*',
'--allowlist-var', 'DRM_.*',
'--allowlist-var', 'NAK_.*',
'--allowlist-var', 'NVIDIA_VENDOR_ID',
'--allowlist-function', 'drm.*',
'--allowlist-function', 'nak_.*',
+6
View File
@@ -251,6 +251,12 @@ struct nak_qmd_info {
struct nak_qmd_cbuf cbufs[8];
};
#define NAK_QMD_ALIGN_B 256
#define NAK_MAX_QMD_SIZE_B 256
#define NAK_MAX_QMD_DWORDS (NAK_MAX_QMD_SIZE_B / 4)
uint32_t nak_qmd_size_B(const struct nv_device_info *dev);
void nak_fill_qmd(const struct nv_device_info *dev,
const struct nak_shader_info *info,
const struct nak_qmd_info *qmd_info,
+21
View File
@@ -580,6 +580,27 @@ fn fill_qmd<Q: QMD>(info: &nak_shader_info, qmd_info: &nak_qmd_info) -> Q {
qmd
}
#[no_mangle]
pub extern "C" fn nak_qmd_size_B(dev: &nv_device_info) -> u32 {
let size_B = if dev.cls_compute >= clcdc0::BLACKWELL_COMPUTE_A {
size_of::<Qmd5_0>().try_into().unwrap()
} else if dev.cls_compute >= clcbc0::HOPPER_COMPUTE_A {
size_of::<Qmd4_0>().try_into().unwrap()
} else if dev.cls_compute >= clc6c0::AMPERE_COMPUTE_A {
size_of::<Qmd3_0>().try_into().unwrap()
} else if dev.cls_compute >= clc3c0::VOLTA_COMPUTE_A {
size_of::<Qmd2_2>().try_into().unwrap()
} else if dev.cls_compute >= clc0c0::PASCAL_COMPUTE_A {
size_of::<Qmd2_1>().try_into().unwrap()
} else if dev.cls_compute >= cla0c0::KEPLER_COMPUTE_A {
size_of::<Qmd0_6>().try_into().unwrap()
} else {
panic!("Unknown shader model");
};
assert!(size_B <= NAK_MAX_QMD_SIZE_B);
size_B
}
#[no_mangle]
pub extern "C" fn nak_fill_qmd(
dev: *const nv_device_info,