1#![allow(clippy::missing_safety_doc)]
21
22pub use opencl_sys::cl_d3d11::*;
23pub use opencl_sys::{
24 CL_INVALID_VALUE, CL_SUCCESS, cl_context, cl_int, cl_mem_flags, cl_mem_object_type, cl_uint,
25};
26
27#[allow(unused_imports)]
28use libc::c_void;
29#[allow(unused_imports)]
30use std::ptr;
31
32#[cfg(any(feature = "cl_khr_d3d11_sharing", feature = "dynamic"))]
33pub unsafe fn get_supported_d3d11_texture_formats_intel(
34 context: cl_context,
35 flags: cl_mem_flags,
36 image_type: cl_mem_object_type,
37 plane: cl_uint,
38) -> Result<Vec<cl_uint>, cl_int> {
39 let mut count: cl_uint = 0;
40 let status: cl_int = cl_call!(cl_d3d11::clGetSupportedD3D11TextureFormatsINTEL(
41 context,
42 flags,
43 image_type,
44 plane,
45 0,
46 ptr::null_mut(),
47 &raw mut count,
48 ));
49 if CL_SUCCESS != status {
50 Err(status)
51 } else if 0 < count {
52 let len = count as usize;
54 let mut ids: Vec<cl_uint> = Vec::with_capacity(len);
55 let status: cl_int = cl_call!(cl_d3d11::clGetSupportedD3D11TextureFormatsINTEL(
56 context,
57 flags,
58 image_type,
59 plane,
60 count,
61 ids.as_mut_ptr(),
62 ptr::null_mut(),
63 ));
64 if CL_SUCCESS == status {
65 Ok(ids)
66 } else {
67 Err(status)
68 }
69 } else {
70 Ok(Vec::default())
71 }
72}