rusticl/mem: implement clCreateImage2D and 3D
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
This commit is contained in:
@@ -563,35 +563,55 @@ extern "C" fn cl_create_buffer(
|
||||
}
|
||||
|
||||
extern "C" fn cl_create_image_2d(
|
||||
_context: cl_context,
|
||||
_flags: cl_mem_flags,
|
||||
_image_format: *const cl_image_format,
|
||||
_image_width: usize,
|
||||
_image_height: usize,
|
||||
_image_row_pitch: usize,
|
||||
_host_ptr: *mut ::std::os::raw::c_void,
|
||||
context: cl_context,
|
||||
flags: cl_mem_flags,
|
||||
image_format: *const cl_image_format,
|
||||
image_width: usize,
|
||||
image_height: usize,
|
||||
image_row_pitch: usize,
|
||||
host_ptr: *mut ::std::os::raw::c_void,
|
||||
errcode_ret: *mut cl_int,
|
||||
) -> cl_mem {
|
||||
println!("cl_create_image_2d not implemented");
|
||||
errcode_ret.write_checked(CL_OUT_OF_HOST_MEMORY);
|
||||
ptr::null_mut()
|
||||
match_obj!(
|
||||
create_image_2d(
|
||||
context,
|
||||
flags,
|
||||
image_format,
|
||||
image_width,
|
||||
image_height,
|
||||
image_row_pitch,
|
||||
host_ptr,
|
||||
),
|
||||
errcode_ret
|
||||
)
|
||||
}
|
||||
|
||||
extern "C" fn cl_create_image_3d(
|
||||
_context: cl_context,
|
||||
_flags: cl_mem_flags,
|
||||
_image_format: *const cl_image_format,
|
||||
_image_width: usize,
|
||||
_image_height: usize,
|
||||
_image_depth: usize,
|
||||
_image_row_pitch: usize,
|
||||
_image_slice_pitch: usize,
|
||||
_host_ptr: *mut ::std::os::raw::c_void,
|
||||
context: cl_context,
|
||||
flags: cl_mem_flags,
|
||||
image_format: *const cl_image_format,
|
||||
image_width: usize,
|
||||
image_height: usize,
|
||||
image_depth: usize,
|
||||
image_row_pitch: usize,
|
||||
image_slice_pitch: usize,
|
||||
host_ptr: *mut ::std::os::raw::c_void,
|
||||
errcode_ret: *mut cl_int,
|
||||
) -> cl_mem {
|
||||
println!("cl_create_image_3d not implemented");
|
||||
errcode_ret.write_checked(CL_OUT_OF_HOST_MEMORY);
|
||||
ptr::null_mut()
|
||||
match_obj!(
|
||||
create_image_3d(
|
||||
context,
|
||||
flags,
|
||||
image_format,
|
||||
image_width,
|
||||
image_height,
|
||||
image_depth,
|
||||
image_row_pitch,
|
||||
image_slice_pitch,
|
||||
host_ptr,
|
||||
),
|
||||
errcode_ret
|
||||
)
|
||||
}
|
||||
|
||||
extern "C" fn cl_retain_mem_object(mem: cl_mem) -> cl_int {
|
||||
|
@@ -738,6 +738,50 @@ pub fn create_image(
|
||||
)
|
||||
}
|
||||
|
||||
pub fn create_image_2d(
|
||||
context: cl_context,
|
||||
flags: cl_mem_flags,
|
||||
image_format: *const cl_image_format,
|
||||
image_width: usize,
|
||||
image_height: usize,
|
||||
image_row_pitch: usize,
|
||||
host_ptr: *mut ::std::os::raw::c_void,
|
||||
) -> CLResult<cl_mem> {
|
||||
let image_desc = cl_image_desc {
|
||||
image_type: CL_MEM_OBJECT_IMAGE2D,
|
||||
image_width: image_width,
|
||||
image_height: image_height,
|
||||
image_row_pitch: image_row_pitch,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
create_image(context, flags, image_format, &image_desc, host_ptr)
|
||||
}
|
||||
|
||||
pub fn create_image_3d(
|
||||
context: cl_context,
|
||||
flags: cl_mem_flags,
|
||||
image_format: *const cl_image_format,
|
||||
image_width: usize,
|
||||
image_height: usize,
|
||||
image_depth: usize,
|
||||
image_row_pitch: usize,
|
||||
image_slice_pitch: usize,
|
||||
host_ptr: *mut ::std::os::raw::c_void,
|
||||
) -> CLResult<cl_mem> {
|
||||
let image_desc = cl_image_desc {
|
||||
image_type: CL_MEM_OBJECT_IMAGE3D,
|
||||
image_width: image_width,
|
||||
image_height: image_height,
|
||||
image_depth: image_depth,
|
||||
image_row_pitch: image_row_pitch,
|
||||
image_slice_pitch: image_slice_pitch,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
create_image(context, flags, image_format, &image_desc, host_ptr)
|
||||
}
|
||||
|
||||
pub fn get_supported_image_formats(
|
||||
context: cl_context,
|
||||
flags: cl_mem_flags,
|
||||
|
Reference in New Issue
Block a user