rusticl: deal with compute_param returning 0

Some drivers might return 0 indicating they haven't written any data. But
treating it as 0 for all current `COMPUTE_CAP`s is fine, so no need to
panic at runtime here.

Signed-off-by: Karol Herbst <git@karolherbst.de>
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Nora Allen <blackcatgames@protonmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22893>
This commit is contained in:
Karol Herbst 2023-05-07 01:45:22 +02:00 committed by Marge Bot
parent a8df5cfa3a
commit 0fd1b21db2

View File

@ -37,6 +37,9 @@ macro_rules! compute_param_impl {
fn compute_param(&self, cap: pipe_compute_cap) -> $ty {
let size = self.compute_param_wrapped(cap, ptr::null_mut());
let mut d = [0; size_of::<$ty>()];
if size == 0 {
return Default::default();
}
assert_eq!(size as usize, d.len());
self.compute_param_wrapped(cap, d.as_mut_ptr().cast());
<$ty>::from_ne_bytes(d)