mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
rusticl/image: fix clEnqueueFillImage for CL_DEPTH
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30831>
This commit is contained in:
parent
2acfb55dfb
commit
2aec563acf
2 changed files with 15 additions and 11 deletions
|
|
@ -1967,16 +1967,25 @@ fn enqueue_fill_image(
|
|||
// description for origin and region.
|
||||
validate_image_bounds(&i, origin, region)?;
|
||||
|
||||
// we have to copy memory and it's always a 4 component int value
|
||||
// TODO but not for CL_DEPTH
|
||||
let fill_color = unsafe { slice::from_raw_parts(fill_color.cast(), 4).to_vec() };
|
||||
// The fill color is a single floating-point value if the channel order is CL_DEPTH. Otherwise,
|
||||
// the fill color is a four component RGBA floating-point color value if the image channel data
|
||||
// type is not an unnormalized signed or unsigned integer type, is a four component signed
|
||||
// integer value if the image channel data type is an unnormalized signed integer type and is a
|
||||
// four component unsigned integer value if the image channel data type is an unnormalized
|
||||
// unsigned integer type.
|
||||
let fill_color = if i.image_format.image_channel_order == CL_DEPTH {
|
||||
[unsafe { fill_color.cast::<u32>().read() }, 0, 0, 0]
|
||||
} else {
|
||||
unsafe { fill_color.cast::<[u32; 4]>().read() }
|
||||
};
|
||||
|
||||
create_and_queue(
|
||||
q,
|
||||
CL_COMMAND_FILL_BUFFER,
|
||||
evs,
|
||||
event,
|
||||
false,
|
||||
Box::new(move |q, ctx| i.fill(q, ctx, &fill_color, &origin, ®ion)),
|
||||
Box::new(move |q, ctx| i.fill(q, ctx, fill_color, &origin, ®ion)),
|
||||
)
|
||||
|
||||
//• CL_INVALID_IMAGE_SIZE if image dimensions (image width, height, specified or compute row and/or slice pitch) for image are not supported by device associated with queue.
|
||||
|
|
|
|||
|
|
@ -1293,7 +1293,7 @@ impl Image {
|
|||
&self,
|
||||
q: &Queue,
|
||||
ctx: &PipeContext,
|
||||
pattern: &[u32],
|
||||
pattern: [u32; 4],
|
||||
origin: &CLVec<usize>,
|
||||
region: &CLVec<usize>,
|
||||
) -> CLResult<()> {
|
||||
|
|
@ -1301,19 +1301,14 @@ 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: usize = self.image_format.pixel_size().unwrap().into();
|
||||
let mut new_pattern: Vec<u32> = vec![0; pixel_size.div_ceil(size_of::<u32>())];
|
||||
|
||||
// we don't support CL_DEPTH for now
|
||||
assert!(pattern.len() == 4);
|
||||
|
||||
// SAFETY: pointers have to be valid for read/writes of exactly one pixel of their
|
||||
// respective format.
|
||||
// `new_pattern` has the correct size due to the `size` above.
|
||||
// `pattern` is validated through the CL API and allows undefined behavior if not followed
|
||||
// by CL API rules. It's expected to be a 4 component array of 32 bit values, except for
|
||||
// CL_DEPTH where it's just one value.
|
||||
// by CL API rules.
|
||||
unsafe {
|
||||
util_format_pack_rgba(
|
||||
self.pipe_format,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue