xref: /aosp_15_r20/external/ComputeLibrary/include/CL/cl_gl.h (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1*c217d954SCole Faust /*******************************************************************************
2*c217d954SCole Faust  * Copyright (c) 2008-2021 The Khronos Group Inc.
3*c217d954SCole Faust  *
4*c217d954SCole Faust  * Licensed under the Apache License, Version 2.0 (the "License");
5*c217d954SCole Faust  * you may not use this file except in compliance with the License.
6*c217d954SCole Faust  * You may obtain a copy of the License at
7*c217d954SCole Faust  *
8*c217d954SCole Faust  *    http://www.apache.org/licenses/LICENSE-2.0
9*c217d954SCole Faust  *
10*c217d954SCole Faust  * Unless required by applicable law or agreed to in writing, software
11*c217d954SCole Faust  * distributed under the License is distributed on an "AS IS" BASIS,
12*c217d954SCole Faust  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*c217d954SCole Faust  * See the License for the specific language governing permissions and
14*c217d954SCole Faust  * limitations under the License.
15*c217d954SCole Faust  ******************************************************************************/
16*c217d954SCole Faust 
17*c217d954SCole Faust #ifndef __OPENCL_CL_GL_H
18*c217d954SCole Faust #define __OPENCL_CL_GL_H
19*c217d954SCole Faust 
20*c217d954SCole Faust #include <CL/cl.h>
21*c217d954SCole Faust 
22*c217d954SCole Faust #ifdef __cplusplus
23*c217d954SCole Faust extern "C" {
24*c217d954SCole Faust #endif
25*c217d954SCole Faust 
26*c217d954SCole Faust typedef cl_uint     cl_gl_object_type;
27*c217d954SCole Faust typedef cl_uint     cl_gl_texture_info;
28*c217d954SCole Faust typedef cl_uint     cl_gl_platform_info;
29*c217d954SCole Faust typedef struct __GLsync *cl_GLsync;
30*c217d954SCole Faust 
31*c217d954SCole Faust /* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken           */
32*c217d954SCole Faust #define CL_GL_OBJECT_BUFFER                     0x2000
33*c217d954SCole Faust #define CL_GL_OBJECT_TEXTURE2D                  0x2001
34*c217d954SCole Faust #define CL_GL_OBJECT_TEXTURE3D                  0x2002
35*c217d954SCole Faust #define CL_GL_OBJECT_RENDERBUFFER               0x2003
36*c217d954SCole Faust #ifdef CL_VERSION_1_2
37*c217d954SCole Faust #define CL_GL_OBJECT_TEXTURE2D_ARRAY            0x200E
38*c217d954SCole Faust #define CL_GL_OBJECT_TEXTURE1D                  0x200F
39*c217d954SCole Faust #define CL_GL_OBJECT_TEXTURE1D_ARRAY            0x2010
40*c217d954SCole Faust #define CL_GL_OBJECT_TEXTURE_BUFFER             0x2011
41*c217d954SCole Faust #endif
42*c217d954SCole Faust 
43*c217d954SCole Faust /* cl_gl_texture_info           */
44*c217d954SCole Faust #define CL_GL_TEXTURE_TARGET                    0x2004
45*c217d954SCole Faust #define CL_GL_MIPMAP_LEVEL                      0x2005
46*c217d954SCole Faust #ifdef CL_VERSION_1_2
47*c217d954SCole Faust #define CL_GL_NUM_SAMPLES                       0x2012
48*c217d954SCole Faust #endif
49*c217d954SCole Faust 
50*c217d954SCole Faust 
51*c217d954SCole Faust extern CL_API_ENTRY cl_mem CL_API_CALL
52*c217d954SCole Faust clCreateFromGLBuffer(cl_context     context,
53*c217d954SCole Faust                      cl_mem_flags   flags,
54*c217d954SCole Faust                      cl_GLuint      bufobj,
55*c217d954SCole Faust                      cl_int *       errcode_ret) CL_API_SUFFIX__VERSION_1_0;
56*c217d954SCole Faust 
57*c217d954SCole Faust #ifdef CL_VERSION_1_2
58*c217d954SCole Faust 
59*c217d954SCole Faust extern CL_API_ENTRY cl_mem CL_API_CALL
60*c217d954SCole Faust clCreateFromGLTexture(cl_context      context,
61*c217d954SCole Faust                       cl_mem_flags    flags,
62*c217d954SCole Faust                       cl_GLenum       target,
63*c217d954SCole Faust                       cl_GLint        miplevel,
64*c217d954SCole Faust                       cl_GLuint       texture,
65*c217d954SCole Faust                       cl_int *        errcode_ret) CL_API_SUFFIX__VERSION_1_2;
66*c217d954SCole Faust 
67*c217d954SCole Faust #endif
68*c217d954SCole Faust 
69*c217d954SCole Faust extern CL_API_ENTRY cl_mem CL_API_CALL
70*c217d954SCole Faust clCreateFromGLRenderbuffer(cl_context   context,
71*c217d954SCole Faust                            cl_mem_flags flags,
72*c217d954SCole Faust                            cl_GLuint    renderbuffer,
73*c217d954SCole Faust                            cl_int *     errcode_ret) CL_API_SUFFIX__VERSION_1_0;
74*c217d954SCole Faust 
75*c217d954SCole Faust extern CL_API_ENTRY cl_int CL_API_CALL
76*c217d954SCole Faust clGetGLObjectInfo(cl_mem                memobj,
77*c217d954SCole Faust                   cl_gl_object_type *   gl_object_type,
78*c217d954SCole Faust                   cl_GLuint *           gl_object_name) CL_API_SUFFIX__VERSION_1_0;
79*c217d954SCole Faust 
80*c217d954SCole Faust extern CL_API_ENTRY cl_int CL_API_CALL
81*c217d954SCole Faust clGetGLTextureInfo(cl_mem               memobj,
82*c217d954SCole Faust                    cl_gl_texture_info   param_name,
83*c217d954SCole Faust                    size_t               param_value_size,
84*c217d954SCole Faust                    void *               param_value,
85*c217d954SCole Faust                    size_t *             param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
86*c217d954SCole Faust 
87*c217d954SCole Faust extern CL_API_ENTRY cl_int CL_API_CALL
88*c217d954SCole Faust clEnqueueAcquireGLObjects(cl_command_queue      command_queue,
89*c217d954SCole Faust                           cl_uint               num_objects,
90*c217d954SCole Faust                           const cl_mem *        mem_objects,
91*c217d954SCole Faust                           cl_uint               num_events_in_wait_list,
92*c217d954SCole Faust                           const cl_event *      event_wait_list,
93*c217d954SCole Faust                           cl_event *            event) CL_API_SUFFIX__VERSION_1_0;
94*c217d954SCole Faust 
95*c217d954SCole Faust extern CL_API_ENTRY cl_int CL_API_CALL
96*c217d954SCole Faust clEnqueueReleaseGLObjects(cl_command_queue      command_queue,
97*c217d954SCole Faust                           cl_uint               num_objects,
98*c217d954SCole Faust                           const cl_mem *        mem_objects,
99*c217d954SCole Faust                           cl_uint               num_events_in_wait_list,
100*c217d954SCole Faust                           const cl_event *      event_wait_list,
101*c217d954SCole Faust                           cl_event *            event) CL_API_SUFFIX__VERSION_1_0;
102*c217d954SCole Faust 
103*c217d954SCole Faust 
104*c217d954SCole Faust /* Deprecated OpenCL 1.1 APIs */
105*c217d954SCole Faust extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
106*c217d954SCole Faust clCreateFromGLTexture2D(cl_context      context,
107*c217d954SCole Faust                         cl_mem_flags    flags,
108*c217d954SCole Faust                         cl_GLenum       target,
109*c217d954SCole Faust                         cl_GLint        miplevel,
110*c217d954SCole Faust                         cl_GLuint       texture,
111*c217d954SCole Faust                         cl_int *        errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
112*c217d954SCole Faust 
113*c217d954SCole Faust extern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
114*c217d954SCole Faust clCreateFromGLTexture3D(cl_context      context,
115*c217d954SCole Faust                         cl_mem_flags    flags,
116*c217d954SCole Faust                         cl_GLenum       target,
117*c217d954SCole Faust                         cl_GLint        miplevel,
118*c217d954SCole Faust                         cl_GLuint       texture,
119*c217d954SCole Faust                         cl_int *        errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
120*c217d954SCole Faust 
121*c217d954SCole Faust /* cl_khr_gl_sharing extension  */
122*c217d954SCole Faust 
123*c217d954SCole Faust #define cl_khr_gl_sharing 1
124*c217d954SCole Faust 
125*c217d954SCole Faust typedef cl_uint     cl_gl_context_info;
126*c217d954SCole Faust 
127*c217d954SCole Faust /* Additional Error Codes  */
128*c217d954SCole Faust #define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR  -1000
129*c217d954SCole Faust 
130*c217d954SCole Faust /* cl_gl_context_info  */
131*c217d954SCole Faust #define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR    0x2006
132*c217d954SCole Faust #define CL_DEVICES_FOR_GL_CONTEXT_KHR           0x2007
133*c217d954SCole Faust 
134*c217d954SCole Faust /* Additional cl_context_properties  */
135*c217d954SCole Faust #define CL_GL_CONTEXT_KHR                       0x2008
136*c217d954SCole Faust #define CL_EGL_DISPLAY_KHR                      0x2009
137*c217d954SCole Faust #define CL_GLX_DISPLAY_KHR                      0x200A
138*c217d954SCole Faust #define CL_WGL_HDC_KHR                          0x200B
139*c217d954SCole Faust #define CL_CGL_SHAREGROUP_KHR                   0x200C
140*c217d954SCole Faust 
141*c217d954SCole Faust extern CL_API_ENTRY cl_int CL_API_CALL
142*c217d954SCole Faust clGetGLContextInfoKHR(const cl_context_properties * properties,
143*c217d954SCole Faust                       cl_gl_context_info            param_name,
144*c217d954SCole Faust                       size_t                        param_value_size,
145*c217d954SCole Faust                       void *                        param_value,
146*c217d954SCole Faust                       size_t *                      param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
147*c217d954SCole Faust 
148*c217d954SCole Faust typedef cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
149*c217d954SCole Faust     const cl_context_properties * properties,
150*c217d954SCole Faust     cl_gl_context_info            param_name,
151*c217d954SCole Faust     size_t                        param_value_size,
152*c217d954SCole Faust     void *                        param_value,
153*c217d954SCole Faust     size_t *                      param_value_size_ret);
154*c217d954SCole Faust 
155*c217d954SCole Faust /*
156*c217d954SCole Faust  *  cl_khr_gl_event extension
157*c217d954SCole Faust  */
158*c217d954SCole Faust #define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR     0x200D
159*c217d954SCole Faust 
160*c217d954SCole Faust extern CL_API_ENTRY cl_event CL_API_CALL
161*c217d954SCole Faust clCreateEventFromGLsyncKHR(cl_context context,
162*c217d954SCole Faust                            cl_GLsync  sync,
163*c217d954SCole Faust                            cl_int *   errcode_ret) CL_API_SUFFIX__VERSION_1_1;
164*c217d954SCole Faust 
165*c217d954SCole Faust #ifdef __cplusplus
166*c217d954SCole Faust }
167*c217d954SCole Faust #endif
168*c217d954SCole Faust 
169*c217d954SCole Faust #endif  /* __OPENCL_CL_GL_H */
170