opencl_sys/
cl_d3d10.rs

1// Copyright (c) 2021-2023 Via Technology Ltd.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//    http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! FFI bindings for [cl_d3d10.h](https://github.com/KhronosGroup/OpenCL-Headers/blob/main/CL/cl_d3d10.h).
16//!
17//! `cl_d3d10.h` contains `OpenCL` extensions that provide interoperability with `Direct3D` 10.
18//! `OpenCL` extensions are documented in the [OpenCL-Registry](https://github.com/KhronosGroup/OpenCL-Registry)
19
20#![allow(non_camel_case_types, non_upper_case_globals)]
21
22use super::cl::{
23    cl_command_queue, cl_command_type, cl_context, cl_context_info, cl_device_id, cl_event,
24    cl_image_info, cl_mem, cl_mem_flags, cl_mem_info, cl_mem_object_type, cl_platform_id,
25};
26use super::cl_platform::{DXGI_FORMAT, cl_int, cl_uint};
27use libc::c_void;
28
29// cl_khr_d3d10_sharing
30
31pub type cl_d3d10_device_source_khr = cl_uint;
32pub type cl_d3d10_device_set_khr = cl_uint;
33
34// Error Codes
35pub const CL_INVALID_D3D10_DEVICE_KHR: cl_int = -1002;
36pub const CL_INVALID_D3D10_RESOURCE_KHR: cl_int = -1003;
37pub const CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR: cl_int = -1004;
38pub const CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR: cl_int = -1005;
39
40// cl_d3d10_device_source_khr
41pub const CL_D3D10_DEVICE_KHR: cl_d3d10_device_source_khr = 0x4010;
42pub const CL_D3D10_DXGI_ADAPTER_KHR: cl_d3d10_device_source_khr = 0x4011;
43
44// cl_d3d10_device_set_khr
45pub const CL_PREFERRED_DEVICES_FOR_D3D10_KHR: cl_d3d10_device_set_khr = 0x4012;
46pub const CL_ALL_DEVICES_FOR_D3D10_KHR: cl_d3d10_device_set_khr = 0x4013;
47
48// cl_context_info
49pub const CL_CONTEXT_D3D10_DEVICE_KHR: cl_context_info = 0x4014;
50pub const CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR: cl_context_info = 0x402C;
51
52// cl_mem_info
53pub const CL_MEM_D3D10_RESOURCE_KHR: cl_mem_info = 0x4015;
54
55// cl_image_info
56pub const CL_IMAGE_D3D10_SUBRESOURCE_KHR: cl_image_info = 0x4016;
57
58// cl_command_type
59pub const CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR: cl_command_type = 0x4017;
60pub const CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR: cl_command_type = 0x4018;
61
62pub type ID3D10Buffer_ptr = *mut c_void;
63pub type ID3D10Texture2D_ptr = *mut c_void;
64pub type ID3D10Texture3D_ptr = *mut c_void;
65
66pub type clGetDeviceIDsFromD3D10KHR_t = Option<
67    unsafe extern "C" fn(
68        platform: cl_platform_id,
69        d3d_device_source: cl_d3d10_device_source_khr,
70        d3d_object: *mut c_void,
71        d3d_device_set: cl_d3d10_device_set_khr,
72        num_entries: cl_uint,
73        devices: *mut cl_device_id,
74        num_devices: *mut cl_uint,
75    ) -> cl_int,
76>;
77pub type clGetDeviceIDsFromD3D10KHR_fn = clGetDeviceIDsFromD3D10KHR_t;
78
79pub type clCreateFromD3D10BufferKHR_t = Option<
80    unsafe extern "C" fn(
81        context: cl_context,
82        flags: cl_mem_flags,
83        resource: ID3D10Buffer_ptr,
84        errcode_ret: *mut cl_int,
85    ) -> cl_mem,
86>;
87pub type clCreateFromD3D10BufferKHR_fn = clCreateFromD3D10BufferKHR_t;
88
89pub type clCreateFromD3D10Texture2DKHR_t = Option<
90    unsafe extern "C" fn(
91        context: cl_context,
92        flags: cl_mem_flags,
93        resource: ID3D10Texture2D_ptr,
94        subresource: cl_uint,
95        errcode_ret: *mut cl_int,
96    ) -> cl_mem,
97>;
98pub type clCreateFromD3D10Texture2DKHR_fn = clCreateFromD3D10Texture2DKHR_t;
99
100pub type clCreateFromD3D10Texture3DKHR_t = Option<
101    unsafe extern "C" fn(
102        context: cl_context,
103        flags: cl_mem_flags,
104        resource: ID3D10Texture3D_ptr,
105        subresource: cl_uint,
106        errcode_ret: *mut cl_int,
107    ) -> cl_mem,
108>;
109pub type clCreateFromD3D10Texture3DKHR_fn = clCreateFromD3D10Texture3DKHR_t;
110
111pub type clEnqueueAcquireD3D10ObjectsKHR_t = Option<
112    unsafe extern "C" fn(
113        command_queue: cl_command_queue,
114        num_objects: cl_uint,
115        mem_objects: *const cl_mem,
116        num_events_in_wait_list: cl_uint,
117        event_wait_list: *const cl_event,
118        event: *mut cl_event,
119    ) -> cl_int,
120>;
121pub type clEnqueueAcquireD3D10ObjectsKHR_fn = clEnqueueAcquireD3D10ObjectsKHR_t;
122
123pub type clEnqueueReleaseD3D10ObjectsKHR_t = Option<
124    unsafe extern "C" fn(
125        command_queue: cl_command_queue,
126        num_objects: cl_uint,
127        mem_objects: *const cl_mem,
128        num_events_in_wait_list: cl_uint,
129        event_wait_list: *const cl_event,
130        event: *mut cl_event,
131    ) -> cl_int,
132>;
133pub type clEnqueueReleaseD3D10ObjectsKHR_fn = clEnqueueReleaseD3D10ObjectsKHR_t;
134
135// when cl_khr_d3d10_sharing is supported
136
137pub type clGetSupportedD3D10TextureFormatsINTEL_t = Option<
138    unsafe extern "C" fn(
139        context: cl_context,
140        flags: cl_mem_flags,
141        image_type: cl_mem_object_type,
142        num_entries: cl_uint,
143        d3d10_formats: *mut DXGI_FORMAT,
144        num_surface_formats: *mut cl_uint,
145    ) -> cl_int,
146>;
147
148pub type clGetSupportedD3D10TextureFormatsINTEL_fn = clGetSupportedD3D10TextureFormatsINTEL_t;
149
150#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
151#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
152#[cfg(feature = "cl_khr_d3d10_sharing")]
153#[cfg(feature = "static")]
154unsafe extern "system" {
155
156    pub fn clGetSupportedD3D10TextureFormatsINTEL(
157        context: cl_context,
158        flags: cl_mem_flags,
159        image_type: cl_mem_object_type,
160        num_entries: cl_uint,
161        d3d10_formats: *mut DXGI_FORMAT,
162        num_surface_formats: *mut cl_uint,
163    ) -> cl_int;
164}