| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2019-2020 The Khronos Group Inc. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
******************************************************************************/ |
| 16 |
|
| 17 |
#ifndef OPENCL_CL_ICD_H |
| 18 |
#define OPENCL_CL_ICD_H |
| 19 |
|
| 20 |
#include <CL/cl.h> |
| 21 |
#include <CL/cl_function_types.h> |
| 22 |
#include <CL/cl_egl.h> |
| 23 |
#include <CL/cl_ext.h> |
| 24 |
#include <CL/cl_gl.h> |
| 25 |
#include <CL/cl_platform.h> |
| 26 |
|
| 27 |
#if defined(_WIN32) |
| 28 |
#include <CL/cl_d3d11.h> |
| 29 |
#include <CL/cl_d3d10.h> |
| 30 |
#include <CL/cl_dx9_media_sharing.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ |
| 34 |
/* Disable warning C4201: nonstandard extension used : nameless struct/union */ |
| 35 |
#pragma warning( push ) |
| 36 |
#pragma warning( disable : 4201 ) |
| 37 |
#endif |
| 38 |
|
| 39 |
#ifdef __cplusplus |
| 40 |
extern "C" { |
| 41 |
#endif |
| 42 |
|
| 43 |
/* Vendor dispatch table structure */ |
| 44 |
|
| 45 |
typedef struct _cl_icd_dispatch { |
| 46 |
/* OpenCL 1.0 */ |
| 47 |
#if __CL_HAS_ANON_UNION__ |
| 48 |
__CL_ANON_UNION__ union { |
| 49 |
#endif |
| 50 |
clGetPlatformIDs_t *clGetPlatformIDs; |
| 51 |
#if __CL_HAS_ANON_UNION__ |
| 52 |
/* Set to CL_ICD2_TAG_KHR for cl_khr_icd 2.0.0 */ |
| 53 |
intptr_t clGetPlatformIDs_icd2_tag; |
| 54 |
}; |
| 55 |
#endif |
| 56 |
clGetPlatformInfo_t *clGetPlatformInfo; |
| 57 |
clGetDeviceIDs_t *clGetDeviceIDs; |
| 58 |
clGetDeviceInfo_t *clGetDeviceInfo; |
| 59 |
clCreateContext_t *clCreateContext; |
| 60 |
clCreateContextFromType_t *clCreateContextFromType; |
| 61 |
clRetainContext_t *clRetainContext; |
| 62 |
clReleaseContext_t *clReleaseContext; |
| 63 |
clGetContextInfo_t *clGetContextInfo; |
| 64 |
clCreateCommandQueue_t *clCreateCommandQueue; |
| 65 |
clRetainCommandQueue_t *clRetainCommandQueue; |
| 66 |
clReleaseCommandQueue_t *clReleaseCommandQueue; |
| 67 |
clGetCommandQueueInfo_t *clGetCommandQueueInfo; |
| 68 |
clSetCommandQueueProperty_t *clSetCommandQueueProperty; |
| 69 |
clCreateBuffer_t *clCreateBuffer; |
| 70 |
clCreateImage2D_t *clCreateImage2D; |
| 71 |
clCreateImage3D_t *clCreateImage3D; |
| 72 |
clRetainMemObject_t *clRetainMemObject; |
| 73 |
clReleaseMemObject_t *clReleaseMemObject; |
| 74 |
clGetSupportedImageFormats_t *clGetSupportedImageFormats; |
| 75 |
clGetMemObjectInfo_t *clGetMemObjectInfo; |
| 76 |
clGetImageInfo_t *clGetImageInfo; |
| 77 |
clCreateSampler_t *clCreateSampler; |
| 78 |
clRetainSampler_t *clRetainSampler; |
| 79 |
clReleaseSampler_t *clReleaseSampler; |
| 80 |
clGetSamplerInfo_t *clGetSamplerInfo; |
| 81 |
clCreateProgramWithSource_t *clCreateProgramWithSource; |
| 82 |
clCreateProgramWithBinary_t *clCreateProgramWithBinary; |
| 83 |
clRetainProgram_t *clRetainProgram; |
| 84 |
clReleaseProgram_t *clReleaseProgram; |
| 85 |
clBuildProgram_t *clBuildProgram; |
| 86 |
#if __CL_HAS_ANON_UNION__ |
| 87 |
__CL_ANON_UNION__ union { |
| 88 |
#endif |
| 89 |
clUnloadCompiler_t *clUnloadCompiler; |
| 90 |
#if __CL_HAS_ANON_UNION__ |
| 91 |
/* Set to CL_ICD2_TAG_KHR for cl_khr_icd 2.0.0 */ |
| 92 |
intptr_t clUnloadCompiler_icd2_tag; |
| 93 |
}; |
| 94 |
#endif |
| 95 |
clGetProgramInfo_t *clGetProgramInfo; |
| 96 |
clGetProgramBuildInfo_t *clGetProgramBuildInfo; |
| 97 |
clCreateKernel_t *clCreateKernel; |
| 98 |
clCreateKernelsInProgram_t *clCreateKernelsInProgram; |
| 99 |
clRetainKernel_t *clRetainKernel; |
| 100 |
clReleaseKernel_t *clReleaseKernel; |
| 101 |
clSetKernelArg_t *clSetKernelArg; |
| 102 |
clGetKernelInfo_t *clGetKernelInfo; |
| 103 |
clGetKernelWorkGroupInfo_t *clGetKernelWorkGroupInfo; |
| 104 |
clWaitForEvents_t *clWaitForEvents; |
| 105 |
clGetEventInfo_t *clGetEventInfo; |
| 106 |
clRetainEvent_t *clRetainEvent; |
| 107 |
clReleaseEvent_t *clReleaseEvent; |
| 108 |
clGetEventProfilingInfo_t *clGetEventProfilingInfo; |
| 109 |
clFlush_t *clFlush; |
| 110 |
clFinish_t *clFinish; |
| 111 |
clEnqueueReadBuffer_t *clEnqueueReadBuffer; |
| 112 |
clEnqueueWriteBuffer_t *clEnqueueWriteBuffer; |
| 113 |
clEnqueueCopyBuffer_t *clEnqueueCopyBuffer; |
| 114 |
clEnqueueReadImage_t *clEnqueueReadImage; |
| 115 |
clEnqueueWriteImage_t *clEnqueueWriteImage; |
| 116 |
clEnqueueCopyImage_t *clEnqueueCopyImage; |
| 117 |
clEnqueueCopyImageToBuffer_t *clEnqueueCopyImageToBuffer; |
| 118 |
clEnqueueCopyBufferToImage_t *clEnqueueCopyBufferToImage; |
| 119 |
clEnqueueMapBuffer_t *clEnqueueMapBuffer; |
| 120 |
clEnqueueMapImage_t *clEnqueueMapImage; |
| 121 |
clEnqueueUnmapMemObject_t *clEnqueueUnmapMemObject; |
| 122 |
clEnqueueNDRangeKernel_t *clEnqueueNDRangeKernel; |
| 123 |
clEnqueueTask_t *clEnqueueTask; |
| 124 |
clEnqueueNativeKernel_t *clEnqueueNativeKernel; |
| 125 |
clEnqueueMarker_t *clEnqueueMarker; |
| 126 |
clEnqueueWaitForEvents_t *clEnqueueWaitForEvents; |
| 127 |
clEnqueueBarrier_t *clEnqueueBarrier; |
| 128 |
clGetExtensionFunctionAddress_t *clGetExtensionFunctionAddress; |
| 129 |
clCreateFromGLBuffer_t *clCreateFromGLBuffer; |
| 130 |
clCreateFromGLTexture2D_t *clCreateFromGLTexture2D; |
| 131 |
clCreateFromGLTexture3D_t *clCreateFromGLTexture3D; |
| 132 |
clCreateFromGLRenderbuffer_t *clCreateFromGLRenderbuffer; |
| 133 |
clGetGLObjectInfo_t *clGetGLObjectInfo; |
| 134 |
clGetGLTextureInfo_t *clGetGLTextureInfo; |
| 135 |
clEnqueueAcquireGLObjects_t *clEnqueueAcquireGLObjects; |
| 136 |
clEnqueueReleaseGLObjects_t *clEnqueueReleaseGLObjects; |
| 137 |
clGetGLContextInfoKHR_t *clGetGLContextInfoKHR; |
| 138 |
|
| 139 |
/* cl_khr_d3d10_sharing */ |
| 140 |
#ifdef _WIN32 |
| 141 |
clGetDeviceIDsFromD3D10KHR_t *clGetDeviceIDsFromD3D10KHR; |
| 142 |
clCreateFromD3D10BufferKHR_t *clCreateFromD3D10BufferKHR; |
| 143 |
clCreateFromD3D10Texture2DKHR_t *clCreateFromD3D10Texture2DKHR; |
| 144 |
clCreateFromD3D10Texture3DKHR_t *clCreateFromD3D10Texture3DKHR; |
| 145 |
clEnqueueAcquireD3D10ObjectsKHR_t *clEnqueueAcquireD3D10ObjectsKHR; |
| 146 |
clEnqueueReleaseD3D10ObjectsKHR_t *clEnqueueReleaseD3D10ObjectsKHR; |
| 147 |
#else |
| 148 |
void *clGetDeviceIDsFromD3D10KHR; |
| 149 |
void *clCreateFromD3D10BufferKHR; |
| 150 |
void *clCreateFromD3D10Texture2DKHR; |
| 151 |
void *clCreateFromD3D10Texture3DKHR; |
| 152 |
void *clEnqueueAcquireD3D10ObjectsKHR; |
| 153 |
void *clEnqueueReleaseD3D10ObjectsKHR; |
| 154 |
#endif |
| 155 |
|
| 156 |
/* OpenCL 1.1 */ |
| 157 |
#ifdef CL_VERSION_1_1 |
| 158 |
clSetEventCallback_t *clSetEventCallback; |
| 159 |
clCreateSubBuffer_t *clCreateSubBuffer; |
| 160 |
clSetMemObjectDestructorCallback_t *clSetMemObjectDestructorCallback; |
| 161 |
clCreateUserEvent_t *clCreateUserEvent; |
| 162 |
clSetUserEventStatus_t *clSetUserEventStatus; |
| 163 |
clEnqueueReadBufferRect_t *clEnqueueReadBufferRect; |
| 164 |
clEnqueueWriteBufferRect_t *clEnqueueWriteBufferRect; |
| 165 |
clEnqueueCopyBufferRect_t *clEnqueueCopyBufferRect; |
| 166 |
#else |
| 167 |
void *clSetEventCallback; |
| 168 |
void *clCreateSubBuffer; |
| 169 |
void *clSetMemObjectDestructorCallback; |
| 170 |
void *clCreateUserEvent; |
| 171 |
void *clSetUserEventStatus; |
| 172 |
void *clEnqueueReadBufferRect; |
| 173 |
void *clEnqueueWriteBufferRect; |
| 174 |
void *clEnqueueCopyBufferRect; |
| 175 |
#endif |
| 176 |
|
| 177 |
/* cl_ext_device_fission */ |
| 178 |
clCreateSubDevicesEXT_t *clCreateSubDevicesEXT; |
| 179 |
clRetainDeviceEXT_t *clRetainDeviceEXT; |
| 180 |
clReleaseDeviceEXT_t *clReleaseDeviceEXT; |
| 181 |
|
| 182 |
/* cl_khr_gl_event */ |
| 183 |
clCreateEventFromGLsyncKHR_t *clCreateEventFromGLsyncKHR; |
| 184 |
|
| 185 |
/* OpenCL 1.2 */ |
| 186 |
#ifdef CL_VERSION_1_2 |
| 187 |
clCreateSubDevices_t *clCreateSubDevices; |
| 188 |
clRetainDevice_t *clRetainDevice; |
| 189 |
clReleaseDevice_t *clReleaseDevice; |
| 190 |
clCreateImage_t *clCreateImage; |
| 191 |
clCreateProgramWithBuiltInKernels_t *clCreateProgramWithBuiltInKernels; |
| 192 |
clCompileProgram_t *clCompileProgram; |
| 193 |
clLinkProgram_t *clLinkProgram; |
| 194 |
clUnloadPlatformCompiler_t *clUnloadPlatformCompiler; |
| 195 |
clGetKernelArgInfo_t *clGetKernelArgInfo; |
| 196 |
clEnqueueFillBuffer_t *clEnqueueFillBuffer; |
| 197 |
clEnqueueFillImage_t *clEnqueueFillImage; |
| 198 |
clEnqueueMigrateMemObjects_t *clEnqueueMigrateMemObjects; |
| 199 |
clEnqueueMarkerWithWaitList_t *clEnqueueMarkerWithWaitList; |
| 200 |
clEnqueueBarrierWithWaitList_t *clEnqueueBarrierWithWaitList; |
| 201 |
clGetExtensionFunctionAddressForPlatform_t * |
| 202 |
clGetExtensionFunctionAddressForPlatform; |
| 203 |
clCreateFromGLTexture_t *clCreateFromGLTexture; |
| 204 |
#else |
| 205 |
void *clCreateSubDevices; |
| 206 |
void *clRetainDevice; |
| 207 |
void *clReleaseDevice; |
| 208 |
void *clCreateImage; |
| 209 |
void *clCreateProgramWithBuiltInKernels; |
| 210 |
void *clCompileProgram; |
| 211 |
void *clLinkProgram; |
| 212 |
void *clUnloadPlatformCompiler; |
| 213 |
void *clGetKernelArgInfo; |
| 214 |
void *clEnqueueFillBuffer; |
| 215 |
void *clEnqueueFillImage; |
| 216 |
void *clEnqueueMigrateMemObjects; |
| 217 |
void *clEnqueueMarkerWithWaitList; |
| 218 |
void *clEnqueueBarrierWithWaitList; |
| 219 |
void *clGetExtensionFunctionAddressForPlatform; |
| 220 |
void *clCreateFromGLTexture; |
| 221 |
#endif |
| 222 |
|
| 223 |
/* cl_khr_d3d11_sharing and cl_khr_dx9_media_sharing */ |
| 224 |
#ifdef _WIN32 |
| 225 |
clGetDeviceIDsFromD3D11KHR_t *clGetDeviceIDsFromD3D11KHR; |
| 226 |
clCreateFromD3D11BufferKHR_t *clCreateFromD3D11BufferKHR; |
| 227 |
clCreateFromD3D11Texture2DKHR_t *clCreateFromD3D11Texture2DKHR; |
| 228 |
clCreateFromD3D11Texture3DKHR_t *clCreateFromD3D11Texture3DKHR; |
| 229 |
clCreateFromDX9MediaSurfaceKHR_t *clCreateFromDX9MediaSurfaceKHR; |
| 230 |
clEnqueueAcquireD3D11ObjectsKHR_t *clEnqueueAcquireD3D11ObjectsKHR; |
| 231 |
clEnqueueReleaseD3D11ObjectsKHR_t *clEnqueueReleaseD3D11ObjectsKHR; |
| 232 |
clGetDeviceIDsFromDX9MediaAdapterKHR_t * |
| 233 |
clGetDeviceIDsFromDX9MediaAdapterKHR; |
| 234 |
clEnqueueAcquireDX9MediaSurfacesKHR_t * |
| 235 |
clEnqueueAcquireDX9MediaSurfacesKHR; |
| 236 |
clEnqueueReleaseDX9MediaSurfacesKHR_t * |
| 237 |
clEnqueueReleaseDX9MediaSurfacesKHR; |
| 238 |
#else |
| 239 |
void *clGetDeviceIDsFromD3D11KHR; |
| 240 |
void *clCreateFromD3D11BufferKHR; |
| 241 |
void *clCreateFromD3D11Texture2DKHR; |
| 242 |
void *clCreateFromD3D11Texture3DKHR; |
| 243 |
void *clCreateFromDX9MediaSurfaceKHR; |
| 244 |
void *clEnqueueAcquireD3D11ObjectsKHR; |
| 245 |
void *clEnqueueReleaseD3D11ObjectsKHR; |
| 246 |
void *clGetDeviceIDsFromDX9MediaAdapterKHR; |
| 247 |
void *clEnqueueAcquireDX9MediaSurfacesKHR; |
| 248 |
void *clEnqueueReleaseDX9MediaSurfacesKHR; |
| 249 |
#endif |
| 250 |
|
| 251 |
/* cl_khr_egl_image */ |
| 252 |
clCreateFromEGLImageKHR_t *clCreateFromEGLImageKHR; |
| 253 |
clEnqueueAcquireEGLObjectsKHR_t *clEnqueueAcquireEGLObjectsKHR; |
| 254 |
clEnqueueReleaseEGLObjectsKHR_t *clEnqueueReleaseEGLObjectsKHR; |
| 255 |
|
| 256 |
/* cl_khr_egl_event */ |
| 257 |
clCreateEventFromEGLSyncKHR_t *clCreateEventFromEGLSyncKHR; |
| 258 |
|
| 259 |
/* OpenCL 2.0 */ |
| 260 |
#ifdef CL_VERSION_2_0 |
| 261 |
clCreateCommandQueueWithProperties_t *clCreateCommandQueueWithProperties; |
| 262 |
clCreatePipe_t *clCreatePipe; |
| 263 |
clGetPipeInfo_t *clGetPipeInfo; |
| 264 |
clSVMAlloc_t *clSVMAlloc; |
| 265 |
clSVMFree_t *clSVMFree; |
| 266 |
clEnqueueSVMFree_t *clEnqueueSVMFree; |
| 267 |
clEnqueueSVMMemcpy_t *clEnqueueSVMMemcpy; |
| 268 |
clEnqueueSVMMemFill_t *clEnqueueSVMMemFill; |
| 269 |
clEnqueueSVMMap_t *clEnqueueSVMMap; |
| 270 |
clEnqueueSVMUnmap_t *clEnqueueSVMUnmap; |
| 271 |
clCreateSamplerWithProperties_t *clCreateSamplerWithProperties; |
| 272 |
clSetKernelArgSVMPointer_t *clSetKernelArgSVMPointer; |
| 273 |
clSetKernelExecInfo_t *clSetKernelExecInfo; |
| 274 |
#else |
| 275 |
void *clCreateCommandQueueWithProperties; |
| 276 |
void *clCreatePipe; |
| 277 |
void *clGetPipeInfo; |
| 278 |
void *clSVMAlloc; |
| 279 |
void *clSVMFree; |
| 280 |
void *clEnqueueSVMFree; |
| 281 |
void *clEnqueueSVMMemcpy; |
| 282 |
void *clEnqueueSVMMemFill; |
| 283 |
void *clEnqueueSVMMap; |
| 284 |
void *clEnqueueSVMUnmap; |
| 285 |
void *clCreateSamplerWithProperties; |
| 286 |
void *clSetKernelArgSVMPointer; |
| 287 |
void *clSetKernelExecInfo; |
| 288 |
#endif |
| 289 |
|
| 290 |
/* cl_khr_sub_groups */ |
| 291 |
clGetKernelSubGroupInfoKHR_t *clGetKernelSubGroupInfoKHR; |
| 292 |
|
| 293 |
/* OpenCL 2.1 */ |
| 294 |
#ifdef CL_VERSION_2_1 |
| 295 |
clCloneKernel_t *clCloneKernel; |
| 296 |
clCreateProgramWithIL_t *clCreateProgramWithIL; |
| 297 |
clEnqueueSVMMigrateMem_t *clEnqueueSVMMigrateMem; |
| 298 |
clGetDeviceAndHostTimer_t *clGetDeviceAndHostTimer; |
| 299 |
clGetHostTimer_t *clGetHostTimer; |
| 300 |
clGetKernelSubGroupInfo_t *clGetKernelSubGroupInfo; |
| 301 |
clSetDefaultDeviceCommandQueue_t *clSetDefaultDeviceCommandQueue; |
| 302 |
#else |
| 303 |
void *clCloneKernel; |
| 304 |
void *clCreateProgramWithIL; |
| 305 |
void *clEnqueueSVMMigrateMem; |
| 306 |
void *clGetDeviceAndHostTimer; |
| 307 |
void *clGetHostTimer; |
| 308 |
void *clGetKernelSubGroupInfo; |
| 309 |
void *clSetDefaultDeviceCommandQueue; |
| 310 |
#endif |
| 311 |
|
| 312 |
/* OpenCL 2.2 */ |
| 313 |
#ifdef CL_VERSION_2_2 |
| 314 |
clSetProgramReleaseCallback_t *clSetProgramReleaseCallback; |
| 315 |
clSetProgramSpecializationConstant_t *clSetProgramSpecializationConstant; |
| 316 |
#else |
| 317 |
void *clSetProgramReleaseCallback; |
| 318 |
void *clSetProgramSpecializationConstant; |
| 319 |
#endif |
| 320 |
|
| 321 |
/* OpenCL 3.0 */ |
| 322 |
#ifdef CL_VERSION_3_0 |
| 323 |
clCreateBufferWithProperties_t *clCreateBufferWithProperties; |
| 324 |
clCreateImageWithProperties_t *clCreateImageWithProperties; |
| 325 |
clSetContextDestructorCallback_t *clSetContextDestructorCallback; |
| 326 |
#else |
| 327 |
void *clCreateBufferWithProperties; |
| 328 |
void *clCreateImageWithProperties; |
| 329 |
void *clSetContextDestructorCallback; |
| 330 |
#endif |
| 331 |
|
| 332 |
} cl_icd_dispatch; |
| 333 |
|
| 334 |
#ifdef __cplusplus |
| 335 |
} |
| 336 |
#endif |
| 337 |
|
| 338 |
#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ |
| 339 |
#pragma warning( pop ) |
| 340 |
#endif |
| 341 |
|
| 342 |
#endif /* #ifndef OPENCL_CL_ICD_H */ |