opencl_sys/
cl_egl.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_egl.h](https://github.com/KhronosGroup/OpenCL-Headers/blob/main/CL/cl_egl.h).
16//!
17//! `OpenCL` extensions are documented in the [OpenCL-Registry](https://github.com/KhronosGroup/OpenCL-Registry)
18
19#![allow(non_camel_case_types)]
20
21use super::cl::{cl_command_queue, cl_command_type, cl_context, cl_event, cl_mem, cl_mem_flags};
22use super::cl_platform::{cl_int, cl_uint};
23use libc::{c_void, intptr_t};
24
25// Command type for events created with clEnqueueAcquireEGLObjectsKHR
26pub const CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR: cl_command_type = 0x202F;
27pub const CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR: cl_command_type = 0x202D;
28pub const CL_COMMAND_RELEASE_EGL_OBJECTS_KHR: cl_command_type = 0x202E;
29
30// Error type for clCreateFromEGLImageKHR
31pub const CL_INVALID_EGL_OBJECT_KHR: cl_int = -1093;
32pub const CL_EGL_RESOURCE_NOT_ACQUIRED_KHR: cl_int = -1092;
33
34// CLeglImageKHR is an opaque handle to an EGLImage
35pub type CLeglImageKHR = *mut c_void;
36
37// CLeglDisplayKHR is an opaque handle to an EGLDisplay
38pub type CLeglDisplayKHR = *mut c_void;
39
40// CLeglSyncKHR is an opaque handle to an EGLSync object
41pub type CLeglSyncKHR = *mut c_void;
42
43// properties passed to clCreateFromEGLImageKHR
44pub type cl_egl_image_properties_khr = intptr_t;
45
46pub type clCreateFromEGLImageKHR_t = Option<
47    unsafe extern "C" fn(
48        context: cl_context,
49        egldisplay: CLeglDisplayKHR,
50        eglimage: CLeglImageKHR,
51        flags: cl_mem_flags,
52        properties: *const cl_egl_image_properties_khr,
53        errcode_ret: *mut cl_int,
54    ) -> cl_mem,
55>;
56pub type clCreateFromEGLImageKHR_fn = clCreateFromEGLImageKHR_t;
57
58pub type clEnqueueAcquireEGLObjectsKHR_t = Option<
59    unsafe extern "C" fn(
60        command_queue: cl_command_queue,
61        num_objects: cl_uint,
62        mem_objects: *const cl_mem,
63        num_events_in_wait_list: cl_uint,
64        event_wait_list: *const cl_event,
65        event: *mut cl_event,
66    ) -> cl_int,
67>;
68pub type clEnqueueAcquireEGLObjectsKHR_fn = clEnqueueAcquireEGLObjectsKHR_t;
69
70pub type clEnqueueReleaseEGLObjectsKHR_t = Option<
71    unsafe extern "C" fn(
72        command_queue: cl_command_queue,
73        num_objects: cl_uint,
74        mem_objects: *const cl_mem,
75        num_events_in_wait_list: cl_uint,
76        event_wait_list: *const cl_event,
77        event: *mut cl_event,
78    ) -> cl_int,
79>;
80pub type clEnqueueReleaseEGLObjectsKHR_fn = clEnqueueReleaseEGLObjectsKHR_t;
81
82pub type clCreateEventFromEGLSyncKHR_t = Option<
83    unsafe extern "C" fn(
84        context: cl_context,
85        sync: CLeglSyncKHR,
86        display: CLeglDisplayKHR,
87        errcode_ret: *mut cl_int,
88    ) -> cl_event,
89>;
90pub type clCreateEventFromEGLSyncKHR_fn = clCreateEventFromEGLSyncKHR_t;
91
92#[cfg_attr(not(target_os = "macos"), link(name = "OpenCL"))]
93#[cfg_attr(target_os = "macos", link(name = "OpenCL", kind = "framework"))]
94#[cfg(feature = "static")]
95unsafe extern "system" {
96
97    pub fn clCreateFromEGLImageKHR(
98        context: cl_context,
99        display: CLeglDisplayKHR,
100        image: CLeglImageKHR,
101        flags: cl_mem_flags,
102        properties: *const cl_egl_image_properties_khr,
103        errcode_ret: *mut cl_int,
104    ) -> cl_mem;
105
106    pub fn clEnqueueAcquireEGLObjectsKHR(
107        command_queue: cl_command_queue,
108        num_objects: cl_uint,
109        mem_objects: *const cl_mem,
110        num_events_in_wait_list: cl_uint,
111        event_wait_list: *const cl_event,
112        event: *mut cl_event,
113    ) -> cl_int;
114
115    pub fn clEnqueueReleaseEGLObjectsKHR(
116        command_queue: cl_command_queue,
117        num_objects: cl_uint,
118        mem_objects: *const cl_mem,
119        num_events_in_wait_list: cl_uint,
120        event_wait_list: *const cl_event,
121        event: *mut cl_event,
122    ) -> cl_int;
123
124    pub fn clCreateEventFromEGLSyncKHR(
125        context: cl_context,
126        sync: CLeglSyncKHR,
127        display: CLeglDisplayKHR,
128        errcode_ret: *mut cl_int,
129    ) -> cl_event;
130
131}