180d59932Sopenharmony_ci/*******************************************************************************
280d59932Sopenharmony_ci * Copyright (c) 2008-2021 The Khronos Group Inc.
380d59932Sopenharmony_ci *
480d59932Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
580d59932Sopenharmony_ci * you may not use this file except in compliance with the License.
680d59932Sopenharmony_ci * You may obtain a copy of the License at
780d59932Sopenharmony_ci *
880d59932Sopenharmony_ci *    http://www.apache.org/licenses/LICENSE-2.0
980d59932Sopenharmony_ci *
1080d59932Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1180d59932Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1280d59932Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1380d59932Sopenharmony_ci * See the License for the specific language governing permissions and
1480d59932Sopenharmony_ci * limitations under the License.
1580d59932Sopenharmony_ci ******************************************************************************/
1680d59932Sopenharmony_ci
1780d59932Sopenharmony_ci#ifndef __OPENCL_CL_GL_H
1880d59932Sopenharmony_ci#define __OPENCL_CL_GL_H
1980d59932Sopenharmony_ci
2080d59932Sopenharmony_ci#include <CL/cl.h>
2180d59932Sopenharmony_ci
2280d59932Sopenharmony_ci#ifdef __cplusplus
2380d59932Sopenharmony_ciextern "C" {
2480d59932Sopenharmony_ci#endif
2580d59932Sopenharmony_ci
2680d59932Sopenharmony_citypedef cl_uint     cl_gl_object_type;
2780d59932Sopenharmony_citypedef cl_uint     cl_gl_texture_info;
2880d59932Sopenharmony_citypedef cl_uint     cl_gl_platform_info;
2980d59932Sopenharmony_citypedef struct __GLsync *cl_GLsync;
3080d59932Sopenharmony_ci
3180d59932Sopenharmony_ci/* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken           */
3280d59932Sopenharmony_ci#define CL_GL_OBJECT_BUFFER                     0x2000
3380d59932Sopenharmony_ci#define CL_GL_OBJECT_TEXTURE2D                  0x2001
3480d59932Sopenharmony_ci#define CL_GL_OBJECT_TEXTURE3D                  0x2002
3580d59932Sopenharmony_ci#define CL_GL_OBJECT_RENDERBUFFER               0x2003
3680d59932Sopenharmony_ci#ifdef CL_VERSION_1_2
3780d59932Sopenharmony_ci#define CL_GL_OBJECT_TEXTURE2D_ARRAY            0x200E
3880d59932Sopenharmony_ci#define CL_GL_OBJECT_TEXTURE1D                  0x200F
3980d59932Sopenharmony_ci#define CL_GL_OBJECT_TEXTURE1D_ARRAY            0x2010
4080d59932Sopenharmony_ci#define CL_GL_OBJECT_TEXTURE_BUFFER             0x2011
4180d59932Sopenharmony_ci#endif
4280d59932Sopenharmony_ci
4380d59932Sopenharmony_ci/* cl_gl_texture_info           */
4480d59932Sopenharmony_ci#define CL_GL_TEXTURE_TARGET                    0x2004
4580d59932Sopenharmony_ci#define CL_GL_MIPMAP_LEVEL                      0x2005
4680d59932Sopenharmony_ci#ifdef CL_VERSION_1_2
4780d59932Sopenharmony_ci#define CL_GL_NUM_SAMPLES                       0x2012
4880d59932Sopenharmony_ci#endif
4980d59932Sopenharmony_ci
5080d59932Sopenharmony_ci
5180d59932Sopenharmony_ciextern CL_API_ENTRY cl_mem CL_API_CALL
5280d59932Sopenharmony_ciclCreateFromGLBuffer(cl_context     context,
5380d59932Sopenharmony_ci                     cl_mem_flags   flags,
5480d59932Sopenharmony_ci                     cl_GLuint      bufobj,
5580d59932Sopenharmony_ci                     cl_int *       errcode_ret) CL_API_SUFFIX__VERSION_1_0;
5680d59932Sopenharmony_ci
5780d59932Sopenharmony_ci#ifdef CL_VERSION_1_2
5880d59932Sopenharmony_ci
5980d59932Sopenharmony_ciextern CL_API_ENTRY cl_mem CL_API_CALL
6080d59932Sopenharmony_ciclCreateFromGLTexture(cl_context      context,
6180d59932Sopenharmony_ci                      cl_mem_flags    flags,
6280d59932Sopenharmony_ci                      cl_GLenum       target,
6380d59932Sopenharmony_ci                      cl_GLint        miplevel,
6480d59932Sopenharmony_ci                      cl_GLuint       texture,
6580d59932Sopenharmony_ci                      cl_int *        errcode_ret) CL_API_SUFFIX__VERSION_1_2;
6680d59932Sopenharmony_ci
6780d59932Sopenharmony_ci#endif
6880d59932Sopenharmony_ci
6980d59932Sopenharmony_ciextern CL_API_ENTRY cl_mem CL_API_CALL
7080d59932Sopenharmony_ciclCreateFromGLRenderbuffer(cl_context   context,
7180d59932Sopenharmony_ci                           cl_mem_flags flags,
7280d59932Sopenharmony_ci                           cl_GLuint    renderbuffer,
7380d59932Sopenharmony_ci                           cl_int *     errcode_ret) CL_API_SUFFIX__VERSION_1_0;
7480d59932Sopenharmony_ci
7580d59932Sopenharmony_ciextern CL_API_ENTRY cl_int CL_API_CALL
7680d59932Sopenharmony_ciclGetGLObjectInfo(cl_mem                memobj,
7780d59932Sopenharmony_ci                  cl_gl_object_type *   gl_object_type,
7880d59932Sopenharmony_ci                  cl_GLuint *           gl_object_name) CL_API_SUFFIX__VERSION_1_0;
7980d59932Sopenharmony_ci
8080d59932Sopenharmony_ciextern CL_API_ENTRY cl_int CL_API_CALL
8180d59932Sopenharmony_ciclGetGLTextureInfo(cl_mem               memobj,
8280d59932Sopenharmony_ci                   cl_gl_texture_info   param_name,
8380d59932Sopenharmony_ci                   size_t               param_value_size,
8480d59932Sopenharmony_ci                   void *               param_value,
8580d59932Sopenharmony_ci                   size_t *             param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
8680d59932Sopenharmony_ci
8780d59932Sopenharmony_ciextern CL_API_ENTRY cl_int CL_API_CALL
8880d59932Sopenharmony_ciclEnqueueAcquireGLObjects(cl_command_queue      command_queue,
8980d59932Sopenharmony_ci                          cl_uint               num_objects,
9080d59932Sopenharmony_ci                          const cl_mem *        mem_objects,
9180d59932Sopenharmony_ci                          cl_uint               num_events_in_wait_list,
9280d59932Sopenharmony_ci                          const cl_event *      event_wait_list,
9380d59932Sopenharmony_ci                          cl_event *            event) CL_API_SUFFIX__VERSION_1_0;
9480d59932Sopenharmony_ci
9580d59932Sopenharmony_ciextern CL_API_ENTRY cl_int CL_API_CALL
9680d59932Sopenharmony_ciclEnqueueReleaseGLObjects(cl_command_queue      command_queue,
9780d59932Sopenharmony_ci                          cl_uint               num_objects,
9880d59932Sopenharmony_ci                          const cl_mem *        mem_objects,
9980d59932Sopenharmony_ci                          cl_uint               num_events_in_wait_list,
10080d59932Sopenharmony_ci                          const cl_event *      event_wait_list,
10180d59932Sopenharmony_ci                          cl_event *            event) CL_API_SUFFIX__VERSION_1_0;
10280d59932Sopenharmony_ci
10380d59932Sopenharmony_ci
10480d59932Sopenharmony_ci/* Deprecated OpenCL 1.1 APIs */
10580d59932Sopenharmony_ciextern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
10680d59932Sopenharmony_ciclCreateFromGLTexture2D(cl_context      context,
10780d59932Sopenharmony_ci                        cl_mem_flags    flags,
10880d59932Sopenharmony_ci                        cl_GLenum       target,
10980d59932Sopenharmony_ci                        cl_GLint        miplevel,
11080d59932Sopenharmony_ci                        cl_GLuint       texture,
11180d59932Sopenharmony_ci                        cl_int *        errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
11280d59932Sopenharmony_ci
11380d59932Sopenharmony_ciextern CL_API_ENTRY CL_API_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
11480d59932Sopenharmony_ciclCreateFromGLTexture3D(cl_context      context,
11580d59932Sopenharmony_ci                        cl_mem_flags    flags,
11680d59932Sopenharmony_ci                        cl_GLenum       target,
11780d59932Sopenharmony_ci                        cl_GLint        miplevel,
11880d59932Sopenharmony_ci                        cl_GLuint       texture,
11980d59932Sopenharmony_ci                        cl_int *        errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED;
12080d59932Sopenharmony_ci
12180d59932Sopenharmony_ci/* cl_khr_gl_sharing extension  */
12280d59932Sopenharmony_ci
12380d59932Sopenharmony_ci#define cl_khr_gl_sharing 1
12480d59932Sopenharmony_ci
12580d59932Sopenharmony_citypedef cl_uint     cl_gl_context_info;
12680d59932Sopenharmony_ci
12780d59932Sopenharmony_ci/* Additional Error Codes  */
12880d59932Sopenharmony_ci#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR  -1000
12980d59932Sopenharmony_ci
13080d59932Sopenharmony_ci/* cl_gl_context_info  */
13180d59932Sopenharmony_ci#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR    0x2006
13280d59932Sopenharmony_ci#define CL_DEVICES_FOR_GL_CONTEXT_KHR           0x2007
13380d59932Sopenharmony_ci
13480d59932Sopenharmony_ci/* Additional cl_context_properties  */
13580d59932Sopenharmony_ci#define CL_GL_CONTEXT_KHR                       0x2008
13680d59932Sopenharmony_ci#define CL_EGL_DISPLAY_KHR                      0x2009
13780d59932Sopenharmony_ci#define CL_GLX_DISPLAY_KHR                      0x200A
13880d59932Sopenharmony_ci#define CL_WGL_HDC_KHR                          0x200B
13980d59932Sopenharmony_ci#define CL_CGL_SHAREGROUP_KHR                   0x200C
14080d59932Sopenharmony_ci
14180d59932Sopenharmony_ciextern CL_API_ENTRY cl_int CL_API_CALL
14280d59932Sopenharmony_ciclGetGLContextInfoKHR(const cl_context_properties * properties,
14380d59932Sopenharmony_ci                      cl_gl_context_info            param_name,
14480d59932Sopenharmony_ci                      size_t                        param_value_size,
14580d59932Sopenharmony_ci                      void *                        param_value,
14680d59932Sopenharmony_ci                      size_t *                      param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
14780d59932Sopenharmony_ci
14880d59932Sopenharmony_citypedef cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
14980d59932Sopenharmony_ci    const cl_context_properties * properties,
15080d59932Sopenharmony_ci    cl_gl_context_info            param_name,
15180d59932Sopenharmony_ci    size_t                        param_value_size,
15280d59932Sopenharmony_ci    void *                        param_value,
15380d59932Sopenharmony_ci    size_t *                      param_value_size_ret);
15480d59932Sopenharmony_ci
15580d59932Sopenharmony_ci/*
15680d59932Sopenharmony_ci *  cl_khr_gl_event extension
15780d59932Sopenharmony_ci */
15880d59932Sopenharmony_ci#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR     0x200D
15980d59932Sopenharmony_ci
16080d59932Sopenharmony_ciextern CL_API_ENTRY cl_event CL_API_CALL
16180d59932Sopenharmony_ciclCreateEventFromGLsyncKHR(cl_context context,
16280d59932Sopenharmony_ci                           cl_GLsync  sync,
16380d59932Sopenharmony_ci                           cl_int *   errcode_ret) CL_API_SUFFIX__VERSION_1_1;
16480d59932Sopenharmony_ci
16580d59932Sopenharmony_ci/***************************************************************
16680d59932Sopenharmony_ci* cl_intel_sharing_format_query_gl
16780d59932Sopenharmony_ci***************************************************************/
16880d59932Sopenharmony_ci#define cl_intel_sharing_format_query_gl 1
16980d59932Sopenharmony_ci
17080d59932Sopenharmony_ci/* when cl_khr_gl_sharing is supported */
17180d59932Sopenharmony_ci
17280d59932Sopenharmony_ciextern CL_API_ENTRY cl_int CL_API_CALL
17380d59932Sopenharmony_ciclGetSupportedGLTextureFormatsINTEL(
17480d59932Sopenharmony_ci    cl_context context,
17580d59932Sopenharmony_ci    cl_mem_flags flags,
17680d59932Sopenharmony_ci    cl_mem_object_type image_type,
17780d59932Sopenharmony_ci    cl_uint num_entries,
17880d59932Sopenharmony_ci    cl_GLenum* gl_formats,
17980d59932Sopenharmony_ci    cl_uint* num_texture_formats) ;
18080d59932Sopenharmony_ci
18180d59932Sopenharmony_citypedef cl_int (CL_API_CALL *
18280d59932Sopenharmony_ciclGetSupportedGLTextureFormatsINTEL_fn)(
18380d59932Sopenharmony_ci    cl_context context,
18480d59932Sopenharmony_ci    cl_mem_flags flags,
18580d59932Sopenharmony_ci    cl_mem_object_type image_type,
18680d59932Sopenharmony_ci    cl_uint num_entries,
18780d59932Sopenharmony_ci    cl_GLenum* gl_formats,
18880d59932Sopenharmony_ci    cl_uint* num_texture_formats) ;
18980d59932Sopenharmony_ci
19080d59932Sopenharmony_ci#ifdef __cplusplus
19180d59932Sopenharmony_ci}
19280d59932Sopenharmony_ci#endif
19380d59932Sopenharmony_ci
19480d59932Sopenharmony_ci#endif  /* __OPENCL_CL_GL_H */
195