mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-21 18:30:42 +02:00
NirShader: don't fail on null constant_buffer
On iris (and probably other platforms too), an empty buffer could be a null pointer. This is problematic, because even empty slices can't have a null pointer. When we encounter an empty buffer, send an empty static slice instead. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28309>
This commit is contained in:
parent
f9b3e32440
commit
7a8771f7b5
1 changed files with 6 additions and 1 deletions
|
|
@ -440,7 +440,12 @@ impl NirShader {
|
|||
pub fn get_constant_buffer(&self) -> &[u8] {
|
||||
unsafe {
|
||||
let nir = self.nir.as_ref();
|
||||
slice::from_raw_parts(nir.constant_data.cast(), nir.constant_data_size as usize)
|
||||
// Sometimes, constant_data can be a null pointer if the size is 0
|
||||
if nir.constant_data_size == 0 {
|
||||
&[]
|
||||
} else {
|
||||
slice::from_raw_parts(nir.constant_data.cast(), nir.constant_data_size as usize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue