rusticl/memory: fix clFillImage for buffer images

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29776>
(cherry picked from commit 4df8567394)
This commit is contained in:
Karol Herbst 2024-06-19 01:12:59 +02:00 committed by Eric Engestrom
parent 6489f1c1c4
commit a063c0503e
3 changed files with 4 additions and 10 deletions

View file

@ -14,7 +14,7 @@
"description": "rusticl/memory: fix clFillImage for buffer images",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -1309,11 +1309,8 @@ impl Image {
// make sure we allocate multiples of 4 bytes so drivers don't read out of bounds or
// unaligned.
// TODO: use div_ceil once it's available
let pixel_size = align(
self.image_format.pixel_size().unwrap().into(),
size_of::<u32>(),
);
let mut new_pattern: Vec<u32> = vec![0; pixel_size / size_of::<u32>()];
let pixel_size = self.image_format.pixel_size().unwrap().into();
let mut new_pattern: Vec<u32> = vec![0; div_round_up(pixel_size, size_of::<u32>())];
// we don't support CL_DEPTH for now
assert!(pattern.len() == 4);

View file

@ -143,9 +143,6 @@ impl PipeContext {
.map(|i| ((origin[i] + [0, y, z][i]) * pitch[i]) as u32)
.sum();
// SAFETY: clear_buffer arguments are specified
// in bytes, so pattern.len() dimension value
// should be multiplied by pixel_size
unsafe {
self.pipe.as_ref().clear_buffer.unwrap()(
self.pipe.as_ptr(),
@ -153,7 +150,7 @@ impl PipeContext {
offset,
(region[0] * pixel_size) as u32,
pattern.as_ptr().cast(),
(pattern.len() * pixel_size) as i32,
pixel_size as i32,
)
};
}