├── .clang-format ├── .github └── workflows │ ├── presubmit.yml │ └── release.yml ├── .gitignore ├── CL ├── cl.h ├── cl_d3d10.h ├── cl_d3d11.h ├── cl_dx9_media_sharing.h ├── cl_dx9_media_sharing_intel.h ├── cl_egl.h ├── cl_ext.h ├── cl_ext_intel.h ├── cl_function_types.h ├── cl_gl.h ├── cl_gl_ext.h ├── cl_half.h ├── cl_icd.h ├── cl_layer.h ├── cl_platform.h ├── cl_va_api_media_sharing_intel.h ├── cl_version.h └── opencl.h ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── LICENSE ├── OpenCL-Headers.pc.in ├── README.md ├── build.py ├── cmake ├── DebSourcePkg.cmake ├── JoinPaths.cmake ├── Package.cmake └── PackageSetup.cmake ├── conanfile.py ├── scripts ├── .gitignore ├── README.md ├── check-format.sh ├── cl_ext.h.mako ├── cl_function_types.h.mako ├── gen │ └── __init__.py ├── gen_headers.py └── requirements.txt └── tests ├── CMakeLists.txt ├── README.md ├── conan ├── CMakeLists.txt ├── conanfile.py └── example.c ├── lang_c └── CMakeLists.txt ├── lang_cpp └── CMakeLists.txt ├── pkgconfig ├── bare │ └── CMakeLists.txt ├── pkgconfig.c └── sdk │ └── CMakeLists.txt ├── test_cl.h.c ├── test_cl_d3d10.h.c ├── test_cl_d3d11.h.c ├── test_cl_dx9_media_sharing.h.c ├── test_cl_dx9_media_sharing_intel.h.c ├── test_cl_egl.h.c ├── test_cl_ext.h.c ├── test_cl_ext_intel.h.c ├── test_cl_gl.h.c ├── test_cl_gl_ext.h.c ├── test_cl_half.h.c ├── test_cl_icd.h.c ├── test_cl_layer.h.c ├── test_cl_platform.h.c ├── test_cl_version.h.c ├── test_ext_headers.c ├── test_headers.c └── test_opencl.h.c /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -4 4 | AlignAfterOpenBracket: Align 5 | AlignConsecutiveAssignments: false 6 | AlignConsecutiveDeclarations: false 7 | AlignEscapedNewlines: Right 8 | AlignOperands: false 9 | AlignTrailingComments: false 10 | AllowAllArgumentsOnNextLine: true 11 | AllowAllConstructorInitializersOnNextLine: true 12 | AllowAllParametersOfDeclarationOnNextLine: true 13 | AllowShortBlocksOnASingleLine: false 14 | AllowShortCaseLabelsOnASingleLine: true 15 | AllowShortFunctionsOnASingleLine: All 16 | AllowShortLambdasOnASingleLine: All 17 | AllowShortIfStatementsOnASingleLine: WithoutElse 18 | AllowShortLoopsOnASingleLine: true 19 | AlwaysBreakAfterDefinitionReturnType: None 20 | AlwaysBreakAfterReturnType: None 21 | AlwaysBreakBeforeMultilineStrings: false 22 | AlwaysBreakTemplateDeclarations: MultiLine 23 | BinPackArguments: true 24 | BinPackParameters: true 25 | BraceWrapping: 26 | AfterCaseLabel: false 27 | AfterClass: false 28 | AfterControlStatement: true 29 | AfterEnum: true 30 | AfterFunction: true 31 | AfterNamespace: false 32 | AfterObjCDeclaration: false 33 | AfterStruct: true 34 | AfterUnion: false 35 | AfterExternBlock: false 36 | BeforeCatch: false 37 | BeforeElse: true 38 | IndentBraces: false 39 | SplitEmptyFunction: false 40 | SplitEmptyRecord: true 41 | SplitEmptyNamespace: true 42 | BreakBeforeBinaryOperators: NonAssignment 43 | BreakBeforeBraces: Custom 44 | BreakBeforeInheritanceComma: false 45 | BreakInheritanceList: BeforeColon 46 | BreakBeforeTernaryOperators: true 47 | BreakConstructorInitializersBeforeComma: false 48 | BreakConstructorInitializers: BeforeColon 49 | BreakAfterJavaFieldAnnotations: false 50 | BreakStringLiterals: true 51 | ColumnLimit: 80 52 | CommentPragmas: '^ IWYU pragma:' 53 | CompactNamespaces: false 54 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 55 | ConstructorInitializerIndentWidth: 4 56 | ContinuationIndentWidth: 4 57 | Cpp11BracedListStyle: false 58 | DerivePointerAlignment: true 59 | DisableFormat: false 60 | ExperimentalAutoDetectBinPacking: false 61 | FixNamespaceComments: false 62 | ForEachMacros: 63 | - foreach 64 | - Q_FOREACH 65 | - BOOST_FOREACH 66 | IncludeBlocks: Preserve 67 | IncludeCategories: 68 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/' 69 | Priority: 2 70 | - Regex: '^(<|"(gtest|gmock|isl|json)/)' 71 | Priority: 3 72 | - Regex: '.*' 73 | Priority: 1 74 | IncludeIsMainRegex: '(Test)?$' 75 | IndentCaseLabels: true 76 | IndentPPDirectives: None 77 | IndentWidth: 4 78 | IndentWrappedFunctionNames: false 79 | JavaScriptQuotes: Leave 80 | JavaScriptWrapImports: true 81 | KeepEmptyLinesAtTheStartOfBlocks: true 82 | MacroBlockBegin: '' 83 | MacroBlockEnd: '' 84 | MaxEmptyLinesToKeep: 2 85 | NamespaceIndentation: Inner 86 | ObjCBinPackProtocolList: Auto 87 | ObjCBlockIndentWidth: 4 88 | ObjCSpaceAfterProperty: true 89 | ObjCSpaceBeforeProtocolList: true 90 | PenaltyBreakAssignment: 2 91 | PenaltyBreakBeforeFirstCallParameter: 19 92 | PenaltyBreakComment: 300 93 | PenaltyBreakFirstLessLess: 120 94 | PenaltyBreakString: 1000 95 | PenaltyBreakTemplateDeclaration: 10 96 | PenaltyExcessCharacter: 1000000 97 | PenaltyReturnTypeOnItsOwnLine: 60 98 | PointerAlignment: Left 99 | ReflowComments: true 100 | SortIncludes: false 101 | SortUsingDeclarations: true 102 | SpaceAfterCStyleCast: false 103 | SpaceAfterLogicalNot: false 104 | SpaceAfterTemplateKeyword: true 105 | SpaceBeforeAssignmentOperators: true 106 | SpaceBeforeCpp11BracedList: false 107 | SpaceBeforeCtorInitializerColon: false 108 | SpaceBeforeInheritanceColon: true 109 | SpaceBeforeParens: ControlStatements 110 | SpaceBeforeRangeBasedForLoopColon: true 111 | SpaceInEmptyParentheses: false 112 | SpacesBeforeTrailingComments: 1 113 | SpacesInAngles: false 114 | SpacesInContainerLiterals: true 115 | SpacesInCStyleCastParentheses: false 116 | SpacesInParentheses: false 117 | SpacesInSquareBrackets: false 118 | Standard: Cpp11 119 | StatementMacros: 120 | - Q_UNUSED 121 | - QT_REQUIRE_VERSION 122 | TabWidth: 4 123 | UseTab: Never 124 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | env: 8 | distroseries: jammy 9 | 10 | jobs: 11 | release: 12 | if: false 13 | runs-on: ubuntu-latest 14 | defaults: 15 | run: 16 | shell: bash 17 | steps: 18 | - name: Install prerequisites 19 | run: sudo apt-get update -qq && sudo apt-get install -y cmake devscripts debhelper-compat=13 20 | 21 | - name: Import GPG signing key 22 | run: echo "${{ secrets.DEB_SIGNING_KEY }}" | gpg --import 23 | 24 | - name: Download and extract source code 25 | run: | 26 | wget -O $GITHUB_WORKSPACE/source.orig.tar.gz https://github.com/$GITHUB_REPOSITORY/archive/refs/tags/$GITHUB_REF_NAME.tar.gz 27 | tar -xvf $GITHUB_WORKSPACE/source.orig.tar.gz 28 | 29 | - name: Configure project out-of-tree 30 | run: cmake 31 | -S $GITHUB_WORKSPACE/OpenCL-Headers* 32 | -B $GITHUB_WORKSPACE/../build 33 | -D CMAKE_BUILD_TYPE=Release 34 | -D CMAKE_INSTALL_PREFIX=/usr 35 | -D BUILD_TESTING=OFF 36 | -D LATEST_RELEASE_VERSION=$GITHUB_REF_NAME 37 | -D CPACK_DEBIAN_PACKAGE_MAINTAINER="${{ vars.DEB_MAINTAINER }}" 38 | -D DEBIAN_VERSION_SUFFIX=${{ vars.DEB_VERSION_SUFFIX }} 39 | 40 | - name: Generate packaging scripts 41 | run: cmake 42 | -D CMAKE_CACHE_PATH=$GITHUB_WORKSPACE/../build/CMakeCache.txt 43 | -D ORIG_ARCHIVE=$GITHUB_WORKSPACE/source.orig.tar.gz 44 | -D LATEST_RELEASE_VERSION=$GITHUB_REF_NAME 45 | -D DEBIAN_DISTROSERIES=${{ env.distroseries }} 46 | -D DEBIAN_PACKAGE_MAINTAINER="${{ vars.DEB_MAINTAINER }}" 47 | -D DEBIAN_VERSION_SUFFIX=${{ vars.DEB_VERSION_SUFFIX }} 48 | -P $GITHUB_WORKSPACE/OpenCL-Headers*/cmake/DebSourcePkg.cmake 49 | 50 | - name: Build source package 51 | run: | 52 | cd $GITHUB_WORKSPACE/OpenCL-Headers*/ 53 | debuild -S -sa 54 | 55 | - name: Build binary package 56 | run: cpack 57 | -G DEB 58 | -C Release 59 | -B $GITHUB_WORKSPACE/../build 60 | --config $GITHUB_WORKSPACE/../build/CPackConfig.cmake 61 | 62 | # The following step does not depend on the previous step "Build binary package", 63 | # but if the binary package build is unsuccessful, it is better not to push the 64 | # source packages to the PPA 65 | - name: Push source package to the PPA 66 | run: dput ppa:${{ vars.PPA }} $GITHUB_WORKSPACE/*source.changes 67 | 68 | - name: Create GitHub release 69 | uses: softprops/action-gh-release@v1 70 | with: 71 | files: ${{ github.workspace }}/../build/*.deb 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build dir 2 | [Bb]uild/ 3 | 4 | # Install dir 5 | [Ii]nstall/ 6 | 7 | # Package dir 8 | [Pp]ackage[-_\s\d]*/ 9 | 10 | # Test dir 11 | [Tt]esting/ 12 | 13 | # Visual Studio Code 14 | .vscode 15 | -------------------------------------------------------------------------------- /CL/cl_d3d10.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2023 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_D3D10_H_ 18 | #define OPENCL_CL_D3D10_H_ 19 | 20 | /* 21 | ** This header is generated from the Khronos OpenCL XML API Registry. 22 | */ 23 | 24 | #if defined(_MSC_VER) 25 | #if _MSC_VER >=1500 26 | #pragma warning( push ) 27 | #pragma warning( disable : 4201 ) 28 | #pragma warning( disable : 5105 ) 29 | #endif 30 | #endif 31 | #include 32 | #if defined(_MSC_VER) 33 | #if _MSC_VER >=1500 34 | #pragma warning( pop ) 35 | #endif 36 | #endif 37 | 38 | #include 39 | 40 | /* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ 41 | #if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) 42 | #define CL_NO_EXTENSION_PROTOTYPES 43 | #endif 44 | 45 | /* CL_NO_EXTENSION_PROTOTYPES implies 46 | CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and 47 | CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ 48 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 49 | !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 50 | #define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES 51 | #endif 52 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 53 | !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 54 | #define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES 55 | #endif 56 | 57 | #ifdef __cplusplus 58 | extern "C" { 59 | #endif 60 | 61 | /*************************************************************** 62 | * cl_khr_d3d10_sharing 63 | ***************************************************************/ 64 | #define cl_khr_d3d10_sharing 1 65 | #define CL_KHR_D3D10_SHARING_EXTENSION_NAME \ 66 | "cl_khr_d3d10_sharing" 67 | 68 | 69 | #define CL_KHR_D3D10_SHARING_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 70 | 71 | typedef cl_uint cl_d3d10_device_source_khr; 72 | typedef cl_uint cl_d3d10_device_set_khr; 73 | 74 | /* Error codes */ 75 | #define CL_INVALID_D3D10_DEVICE_KHR -1002 76 | #define CL_INVALID_D3D10_RESOURCE_KHR -1003 77 | #define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004 78 | #define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005 79 | 80 | /* cl_d3d10_device_source_khr */ 81 | #define CL_D3D10_DEVICE_KHR 0x4010 82 | #define CL_D3D10_DXGI_ADAPTER_KHR 0x4011 83 | 84 | /* cl_d3d10_device_set_khr */ 85 | #define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012 86 | #define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013 87 | 88 | /* cl_context_info */ 89 | #define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014 90 | #define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C 91 | 92 | /* cl_mem_info */ 93 | #define CL_MEM_D3D10_RESOURCE_KHR 0x4015 94 | 95 | /* cl_image_info */ 96 | #define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016 97 | 98 | /* cl_command_type */ 99 | #define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017 100 | #define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018 101 | 102 | 103 | typedef cl_int CL_API_CALL 104 | clGetDeviceIDsFromD3D10KHR_t( 105 | cl_platform_id platform, 106 | cl_d3d10_device_source_khr d3d_device_source, 107 | void* d3d_object, 108 | cl_d3d10_device_set_khr d3d_device_set, 109 | cl_uint num_entries, 110 | cl_device_id* devices, 111 | cl_uint* num_devices); 112 | 113 | typedef clGetDeviceIDsFromD3D10KHR_t * 114 | clGetDeviceIDsFromD3D10KHR_fn CL_API_SUFFIX__VERSION_1_0; 115 | 116 | typedef cl_mem CL_API_CALL 117 | clCreateFromD3D10BufferKHR_t( 118 | cl_context context, 119 | cl_mem_flags flags, 120 | ID3D10Buffer* resource, 121 | cl_int* errcode_ret); 122 | 123 | typedef clCreateFromD3D10BufferKHR_t * 124 | clCreateFromD3D10BufferKHR_fn CL_API_SUFFIX__VERSION_1_0; 125 | 126 | typedef cl_mem CL_API_CALL 127 | clCreateFromD3D10Texture2DKHR_t( 128 | cl_context context, 129 | cl_mem_flags flags, 130 | ID3D10Texture2D* resource, 131 | UINT subresource, 132 | cl_int* errcode_ret); 133 | 134 | typedef clCreateFromD3D10Texture2DKHR_t * 135 | clCreateFromD3D10Texture2DKHR_fn CL_API_SUFFIX__VERSION_1_0; 136 | 137 | typedef cl_mem CL_API_CALL 138 | clCreateFromD3D10Texture3DKHR_t( 139 | cl_context context, 140 | cl_mem_flags flags, 141 | ID3D10Texture3D* resource, 142 | UINT subresource, 143 | cl_int* errcode_ret); 144 | 145 | typedef clCreateFromD3D10Texture3DKHR_t * 146 | clCreateFromD3D10Texture3DKHR_fn CL_API_SUFFIX__VERSION_1_0; 147 | 148 | typedef cl_int CL_API_CALL 149 | clEnqueueAcquireD3D10ObjectsKHR_t( 150 | cl_command_queue command_queue, 151 | cl_uint num_objects, 152 | const cl_mem* mem_objects, 153 | cl_uint num_events_in_wait_list, 154 | const cl_event* event_wait_list, 155 | cl_event* event); 156 | 157 | typedef clEnqueueAcquireD3D10ObjectsKHR_t * 158 | clEnqueueAcquireD3D10ObjectsKHR_fn CL_API_SUFFIX__VERSION_1_0; 159 | 160 | typedef cl_int CL_API_CALL 161 | clEnqueueReleaseD3D10ObjectsKHR_t( 162 | cl_command_queue command_queue, 163 | cl_uint num_objects, 164 | const cl_mem* mem_objects, 165 | cl_uint num_events_in_wait_list, 166 | const cl_event* event_wait_list, 167 | cl_event* event); 168 | 169 | typedef clEnqueueReleaseD3D10ObjectsKHR_t * 170 | clEnqueueReleaseD3D10ObjectsKHR_fn CL_API_SUFFIX__VERSION_1_0; 171 | 172 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 173 | 174 | extern CL_API_ENTRY cl_int CL_API_CALL 175 | clGetDeviceIDsFromD3D10KHR( 176 | cl_platform_id platform, 177 | cl_d3d10_device_source_khr d3d_device_source, 178 | void* d3d_object, 179 | cl_d3d10_device_set_khr d3d_device_set, 180 | cl_uint num_entries, 181 | cl_device_id* devices, 182 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_0; 183 | 184 | extern CL_API_ENTRY cl_mem CL_API_CALL 185 | clCreateFromD3D10BufferKHR( 186 | cl_context context, 187 | cl_mem_flags flags, 188 | ID3D10Buffer* resource, 189 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; 190 | 191 | extern CL_API_ENTRY cl_mem CL_API_CALL 192 | clCreateFromD3D10Texture2DKHR( 193 | cl_context context, 194 | cl_mem_flags flags, 195 | ID3D10Texture2D* resource, 196 | UINT subresource, 197 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; 198 | 199 | extern CL_API_ENTRY cl_mem CL_API_CALL 200 | clCreateFromD3D10Texture3DKHR( 201 | cl_context context, 202 | cl_mem_flags flags, 203 | ID3D10Texture3D* resource, 204 | UINT subresource, 205 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; 206 | 207 | extern CL_API_ENTRY cl_int CL_API_CALL 208 | clEnqueueAcquireD3D10ObjectsKHR( 209 | cl_command_queue command_queue, 210 | cl_uint num_objects, 211 | const cl_mem* mem_objects, 212 | cl_uint num_events_in_wait_list, 213 | const cl_event* event_wait_list, 214 | cl_event* event) CL_API_SUFFIX__VERSION_1_0; 215 | 216 | extern CL_API_ENTRY cl_int CL_API_CALL 217 | clEnqueueReleaseD3D10ObjectsKHR( 218 | cl_command_queue command_queue, 219 | cl_uint num_objects, 220 | const cl_mem* mem_objects, 221 | cl_uint num_events_in_wait_list, 222 | const cl_event* event_wait_list, 223 | cl_event* event) CL_API_SUFFIX__VERSION_1_0; 224 | 225 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 226 | 227 | /*************************************************************** 228 | * cl_intel_sharing_format_query_d3d10 229 | ***************************************************************/ 230 | #define cl_intel_sharing_format_query_d3d10 1 231 | #define CL_INTEL_SHARING_FORMAT_QUERY_D3D10_EXTENSION_NAME \ 232 | "cl_intel_sharing_format_query_d3d10" 233 | 234 | 235 | #define CL_INTEL_SHARING_FORMAT_QUERY_D3D10_EXTENSION_VERSION CL_MAKE_VERSION(0, 0, 0) 236 | 237 | /* when cl_khr_d3d10_sharing is supported */ 238 | 239 | typedef cl_int CL_API_CALL 240 | clGetSupportedD3D10TextureFormatsINTEL_t( 241 | cl_context context, 242 | cl_mem_flags flags, 243 | cl_mem_object_type image_type, 244 | cl_uint num_entries, 245 | DXGI_FORMAT* d3d10_formats, 246 | cl_uint* num_texture_formats); 247 | 248 | typedef clGetSupportedD3D10TextureFormatsINTEL_t * 249 | clGetSupportedD3D10TextureFormatsINTEL_fn ; 250 | 251 | #if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 252 | 253 | extern CL_API_ENTRY cl_int CL_API_CALL 254 | clGetSupportedD3D10TextureFormatsINTEL( 255 | cl_context context, 256 | cl_mem_flags flags, 257 | cl_mem_object_type image_type, 258 | cl_uint num_entries, 259 | DXGI_FORMAT* d3d10_formats, 260 | cl_uint* num_texture_formats) ; 261 | 262 | #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 263 | 264 | #ifdef __cplusplus 265 | } 266 | #endif 267 | 268 | #endif /* OPENCL_CL_D3D10_H_ */ 269 | -------------------------------------------------------------------------------- /CL/cl_d3d11.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2023 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_D3D11_H_ 18 | #define OPENCL_CL_D3D11_H_ 19 | 20 | /* 21 | ** This header is generated from the Khronos OpenCL XML API Registry. 22 | */ 23 | 24 | #if defined(_MSC_VER) 25 | #if _MSC_VER >=1500 26 | #pragma warning( push ) 27 | #pragma warning( disable : 4201 ) 28 | #pragma warning( disable : 5105 ) 29 | #endif 30 | #endif 31 | #include 32 | #if defined(_MSC_VER) 33 | #if _MSC_VER >=1500 34 | #pragma warning( pop ) 35 | #endif 36 | #endif 37 | 38 | #include 39 | 40 | /* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ 41 | #if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) 42 | #define CL_NO_EXTENSION_PROTOTYPES 43 | #endif 44 | 45 | /* CL_NO_EXTENSION_PROTOTYPES implies 46 | CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and 47 | CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ 48 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 49 | !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 50 | #define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES 51 | #endif 52 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 53 | !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 54 | #define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES 55 | #endif 56 | 57 | #ifdef __cplusplus 58 | extern "C" { 59 | #endif 60 | 61 | /*************************************************************** 62 | * cl_khr_d3d11_sharing 63 | ***************************************************************/ 64 | #define cl_khr_d3d11_sharing 1 65 | #define CL_KHR_D3D11_SHARING_EXTENSION_NAME \ 66 | "cl_khr_d3d11_sharing" 67 | 68 | 69 | #define CL_KHR_D3D11_SHARING_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 70 | 71 | typedef cl_uint cl_d3d11_device_source_khr; 72 | typedef cl_uint cl_d3d11_device_set_khr; 73 | 74 | /* Error codes */ 75 | #define CL_INVALID_D3D11_DEVICE_KHR -1006 76 | #define CL_INVALID_D3D11_RESOURCE_KHR -1007 77 | #define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR -1008 78 | #define CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR -1009 79 | 80 | /* cl_d3d11_device_source_khr */ 81 | #define CL_D3D11_DEVICE_KHR 0x4019 82 | #define CL_D3D11_DXGI_ADAPTER_KHR 0x401A 83 | 84 | /* cl_d3d11_device_set_khr */ 85 | #define CL_PREFERRED_DEVICES_FOR_D3D11_KHR 0x401B 86 | #define CL_ALL_DEVICES_FOR_D3D11_KHR 0x401C 87 | 88 | /* cl_context_info */ 89 | #define CL_CONTEXT_D3D11_DEVICE_KHR 0x401D 90 | #define CL_CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR 0x402D 91 | 92 | /* cl_mem_info */ 93 | #define CL_MEM_D3D11_RESOURCE_KHR 0x401E 94 | 95 | /* cl_image_info */ 96 | #define CL_IMAGE_D3D11_SUBRESOURCE_KHR 0x401F 97 | 98 | /* cl_command_type */ 99 | #define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_KHR 0x4020 100 | #define CL_COMMAND_RELEASE_D3D11_OBJECTS_KHR 0x4021 101 | 102 | 103 | typedef cl_int CL_API_CALL 104 | clGetDeviceIDsFromD3D11KHR_t( 105 | cl_platform_id platform, 106 | cl_d3d11_device_source_khr d3d_device_source, 107 | void* d3d_object, 108 | cl_d3d11_device_set_khr d3d_device_set, 109 | cl_uint num_entries, 110 | cl_device_id* devices, 111 | cl_uint* num_devices); 112 | 113 | typedef clGetDeviceIDsFromD3D11KHR_t * 114 | clGetDeviceIDsFromD3D11KHR_fn CL_API_SUFFIX__VERSION_1_2; 115 | 116 | typedef cl_mem CL_API_CALL 117 | clCreateFromD3D11BufferKHR_t( 118 | cl_context context, 119 | cl_mem_flags flags, 120 | ID3D11Buffer* resource, 121 | cl_int* errcode_ret); 122 | 123 | typedef clCreateFromD3D11BufferKHR_t * 124 | clCreateFromD3D11BufferKHR_fn CL_API_SUFFIX__VERSION_1_2; 125 | 126 | typedef cl_mem CL_API_CALL 127 | clCreateFromD3D11Texture2DKHR_t( 128 | cl_context context, 129 | cl_mem_flags flags, 130 | ID3D11Texture2D* resource, 131 | UINT subresource, 132 | cl_int* errcode_ret); 133 | 134 | typedef clCreateFromD3D11Texture2DKHR_t * 135 | clCreateFromD3D11Texture2DKHR_fn CL_API_SUFFIX__VERSION_1_2; 136 | 137 | typedef cl_mem CL_API_CALL 138 | clCreateFromD3D11Texture3DKHR_t( 139 | cl_context context, 140 | cl_mem_flags flags, 141 | ID3D11Texture3D* resource, 142 | UINT subresource, 143 | cl_int* errcode_ret); 144 | 145 | typedef clCreateFromD3D11Texture3DKHR_t * 146 | clCreateFromD3D11Texture3DKHR_fn CL_API_SUFFIX__VERSION_1_2; 147 | 148 | typedef cl_int CL_API_CALL 149 | clEnqueueAcquireD3D11ObjectsKHR_t( 150 | cl_command_queue command_queue, 151 | cl_uint num_objects, 152 | const cl_mem* mem_objects, 153 | cl_uint num_events_in_wait_list, 154 | const cl_event* event_wait_list, 155 | cl_event* event); 156 | 157 | typedef clEnqueueAcquireD3D11ObjectsKHR_t * 158 | clEnqueueAcquireD3D11ObjectsKHR_fn CL_API_SUFFIX__VERSION_1_2; 159 | 160 | typedef cl_int CL_API_CALL 161 | clEnqueueReleaseD3D11ObjectsKHR_t( 162 | cl_command_queue command_queue, 163 | cl_uint num_objects, 164 | const cl_mem* mem_objects, 165 | cl_uint num_events_in_wait_list, 166 | const cl_event* event_wait_list, 167 | cl_event* event); 168 | 169 | typedef clEnqueueReleaseD3D11ObjectsKHR_t * 170 | clEnqueueReleaseD3D11ObjectsKHR_fn CL_API_SUFFIX__VERSION_1_2; 171 | 172 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 173 | 174 | extern CL_API_ENTRY cl_int CL_API_CALL 175 | clGetDeviceIDsFromD3D11KHR( 176 | cl_platform_id platform, 177 | cl_d3d11_device_source_khr d3d_device_source, 178 | void* d3d_object, 179 | cl_d3d11_device_set_khr d3d_device_set, 180 | cl_uint num_entries, 181 | cl_device_id* devices, 182 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; 183 | 184 | extern CL_API_ENTRY cl_mem CL_API_CALL 185 | clCreateFromD3D11BufferKHR( 186 | cl_context context, 187 | cl_mem_flags flags, 188 | ID3D11Buffer* resource, 189 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; 190 | 191 | extern CL_API_ENTRY cl_mem CL_API_CALL 192 | clCreateFromD3D11Texture2DKHR( 193 | cl_context context, 194 | cl_mem_flags flags, 195 | ID3D11Texture2D* resource, 196 | UINT subresource, 197 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; 198 | 199 | extern CL_API_ENTRY cl_mem CL_API_CALL 200 | clCreateFromD3D11Texture3DKHR( 201 | cl_context context, 202 | cl_mem_flags flags, 203 | ID3D11Texture3D* resource, 204 | UINT subresource, 205 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; 206 | 207 | extern CL_API_ENTRY cl_int CL_API_CALL 208 | clEnqueueAcquireD3D11ObjectsKHR( 209 | cl_command_queue command_queue, 210 | cl_uint num_objects, 211 | const cl_mem* mem_objects, 212 | cl_uint num_events_in_wait_list, 213 | const cl_event* event_wait_list, 214 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 215 | 216 | extern CL_API_ENTRY cl_int CL_API_CALL 217 | clEnqueueReleaseD3D11ObjectsKHR( 218 | cl_command_queue command_queue, 219 | cl_uint num_objects, 220 | const cl_mem* mem_objects, 221 | cl_uint num_events_in_wait_list, 222 | const cl_event* event_wait_list, 223 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 224 | 225 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 226 | 227 | /*************************************************************** 228 | * cl_intel_sharing_format_query_d3d11 229 | ***************************************************************/ 230 | #define cl_intel_sharing_format_query_d3d11 1 231 | #define CL_INTEL_SHARING_FORMAT_QUERY_D3D11_EXTENSION_NAME \ 232 | "cl_intel_sharing_format_query_d3d11" 233 | 234 | 235 | #define CL_INTEL_SHARING_FORMAT_QUERY_D3D11_EXTENSION_VERSION CL_MAKE_VERSION(0, 0, 0) 236 | 237 | /* when cl_khr_d3d11_sharing is supported */ 238 | 239 | typedef cl_int CL_API_CALL 240 | clGetSupportedD3D11TextureFormatsINTEL_t( 241 | cl_context context, 242 | cl_mem_flags flags, 243 | cl_mem_object_type image_type, 244 | cl_uint plane, 245 | cl_uint num_entries, 246 | DXGI_FORMAT* d3d11_formats, 247 | cl_uint* num_texture_formats); 248 | 249 | typedef clGetSupportedD3D11TextureFormatsINTEL_t * 250 | clGetSupportedD3D11TextureFormatsINTEL_fn ; 251 | 252 | #if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 253 | 254 | extern CL_API_ENTRY cl_int CL_API_CALL 255 | clGetSupportedD3D11TextureFormatsINTEL( 256 | cl_context context, 257 | cl_mem_flags flags, 258 | cl_mem_object_type image_type, 259 | cl_uint plane, 260 | cl_uint num_entries, 261 | DXGI_FORMAT* d3d11_formats, 262 | cl_uint* num_texture_formats) ; 263 | 264 | #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 265 | 266 | #ifdef __cplusplus 267 | } 268 | #endif 269 | 270 | #endif /* OPENCL_CL_D3D11_H_ */ 271 | -------------------------------------------------------------------------------- /CL/cl_dx9_media_sharing.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2023 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_DX9_MEDIA_SHARING_H_ 18 | #define OPENCL_CL_DX9_MEDIA_SHARING_H_ 19 | 20 | /* 21 | ** This header is generated from the Khronos OpenCL XML API Registry. 22 | */ 23 | 24 | #if defined(_WIN32) 25 | #if defined(_MSC_VER) 26 | #if _MSC_VER >=1500 27 | #pragma warning( push ) 28 | #pragma warning( disable : 4201 ) 29 | #pragma warning( disable : 5105 ) 30 | #endif 31 | #endif 32 | #include 33 | #if defined(_MSC_VER) 34 | #if _MSC_VER >=1500 35 | #pragma warning( pop ) 36 | #endif 37 | #endif 38 | #endif 39 | 40 | #include 41 | 42 | /* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ 43 | #if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) 44 | #define CL_NO_EXTENSION_PROTOTYPES 45 | #endif 46 | 47 | /* CL_NO_EXTENSION_PROTOTYPES implies 48 | CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and 49 | CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ 50 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 51 | !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 52 | #define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES 53 | #endif 54 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 55 | !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 56 | #define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES 57 | #endif 58 | 59 | #ifdef __cplusplus 60 | extern "C" { 61 | #endif 62 | 63 | /*************************************************************** 64 | * cl_khr_dx9_media_sharing 65 | ***************************************************************/ 66 | #define cl_khr_dx9_media_sharing 1 67 | #define CL_KHR_DX9_MEDIA_SHARING_EXTENSION_NAME \ 68 | "cl_khr_dx9_media_sharing" 69 | 70 | 71 | #define CL_KHR_DX9_MEDIA_SHARING_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 72 | 73 | typedef cl_uint cl_dx9_media_adapter_type_khr; 74 | typedef cl_uint cl_dx9_media_adapter_set_khr; 75 | 76 | #if defined(_WIN32) 77 | typedef struct _cl_dx9_surface_info_khr { 78 | IDirect3DSurface9* resource; 79 | HANDLE shared_handle; 80 | } cl_dx9_surface_info_khr; 81 | 82 | #endif /* defined(_WIN32) */ 83 | 84 | /* Error codes */ 85 | #define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010 86 | #define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011 87 | #define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012 88 | #define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013 89 | 90 | /* cl_media_adapter_type_khr */ 91 | #define CL_ADAPTER_D3D9_KHR 0x2020 92 | #define CL_ADAPTER_D3D9EX_KHR 0x2021 93 | #define CL_ADAPTER_DXVA_KHR 0x2022 94 | 95 | /* cl_media_adapter_set_khr */ 96 | #define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023 97 | #define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024 98 | 99 | /* cl_context_info */ 100 | #define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025 101 | #define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026 102 | #define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027 103 | 104 | /* cl_mem_info */ 105 | #define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028 106 | #define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029 107 | 108 | /* cl_image_info */ 109 | #define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A 110 | 111 | /* cl_command_type */ 112 | #define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B 113 | #define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C 114 | 115 | 116 | typedef cl_int CL_API_CALL 117 | clGetDeviceIDsFromDX9MediaAdapterKHR_t( 118 | cl_platform_id platform, 119 | cl_uint num_media_adapters, 120 | cl_dx9_media_adapter_type_khr* media_adapter_type, 121 | void* media_adapters, 122 | cl_dx9_media_adapter_set_khr media_adapter_set, 123 | cl_uint num_entries, 124 | cl_device_id* devices, 125 | cl_uint* num_devices); 126 | 127 | typedef clGetDeviceIDsFromDX9MediaAdapterKHR_t * 128 | clGetDeviceIDsFromDX9MediaAdapterKHR_fn CL_API_SUFFIX__VERSION_1_2; 129 | 130 | typedef cl_mem CL_API_CALL 131 | clCreateFromDX9MediaSurfaceKHR_t( 132 | cl_context context, 133 | cl_mem_flags flags, 134 | cl_dx9_media_adapter_type_khr adapter_type, 135 | void* surface_info, 136 | cl_uint plane, 137 | cl_int* errcode_ret); 138 | 139 | typedef clCreateFromDX9MediaSurfaceKHR_t * 140 | clCreateFromDX9MediaSurfaceKHR_fn CL_API_SUFFIX__VERSION_1_2; 141 | 142 | typedef cl_int CL_API_CALL 143 | clEnqueueAcquireDX9MediaSurfacesKHR_t( 144 | cl_command_queue command_queue, 145 | cl_uint num_objects, 146 | const cl_mem* mem_objects, 147 | cl_uint num_events_in_wait_list, 148 | const cl_event* event_wait_list, 149 | cl_event* event); 150 | 151 | typedef clEnqueueAcquireDX9MediaSurfacesKHR_t * 152 | clEnqueueAcquireDX9MediaSurfacesKHR_fn CL_API_SUFFIX__VERSION_1_2; 153 | 154 | typedef cl_int CL_API_CALL 155 | clEnqueueReleaseDX9MediaSurfacesKHR_t( 156 | cl_command_queue command_queue, 157 | cl_uint num_objects, 158 | const cl_mem* mem_objects, 159 | cl_uint num_events_in_wait_list, 160 | const cl_event* event_wait_list, 161 | cl_event* event); 162 | 163 | typedef clEnqueueReleaseDX9MediaSurfacesKHR_t * 164 | clEnqueueReleaseDX9MediaSurfacesKHR_fn CL_API_SUFFIX__VERSION_1_2; 165 | 166 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 167 | 168 | extern CL_API_ENTRY cl_int CL_API_CALL 169 | clGetDeviceIDsFromDX9MediaAdapterKHR( 170 | cl_platform_id platform, 171 | cl_uint num_media_adapters, 172 | cl_dx9_media_adapter_type_khr* media_adapter_type, 173 | void* media_adapters, 174 | cl_dx9_media_adapter_set_khr media_adapter_set, 175 | cl_uint num_entries, 176 | cl_device_id* devices, 177 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; 178 | 179 | extern CL_API_ENTRY cl_mem CL_API_CALL 180 | clCreateFromDX9MediaSurfaceKHR( 181 | cl_context context, 182 | cl_mem_flags flags, 183 | cl_dx9_media_adapter_type_khr adapter_type, 184 | void* surface_info, 185 | cl_uint plane, 186 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; 187 | 188 | extern CL_API_ENTRY cl_int CL_API_CALL 189 | clEnqueueAcquireDX9MediaSurfacesKHR( 190 | cl_command_queue command_queue, 191 | cl_uint num_objects, 192 | const cl_mem* mem_objects, 193 | cl_uint num_events_in_wait_list, 194 | const cl_event* event_wait_list, 195 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 196 | 197 | extern CL_API_ENTRY cl_int CL_API_CALL 198 | clEnqueueReleaseDX9MediaSurfacesKHR( 199 | cl_command_queue command_queue, 200 | cl_uint num_objects, 201 | const cl_mem* mem_objects, 202 | cl_uint num_events_in_wait_list, 203 | const cl_event* event_wait_list, 204 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 205 | 206 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 207 | 208 | /*************************************************************** 209 | * cl_intel_dx9_media_sharing 210 | ***************************************************************/ 211 | #define cl_intel_dx9_media_sharing 1 212 | #define CL_INTEL_DX9_MEDIA_SHARING_EXTENSION_NAME \ 213 | "cl_intel_dx9_media_sharing" 214 | 215 | 216 | #define CL_INTEL_DX9_MEDIA_SHARING_EXTENSION_VERSION CL_MAKE_VERSION(0, 0, 0) 217 | 218 | typedef cl_uint cl_dx9_device_source_intel; 219 | typedef cl_uint cl_dx9_device_set_intel; 220 | 221 | /* Error codes */ 222 | #define CL_INVALID_DX9_DEVICE_INTEL -1010 223 | #define CL_INVALID_DX9_RESOURCE_INTEL -1011 224 | #define CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL -1012 225 | #define CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL -1013 226 | 227 | /* cl_dx9_device_source_intel */ 228 | #define CL_D3D9_DEVICE_INTEL 0x4022 229 | #define CL_D3D9EX_DEVICE_INTEL 0x4070 230 | #define CL_DXVA_DEVICE_INTEL 0x4071 231 | 232 | /* cl_dx9_device_set_intel */ 233 | #define CL_PREFERRED_DEVICES_FOR_DX9_INTEL 0x4024 234 | #define CL_ALL_DEVICES_FOR_DX9_INTEL 0x4025 235 | 236 | /* cl_context_info */ 237 | #define CL_CONTEXT_D3D9_DEVICE_INTEL 0x4026 238 | #define CL_CONTEXT_D3D9EX_DEVICE_INTEL 0x4072 239 | #define CL_CONTEXT_DXVA_DEVICE_INTEL 0x4073 240 | 241 | /* cl_mem_info */ 242 | #define CL_MEM_DX9_RESOURCE_INTEL 0x4027 243 | #define CL_MEM_DX9_SHARED_HANDLE_INTEL 0x4074 244 | 245 | /* cl_image_info */ 246 | #define CL_IMAGE_DX9_PLANE_INTEL 0x4075 247 | 248 | /* cl_command_type */ 249 | #define CL_COMMAND_ACQUIRE_DX9_OBJECTS_INTEL 0x402A 250 | #define CL_COMMAND_RELEASE_DX9_OBJECTS_INTEL 0x402B 251 | 252 | 253 | typedef cl_int CL_API_CALL 254 | clGetDeviceIDsFromDX9INTEL_t( 255 | cl_platform_id platform, 256 | cl_dx9_device_source_intel dx9_device_source, 257 | void* dx9_object, 258 | cl_dx9_device_set_intel dx9_device_set, 259 | cl_uint num_entries, 260 | cl_device_id* devices, 261 | cl_uint* num_devices); 262 | 263 | typedef clGetDeviceIDsFromDX9INTEL_t * 264 | clGetDeviceIDsFromDX9INTEL_fn CL_API_SUFFIX__VERSION_1_1; 265 | 266 | typedef cl_mem CL_API_CALL 267 | clCreateFromDX9MediaSurfaceINTEL_t( 268 | cl_context context, 269 | cl_mem_flags flags, 270 | IDirect3DSurface9* resource, 271 | HANDLE sharedHandle, 272 | UINT plane, 273 | cl_int* errcode_ret); 274 | 275 | typedef clCreateFromDX9MediaSurfaceINTEL_t * 276 | clCreateFromDX9MediaSurfaceINTEL_fn CL_API_SUFFIX__VERSION_1_1; 277 | 278 | typedef cl_int CL_API_CALL 279 | clEnqueueAcquireDX9ObjectsINTEL_t( 280 | cl_command_queue command_queue, 281 | cl_uint num_objects, 282 | const cl_mem* mem_objects, 283 | cl_uint num_events_in_wait_list, 284 | const cl_event* event_wait_list, 285 | cl_event* event); 286 | 287 | typedef clEnqueueAcquireDX9ObjectsINTEL_t * 288 | clEnqueueAcquireDX9ObjectsINTEL_fn CL_API_SUFFIX__VERSION_1_1; 289 | 290 | typedef cl_int CL_API_CALL 291 | clEnqueueReleaseDX9ObjectsINTEL_t( 292 | cl_command_queue command_queue, 293 | cl_uint num_objects, 294 | cl_mem* mem_objects, 295 | cl_uint num_events_in_wait_list, 296 | const cl_event* event_wait_list, 297 | cl_event* event); 298 | 299 | typedef clEnqueueReleaseDX9ObjectsINTEL_t * 300 | clEnqueueReleaseDX9ObjectsINTEL_fn CL_API_SUFFIX__VERSION_1_1; 301 | 302 | #if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 303 | 304 | extern CL_API_ENTRY cl_int CL_API_CALL 305 | clGetDeviceIDsFromDX9INTEL( 306 | cl_platform_id platform, 307 | cl_dx9_device_source_intel dx9_device_source, 308 | void* dx9_object, 309 | cl_dx9_device_set_intel dx9_device_set, 310 | cl_uint num_entries, 311 | cl_device_id* devices, 312 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; 313 | 314 | extern CL_API_ENTRY cl_mem CL_API_CALL 315 | clCreateFromDX9MediaSurfaceINTEL( 316 | cl_context context, 317 | cl_mem_flags flags, 318 | IDirect3DSurface9* resource, 319 | HANDLE sharedHandle, 320 | UINT plane, 321 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; 322 | 323 | extern CL_API_ENTRY cl_int CL_API_CALL 324 | clEnqueueAcquireDX9ObjectsINTEL( 325 | cl_command_queue command_queue, 326 | cl_uint num_objects, 327 | const cl_mem* mem_objects, 328 | cl_uint num_events_in_wait_list, 329 | const cl_event* event_wait_list, 330 | cl_event* event) CL_API_SUFFIX__VERSION_1_1; 331 | 332 | extern CL_API_ENTRY cl_int CL_API_CALL 333 | clEnqueueReleaseDX9ObjectsINTEL( 334 | cl_command_queue command_queue, 335 | cl_uint num_objects, 336 | cl_mem* mem_objects, 337 | cl_uint num_events_in_wait_list, 338 | const cl_event* event_wait_list, 339 | cl_event* event) CL_API_SUFFIX__VERSION_1_1; 340 | 341 | #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 342 | 343 | /*************************************************************** 344 | * cl_intel_sharing_format_query_dx9 345 | ***************************************************************/ 346 | #define cl_intel_sharing_format_query_dx9 1 347 | #define CL_INTEL_SHARING_FORMAT_QUERY_DX9_EXTENSION_NAME \ 348 | "cl_intel_sharing_format_query_dx9" 349 | 350 | 351 | #define CL_INTEL_SHARING_FORMAT_QUERY_DX9_EXTENSION_VERSION CL_MAKE_VERSION(0, 0, 0) 352 | 353 | /* when cl_khr_dx9_media_sharing or cl_intel_dx9_media_sharing is supported */ 354 | 355 | typedef cl_int CL_API_CALL 356 | clGetSupportedDX9MediaSurfaceFormatsINTEL_t( 357 | cl_context context, 358 | cl_mem_flags flags, 359 | cl_mem_object_type image_type, 360 | cl_uint plane, 361 | cl_uint num_entries, 362 | D3DFORMAT* dx9_formats, 363 | cl_uint* num_surface_formats); 364 | 365 | typedef clGetSupportedDX9MediaSurfaceFormatsINTEL_t * 366 | clGetSupportedDX9MediaSurfaceFormatsINTEL_fn ; 367 | 368 | #if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 369 | 370 | extern CL_API_ENTRY cl_int CL_API_CALL 371 | clGetSupportedDX9MediaSurfaceFormatsINTEL( 372 | cl_context context, 373 | cl_mem_flags flags, 374 | cl_mem_object_type image_type, 375 | cl_uint plane, 376 | cl_uint num_entries, 377 | D3DFORMAT* dx9_formats, 378 | cl_uint* num_surface_formats) ; 379 | 380 | #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 381 | 382 | #ifdef __cplusplus 383 | } 384 | #endif 385 | 386 | #endif /* OPENCL_CL_DX9_MEDIA_SHARING_H_ */ 387 | -------------------------------------------------------------------------------- /CL/cl_dx9_media_sharing_intel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-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 | #include 18 | #pragma message("The Intel DX9 media sharing extensions have been moved into cl_dx9_media_sharing.h. Please include cl_dx9_media_sharing.h directly.") 19 | -------------------------------------------------------------------------------- /CL/cl_egl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2023 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_EGL_H_ 18 | #define OPENCL_CL_EGL_H_ 19 | 20 | /* 21 | ** This header is generated from the Khronos OpenCL XML API Registry. 22 | */ 23 | 24 | #include 25 | 26 | /* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ 27 | #if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) 28 | #define CL_NO_EXTENSION_PROTOTYPES 29 | #endif 30 | 31 | /* CL_NO_EXTENSION_PROTOTYPES implies 32 | CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and 33 | CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ 34 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 35 | !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 36 | #define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES 37 | #endif 38 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 39 | !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 40 | #define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES 41 | #endif 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /*************************************************************** 48 | * cl_khr_egl_image 49 | ***************************************************************/ 50 | #define cl_khr_egl_image 1 51 | #define CL_KHR_EGL_IMAGE_EXTENSION_NAME \ 52 | "cl_khr_egl_image" 53 | 54 | 55 | #define CL_KHR_EGL_IMAGE_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 56 | 57 | /* Command type for events created with clEnqueueAcquireEGLObjectsKHR */ 58 | #define CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR 0x202F 59 | #define CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR 0x202D 60 | #define CL_COMMAND_RELEASE_EGL_OBJECTS_KHR 0x202E 61 | 62 | /* Error type for clCreateFromEGLImageKHR */ 63 | #define CL_INVALID_EGL_OBJECT_KHR -1093 64 | #define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092 65 | 66 | /* CLeglImageKHR is an opaque handle to an EGLImage */ 67 | typedef void* CLeglImageKHR; 68 | 69 | /* CLeglDisplayKHR is an opaque handle to an EGLDisplay */ 70 | typedef void* CLeglDisplayKHR; 71 | 72 | /* properties passed to clCreateFromEGLImageKHR */ 73 | typedef intptr_t cl_egl_image_properties_khr; 74 | 75 | 76 | typedef cl_mem CL_API_CALL 77 | clCreateFromEGLImageKHR_t( 78 | cl_context context, 79 | CLeglDisplayKHR egldisplay, 80 | CLeglImageKHR eglimage, 81 | cl_mem_flags flags, 82 | const cl_egl_image_properties_khr* properties, 83 | cl_int* errcode_ret); 84 | 85 | typedef clCreateFromEGLImageKHR_t * 86 | clCreateFromEGLImageKHR_fn CL_API_SUFFIX__VERSION_1_0; 87 | 88 | typedef cl_int CL_API_CALL 89 | clEnqueueAcquireEGLObjectsKHR_t( 90 | cl_command_queue command_queue, 91 | cl_uint num_objects, 92 | const cl_mem* mem_objects, 93 | cl_uint num_events_in_wait_list, 94 | const cl_event* event_wait_list, 95 | cl_event* event); 96 | 97 | typedef clEnqueueAcquireEGLObjectsKHR_t * 98 | clEnqueueAcquireEGLObjectsKHR_fn CL_API_SUFFIX__VERSION_1_0; 99 | 100 | typedef cl_int CL_API_CALL 101 | clEnqueueReleaseEGLObjectsKHR_t( 102 | cl_command_queue command_queue, 103 | cl_uint num_objects, 104 | const cl_mem* mem_objects, 105 | cl_uint num_events_in_wait_list, 106 | const cl_event* event_wait_list, 107 | cl_event* event); 108 | 109 | typedef clEnqueueReleaseEGLObjectsKHR_t * 110 | clEnqueueReleaseEGLObjectsKHR_fn CL_API_SUFFIX__VERSION_1_0; 111 | 112 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 113 | 114 | extern CL_API_ENTRY cl_mem CL_API_CALL 115 | clCreateFromEGLImageKHR( 116 | cl_context context, 117 | CLeglDisplayKHR egldisplay, 118 | CLeglImageKHR eglimage, 119 | cl_mem_flags flags, 120 | const cl_egl_image_properties_khr* properties, 121 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; 122 | 123 | extern CL_API_ENTRY cl_int CL_API_CALL 124 | clEnqueueAcquireEGLObjectsKHR( 125 | cl_command_queue command_queue, 126 | cl_uint num_objects, 127 | const cl_mem* mem_objects, 128 | cl_uint num_events_in_wait_list, 129 | const cl_event* event_wait_list, 130 | cl_event* event) CL_API_SUFFIX__VERSION_1_0; 131 | 132 | extern CL_API_ENTRY cl_int CL_API_CALL 133 | clEnqueueReleaseEGLObjectsKHR( 134 | cl_command_queue command_queue, 135 | cl_uint num_objects, 136 | const cl_mem* mem_objects, 137 | cl_uint num_events_in_wait_list, 138 | const cl_event* event_wait_list, 139 | cl_event* event) CL_API_SUFFIX__VERSION_1_0; 140 | 141 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 142 | 143 | /*************************************************************** 144 | * cl_khr_egl_event 145 | ***************************************************************/ 146 | #define cl_khr_egl_event 1 147 | #define CL_KHR_EGL_EVENT_EXTENSION_NAME \ 148 | "cl_khr_egl_event" 149 | 150 | 151 | #define CL_KHR_EGL_EVENT_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 152 | 153 | /* CLeglDisplayKHR is an opaque handle to an EGLDisplay */ 154 | /* type CLeglDisplayKHR */ 155 | 156 | /* CLeglSyncKHR is an opaque handle to an EGLSync object */ 157 | typedef void* CLeglSyncKHR; 158 | 159 | 160 | typedef cl_event CL_API_CALL 161 | clCreateEventFromEGLSyncKHR_t( 162 | cl_context context, 163 | CLeglSyncKHR sync, 164 | CLeglDisplayKHR display, 165 | cl_int* errcode_ret); 166 | 167 | typedef clCreateEventFromEGLSyncKHR_t * 168 | clCreateEventFromEGLSyncKHR_fn CL_API_SUFFIX__VERSION_1_0; 169 | 170 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 171 | 172 | extern CL_API_ENTRY cl_event CL_API_CALL 173 | clCreateEventFromEGLSyncKHR( 174 | cl_context context, 175 | CLeglSyncKHR sync, 176 | CLeglDisplayKHR display, 177 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; 178 | 179 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 180 | 181 | #ifdef __cplusplus 182 | } 183 | #endif 184 | 185 | #endif /* OPENCL_CL_EGL_H_ */ 186 | -------------------------------------------------------------------------------- /CL/cl_ext_intel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-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 | 18 | #include 19 | #pragma message("The Intel extensions have been moved into cl_ext.h. Please include cl_ext.h directly.") 20 | -------------------------------------------------------------------------------- /CL/cl_gl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2023 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_GL_H_ 18 | #define OPENCL_CL_GL_H_ 19 | 20 | /* 21 | ** This header is generated from the Khronos OpenCL XML API Registry. 22 | */ 23 | 24 | #include 25 | 26 | /* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ 27 | #if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) 28 | #define CL_NO_EXTENSION_PROTOTYPES 29 | #endif 30 | 31 | /* CL_NO_EXTENSION_PROTOTYPES implies 32 | CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and 33 | CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ 34 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 35 | !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 36 | #define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES 37 | #endif 38 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 39 | !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 40 | #define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES 41 | #endif 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /*************************************************************** 48 | * cl_khr_gl_sharing 49 | ***************************************************************/ 50 | #define cl_khr_gl_sharing 1 51 | #define CL_KHR_GL_SHARING_EXTENSION_NAME \ 52 | "cl_khr_gl_sharing" 53 | 54 | 55 | #define CL_KHR_GL_SHARING_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 56 | 57 | typedef int cl_GLint; 58 | typedef unsigned int cl_GLenum; 59 | typedef unsigned int cl_GLuint; 60 | 61 | typedef cl_uint cl_gl_context_info; 62 | 63 | /* Error codes */ 64 | #define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 65 | 66 | /* cl_gl_context_info */ 67 | #define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 68 | #define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 69 | 70 | /* Additional cl_context_properties */ 71 | #define CL_GL_CONTEXT_KHR 0x2008 72 | #define CL_EGL_DISPLAY_KHR 0x2009 73 | #define CL_GLX_DISPLAY_KHR 0x200A 74 | #define CL_WGL_HDC_KHR 0x200B 75 | #define CL_CGL_SHAREGROUP_KHR 0x200C 76 | 77 | typedef cl_uint cl_gl_object_type; 78 | typedef cl_uint cl_gl_texture_info; 79 | typedef cl_uint cl_gl_platform_info; 80 | 81 | /* cl_gl_object_type */ 82 | #define CL_GL_OBJECT_BUFFER 0x2000 83 | #define CL_GL_OBJECT_TEXTURE2D 0x2001 84 | #define CL_GL_OBJECT_TEXTURE3D 0x2002 85 | #define CL_GL_OBJECT_RENDERBUFFER 0x2003 86 | 87 | #if defined(CL_VERSION_1_2) 88 | /* cl_gl_object_type */ 89 | #define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E 90 | #define CL_GL_OBJECT_TEXTURE1D 0x200F 91 | #define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010 92 | #define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011 93 | 94 | #endif /* defined(CL_VERSION_1_2) */ 95 | 96 | /* cl_gl_texture_info */ 97 | #define CL_GL_TEXTURE_TARGET 0x2004 98 | #define CL_GL_MIPMAP_LEVEL 0x2005 99 | 100 | 101 | typedef cl_int CL_API_CALL 102 | clGetGLContextInfoKHR_t( 103 | const cl_context_properties* properties, 104 | cl_gl_context_info param_name, 105 | size_t param_value_size, 106 | void* param_value, 107 | size_t* param_value_size_ret); 108 | 109 | typedef clGetGLContextInfoKHR_t * 110 | clGetGLContextInfoKHR_fn CL_API_SUFFIX__VERSION_1_0; 111 | 112 | typedef cl_mem CL_API_CALL 113 | clCreateFromGLBuffer_t( 114 | cl_context context, 115 | cl_mem_flags flags, 116 | cl_GLuint bufobj, 117 | cl_int* errcode_ret); 118 | 119 | typedef clCreateFromGLBuffer_t * 120 | clCreateFromGLBuffer_fn CL_API_SUFFIX__VERSION_1_0; 121 | 122 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 123 | 124 | extern CL_API_ENTRY cl_int CL_API_CALL 125 | clGetGLContextInfoKHR( 126 | const cl_context_properties* properties, 127 | cl_gl_context_info param_name, 128 | size_t param_value_size, 129 | void* param_value, 130 | size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 131 | 132 | extern CL_API_ENTRY cl_mem CL_API_CALL 133 | clCreateFromGLBuffer( 134 | cl_context context, 135 | cl_mem_flags flags, 136 | cl_GLuint bufobj, 137 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; 138 | 139 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 140 | 141 | #if defined(CL_VERSION_1_2) 142 | 143 | typedef cl_mem CL_API_CALL 144 | clCreateFromGLTexture_t( 145 | cl_context context, 146 | cl_mem_flags flags, 147 | cl_GLenum target, 148 | cl_GLint miplevel, 149 | cl_GLuint texture, 150 | cl_int* errcode_ret); 151 | 152 | typedef clCreateFromGLTexture_t * 153 | clCreateFromGLTexture_fn CL_API_SUFFIX__VERSION_1_2; 154 | 155 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 156 | 157 | extern CL_API_ENTRY cl_mem CL_API_CALL 158 | clCreateFromGLTexture( 159 | cl_context context, 160 | cl_mem_flags flags, 161 | cl_GLenum target, 162 | cl_GLint miplevel, 163 | cl_GLuint texture, 164 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; 165 | 166 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 167 | 168 | #endif /* defined(CL_VERSION_1_2) */ 169 | 170 | 171 | typedef cl_mem CL_API_CALL 172 | clCreateFromGLRenderbuffer_t( 173 | cl_context context, 174 | cl_mem_flags flags, 175 | cl_GLuint renderbuffer, 176 | cl_int* errcode_ret); 177 | 178 | typedef clCreateFromGLRenderbuffer_t * 179 | clCreateFromGLRenderbuffer_fn CL_API_SUFFIX__VERSION_1_0; 180 | 181 | typedef cl_int CL_API_CALL 182 | clGetGLObjectInfo_t( 183 | cl_mem memobj, 184 | cl_gl_object_type* gl_object_type, 185 | cl_GLuint* gl_object_name); 186 | 187 | typedef clGetGLObjectInfo_t * 188 | clGetGLObjectInfo_fn CL_API_SUFFIX__VERSION_1_0; 189 | 190 | typedef cl_int CL_API_CALL 191 | clGetGLTextureInfo_t( 192 | cl_mem memobj, 193 | cl_gl_texture_info param_name, 194 | size_t param_value_size, 195 | void* param_value, 196 | size_t* param_value_size_ret); 197 | 198 | typedef clGetGLTextureInfo_t * 199 | clGetGLTextureInfo_fn CL_API_SUFFIX__VERSION_1_0; 200 | 201 | typedef cl_int CL_API_CALL 202 | clEnqueueAcquireGLObjects_t( 203 | cl_command_queue command_queue, 204 | cl_uint num_objects, 205 | const cl_mem* mem_objects, 206 | cl_uint num_events_in_wait_list, 207 | const cl_event* event_wait_list, 208 | cl_event* event); 209 | 210 | typedef clEnqueueAcquireGLObjects_t * 211 | clEnqueueAcquireGLObjects_fn CL_API_SUFFIX__VERSION_1_0; 212 | 213 | typedef cl_int CL_API_CALL 214 | clEnqueueReleaseGLObjects_t( 215 | cl_command_queue command_queue, 216 | cl_uint num_objects, 217 | const cl_mem* mem_objects, 218 | cl_uint num_events_in_wait_list, 219 | const cl_event* event_wait_list, 220 | cl_event* event); 221 | 222 | typedef clEnqueueReleaseGLObjects_t * 223 | clEnqueueReleaseGLObjects_fn CL_API_SUFFIX__VERSION_1_0; 224 | 225 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 226 | 227 | extern CL_API_ENTRY cl_mem CL_API_CALL 228 | clCreateFromGLRenderbuffer( 229 | cl_context context, 230 | cl_mem_flags flags, 231 | cl_GLuint renderbuffer, 232 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_0; 233 | 234 | extern CL_API_ENTRY cl_int CL_API_CALL 235 | clGetGLObjectInfo( 236 | cl_mem memobj, 237 | cl_gl_object_type* gl_object_type, 238 | cl_GLuint* gl_object_name) CL_API_SUFFIX__VERSION_1_0; 239 | 240 | extern CL_API_ENTRY cl_int CL_API_CALL 241 | clGetGLTextureInfo( 242 | cl_mem memobj, 243 | cl_gl_texture_info param_name, 244 | size_t param_value_size, 245 | void* param_value, 246 | size_t* param_value_size_ret) CL_API_SUFFIX__VERSION_1_0; 247 | 248 | extern CL_API_ENTRY cl_int CL_API_CALL 249 | clEnqueueAcquireGLObjects( 250 | cl_command_queue command_queue, 251 | cl_uint num_objects, 252 | const cl_mem* mem_objects, 253 | cl_uint num_events_in_wait_list, 254 | const cl_event* event_wait_list, 255 | cl_event* event) CL_API_SUFFIX__VERSION_1_0; 256 | 257 | extern CL_API_ENTRY cl_int CL_API_CALL 258 | clEnqueueReleaseGLObjects( 259 | cl_command_queue command_queue, 260 | cl_uint num_objects, 261 | const cl_mem* mem_objects, 262 | cl_uint num_events_in_wait_list, 263 | const cl_event* event_wait_list, 264 | cl_event* event) CL_API_SUFFIX__VERSION_1_0; 265 | 266 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 267 | 268 | /* OpenCL 1.0 APIs that were deprecated in OpenCL 1.2 */ 269 | 270 | typedef cl_mem CL_API_CALL 271 | clCreateFromGLTexture2D_t( 272 | cl_context context, 273 | cl_mem_flags flags, 274 | cl_GLenum target, 275 | cl_GLint miplevel, 276 | cl_GLuint texture, 277 | cl_int* errcode_ret); 278 | 279 | typedef clCreateFromGLTexture2D_t * 280 | clCreateFromGLTexture2D_fn CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 281 | 282 | typedef cl_mem CL_API_CALL 283 | clCreateFromGLTexture3D_t( 284 | cl_context context, 285 | cl_mem_flags flags, 286 | cl_GLenum target, 287 | cl_GLint miplevel, 288 | cl_GLuint texture, 289 | cl_int* errcode_ret); 290 | 291 | typedef clCreateFromGLTexture3D_t * 292 | clCreateFromGLTexture3D_fn CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 293 | 294 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 295 | 296 | extern CL_API_ENTRY cl_mem CL_API_CALL 297 | clCreateFromGLTexture2D( 298 | cl_context context, 299 | cl_mem_flags flags, 300 | cl_GLenum target, 301 | cl_GLint miplevel, 302 | cl_GLuint texture, 303 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 304 | 305 | extern CL_API_ENTRY cl_mem CL_API_CALL 306 | clCreateFromGLTexture3D( 307 | cl_context context, 308 | cl_mem_flags flags, 309 | cl_GLenum target, 310 | cl_GLint miplevel, 311 | cl_GLuint texture, 312 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1_DEPRECATED; 313 | 314 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 315 | 316 | /*************************************************************** 317 | * cl_khr_gl_event 318 | ***************************************************************/ 319 | #define cl_khr_gl_event 1 320 | #define CL_KHR_GL_EVENT_EXTENSION_NAME \ 321 | "cl_khr_gl_event" 322 | 323 | 324 | #define CL_KHR_GL_EVENT_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 325 | 326 | typedef struct __GLsync * cl_GLsync; 327 | 328 | /* cl_command_type */ 329 | #define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D 330 | 331 | 332 | typedef cl_event CL_API_CALL 333 | clCreateEventFromGLsyncKHR_t( 334 | cl_context context, 335 | cl_GLsync sync, 336 | cl_int* errcode_ret); 337 | 338 | typedef clCreateEventFromGLsyncKHR_t * 339 | clCreateEventFromGLsyncKHR_fn CL_API_SUFFIX__VERSION_1_1; 340 | 341 | #if !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 342 | 343 | extern CL_API_ENTRY cl_event CL_API_CALL 344 | clCreateEventFromGLsyncKHR( 345 | cl_context context, 346 | cl_GLsync sync, 347 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; 348 | 349 | #endif /* !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 350 | 351 | /*************************************************************** 352 | * cl_khr_gl_depth_images 353 | ***************************************************************/ 354 | #define cl_khr_gl_depth_images 1 355 | #define CL_KHR_GL_DEPTH_IMAGES_EXTENSION_NAME \ 356 | "cl_khr_gl_depth_images" 357 | 358 | 359 | #define CL_KHR_GL_DEPTH_IMAGES_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 360 | 361 | /* cl_channel_order */ 362 | #define CL_DEPTH_STENCIL 0x10BE 363 | 364 | /* cl_channel_type */ 365 | #define CL_UNORM_INT24 0x10DF 366 | 367 | /*************************************************************** 368 | * cl_khr_gl_msaa_sharing 369 | ***************************************************************/ 370 | #define cl_khr_gl_msaa_sharing 1 371 | #define CL_KHR_GL_MSAA_SHARING_EXTENSION_NAME \ 372 | "cl_khr_gl_msaa_sharing" 373 | 374 | 375 | #define CL_KHR_GL_MSAA_SHARING_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 376 | 377 | /* cl_gl_texture_info */ 378 | #define CL_GL_NUM_SAMPLES 0x2012 379 | 380 | /*************************************************************** 381 | * cl_intel_sharing_format_query_gl 382 | ***************************************************************/ 383 | #define cl_intel_sharing_format_query_gl 1 384 | #define CL_INTEL_SHARING_FORMAT_QUERY_GL_EXTENSION_NAME \ 385 | "cl_intel_sharing_format_query_gl" 386 | 387 | 388 | #define CL_INTEL_SHARING_FORMAT_QUERY_GL_EXTENSION_VERSION CL_MAKE_VERSION(0, 0, 0) 389 | 390 | /* when cl_khr_gl_sharing is supported */ 391 | 392 | typedef cl_int CL_API_CALL 393 | clGetSupportedGLTextureFormatsINTEL_t( 394 | cl_context context, 395 | cl_mem_flags flags, 396 | cl_mem_object_type image_type, 397 | cl_uint num_entries, 398 | cl_GLenum* gl_formats, 399 | cl_uint* num_texture_formats); 400 | 401 | typedef clGetSupportedGLTextureFormatsINTEL_t * 402 | clGetSupportedGLTextureFormatsINTEL_fn ; 403 | 404 | #if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 405 | 406 | extern CL_API_ENTRY cl_int CL_API_CALL 407 | clGetSupportedGLTextureFormatsINTEL( 408 | cl_context context, 409 | cl_mem_flags flags, 410 | cl_mem_object_type image_type, 411 | cl_uint num_entries, 412 | cl_GLenum* gl_formats, 413 | cl_uint* num_texture_formats) ; 414 | 415 | #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 416 | 417 | #ifdef __cplusplus 418 | } 419 | #endif 420 | 421 | #endif /* OPENCL_CL_GL_H_ */ 422 | -------------------------------------------------------------------------------- /CL/cl_gl_ext.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2021 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 | #include 18 | #pragma message("The extensions in cl_gl_ext.h have been moved into cl_gl.h. Please include cl_gl.h directly.") 19 | -------------------------------------------------------------------------------- /CL/cl_half.h: -------------------------------------------------------------------------------- 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 | /** 18 | * This is a header-only utility library that provides OpenCL host code with 19 | * routines for converting to/from cl_half values. 20 | * 21 | * Example usage: 22 | * 23 | * #include 24 | * ... 25 | * cl_half h = cl_half_from_float(0.5f, CL_HALF_RTE); 26 | * cl_float f = cl_half_to_float(h); 27 | */ 28 | 29 | #ifndef OPENCL_CL_HALF_H 30 | #define OPENCL_CL_HALF_H 31 | 32 | #include 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | 41 | /** 42 | * Rounding mode used when converting to cl_half. 43 | */ 44 | typedef enum 45 | { 46 | CL_HALF_RTE, // round to nearest even 47 | CL_HALF_RTZ, // round towards zero 48 | CL_HALF_RTP, // round towards positive infinity 49 | CL_HALF_RTN, // round towards negative infinity 50 | } cl_half_rounding_mode; 51 | 52 | 53 | /* Private utility macros. */ 54 | #define CL_HALF_EXP_MASK 0x7C00 55 | #define CL_HALF_MAX_FINITE_MAG 0x7BFF 56 | 57 | 58 | /* 59 | * Utility to deal with values that overflow when converting to half precision. 60 | */ 61 | static inline cl_half cl_half_handle_overflow(cl_half_rounding_mode rounding_mode, 62 | uint16_t sign) 63 | { 64 | if (rounding_mode == CL_HALF_RTZ) 65 | { 66 | // Round overflow towards zero -> largest finite number (preserving sign) 67 | return (sign << 15) | CL_HALF_MAX_FINITE_MAG; 68 | } 69 | else if (rounding_mode == CL_HALF_RTP && sign) 70 | { 71 | // Round negative overflow towards positive infinity -> most negative finite number 72 | return (1 << 15) | CL_HALF_MAX_FINITE_MAG; 73 | } 74 | else if (rounding_mode == CL_HALF_RTN && !sign) 75 | { 76 | // Round positive overflow towards negative infinity -> largest finite number 77 | return CL_HALF_MAX_FINITE_MAG; 78 | } 79 | 80 | // Overflow to infinity 81 | return (sign << 15) | CL_HALF_EXP_MASK; 82 | } 83 | 84 | /* 85 | * Utility to deal with values that underflow when converting to half precision. 86 | */ 87 | static inline cl_half cl_half_handle_underflow(cl_half_rounding_mode rounding_mode, 88 | uint16_t sign) 89 | { 90 | if (rounding_mode == CL_HALF_RTP && !sign) 91 | { 92 | // Round underflow towards positive infinity -> smallest positive value 93 | return (sign << 15) | 1; 94 | } 95 | else if (rounding_mode == CL_HALF_RTN && sign) 96 | { 97 | // Round underflow towards negative infinity -> largest negative value 98 | return (sign << 15) | 1; 99 | } 100 | 101 | // Flush to zero 102 | return (sign << 15); 103 | } 104 | 105 | 106 | /** 107 | * Convert a cl_float to a cl_half. 108 | */ 109 | static inline cl_half cl_half_from_float(cl_float f, cl_half_rounding_mode rounding_mode) 110 | { 111 | // Type-punning to get direct access to underlying bits 112 | union 113 | { 114 | cl_float f; 115 | uint32_t i; 116 | } f32; 117 | f32.f = f; 118 | 119 | // Extract sign bit 120 | uint16_t sign = f32.i >> 31; 121 | 122 | // Extract FP32 exponent and mantissa 123 | uint32_t f_exp = (f32.i >> (CL_FLT_MANT_DIG - 1)) & 0xFF; 124 | uint32_t f_mant = f32.i & ((1 << (CL_FLT_MANT_DIG - 1)) - 1); 125 | 126 | // Remove FP32 exponent bias 127 | int32_t exp = f_exp - CL_FLT_MAX_EXP + 1; 128 | 129 | // Add FP16 exponent bias 130 | uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1); 131 | 132 | // Position of the bit that will become the FP16 mantissa LSB 133 | uint32_t lsb_pos = CL_FLT_MANT_DIG - CL_HALF_MANT_DIG; 134 | 135 | // Check for NaN / infinity 136 | if (f_exp == 0xFF) 137 | { 138 | if (f_mant) 139 | { 140 | // NaN -> propagate mantissa and silence it 141 | uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos); 142 | h_mant |= 0x200; 143 | return (sign << 15) | CL_HALF_EXP_MASK | h_mant; 144 | } 145 | else 146 | { 147 | // Infinity -> zero mantissa 148 | return (sign << 15) | CL_HALF_EXP_MASK; 149 | } 150 | } 151 | 152 | // Check for zero 153 | if (!f_exp && !f_mant) 154 | { 155 | return (sign << 15); 156 | } 157 | 158 | // Check for overflow 159 | if (exp >= CL_HALF_MAX_EXP) 160 | { 161 | return cl_half_handle_overflow(rounding_mode, sign); 162 | } 163 | 164 | // Check for underflow 165 | if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) 166 | { 167 | return cl_half_handle_underflow(rounding_mode, sign); 168 | } 169 | 170 | // Check for value that will become denormal 171 | if (exp < -14) 172 | { 173 | // Denormal -> include the implicit 1 from the FP32 mantissa 174 | h_exp = 0; 175 | f_mant |= 1 << (CL_FLT_MANT_DIG - 1); 176 | 177 | // Mantissa shift amount depends on exponent 178 | lsb_pos = -exp + (CL_FLT_MANT_DIG - 25); 179 | } 180 | 181 | // Generate FP16 mantissa by shifting FP32 mantissa 182 | uint16_t h_mant = (uint16_t)(f_mant >> lsb_pos); 183 | 184 | // Check whether we need to round 185 | uint32_t halfway = 1 << (lsb_pos - 1); 186 | uint32_t mask = (halfway << 1) - 1; 187 | switch (rounding_mode) 188 | { 189 | case CL_HALF_RTE: 190 | if ((f_mant & mask) > halfway) 191 | { 192 | // More than halfway -> round up 193 | h_mant += 1; 194 | } 195 | else if ((f_mant & mask) == halfway) 196 | { 197 | // Exactly halfway -> round to nearest even 198 | if (h_mant & 0x1) 199 | h_mant += 1; 200 | } 201 | break; 202 | case CL_HALF_RTZ: 203 | // Mantissa has already been truncated -> do nothing 204 | break; 205 | case CL_HALF_RTP: 206 | if ((f_mant & mask) && !sign) 207 | { 208 | // Round positive numbers up 209 | h_mant += 1; 210 | } 211 | break; 212 | case CL_HALF_RTN: 213 | if ((f_mant & mask) && sign) 214 | { 215 | // Round negative numbers down 216 | h_mant += 1; 217 | } 218 | break; 219 | } 220 | 221 | // Check for mantissa overflow 222 | if (h_mant & 0x400) 223 | { 224 | h_exp += 1; 225 | h_mant = 0; 226 | } 227 | 228 | return (sign << 15) | (h_exp << 10) | h_mant; 229 | } 230 | 231 | 232 | /** 233 | * Convert a cl_double to a cl_half. 234 | */ 235 | static inline cl_half cl_half_from_double(cl_double d, cl_half_rounding_mode rounding_mode) 236 | { 237 | // Type-punning to get direct access to underlying bits 238 | union 239 | { 240 | cl_double d; 241 | uint64_t i; 242 | } f64; 243 | f64.d = d; 244 | 245 | // Extract sign bit 246 | uint16_t sign = f64.i >> 63; 247 | 248 | // Extract FP64 exponent and mantissa 249 | uint64_t d_exp = (f64.i >> (CL_DBL_MANT_DIG - 1)) & 0x7FF; 250 | uint64_t d_mant = f64.i & (((uint64_t)1 << (CL_DBL_MANT_DIG - 1)) - 1); 251 | 252 | // Remove FP64 exponent bias 253 | int64_t exp = d_exp - CL_DBL_MAX_EXP + 1; 254 | 255 | // Add FP16 exponent bias 256 | uint16_t h_exp = (uint16_t)(exp + CL_HALF_MAX_EXP - 1); 257 | 258 | // Position of the bit that will become the FP16 mantissa LSB 259 | uint32_t lsb_pos = CL_DBL_MANT_DIG - CL_HALF_MANT_DIG; 260 | 261 | // Check for NaN / infinity 262 | if (d_exp == 0x7FF) 263 | { 264 | if (d_mant) 265 | { 266 | // NaN -> propagate mantissa and silence it 267 | uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos); 268 | h_mant |= 0x200; 269 | return (sign << 15) | CL_HALF_EXP_MASK | h_mant; 270 | } 271 | else 272 | { 273 | // Infinity -> zero mantissa 274 | return (sign << 15) | CL_HALF_EXP_MASK; 275 | } 276 | } 277 | 278 | // Check for zero 279 | if (!d_exp && !d_mant) 280 | { 281 | return (sign << 15); 282 | } 283 | 284 | // Check for overflow 285 | if (exp >= CL_HALF_MAX_EXP) 286 | { 287 | return cl_half_handle_overflow(rounding_mode, sign); 288 | } 289 | 290 | // Check for underflow 291 | if (exp < (CL_HALF_MIN_EXP - CL_HALF_MANT_DIG - 1)) 292 | { 293 | return cl_half_handle_underflow(rounding_mode, sign); 294 | } 295 | 296 | // Check for value that will become denormal 297 | if (exp < -14) 298 | { 299 | // Include the implicit 1 from the FP64 mantissa 300 | h_exp = 0; 301 | d_mant |= (uint64_t)1 << (CL_DBL_MANT_DIG - 1); 302 | 303 | // Mantissa shift amount depends on exponent 304 | lsb_pos = (uint32_t)(-exp + (CL_DBL_MANT_DIG - 25)); 305 | } 306 | 307 | // Generate FP16 mantissa by shifting FP64 mantissa 308 | uint16_t h_mant = (uint16_t)(d_mant >> lsb_pos); 309 | 310 | // Check whether we need to round 311 | uint64_t halfway = (uint64_t)1 << (lsb_pos - 1); 312 | uint64_t mask = (halfway << 1) - 1; 313 | switch (rounding_mode) 314 | { 315 | case CL_HALF_RTE: 316 | if ((d_mant & mask) > halfway) 317 | { 318 | // More than halfway -> round up 319 | h_mant += 1; 320 | } 321 | else if ((d_mant & mask) == halfway) 322 | { 323 | // Exactly halfway -> round to nearest even 324 | if (h_mant & 0x1) 325 | h_mant += 1; 326 | } 327 | break; 328 | case CL_HALF_RTZ: 329 | // Mantissa has already been truncated -> do nothing 330 | break; 331 | case CL_HALF_RTP: 332 | if ((d_mant & mask) && !sign) 333 | { 334 | // Round positive numbers up 335 | h_mant += 1; 336 | } 337 | break; 338 | case CL_HALF_RTN: 339 | if ((d_mant & mask) && sign) 340 | { 341 | // Round negative numbers down 342 | h_mant += 1; 343 | } 344 | break; 345 | } 346 | 347 | // Check for mantissa overflow 348 | if (h_mant & 0x400) 349 | { 350 | h_exp += 1; 351 | h_mant = 0; 352 | } 353 | 354 | return (sign << 15) | (h_exp << 10) | h_mant; 355 | } 356 | 357 | 358 | /** 359 | * Convert a cl_half to a cl_float. 360 | */ 361 | static inline cl_float cl_half_to_float(cl_half h) 362 | { 363 | // Type-punning to get direct access to underlying bits 364 | union 365 | { 366 | cl_float f; 367 | uint32_t i; 368 | } f32; 369 | 370 | // Extract sign bit 371 | uint16_t sign = h >> 15; 372 | 373 | // Extract FP16 exponent and mantissa 374 | uint16_t h_exp = (h >> (CL_HALF_MANT_DIG - 1)) & 0x1F; 375 | uint16_t h_mant = h & 0x3FF; 376 | 377 | // Remove FP16 exponent bias 378 | int32_t exp = h_exp - CL_HALF_MAX_EXP + 1; 379 | 380 | // Add FP32 exponent bias 381 | uint32_t f_exp = exp + CL_FLT_MAX_EXP - 1; 382 | 383 | // Check for NaN / infinity 384 | if (h_exp == 0x1F) 385 | { 386 | if (h_mant) 387 | { 388 | // NaN -> propagate mantissa and silence it 389 | uint32_t f_mant = h_mant << (CL_FLT_MANT_DIG - CL_HALF_MANT_DIG); 390 | f_mant |= 0x400000; 391 | f32.i = (sign << 31) | 0x7F800000 | f_mant; 392 | return f32.f; 393 | } 394 | else 395 | { 396 | // Infinity -> zero mantissa 397 | f32.i = (sign << 31) | 0x7F800000; 398 | return f32.f; 399 | } 400 | } 401 | 402 | // Check for zero / denormal 403 | if (h_exp == 0) 404 | { 405 | if (h_mant == 0) 406 | { 407 | // Zero -> zero exponent 408 | f_exp = 0; 409 | } 410 | else 411 | { 412 | // Denormal -> normalize it 413 | // - Shift mantissa to make most-significant 1 implicit 414 | // - Adjust exponent accordingly 415 | uint32_t shift = 0; 416 | while ((h_mant & 0x400) == 0) 417 | { 418 | h_mant <<= 1; 419 | shift++; 420 | } 421 | h_mant &= 0x3FF; 422 | f_exp -= shift - 1; 423 | } 424 | } 425 | 426 | f32.i = (sign << 31) | (f_exp << 23) | (h_mant << 13); 427 | return f32.f; 428 | } 429 | 430 | 431 | #undef CL_HALF_EXP_MASK 432 | #undef CL_HALF_MAX_FINITE_MAG 433 | 434 | 435 | #ifdef __cplusplus 436 | } 437 | #endif 438 | 439 | 440 | #endif /* OPENCL_CL_HALF_H */ 441 | -------------------------------------------------------------------------------- /CL/cl_icd.h: -------------------------------------------------------------------------------- 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 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #if defined(_WIN32) 27 | #include 28 | #include 29 | #include 30 | #endif 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /* Vendor dispatch table structure */ 37 | 38 | typedef struct _cl_icd_dispatch { 39 | /* OpenCL 1.0 */ 40 | clGetPlatformIDs_t *clGetPlatformIDs; 41 | clGetPlatformInfo_t *clGetPlatformInfo; 42 | clGetDeviceIDs_t *clGetDeviceIDs; 43 | clGetDeviceInfo_t *clGetDeviceInfo; 44 | clCreateContext_t *clCreateContext; 45 | clCreateContextFromType_t *clCreateContextFromType; 46 | clRetainContext_t *clRetainContext; 47 | clReleaseContext_t *clReleaseContext; 48 | clGetContextInfo_t *clGetContextInfo; 49 | clCreateCommandQueue_t *clCreateCommandQueue; 50 | clRetainCommandQueue_t *clRetainCommandQueue; 51 | clReleaseCommandQueue_t *clReleaseCommandQueue; 52 | clGetCommandQueueInfo_t *clGetCommandQueueInfo; 53 | clSetCommandQueueProperty_t *clSetCommandQueueProperty; 54 | clCreateBuffer_t *clCreateBuffer; 55 | clCreateImage2D_t *clCreateImage2D; 56 | clCreateImage3D_t *clCreateImage3D; 57 | clRetainMemObject_t *clRetainMemObject; 58 | clReleaseMemObject_t *clReleaseMemObject; 59 | clGetSupportedImageFormats_t *clGetSupportedImageFormats; 60 | clGetMemObjectInfo_t *clGetMemObjectInfo; 61 | clGetImageInfo_t *clGetImageInfo; 62 | clCreateSampler_t *clCreateSampler; 63 | clRetainSampler_t *clRetainSampler; 64 | clReleaseSampler_t *clReleaseSampler; 65 | clGetSamplerInfo_t *clGetSamplerInfo; 66 | clCreateProgramWithSource_t *clCreateProgramWithSource; 67 | clCreateProgramWithBinary_t *clCreateProgramWithBinary; 68 | clRetainProgram_t *clRetainProgram; 69 | clReleaseProgram_t *clReleaseProgram; 70 | clBuildProgram_t *clBuildProgram; 71 | clUnloadCompiler_t *clUnloadCompiler; 72 | clGetProgramInfo_t *clGetProgramInfo; 73 | clGetProgramBuildInfo_t *clGetProgramBuildInfo; 74 | clCreateKernel_t *clCreateKernel; 75 | clCreateKernelsInProgram_t *clCreateKernelsInProgram; 76 | clRetainKernel_t *clRetainKernel; 77 | clReleaseKernel_t *clReleaseKernel; 78 | clSetKernelArg_t *clSetKernelArg; 79 | clGetKernelInfo_t *clGetKernelInfo; 80 | clGetKernelWorkGroupInfo_t *clGetKernelWorkGroupInfo; 81 | clWaitForEvents_t *clWaitForEvents; 82 | clGetEventInfo_t *clGetEventInfo; 83 | clRetainEvent_t *clRetainEvent; 84 | clReleaseEvent_t *clReleaseEvent; 85 | clGetEventProfilingInfo_t *clGetEventProfilingInfo; 86 | clFlush_t *clFlush; 87 | clFinish_t *clFinish; 88 | clEnqueueReadBuffer_t *clEnqueueReadBuffer; 89 | clEnqueueWriteBuffer_t *clEnqueueWriteBuffer; 90 | clEnqueueCopyBuffer_t *clEnqueueCopyBuffer; 91 | clEnqueueReadImage_t *clEnqueueReadImage; 92 | clEnqueueWriteImage_t *clEnqueueWriteImage; 93 | clEnqueueCopyImage_t *clEnqueueCopyImage; 94 | clEnqueueCopyImageToBuffer_t *clEnqueueCopyImageToBuffer; 95 | clEnqueueCopyBufferToImage_t *clEnqueueCopyBufferToImage; 96 | clEnqueueMapBuffer_t *clEnqueueMapBuffer; 97 | clEnqueueMapImage_t *clEnqueueMapImage; 98 | clEnqueueUnmapMemObject_t *clEnqueueUnmapMemObject; 99 | clEnqueueNDRangeKernel_t *clEnqueueNDRangeKernel; 100 | clEnqueueTask_t *clEnqueueTask; 101 | clEnqueueNativeKernel_t *clEnqueueNativeKernel; 102 | clEnqueueMarker_t *clEnqueueMarker; 103 | clEnqueueWaitForEvents_t *clEnqueueWaitForEvents; 104 | clEnqueueBarrier_t *clEnqueueBarrier; 105 | clGetExtensionFunctionAddress_t *clGetExtensionFunctionAddress; 106 | clCreateFromGLBuffer_t *clCreateFromGLBuffer; 107 | clCreateFromGLTexture2D_t *clCreateFromGLTexture2D; 108 | clCreateFromGLTexture3D_t *clCreateFromGLTexture3D; 109 | clCreateFromGLRenderbuffer_t *clCreateFromGLRenderbuffer; 110 | clGetGLObjectInfo_t *clGetGLObjectInfo; 111 | clGetGLTextureInfo_t *clGetGLTextureInfo; 112 | clEnqueueAcquireGLObjects_t *clEnqueueAcquireGLObjects; 113 | clEnqueueReleaseGLObjects_t *clEnqueueReleaseGLObjects; 114 | clGetGLContextInfoKHR_t *clGetGLContextInfoKHR; 115 | 116 | /* cl_khr_d3d10_sharing */ 117 | #ifdef _WIN32 118 | clGetDeviceIDsFromD3D10KHR_t *clGetDeviceIDsFromD3D10KHR; 119 | clCreateFromD3D10BufferKHR_t *clCreateFromD3D10BufferKHR; 120 | clCreateFromD3D10Texture2DKHR_t *clCreateFromD3D10Texture2DKHR; 121 | clCreateFromD3D10Texture3DKHR_t *clCreateFromD3D10Texture3DKHR; 122 | clEnqueueAcquireD3D10ObjectsKHR_t *clEnqueueAcquireD3D10ObjectsKHR; 123 | clEnqueueReleaseD3D10ObjectsKHR_t *clEnqueueReleaseD3D10ObjectsKHR; 124 | #else 125 | void *clGetDeviceIDsFromD3D10KHR; 126 | void *clCreateFromD3D10BufferKHR; 127 | void *clCreateFromD3D10Texture2DKHR; 128 | void *clCreateFromD3D10Texture3DKHR; 129 | void *clEnqueueAcquireD3D10ObjectsKHR; 130 | void *clEnqueueReleaseD3D10ObjectsKHR; 131 | #endif 132 | 133 | /* OpenCL 1.1 */ 134 | #ifdef CL_VERSION_1_1 135 | clSetEventCallback_t *clSetEventCallback; 136 | clCreateSubBuffer_t *clCreateSubBuffer; 137 | clSetMemObjectDestructorCallback_t *clSetMemObjectDestructorCallback; 138 | clCreateUserEvent_t *clCreateUserEvent; 139 | clSetUserEventStatus_t *clSetUserEventStatus; 140 | clEnqueueReadBufferRect_t *clEnqueueReadBufferRect; 141 | clEnqueueWriteBufferRect_t *clEnqueueWriteBufferRect; 142 | clEnqueueCopyBufferRect_t *clEnqueueCopyBufferRect; 143 | #else 144 | void *clSetEventCallback; 145 | void *clCreateSubBuffer; 146 | void *clSetMemObjectDestructorCallback; 147 | void *clCreateUserEvent; 148 | void *clSetUserEventStatus; 149 | void *clEnqueueReadBufferRect; 150 | void *clEnqueueWriteBufferRect; 151 | void *clEnqueueCopyBufferRect; 152 | #endif 153 | 154 | /* cl_ext_device_fission */ 155 | clCreateSubDevicesEXT_t *clCreateSubDevicesEXT; 156 | clRetainDeviceEXT_t *clRetainDeviceEXT; 157 | clReleaseDeviceEXT_t *clReleaseDeviceEXT; 158 | 159 | /* cl_khr_gl_event */ 160 | clCreateEventFromGLsyncKHR_t *clCreateEventFromGLsyncKHR; 161 | 162 | /* OpenCL 1.2 */ 163 | #ifdef CL_VERSION_1_2 164 | clCreateSubDevices_t *clCreateSubDevices; 165 | clRetainDevice_t *clRetainDevice; 166 | clReleaseDevice_t *clReleaseDevice; 167 | clCreateImage_t *clCreateImage; 168 | clCreateProgramWithBuiltInKernels_t *clCreateProgramWithBuiltInKernels; 169 | clCompileProgram_t *clCompileProgram; 170 | clLinkProgram_t *clLinkProgram; 171 | clUnloadPlatformCompiler_t *clUnloadPlatformCompiler; 172 | clGetKernelArgInfo_t *clGetKernelArgInfo; 173 | clEnqueueFillBuffer_t *clEnqueueFillBuffer; 174 | clEnqueueFillImage_t *clEnqueueFillImage; 175 | clEnqueueMigrateMemObjects_t *clEnqueueMigrateMemObjects; 176 | clEnqueueMarkerWithWaitList_t *clEnqueueMarkerWithWaitList; 177 | clEnqueueBarrierWithWaitList_t *clEnqueueBarrierWithWaitList; 178 | clGetExtensionFunctionAddressForPlatform_t * 179 | clGetExtensionFunctionAddressForPlatform; 180 | clCreateFromGLTexture_t *clCreateFromGLTexture; 181 | #else 182 | void *clCreateSubDevices; 183 | void *clRetainDevice; 184 | void *clReleaseDevice; 185 | void *clCreateImage; 186 | void *clCreateProgramWithBuiltInKernels; 187 | void *clCompileProgram; 188 | void *clLinkProgram; 189 | void *clUnloadPlatformCompiler; 190 | void *clGetKernelArgInfo; 191 | void *clEnqueueFillBuffer; 192 | void *clEnqueueFillImage; 193 | void *clEnqueueMigrateMemObjects; 194 | void *clEnqueueMarkerWithWaitList; 195 | void *clEnqueueBarrierWithWaitList; 196 | void *clGetExtensionFunctionAddressForPlatform; 197 | void *clCreateFromGLTexture; 198 | #endif 199 | 200 | /* cl_khr_d3d11_sharing and cl_khr_dx9_media_sharing */ 201 | #ifdef _WIN32 202 | clGetDeviceIDsFromD3D11KHR_t *clGetDeviceIDsFromD3D11KHR; 203 | clCreateFromD3D11BufferKHR_t *clCreateFromD3D11BufferKHR; 204 | clCreateFromD3D11Texture2DKHR_t *clCreateFromD3D11Texture2DKHR; 205 | clCreateFromD3D11Texture3DKHR_t *clCreateFromD3D11Texture3DKHR; 206 | clCreateFromDX9MediaSurfaceKHR_t *clCreateFromDX9MediaSurfaceKHR; 207 | clEnqueueAcquireD3D11ObjectsKHR_t *clEnqueueAcquireD3D11ObjectsKHR; 208 | clEnqueueReleaseD3D11ObjectsKHR_t *clEnqueueReleaseD3D11ObjectsKHR; 209 | clGetDeviceIDsFromDX9MediaAdapterKHR_t * 210 | clGetDeviceIDsFromDX9MediaAdapterKHR; 211 | clEnqueueAcquireDX9MediaSurfacesKHR_t * 212 | clEnqueueAcquireDX9MediaSurfacesKHR; 213 | clEnqueueReleaseDX9MediaSurfacesKHR_t * 214 | clEnqueueReleaseDX9MediaSurfacesKHR; 215 | #else 216 | void *clGetDeviceIDsFromD3D11KHR; 217 | void *clCreateFromD3D11BufferKHR; 218 | void *clCreateFromD3D11Texture2DKHR; 219 | void *clCreateFromD3D11Texture3DKHR; 220 | void *clCreateFromDX9MediaSurfaceKHR; 221 | void *clEnqueueAcquireD3D11ObjectsKHR; 222 | void *clEnqueueReleaseD3D11ObjectsKHR; 223 | void *clGetDeviceIDsFromDX9MediaAdapterKHR; 224 | void *clEnqueueAcquireDX9MediaSurfacesKHR; 225 | void *clEnqueueReleaseDX9MediaSurfacesKHR; 226 | #endif 227 | 228 | /* cl_khr_egl_image */ 229 | clCreateFromEGLImageKHR_t *clCreateFromEGLImageKHR; 230 | clEnqueueAcquireEGLObjectsKHR_t *clEnqueueAcquireEGLObjectsKHR; 231 | clEnqueueReleaseEGLObjectsKHR_t *clEnqueueReleaseEGLObjectsKHR; 232 | 233 | /* cl_khr_egl_event */ 234 | clCreateEventFromEGLSyncKHR_t *clCreateEventFromEGLSyncKHR; 235 | 236 | /* OpenCL 2.0 */ 237 | #ifdef CL_VERSION_2_0 238 | clCreateCommandQueueWithProperties_t *clCreateCommandQueueWithProperties; 239 | clCreatePipe_t *clCreatePipe; 240 | clGetPipeInfo_t *clGetPipeInfo; 241 | clSVMAlloc_t *clSVMAlloc; 242 | clSVMFree_t *clSVMFree; 243 | clEnqueueSVMFree_t *clEnqueueSVMFree; 244 | clEnqueueSVMMemcpy_t *clEnqueueSVMMemcpy; 245 | clEnqueueSVMMemFill_t *clEnqueueSVMMemFill; 246 | clEnqueueSVMMap_t *clEnqueueSVMMap; 247 | clEnqueueSVMUnmap_t *clEnqueueSVMUnmap; 248 | clCreateSamplerWithProperties_t *clCreateSamplerWithProperties; 249 | clSetKernelArgSVMPointer_t *clSetKernelArgSVMPointer; 250 | clSetKernelExecInfo_t *clSetKernelExecInfo; 251 | #else 252 | void *clCreateCommandQueueWithProperties; 253 | void *clCreatePipe; 254 | void *clGetPipeInfo; 255 | void *clSVMAlloc; 256 | void *clSVMFree; 257 | void *clEnqueueSVMFree; 258 | void *clEnqueueSVMMemcpy; 259 | void *clEnqueueSVMMemFill; 260 | void *clEnqueueSVMMap; 261 | void *clEnqueueSVMUnmap; 262 | void *clCreateSamplerWithProperties; 263 | void *clSetKernelArgSVMPointer; 264 | void *clSetKernelExecInfo; 265 | #endif 266 | 267 | /* cl_khr_sub_groups */ 268 | clGetKernelSubGroupInfoKHR_t *clGetKernelSubGroupInfoKHR; 269 | 270 | /* OpenCL 2.1 */ 271 | #ifdef CL_VERSION_2_1 272 | clCloneKernel_t *clCloneKernel; 273 | clCreateProgramWithIL_t *clCreateProgramWithIL; 274 | clEnqueueSVMMigrateMem_t *clEnqueueSVMMigrateMem; 275 | clGetDeviceAndHostTimer_t *clGetDeviceAndHostTimer; 276 | clGetHostTimer_t *clGetHostTimer; 277 | clGetKernelSubGroupInfo_t *clGetKernelSubGroupInfo; 278 | clSetDefaultDeviceCommandQueue_t *clSetDefaultDeviceCommandQueue; 279 | #else 280 | void *clCloneKernel; 281 | void *clCreateProgramWithIL; 282 | void *clEnqueueSVMMigrateMem; 283 | void *clGetDeviceAndHostTimer; 284 | void *clGetHostTimer; 285 | void *clGetKernelSubGroupInfo; 286 | void *clSetDefaultDeviceCommandQueue; 287 | #endif 288 | 289 | /* OpenCL 2.2 */ 290 | #ifdef CL_VERSION_2_2 291 | clSetProgramReleaseCallback_t *clSetProgramReleaseCallback; 292 | clSetProgramSpecializationConstant_t *clSetProgramSpecializationConstant; 293 | #else 294 | void *clSetProgramReleaseCallback; 295 | void *clSetProgramSpecializationConstant; 296 | #endif 297 | 298 | /* OpenCL 3.0 */ 299 | #ifdef CL_VERSION_3_0 300 | clCreateBufferWithProperties_t *clCreateBufferWithProperties; 301 | clCreateImageWithProperties_t *clCreateImageWithProperties; 302 | clSetContextDestructorCallback_t *clSetContextDestructorCallback; 303 | #else 304 | void *clCreateBufferWithProperties; 305 | void *clCreateImageWithProperties; 306 | void *clSetContextDestructorCallback; 307 | #endif 308 | 309 | } cl_icd_dispatch; 310 | 311 | #ifdef __cplusplus 312 | } 313 | #endif 314 | 315 | #endif /* #ifndef OPENCL_CL_ICD_H */ 316 | -------------------------------------------------------------------------------- /CL/cl_layer.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2023 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_LAYER_H_ 18 | #define OPENCL_CL_LAYER_H_ 19 | 20 | /* 21 | ** This header is generated from the Khronos OpenCL XML API Registry. 22 | */ 23 | 24 | #include 25 | 26 | #include 27 | 28 | /* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ 29 | #if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) 30 | #define CL_NO_EXTENSION_PROTOTYPES 31 | #endif 32 | 33 | /* CL_NO_EXTENSION_PROTOTYPES implies 34 | CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and 35 | CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ 36 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 37 | !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 38 | #define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES 39 | #endif 40 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 41 | !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 42 | #define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES 43 | #endif 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /*************************************************************** 50 | * cl_loader_layers 51 | ***************************************************************/ 52 | #define cl_loader_layers 1 53 | #define CL_LOADER_LAYERS_EXTENSION_NAME \ 54 | "cl_loader_layers" 55 | 56 | 57 | #define CL_LOADER_LAYERS_EXTENSION_VERSION CL_MAKE_VERSION(1, 0, 0) 58 | 59 | typedef cl_uint cl_layer_info; 60 | typedef cl_uint cl_layer_api_version; 61 | 62 | /* cl_layer_info */ 63 | #define CL_LAYER_API_VERSION 0x4240 64 | #define CL_LAYER_NAME 0x4241 65 | 66 | /* Misc API enums */ 67 | #define CL_LAYER_API_VERSION_100 100 68 | 69 | 70 | typedef cl_int CL_API_CALL 71 | clGetLayerInfo_t( 72 | cl_layer_info param_name, 73 | size_t param_value_size, 74 | void* param_value, 75 | size_t* param_value_size_ret); 76 | 77 | typedef clGetLayerInfo_t * 78 | clGetLayerInfo_fn ; 79 | 80 | typedef cl_int CL_API_CALL 81 | clInitLayer_t( 82 | cl_uint num_entries, 83 | const cl_icd_dispatch* target_dispatch, 84 | cl_uint* num_entries_ret, 85 | const cl_icd_dispatch** layer_dispatch_ret); 86 | 87 | typedef clInitLayer_t * 88 | clInitLayer_fn ; 89 | 90 | /* 91 | ** The function pointer typedefs prefixed with "pfn_" are provided for 92 | ** compatibility with earlier versions of the headers. New code is 93 | ** encouraged to use the function pointer typedefs that are suffixed with 94 | ** "_fn" instead, for consistency. 95 | */ 96 | 97 | typedef clGetLayerInfo_t * 98 | pfn_clGetLayerInfo ; 99 | 100 | typedef clInitLayer_t * 101 | pfn_clInitLayer ; 102 | 103 | #if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 104 | 105 | extern CL_API_ENTRY cl_int CL_API_CALL 106 | clGetLayerInfo( 107 | cl_layer_info param_name, 108 | size_t param_value_size, 109 | void* param_value, 110 | size_t* param_value_size_ret) ; 111 | 112 | extern CL_API_ENTRY cl_int CL_API_CALL 113 | clInitLayer( 114 | cl_uint num_entries, 115 | const cl_icd_dispatch* target_dispatch, 116 | cl_uint* num_entries_ret, 117 | const cl_icd_dispatch** layer_dispatch_ret) ; 118 | 119 | #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 120 | 121 | #ifdef __cplusplus 122 | } 123 | #endif 124 | 125 | #endif /* OPENCL_CL_LAYER_H_ */ 126 | -------------------------------------------------------------------------------- /CL/cl_va_api_media_sharing_intel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2023 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_VA_API_MEDIA_SHARING_INTEL_H_ 18 | #define OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H_ 19 | 20 | /* 21 | ** This header is generated from the Khronos OpenCL XML API Registry. 22 | */ 23 | 24 | #include 25 | 26 | #include 27 | 28 | /* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ 29 | #if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) 30 | #define CL_NO_EXTENSION_PROTOTYPES 31 | #endif 32 | 33 | /* CL_NO_EXTENSION_PROTOTYPES implies 34 | CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and 35 | CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ 36 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 37 | !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 38 | #define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES 39 | #endif 40 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && \ 41 | !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 42 | #define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES 43 | #endif 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /*************************************************************** 50 | * cl_intel_sharing_format_query_va_api 51 | ***************************************************************/ 52 | #define cl_intel_sharing_format_query_va_api 1 53 | #define CL_INTEL_SHARING_FORMAT_QUERY_VA_API_EXTENSION_NAME \ 54 | "cl_intel_sharing_format_query_va_api" 55 | 56 | 57 | #define CL_INTEL_SHARING_FORMAT_QUERY_VA_API_EXTENSION_VERSION CL_MAKE_VERSION(0, 0, 0) 58 | 59 | /* when cl_intel_va_api_media_sharing is supported */ 60 | 61 | typedef cl_int CL_API_CALL 62 | clGetSupportedVA_APIMediaSurfaceFormatsINTEL_t( 63 | cl_context context, 64 | cl_mem_flags flags, 65 | cl_mem_object_type image_type, 66 | cl_uint plane, 67 | cl_uint num_entries, 68 | VAImageFormat* va_api_formats, 69 | cl_uint* num_surface_formats); 70 | 71 | typedef clGetSupportedVA_APIMediaSurfaceFormatsINTEL_t * 72 | clGetSupportedVA_APIMediaSurfaceFormatsINTEL_fn ; 73 | 74 | #if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 75 | 76 | extern CL_API_ENTRY cl_int CL_API_CALL 77 | clGetSupportedVA_APIMediaSurfaceFormatsINTEL( 78 | cl_context context, 79 | cl_mem_flags flags, 80 | cl_mem_object_type image_type, 81 | cl_uint plane, 82 | cl_uint num_entries, 83 | VAImageFormat* va_api_formats, 84 | cl_uint* num_surface_formats) ; 85 | 86 | #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 87 | 88 | /*************************************************************** 89 | * cl_intel_va_api_media_sharing 90 | ***************************************************************/ 91 | #define cl_intel_va_api_media_sharing 1 92 | #define CL_INTEL_VA_API_MEDIA_SHARING_EXTENSION_NAME \ 93 | "cl_intel_va_api_media_sharing" 94 | 95 | 96 | #define CL_INTEL_VA_API_MEDIA_SHARING_EXTENSION_VERSION CL_MAKE_VERSION(0, 0, 0) 97 | 98 | typedef cl_uint cl_va_api_device_source_intel; 99 | typedef cl_uint cl_va_api_device_set_intel; 100 | 101 | /* Error codes */ 102 | #define CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL -1098 103 | #define CL_INVALID_VA_API_MEDIA_SURFACE_INTEL -1099 104 | #define CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL -1100 105 | #define CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL -1101 106 | 107 | /* cl_va_api_device_source_intel */ 108 | #define CL_VA_API_DISPLAY_INTEL 0x4094 109 | 110 | /* cl_va_api_device_set_intel */ 111 | #define CL_PREFERRED_DEVICES_FOR_VA_API_INTEL 0x4095 112 | #define CL_ALL_DEVICES_FOR_VA_API_INTEL 0x4096 113 | 114 | /* cl_context_info */ 115 | #define CL_CONTEXT_VA_API_DISPLAY_INTEL 0x4097 116 | 117 | /* cl_mem_info */ 118 | #define CL_MEM_VA_API_MEDIA_SURFACE_INTEL 0x4098 119 | 120 | /* cl_image_info */ 121 | #define CL_IMAGE_VA_API_PLANE_INTEL 0x4099 122 | 123 | /* cl_command_type */ 124 | #define CL_COMMAND_ACQUIRE_VA_API_MEDIA_SURFACES_INTEL 0x409A 125 | #define CL_COMMAND_RELEASE_VA_API_MEDIA_SURFACES_INTEL 0x409B 126 | 127 | 128 | typedef cl_int CL_API_CALL 129 | clGetDeviceIDsFromVA_APIMediaAdapterINTEL_t( 130 | cl_platform_id platform, 131 | cl_va_api_device_source_intel media_adapter_type, 132 | void* media_adapter, 133 | cl_va_api_device_set_intel media_adapter_set, 134 | cl_uint num_entries, 135 | cl_device_id* devices, 136 | cl_uint* num_devices); 137 | 138 | typedef clGetDeviceIDsFromVA_APIMediaAdapterINTEL_t * 139 | clGetDeviceIDsFromVA_APIMediaAdapterINTEL_fn CL_API_SUFFIX__VERSION_1_2; 140 | 141 | typedef cl_mem CL_API_CALL 142 | clCreateFromVA_APIMediaSurfaceINTEL_t( 143 | cl_context context, 144 | cl_mem_flags flags, 145 | VASurfaceID* surface, 146 | cl_uint plane, 147 | cl_int* errcode_ret); 148 | 149 | typedef clCreateFromVA_APIMediaSurfaceINTEL_t * 150 | clCreateFromVA_APIMediaSurfaceINTEL_fn CL_API_SUFFIX__VERSION_1_2; 151 | 152 | typedef cl_int CL_API_CALL 153 | clEnqueueAcquireVA_APIMediaSurfacesINTEL_t( 154 | cl_command_queue command_queue, 155 | cl_uint num_objects, 156 | const cl_mem* mem_objects, 157 | cl_uint num_events_in_wait_list, 158 | const cl_event* event_wait_list, 159 | cl_event* event); 160 | 161 | typedef clEnqueueAcquireVA_APIMediaSurfacesINTEL_t * 162 | clEnqueueAcquireVA_APIMediaSurfacesINTEL_fn CL_API_SUFFIX__VERSION_1_2; 163 | 164 | typedef cl_int CL_API_CALL 165 | clEnqueueReleaseVA_APIMediaSurfacesINTEL_t( 166 | cl_command_queue command_queue, 167 | cl_uint num_objects, 168 | const cl_mem* mem_objects, 169 | cl_uint num_events_in_wait_list, 170 | const cl_event* event_wait_list, 171 | cl_event* event); 172 | 173 | typedef clEnqueueReleaseVA_APIMediaSurfacesINTEL_t * 174 | clEnqueueReleaseVA_APIMediaSurfacesINTEL_fn CL_API_SUFFIX__VERSION_1_2; 175 | 176 | #if !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 177 | 178 | extern CL_API_ENTRY cl_int CL_API_CALL 179 | clGetDeviceIDsFromVA_APIMediaAdapterINTEL( 180 | cl_platform_id platform, 181 | cl_va_api_device_source_intel media_adapter_type, 182 | void* media_adapter, 183 | cl_va_api_device_set_intel media_adapter_set, 184 | cl_uint num_entries, 185 | cl_device_id* devices, 186 | cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_2; 187 | 188 | extern CL_API_ENTRY cl_mem CL_API_CALL 189 | clCreateFromVA_APIMediaSurfaceINTEL( 190 | cl_context context, 191 | cl_mem_flags flags, 192 | VASurfaceID* surface, 193 | cl_uint plane, 194 | cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_2; 195 | 196 | extern CL_API_ENTRY cl_int CL_API_CALL 197 | clEnqueueAcquireVA_APIMediaSurfacesINTEL( 198 | cl_command_queue command_queue, 199 | cl_uint num_objects, 200 | const cl_mem* mem_objects, 201 | cl_uint num_events_in_wait_list, 202 | const cl_event* event_wait_list, 203 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 204 | 205 | extern CL_API_ENTRY cl_int CL_API_CALL 206 | clEnqueueReleaseVA_APIMediaSurfacesINTEL( 207 | cl_command_queue command_queue, 208 | cl_uint num_objects, 209 | const cl_mem* mem_objects, 210 | cl_uint num_events_in_wait_list, 211 | const cl_event* event_wait_list, 212 | cl_event* event) CL_API_SUFFIX__VERSION_1_2; 213 | 214 | #endif /* !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) */ 215 | 216 | #ifdef __cplusplus 217 | } 218 | #endif 219 | 220 | #endif /* OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H_ */ 221 | -------------------------------------------------------------------------------- /CL/cl_version.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2018-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 __CL_VERSION_H 18 | #define __CL_VERSION_H 19 | 20 | /* Detect which version to target */ 21 | #if !defined(CL_TARGET_OPENCL_VERSION) 22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)") 23 | #define CL_TARGET_OPENCL_VERSION 300 24 | #endif 25 | #if CL_TARGET_OPENCL_VERSION != 100 && \ 26 | CL_TARGET_OPENCL_VERSION != 110 && \ 27 | CL_TARGET_OPENCL_VERSION != 120 && \ 28 | CL_TARGET_OPENCL_VERSION != 200 && \ 29 | CL_TARGET_OPENCL_VERSION != 210 && \ 30 | CL_TARGET_OPENCL_VERSION != 220 && \ 31 | CL_TARGET_OPENCL_VERSION != 300 32 | #pragma message("cl_version: CL_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220, 300). Defaulting to 300 (OpenCL 3.0)") 33 | #undef CL_TARGET_OPENCL_VERSION 34 | #define CL_TARGET_OPENCL_VERSION 300 35 | #endif 36 | 37 | 38 | /* OpenCL Version */ 39 | #if CL_TARGET_OPENCL_VERSION >= 300 && !defined(CL_VERSION_3_0) 40 | #define CL_VERSION_3_0 1 41 | #endif 42 | #if CL_TARGET_OPENCL_VERSION >= 220 && !defined(CL_VERSION_2_2) 43 | #define CL_VERSION_2_2 1 44 | #endif 45 | #if CL_TARGET_OPENCL_VERSION >= 210 && !defined(CL_VERSION_2_1) 46 | #define CL_VERSION_2_1 1 47 | #endif 48 | #if CL_TARGET_OPENCL_VERSION >= 200 && !defined(CL_VERSION_2_0) 49 | #define CL_VERSION_2_0 1 50 | #endif 51 | #if CL_TARGET_OPENCL_VERSION >= 120 && !defined(CL_VERSION_1_2) 52 | #define CL_VERSION_1_2 1 53 | #endif 54 | #if CL_TARGET_OPENCL_VERSION >= 110 && !defined(CL_VERSION_1_1) 55 | #define CL_VERSION_1_1 1 56 | #endif 57 | #if CL_TARGET_OPENCL_VERSION >= 100 && !defined(CL_VERSION_1_0) 58 | #define CL_VERSION_1_0 1 59 | #endif 60 | 61 | /* Allow deprecated APIs for older OpenCL versions. */ 62 | #if CL_TARGET_OPENCL_VERSION <= 220 && !defined(CL_USE_DEPRECATED_OPENCL_2_2_APIS) 63 | #define CL_USE_DEPRECATED_OPENCL_2_2_APIS 64 | #endif 65 | #if CL_TARGET_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS) 66 | #define CL_USE_DEPRECATED_OPENCL_2_1_APIS 67 | #endif 68 | #if CL_TARGET_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) 69 | #define CL_USE_DEPRECATED_OPENCL_2_0_APIS 70 | #endif 71 | #if CL_TARGET_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) 72 | #define CL_USE_DEPRECATED_OPENCL_1_2_APIS 73 | #endif 74 | #if CL_TARGET_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) 75 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS 76 | #endif 77 | #if CL_TARGET_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) 78 | #define CL_USE_DEPRECATED_OPENCL_1_0_APIS 79 | #endif 80 | 81 | #endif /* __CL_VERSION_H */ 82 | -------------------------------------------------------------------------------- /CL/opencl.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2008-2021 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_H 18 | #define __OPENCL_H 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __OPENCL_H */ 33 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16...3.26) 2 | 3 | # Include guard for including this project multiple times 4 | if(TARGET Headers) 5 | return() 6 | endif() 7 | 8 | project(OpenCLHeaders 9 | VERSION 3.0 10 | LANGUAGES C # Ideally should be NONE, but GNUInstallDirs detects platform arch using try_compile 11 | # https://stackoverflow.com/questions/43379311/why-does-project-affect-cmakes-opinion-on-cmake-sizeof-void-p 12 | ) 13 | 14 | option(OPENCL_HEADERS_BUILD_TESTING "Enable support for OpenCL C headers testing." OFF) 15 | option(OPENCL_HEADERS_BUILD_CXX_TESTS "Enable support for OpenCL C headers testing in C++ mode." ON) 16 | 17 | set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 18 | include(GNUInstallDirs) 19 | include(JoinPaths) 20 | include(Package) 21 | 22 | add_library(Headers INTERFACE) 23 | add_library(OpenCL::Headers ALIAS Headers) 24 | 25 | if(CMAKE_SYSTEM_NAME MATCHES Darwin) 26 | execute_process( 27 | COMMAND ln -snf ${CMAKE_CURRENT_SOURCE_DIR}/CL ${CMAKE_CURRENT_BINARY_DIR}/CL 28 | COMMAND ln -snf ${CMAKE_CURRENT_SOURCE_DIR}/CL ${CMAKE_CURRENT_BINARY_DIR}/OpenCL 29 | ) 30 | target_include_directories(Headers 31 | INTERFACE 32 | $ 33 | $ 34 | ) 35 | install(CODE " 36 | file(MAKE_DIRECTORY ${CMAKE_INSTALL_FULL_INCLUDEDIR}/CL) 37 | execute_process( 38 | COMMAND ln -snf CL ${CMAKE_INSTALL_FULL_INCLUDEDIR}/OpenCL 39 | )" 40 | ) 41 | else() 42 | target_include_directories(Headers 43 | INTERFACE 44 | $ 45 | $ 46 | ) 47 | endif() 48 | 49 | install( 50 | TARGETS Headers 51 | EXPORT OpenCLHeadersTargets 52 | ) 53 | install( 54 | DIRECTORY CL 55 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 56 | ) 57 | 58 | export( 59 | EXPORT OpenCLHeadersTargets 60 | FILE ${PROJECT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersTargets.cmake 61 | NAMESPACE OpenCL:: 62 | ) 63 | file( 64 | WRITE ${PROJECT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersConfig.cmake 65 | "include(\"\${CMAKE_CURRENT_LIST_DIR}/OpenCLHeadersTargets.cmake\")" 66 | ) 67 | 68 | set(config_package_location ${CMAKE_INSTALL_DATADIR}/cmake/OpenCLHeaders) 69 | install( 70 | EXPORT OpenCLHeadersTargets 71 | FILE OpenCLHeadersTargets.cmake 72 | NAMESPACE OpenCL:: 73 | DESTINATION ${config_package_location} 74 | ) 75 | install( 76 | FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersConfig.cmake 77 | DESTINATION ${config_package_location} 78 | ) 79 | 80 | unset(CMAKE_SIZEOF_VOID_P) 81 | include(CMakePackageConfigHelpers) 82 | write_basic_package_version_file( 83 | ${CMAKE_CURRENT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersConfigVersion.cmake 84 | VERSION ${PROJECT_VERSION} 85 | COMPATIBILITY AnyNewerVersion 86 | ) 87 | install( 88 | FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenCLHeaders/OpenCLHeadersConfigVersion.cmake 89 | DESTINATION ${config_package_location} 90 | ) 91 | 92 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING) 93 | include(CTest) 94 | endif() 95 | if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_HEADERS_BUILD_TESTING) AND BUILD_TESTING) 96 | add_subdirectory(tests) 97 | endif() 98 | 99 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) 100 | find_package(Python3 COMPONENTS Interpreter) 101 | set(OPENCL_HEADERS_XML_PATH CACHE FILEPATH "Path to cl.xml for OpenCL Header genereration") 102 | set(OPENCL_HEADERS_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated) 103 | add_custom_target(headers_generate 104 | COMMAND ${CMAKE_COMMAND} -E make_directory ${OPENCL_HEADERS_OUTPUT_DIRECTORY} 105 | COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR}/scripts 106 | ${Python3_EXECUTABLE} gen_headers.py 107 | -registry ${OPENCL_HEADERS_XML_PATH} 108 | -o ${OPENCL_HEADERS_OUTPUT_DIRECTORY} 109 | ) 110 | add_custom_target(headers_copy 111 | COMMAND ${CMAKE_COMMAND} -E copy 112 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_d3d10.h 113 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 114 | COMMAND ${CMAKE_COMMAND} -E copy 115 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_d3d11.h 116 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 117 | COMMAND ${CMAKE_COMMAND} -E copy 118 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_dx9_media_sharing.h 119 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 120 | COMMAND ${CMAKE_COMMAND} -E copy 121 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_egl.h 122 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 123 | COMMAND ${CMAKE_COMMAND} -E copy 124 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_ext.h 125 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 126 | COMMAND ${CMAKE_COMMAND} -E copy 127 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_gl.h 128 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 129 | COMMAND ${CMAKE_COMMAND} -E copy 130 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_layer.h 131 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 132 | COMMAND ${CMAKE_COMMAND} -E copy 133 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_va_api_media_sharing_intel.h 134 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 135 | COMMAND ${CMAKE_COMMAND} -E copy 136 | ${OPENCL_HEADERS_OUTPUT_DIRECTORY}/cl_function_types.h 137 | ${CMAKE_CURRENT_SOURCE_DIR}/CL 138 | ) 139 | set_target_properties(headers_generate PROPERTIES FOLDER "Generation") 140 | set_target_properties(headers_copy PROPERTIES FOLDER "Generation") 141 | endif() 142 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | A reminder that this issue tracker is managed by the Khronos Group. Interactions here should follow the Khronos Code of Conduct (https://www.khronos.org/developers/code-of-conduct), which prohibits aggressive or derogatory language. Please keep the discussion friendly and civil. 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /OpenCL-Headers.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PKGCONFIG_PREFIX@ 2 | includedir=@OPENCL_INCLUDEDIR_PC@ 3 | 4 | Name: OpenCL-Headers 5 | Description: Khronos OpenCL Headers 6 | Version: 3.0 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenCLTM API Headers 2 | 3 | This repository contains C language headers for the OpenCL API. 4 | 5 | The authoritative public repository for these headers is located at: 6 | 7 | https://github.com/KhronosGroup/OpenCL-Headers 8 | 9 | Issues, proposed fixes for issues, and other suggested changes should be 10 | created using Github. 11 | 12 | ## Build instructions 13 | 14 | > While the OpenCL Headers can be built and installed in isolation, it is part of the [OpenCL SDK](https://github.com/KhronosGroup/OpenCL-SDK). If looking for streamlined build experience and a complete development package, refer to the SDK build instructions instead of the following guide. 15 | 16 | ### Dependencies 17 | 18 | - The OpenCL Headers CMake package support uses CMake for its build system. 19 | If CMake is not provided by your build system or OS package manager, please consult the [CMake website](https://cmake.org). 20 | 21 | ### Example Build 22 | While the headers may just be copied as-is, this repository also contains a 23 | CMake script with an install rule to allow for packaging the headers. 24 | 25 | ```bash 26 | cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/chosen/install/prefix 27 | cmake --build build --target install 28 | ``` 29 | 30 | ### Example Use 31 | 32 | Example CMake invocation 33 | 34 | ```bash 35 | cmake -D CMAKE_PREFIX_PATH=/chosen/install/prefix /path/to/opencl/app 36 | ``` 37 | 38 | and sample `CMakeLists.txt` 39 | 40 | ```cmake 41 | cmake_minimum_required(VERSION 3.0) 42 | cmake_policy(VERSION 3.0...3.18.4) 43 | project(proj) 44 | add_executable(app main.cpp) 45 | find_package(OpenCLHeaders REQUIRED) 46 | target_link_libraries(app PRIVATE OpenCL::Headers) 47 | ``` 48 | 49 | ## Branch Structure 50 | 51 | The OpenCL API headers in this repository are Unified headers and are designed 52 | to work with all released OpenCL versions. This differs from previous OpenCL 53 | API headers, where version-specific API headers either existed in separate 54 | branches, or in separate folders in a branch. 55 | 56 | ## Compiling for a Specific OpenCL Version 57 | 58 | By default, the OpenCL API headers in this repository are for the latest 59 | OpenCL version (currently OpenCL 3.0). To use these API headers to target 60 | a different OpenCL version, an application may `#define` the preprocessor 61 | value `CL_TARGET_OPENCL_VERSION` before including the OpenCL API headers. 62 | The `CL_TARGET_OPENCL_VERSION` is a three digit decimal value representing 63 | the OpenCL API version. 64 | 65 | For example, to enforce usage of no more than the OpenCL 1.2 APIs, you may 66 | include the OpenCL API headers as follows: 67 | 68 | ```c 69 | #define CL_TARGET_OPENCL_VERSION 120 70 | #include 71 | ``` 72 | 73 | ## Controlling Function Prototypes 74 | 75 | By default, the OpenCL API headers in this repository declare function 76 | prototypes for every known core OpenCL API and OpenCL extension API. If this is 77 | not desired, the declared function prototypes can be controlled by the following 78 | preprocessor defines: 79 | 80 | * `CL_NO_PROTOTYPES`: No function prototypes will be declared. This control 81 | applies to core OpenCL APIs and OpenCL extension APIs. 82 | * `CL_NO_CORE_PROTOTYPES`: No function prototypes will be declared for core 83 | OpenCL APIs. 84 | * `CL_NO_EXTENSION_PROTOTYPES`: No function prototypes will be declared for 85 | OpenCL extension APIs. This control applies to all OpenCL extension APIs. 86 | * `CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES`: No function prototypes will be 87 | declared for OpenCL extension APIs that are in the ICD dispatch table for 88 | historical reasons. 89 | * `CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES`: No function prototypes will be 90 | declared for OpenCL extension APIs that are not in the ICD dispatch table. 91 | 92 | For example, to declare function prototypes for core OpenCL 3.0 APIs only, you 93 | may include the OpenCL API headers as follows: 94 | 95 | ```c 96 | #define CL_TARGET_OPENCL_VERSION 300 97 | #define CL_NO_EXTENSION_PROTOTYPES 98 | #include 99 | ``` 100 | 101 | ## Compatibility Notes 102 | 103 | OpenCL values backward compatibility and in most cases an application using an 104 | older version of the OpenCL API headers can seamlessly update to a newer version 105 | of the OpenCL API headers. In rare cases, though, the OpenCL API headers may 106 | break backward compatibility: 107 | 108 | * Very rarely, there may be bugs or other issues in the OpenCL API headers that 109 | cannot be fixed without breaking compatibility. 110 | * The OpenCL API headers for beta features or beta extensions may 111 | be changed in a way that breaks compatibility. 112 | 113 | Applications or libraries that require stable OpenCL API headers are encouraged 114 | to use tagged or released OpenCL API headers. We will do our best to document 115 | any breaking changes in the description of each release. The OpenCL API headers 116 | are tagged at least as often as each OpenCL specification release. 117 | 118 | ## Beta Extensions 119 | 120 | Beta extensions are extensions that are still in development and are 121 | hence subject to change. To further improve compatibility for applications that 122 | do not use beta features, support for beta extensions must be 123 | explicitly enabled. Support for beta extensions is controlled by the 124 | `CL_ENABLE_BETA_EXTENSIONS` preprocessor define. 125 | 126 | For example, to enable support for OpenCL 3.0 APIs and all extensions, including 127 | beta extensions, you may include the OpenCL API headers as follows: 128 | 129 | ```c 130 | #define CL_TARGET_OPENCL_VERSION 300 131 | #define CL_ENABLE_BETA_EXTENSIONS 132 | #include 133 | ``` 134 | 135 | ## Directory Structure 136 | 137 | ``` 138 | README.md This file 139 | LICENSE Source license for the OpenCL API headers 140 | CL/ Unified OpenCL API headers tree 141 | scripts/ Scripts for generating OpenCL extension headers 142 | tests/ OpenCL API header tests 143 | ``` 144 | 145 | ## Packaging 146 | 147 | For packaging instructions, see [RELEASE.md](https://github.com/KhronosGroup/OpenCL-SDK/blob/main/docs/RELEASE.md) 148 | in the OpenCL SDK repository. 149 | 150 | ## License 151 | 152 | See [LICENSE](LICENSE). 153 | 154 | --- 155 | 156 | OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos. 157 | -------------------------------------------------------------------------------- /build.py: -------------------------------------------------------------------------------- 1 | from cpt.packager import ConanMultiPackager 2 | import datetime 3 | 4 | if __name__ == "__main__": 5 | builder = ConanMultiPackager( 6 | username="khronos", 7 | login_username="khronos", 8 | channel="stable" 9 | ) 10 | builder.add_common_builds() 11 | builder.run() 12 | -------------------------------------------------------------------------------- /cmake/DebSourcePkg.cmake: -------------------------------------------------------------------------------- 1 | # This script produces the changelog, control and rules file in the debian 2 | # directory. These files are needed to build a Debian source package from the repository. 3 | # Run this in CMake script mode, e.g. 4 | # $ cd OpenCL-Headers 5 | # $ cmake -S . -B ../build -D BUILD_TESTING=OFF 6 | # $ cmake 7 | # -DCMAKE_CACHE_PATH=../build/CMakeCache.txt 8 | # -DCPACK_DEBIAN_PACKAGE_MAINTAINER="Example Name " 9 | # -DDEBIAN_DISTROSERIES=jammy 10 | # -DORIG_ARCHIVE=../OpenCL-Headers.tar.gz 11 | # -DLATEST_RELEASE_VERSION=v2023.08.29 12 | # -P cmake/DebSourcePkg.cmake 13 | # $ debuild -S -sa 14 | 15 | cmake_minimum_required(VERSION 3.21) # file(COPY_FILE) is added in CMake 3.21 16 | 17 | set(DEB_SOURCE_PKG_NAME "khronos-opencl-headers") 18 | set(DEB_CLHPP_PKG_NAME "opencl-clhpp-headers") 19 | set(DEB_META_PKG_NAME "opencl-headers") 20 | set(DEB_META_PKG_DESCRIPTION "OpenCL (Open Computing Language) header files 21 | OpenCL (Open Computing Language) is a multi-vendor open standard for 22 | general-purpose parallel programming of heterogeneous systems that include 23 | CPUs, GPUs and other processors. 24 | . 25 | This metapackage depends on packages providing the C and C++ headers files 26 | for the OpenCL API as published by The Khronos Group Inc. The corresponding 27 | specification and documentation can be found on the Khronos website.") 28 | 29 | if(NOT EXISTS "${CMAKE_CACHE_PATH}") 30 | message(FATAL_ERROR "CMAKE_CACHE_PATH is not set or does not exist") 31 | endif() 32 | if(NOT DEFINED DEBIAN_PACKAGE_MAINTAINER) 33 | message(FATAL_ERROR "DEBIAN_PACKAGE_MAINTAINER is not set") 34 | endif() 35 | if(NOT DEFINED DEBIAN_DISTROSERIES) 36 | message(FATAL_ERROR "DEBIAN_DISTROSERIES is not set") 37 | endif() 38 | if(NOT DEFINED ORIG_ARCHIVE) 39 | message(WARNING "ORIG_ARCHIVE is not set") 40 | elseif(NOT EXISTS "${ORIG_ARCHIVE}") 41 | message(FATAL_ERROR "ORIG_ARCHIVE is defined, but the file does not exist at \"${ORIG_ARCHIVE}\"") 42 | endif() 43 | if(NOT DEFINED LATEST_RELEASE_VERSION) 44 | message(WARNING "LATEST_RELEASE_VERSION is not set") 45 | endif() 46 | if(NOT DEFINED DEBIAN_VERSION_SUFFIX) 47 | message(WARNING "DEBIAN_VERSION_SUFFIX is not set") 48 | endif() 49 | 50 | # Extracting the project version from the main CMakeLists.txt via regex 51 | file(READ "${CMAKE_CACHE_PATH}" CMAKE_CACHE) 52 | string(REGEX MATCH "CMAKE_PROJECT_VERSION[^=]*=([^\n]*)" REGEX_MATCH "${CMAKE_CACHE}") 53 | if(NOT REGEX_MATCH) 54 | message(FATAL_ERROR "Could not extract project version from CMakeLists.txt") 55 | endif() 56 | set(PROJECT_VERSION "${CMAKE_MATCH_1}") 57 | 58 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") 59 | # Package.cmake contains all details for packaging 60 | include(PackageSetup) 61 | 62 | # Append a space after every newline in the description. This format is required 63 | # in the control file. 64 | string(REPLACE "\n" "\n " CPACK_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}") 65 | 66 | set(DEB_SOURCE_PKG_DIR "${CMAKE_CURRENT_LIST_DIR}/../debian") 67 | # Write debian/control 68 | file(WRITE "${DEB_SOURCE_PKG_DIR}/control" 69 | "Source: ${DEB_SOURCE_PKG_NAME} 70 | Section: ${CPACK_DEBIAN_PACKAGE_SECTION} 71 | Priority: optional 72 | Maintainer: ${DEBIAN_PACKAGE_MAINTAINER} 73 | Build-Depends: cmake, debhelper-compat (=13) 74 | Rules-Requires-Root: no 75 | Homepage: ${CPACK_DEBIAN_PACKAGE_HOMEPAGE} 76 | Standards-Version: 4.6.2 77 | 78 | Package: ${DEBIAN_PACKAGE_NAME} 79 | Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE} 80 | Multi-Arch: foreign 81 | Breaks: ${CPACK_DEBIAN_PACKAGE_BREAKS} 82 | Replaces: ${CPACK_DEBIAN_PACKAGE_REPLACES} 83 | Description: ${CPACK_PACKAGE_DESCRIPTION} 84 | 85 | Package: ${DEB_META_PKG_NAME} 86 | Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE} 87 | Multi-Arch: foreign 88 | Depends: ${DEBIAN_PACKAGE_NAME} (= ${PACKAGE_VERSION_REVISION}), ${DEB_CLHPP_PKG_NAME} (= ${PACKAGE_VERSION_REVISION}) 89 | Description: ${DEB_META_PKG_DESCRIPTION} 90 | " 91 | ) 92 | # Write debian/changelog 93 | string(TIMESTAMP CURRENT_TIMESTAMP "%a, %d %b %Y %H:%M:%S +0000" UTC) 94 | file(WRITE "${DEB_SOURCE_PKG_DIR}/changelog" 95 | "${DEB_SOURCE_PKG_NAME} (${PACKAGE_VERSION_REVISION}) ${DEBIAN_DISTROSERIES}; urgency=medium 96 | 97 | * Released version ${PACKAGE_VERSION_REVISION} 98 | 99 | -- ${DEBIAN_PACKAGE_MAINTAINER} ${CURRENT_TIMESTAMP} 100 | ") 101 | # Write debian/rules 102 | file(WRITE "${DEB_SOURCE_PKG_DIR}/rules" 103 | "#!/usr/bin/make -f 104 | %: 105 | \tdh $@ 106 | 107 | override_dh_auto_configure: 108 | \tdh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF 109 | 110 | override_dh_auto_install: 111 | \tdh_auto_install --destdir=debian/${DEBIAN_PACKAGE_NAME}/ 112 | ") 113 | 114 | if(DEFINED ORIG_ARCHIVE) 115 | # Copy the passed orig.tar.gz file. The target filename is deduced from the version number, as expected by debuild 116 | cmake_path(IS_ABSOLUTE ORIG_ARCHIVE IS_ORIG_ARCHIVE_ABSOLUTE) 117 | if (NOT IS_ORIG_ARCHIVE_ABSOLUTE) 118 | message(FATAL_ERROR "ORIG_ARCHIVE must be an absolute path (passed: \"${ORIG_ARCHIVE}\")") 119 | endif() 120 | cmake_path(GET ORIG_ARCHIVE EXTENSION ORIG_ARCHIVE_EXT) 121 | cmake_path(GET ORIG_ARCHIVE PARENT_PATH ORIG_ARCHIVE_PARENT) 122 | set(TARGET_PATH "${ORIG_ARCHIVE_PARENT}/${DEB_SOURCE_PKG_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}${ORIG_ARCHIVE_EXT}") 123 | message(STATUS "Copying \"${ORIG_ARCHIVE}\" to \"${TARGET_PATH}\"") 124 | file(COPY_FILE "${ORIG_ARCHIVE}" "${TARGET_PATH}") 125 | endif() 126 | -------------------------------------------------------------------------------- /cmake/JoinPaths.cmake: -------------------------------------------------------------------------------- 1 | # This module provides function for joining paths 2 | # known from from most languages 3 | # 4 | # Original license: 5 | # SPDX-License-Identifier: (MIT OR CC0-1.0) 6 | # Explicit permission given to distribute this module under 7 | # the terms of the project as described in /LICENSE.rst. 8 | # Copyright 2020 Jan Tojnar 9 | # https://github.com/jtojnar/cmake-snips 10 | # 11 | # Modelled after Python’s os.path.join 12 | # https://docs.python.org/3.7/library/os.path.html#os.path.join 13 | # Windows not supported 14 | function(join_paths joined_path first_path_segment) 15 | set(temp_path "${first_path_segment}") 16 | foreach(current_segment IN LISTS ARGN) 17 | if(NOT ("${current_segment}" STREQUAL "")) 18 | if(IS_ABSOLUTE "${current_segment}") 19 | set(temp_path "${current_segment}") 20 | else() 21 | set(temp_path "${temp_path}/${current_segment}") 22 | endif() 23 | endif() 24 | endforeach() 25 | set(${joined_path} "${temp_path}" PARENT_SCOPE) 26 | endfunction() 27 | -------------------------------------------------------------------------------- /cmake/Package.cmake: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/PackageSetup.cmake") 2 | 3 | # Configuring pkgconfig 4 | 5 | # We need two different instances of OpenCL-Headers.pc 6 | # One for installing (cmake --install), which contains CMAKE_INSTALL_PREFIX as prefix 7 | # And another for the Debian package, which contains CPACK_PACKAGING_INSTALL_PREFIX as prefix 8 | 9 | join_paths(OPENCL_INCLUDEDIR_PC "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") 10 | 11 | set(pkg_config_location ${CMAKE_INSTALL_DATADIR}/pkgconfig) 12 | set(PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") 13 | configure_file( 14 | OpenCL-Headers.pc.in 15 | ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_install/OpenCL-Headers.pc 16 | @ONLY) 17 | install( 18 | FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_install/OpenCL-Headers.pc 19 | DESTINATION ${pkg_config_location} 20 | COMPONENT pkgconfig_install) 21 | 22 | set(PKGCONFIG_PREFIX "${CPACK_PACKAGING_INSTALL_PREFIX}") 23 | configure_file( 24 | OpenCL-Headers.pc.in 25 | ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_package/OpenCL-Headers.pc 26 | @ONLY) 27 | # This install component is only needed in the Debian package 28 | install( 29 | FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_package/OpenCL-Headers.pc 30 | DESTINATION ${pkg_config_location} 31 | COMPONENT pkgconfig_package 32 | EXCLUDE_FROM_ALL) 33 | 34 | # By using component based packaging, component pkgconfig_install 35 | # can be excluded from the package, and component pkgconfig_package 36 | # can be included. 37 | set(CPACK_DEB_COMPONENT_INSTALL ON) 38 | set(CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE") 39 | 40 | include(CPackComponent) 41 | cpack_add_component(pkgconfig_install) 42 | cpack_add_component(pkgconfig_package) 43 | set(CPACK_COMPONENTS_ALL "Unspecified;pkgconfig_package") 44 | 45 | set(CPACK_DEBIAN_PACKAGE_DEBUG ON) 46 | 47 | include(CPack) 48 | -------------------------------------------------------------------------------- /cmake/PackageSetup.cmake: -------------------------------------------------------------------------------- 1 | set(CPACK_PACKAGE_VENDOR "khronos") 2 | 3 | set(CPACK_PACKAGE_DESCRIPTION "OpenCL (Open Computing Language) C header files 4 | OpenCL (Open Computing Language) is a multi-vendor open standard for 5 | general-purpose parallel programming of heterogeneous systems that include 6 | CPUs, GPUs and other processors. 7 | . 8 | This package provides the C development header files for the OpenCL API 9 | as published by The Khronos Group Inc. The corresponding specification and 10 | documentation can be found on the Khronos website.") 11 | 12 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") 13 | 14 | set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") 15 | 16 | if(NOT CPACK_PACKAGING_INSTALL_PREFIX) 17 | set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 18 | endif() 19 | 20 | # DEB packaging configuration 21 | if(NOT DEFINED CPACK_DEBIAN_PACKAGE_MAINTAINER) 22 | set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_VENDOR}) 23 | endif() 24 | 25 | set(CPACK_DEBIAN_PACKAGE_HOMEPAGE 26 | "https://github.com/KhronosGroup/OpenCL-Headers") 27 | 28 | # Version number [epoch:]upstream_version[-debian_revision] 29 | set(CPACK_DEBIAN_PACKAGE_VERSION "${PROJECT_VERSION}") # upstream_version 30 | if(DEFINED LATEST_RELEASE_VERSION) 31 | # Remove leading "v", if exists 32 | string(LENGTH "${LATEST_RELEASE_VERSION}" LATEST_RELEASE_VERSION_LENGTH) 33 | string(SUBSTRING "${LATEST_RELEASE_VERSION}" 0 1 LATEST_RELEASE_VERSION_FRONT) 34 | if(LATEST_RELEASE_VERSION_FRONT STREQUAL "v") 35 | string(SUBSTRING "${LATEST_RELEASE_VERSION}" 1 ${LATEST_RELEASE_VERSION_LENGTH} LATEST_RELEASE_VERSION) 36 | endif() 37 | 38 | string(APPEND CPACK_DEBIAN_PACKAGE_VERSION "~${LATEST_RELEASE_VERSION}") 39 | endif() 40 | set(CPACK_DEBIAN_PACKAGE_RELEASE "1") # debian_revision (because this is a 41 | # non-native pkg) 42 | set(PACKAGE_VERSION_REVISION "${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}${DEBIAN_VERSION_SUFFIX}") 43 | 44 | set(DEBIAN_PACKAGE_NAME "opencl-c-headers") 45 | set(CPACK_DEBIAN_PACKAGE_NAME 46 | "${DEBIAN_PACKAGE_NAME}" 47 | CACHE STRING "Package name" FORCE) 48 | 49 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all") 50 | set(CPACK_DEBIAN_PACKAGE_SECTION "libdevel") 51 | set(CPACK_DEBIAN_PACKAGE_BREAKS "opencl-headers (<< ${CPACK_DEBIAN_PACKAGE_VERSION}), opencl-clhpp-headers (<< ${CPACK_DEBIAN_PACKAGE_VERSION})") 52 | set(CPACK_DEBIAN_PACKAGE_REPLACES "opencl-headers (<< ${CPACK_DEBIAN_PACKAGE_VERSION})") 53 | 54 | # Package file name in deb format: 55 | # _-_.deb 56 | set(CPACK_DEBIAN_FILE_NAME "${DEBIAN_PACKAGE_NAME}_${PACKAGE_VERSION_REVISION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") 57 | -------------------------------------------------------------------------------- /conanfile.py: -------------------------------------------------------------------------------- 1 | from conans import ConanFile, tools, CMake 2 | import os 3 | 4 | 5 | class OpenCLHeadersConan(ConanFile): 6 | name = "opencl-headers" 7 | version = "20190502" 8 | license = "Apache-2.0" 9 | author = "Khronos Group " 10 | url = "https://github.com/KhronosGroup/OpenCL-ICD-Loader" 11 | description = "Khronos OpenCL Headers" 12 | topics = ("khronos", "opencl", "headers") 13 | exports_sources = "CMakeLists.txt", "CL/*" 14 | no_copy_source = True 15 | 16 | def build(self): 17 | cmake = CMake(self) 18 | cmake.configure() 19 | cmake.build() 20 | cmake.install() 21 | 22 | def package_id(self): 23 | self.info.header_only() -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | gen/__pycache__/* 2 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | # OpenCL Header Code Generation 2 | 3 | ## Introduction 4 | 5 | In order to ease maintenance and enable faster development in the OpenCL headers, the OpenCL headers for extensions are generated from the OpenCL XML machine readable grammar. 6 | Currently, header generation is only enabled for the OpenCL headers for extensions, and the OpenCL headers for core APIs are still authored manually. 7 | 8 | ## Dependencies 9 | 10 | The OpenCL headers are generated using Python [Mako Templates](https://www.makotemplates.org/). 11 | 12 | In most cases, after installing Python for your platform, Mako may be installed using: 13 | 14 | ```sh 15 | $ pip install Mako 16 | ``` 17 | 18 | ## Making Changes 19 | 20 | Most changes only require modifications to the Mako templates. 21 | Small changes modifying syntax or layout are simple and straightforward. 22 | Occasionally, more complicated changes will be required, say when a new API is added that is unlike any previous API or when a new extension header file is needed, but this should be rare. 23 | 24 | The Python script should only need to be modified if additional information needs to be propagated from the XML file into the Mako template itself. 25 | 26 | ## Generating Headers 27 | 28 | The script to generate headers requires the `cl.xml` machine readable grammar. 29 | The latest version of `cl.xml` may be found in the Khronos OpenCL-Docs repo [here](https://github.com/KhronosGroup/OpenCL-Docs/blob/main/xml/cl.xml). 30 | 31 | The easiest way to generate new headers is by using the `headers_generate` target. 32 | For example, from a directory used to build the headers, simply execute: 33 | 34 | ```sh 35 | $ cmake --build . --target headers_generate 36 | ``` 37 | 38 | The `cl.xml` file used to generate headers with the header generation target may be provided by setting the CMake variable `OPENCL_HEADERS_XML_PATH` to the full path to `cl.xml`. 39 | -------------------------------------------------------------------------------- /scripts/check-format.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SOURCE_COMMIT="$1" 4 | if [ "$#" -gt 0 ]; then 5 | shift 6 | fi 7 | 8 | # If no source commit is given target the default branch 9 | if [ "x$SOURCE_COMMIT" = "x" ]; then 10 | # If remote is not set use the remote of the current branch or fallback to "origin" 11 | if [ "x$REMOTE" = "x" ]; then 12 | BRANCH="$(git rev-parse --abbrev-ref HEAD)" 13 | REMOTE="$(git config --local --get "branch.$BRANCH.remote" || echo 'origin')" 14 | fi 15 | SOURCE_COMMIT="remotes/$REMOTE/HEAD" 16 | fi 17 | 18 | # Force colored diff output 19 | DIFF_COLOR_SAVED="$(git config --local --get color.diff)" 20 | if [ "x$DIFF_COLOR_SAVED" != "x" ]; then 21 | git config --local --replace-all "color.diff" "always" 22 | else 23 | git config --local --add "color.diff" "always" 24 | fi 25 | 26 | scratch="$(mktemp -t check-format.XXXXXXXXXX)" 27 | finish () { 28 | # Remove temporary file 29 | rm -rf "$scratch" 30 | # Restore setting 31 | if [ "x$DIFF_COLOR_SAVED" != "x" ]; then 32 | git config --local --replace-all "color.diff" "$DIFF_COLOR_SAVED" 33 | else 34 | git config --local --unset "color.diff" 35 | fi 36 | } 37 | # The trap will be invoked whenever the script exits, even due to a signal, this is a bash only 38 | # feature 39 | trap finish EXIT 40 | 41 | GIT_CLANG_FORMAT="${GIT_CLANG_FORMAT:-git-clang-format}" 42 | "$GIT_CLANG_FORMAT" --style=file --extensions=cc,cp,cpp,c++,cxx,cu,cuh,hh,hpp,hxx,hip,vert,frag --diff "$@" "$SOURCE_COMMIT" > "$scratch" 43 | 44 | # Check for no-ops 45 | grep '^no modified files to format$\|^clang-format did not modify any files$' \ 46 | "$scratch" > /dev/null && exit 0 47 | 48 | # Dump formatting diff and signal failure 49 | printf \ 50 | "\033[31m==== FORMATTING VIOLATIONS DETECTED ====\033[0m 51 | run '\033[33m%s --style=file %s %s\033[0m' to apply these formating changes\n\n" \ 52 | "$GIT_CLANG_FORMAT" "$*" "$SOURCE_COMMIT" 53 | 54 | cat "$scratch" 55 | exit 1 56 | -------------------------------------------------------------------------------- /scripts/cl_ext.h.mako: -------------------------------------------------------------------------------- 1 | <% 2 | # re.match used to parse extension semantic versions 3 | from re import match 4 | 5 | # Extensions to skip by default because they are in dedicated headers: 6 | skipExtensions = { 7 | 'cl_khr_d3d10_sharing', 8 | 'cl_khr_d3d11_sharing', 9 | 'cl_khr_dx9_media_sharing', 10 | 'cl_khr_egl_event', 11 | 'cl_khr_egl_image', 12 | 'cl_khr_gl_depth_images', 13 | 'cl_khr_gl_event', 14 | 'cl_khr_gl_msaa_sharing', 15 | 'cl_khr_gl_sharing', 16 | 'cl_loader_layers', 17 | 'cl_intel_dx9_media_sharing', 18 | 'cl_intel_va_api_media_sharing', 19 | 'cl_intel_sharing_format_query_d3d10', 20 | 'cl_intel_sharing_format_query_d3d11', 21 | 'cl_intel_sharing_format_query_dx9', 22 | 'cl_intel_sharing_format_query_gl', 23 | 'cl_intel_sharing_format_query_va_api', 24 | } 25 | 26 | # Extensions to include in this header: 27 | def shouldGenerate(extension): 28 | if extension in genExtensions: 29 | return True 30 | elif not genExtensions and not extension in skipExtensions: 31 | return True 32 | return False 33 | 34 | # XML blocks to include in the headers: 35 | def shouldEmit(block): 36 | for type in block.findall('type'): 37 | if type.get('name') in typedefs: 38 | return True 39 | elif type.get('name') in macros: 40 | return True 41 | elif type.get('name') in structs: 42 | return True 43 | for enum in block.findall('enum'): 44 | #if enum.get('name') in enums: 45 | return True 46 | for func in block.findall('command'): 47 | return True 48 | return False 49 | 50 | # Initially, keep the same extension order as the original headers: 51 | orderedExtensions = [ 52 | # cl_ext.h: 53 | 'cl_khr_command_buffer', 54 | 'cl_khr_command_buffer_multi_device', 55 | 'cl_khr_command_buffer_mutable_dispatch', 56 | 'cl_khr_fp64', 57 | 'cl_khr_fp16', 58 | 'cl_APPLE_SetMemObjectDestructor', 59 | 'cl_APPLE_ContextLoggingFunctions', 60 | 'cl_khr_icd', 61 | 'cl_khr_il_program', 62 | 'cl_khr_image2D_from_buffer', # incorrect name 63 | 'cl_khr_image2d_from_buffer', 64 | 'cl_khr_initialize_memory', 65 | 'cl_khr_terminate_context', 66 | 'cl_khr_spir', 67 | 'cl_khr_create_command_queue', 68 | 'cl_nv_device_attribute_query', 69 | 'cl_amd_device_attribute_query', 70 | 'cl_arm_printf', 71 | 'cl_ext_device_fission', 72 | 'cl_ext_migrate_memobject', 73 | 'cl_ext_cxx_for_opencl', 74 | 'cl_qcom_ext_host_ptr', 75 | 'cl_qcom_ext_host_ptr_iocoherent', 76 | 'cl_qcom_ion_host_ptr', 77 | 'cl_qcom_android_native_buffer_host_ptr', 78 | 'cl_img_yuv_image', 79 | 'cl_img_cached_allocations', 80 | 'cl_img_use_gralloc_ptr', 81 | 'cl_img_generate_mipmap', 82 | 'cl_img_mem_properties', 83 | 'cl_khr_subgroups', 84 | 'cl_khr_mipmap_image', 85 | 'cl_khr_priority_hints', 86 | 'cl_khr_throttle_hints', 87 | 'cl_khr_subgroup_named_barrier', 88 | 'cl_khr_extended_versioning', 89 | 'cl_khr_device_uuid', 90 | 'cl_khr_pci_bus_info', 91 | 'cl_khr_suggested_local_work_size', 92 | 'cl_khr_integer_dot_product', 93 | 'cl_khr_external_memory', 94 | 'cl_khr_external_memory_dma_buf', 95 | 'cl_khr_external_memory_dx', 96 | 'cl_khr_external_memory_opaque_fd', 97 | 'cl_khr_external_memory_win32', 98 | 'cl_khr_external_semaphore', 99 | 'cl_khr_external_semaphore_dx_fence', 100 | 'cl_khr_external_semaphore_opaque_fd', 101 | 'cl_khr_external_semaphore_sync_fd', 102 | 'cl_khr_external_semaphore_win32', 103 | 'cl_khr_semaphore', 104 | 'cl_arm_import_memory', 105 | 'cl_arm_shared_virtual_memory', 106 | 'cl_arm_get_core_id', 107 | 'cl_arm_job_slot_selection', 108 | 'cl_arm_scheduling_controls', 109 | 'cl_arm_controlled_kernel_termination', 110 | 'cl_arm_protected_memory_allocation', 111 | 'cl_intel_exec_by_local_thread', 112 | 'cl_intel_device_attribute_query', 113 | 'cl_intel_device_partition_by_names', 114 | 'cl_intel_accelerator', 115 | 'cl_intel_motion_estimation', 116 | 'cl_intel_advanced_motion_estimation', 117 | 'cl_intel_simultaneous_sharing', 118 | 'cl_intel_egl_image_yuv', 119 | 'cl_intel_packed_yuv', 120 | 'cl_intel_required_subgroup_size', 121 | 'cl_intel_driver_diagnostics', 122 | 'cl_intel_planar_yuv', 123 | 'cl_intel_device_side_avc_motion_estimation', 124 | 'cl_intel_unified_shared_memory', 125 | 'cl_intel_mem_alloc_buffer_location', 126 | 'cl_intel_create_buffer_with_properties', 127 | 'cl_intel_program_scope_host_pipe', 128 | 'cl_intel_mem_channel_property', 129 | 'cl_intel_mem_force_host_memory', 130 | 'cl_intel_command_queue_families', 131 | 'cl_intel_queue_no_sync_operations', 132 | 'cl_intel_sharing_format_query', 133 | 'cl_ext_image_requirements_info', 134 | 'cl_ext_image_from_buffer', 135 | 'cl_loader_info', 136 | 'cl_khr_depth_images', 137 | 'cl_ext_float_atomics', 138 | 'cl_intel_create_mem_object_properties', 139 | 'cl_pocl_content_size', 140 | 'cl_ext_image_raw10_raw12', 141 | # cl_d3d10.h 142 | 'cl_khr_d3d10_sharing', 143 | 'cl_intel_sharing_format_query_d3d10', 144 | # cl_d3d11.h 145 | 'cl_khr_d3d11_sharing', 146 | 'cl_intel_sharing_format_query_d3d11', 147 | # cl_dx9_media_sharing.h 148 | 'cl_khr_dx9_media_sharing', 149 | 'cl_intel_dx9_media_sharing', 150 | 'cl_intel_sharing_format_query_dx9', 151 | # cl_egl.h 152 | 'cl_khr_egl_image', 153 | 'cl_khr_egl_event', 154 | # cl_gl.h 155 | 'cl_khr_gl_sharing', 156 | 'cl_khr_gl_event', 157 | 'cl_khr_gl_depth_images', 158 | 'cl_khr_gl_msaa_sharing', 159 | 'cl_intel_sharing_format_query_gl', 160 | # cl_layer.h 161 | 'cl_loader_layers', 162 | # cl_va_api_media_sharing_intel.h 163 | 'cl_intel_sharing_format_query_va_api', 164 | 'cl_intel_va_api_media_sharing', 165 | ] 166 | 167 | def getExtensionSortKey(item): 168 | name = item.get('name') 169 | try: 170 | index = orderedExtensions.index(name) 171 | except ValueError: 172 | if name.startswith('cl_khr'): 173 | index = 10000 174 | elif name.startswith('cl_ext'): 175 | index = 10001 176 | else: 177 | index = 10002 178 | return index, name 179 | 180 | # Order the extensions should be emitted in the headers. 181 | # KHR -> EXT -> Vendor Extensions 182 | def getExtensionSortKey_ideal(item): 183 | name = item.get('name') 184 | if name.startswith('cl_khr'): 185 | return 0, name 186 | if name.startswith('cl_ext'): 187 | return 1, name 188 | return 99, name 189 | 190 | # Order enums should be emitted in the headers. 191 | # Enums Without Bits -> Ordered Bit Enums 192 | def getEnumSortKey(item): 193 | name = item.get('name') 194 | if name in enums: 195 | if enums[name].Value: 196 | return -1 197 | if enums[name].Bitpos: 198 | return int(enums[name].Bitpos) 199 | return 99 200 | 201 | # Gets C function parameter strings for the specified API params: 202 | def getCParameterStrings(params): 203 | strings = [] 204 | if len(params) == 0: 205 | strings.append("void") 206 | else: 207 | for param in params: 208 | paramstr = param.Type + ' ' + param.Name + param.TypeEnd 209 | strings.append(paramstr) 210 | return strings 211 | 212 | # Gets a bit string for the specified bit position: 213 | def getBitPosString(bitpos): 214 | ret = '(' 215 | ret += '(cl_bitfield)' if int(bitpos) >= 31 else '' 216 | ret += '1 << ' 217 | ret += bitpos 218 | ret += ')' 219 | return ret 220 | 221 | # Extensions that are included in the ICD dispatch table for historical reasons. 222 | # This should not be required for new extensions! 223 | loaderExtensions = { 224 | 'cl_ext_device_fission', 225 | 'cl_khr_d3d10_sharing', 226 | 'cl_khr_d3d11_sharing', 227 | 'cl_khr_dx9_media_sharing', 228 | 'cl_khr_egl_event', 229 | 'cl_khr_egl_image', 230 | 'cl_khr_gl_event', 231 | 'cl_khr_gl_sharing', 232 | 'cl_khr_subgroups' 233 | } 234 | 235 | # Gets the preprocessor guard for the given extension: 236 | def getPrototypeIfGuard(name): 237 | if name in loaderExtensions: 238 | guard = '!defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES)' 239 | else: 240 | guard = '!defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES)' 241 | return guard 242 | 243 | # Names that have been generated already, since some may be shared by multiple 244 | # extensions: 245 | generatedNames = set() 246 | 247 | def isDuplicateName(name): 248 | if name in generatedNames: 249 | return True 250 | generatedNames.add(name) 251 | return False 252 | 253 | %>/******************************************************************************* 254 | * Copyright (c) 2008-2023 The Khronos Group Inc. 255 | * 256 | * Licensed under the Apache License, Version 2.0 (the "License"); 257 | * you may not use this file except in compliance with the License. 258 | * You may obtain a copy of the License at 259 | * 260 | * http://www.apache.org/licenses/LICENSE-2.0 261 | * 262 | * Unless required by applicable law or agreed to in writing, software 263 | * distributed under the License is distributed on an "AS IS" BASIS, 264 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 265 | * See the License for the specific language governing permissions and 266 | * limitations under the License. 267 | ******************************************************************************/ 268 | 269 | #ifndef ${guard} 270 | #define ${guard} 271 | 272 | /* 273 | ** This header is generated from the Khronos OpenCL XML API Registry. 274 | */ 275 | 276 | %if includes: 277 | ${includes} 278 | 279 | %endif 280 | #include 281 | 282 | /* CL_NO_PROTOTYPES implies CL_NO_EXTENSION_PROTOTYPES: */ 283 | #if defined(CL_NO_PROTOTYPES) && !defined(CL_NO_EXTENSION_PROTOTYPES) 284 | #define CL_NO_EXTENSION_PROTOTYPES 285 | #endif 286 | 287 | /* CL_NO_EXTENSION_PROTOTYPES implies 288 | CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES and 289 | CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES: */ 290 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && ${"\\"} 291 | !defined(CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES) 292 | #define CL_NO_ICD_DISPATCH_EXTENSION_PROTOTYPES 293 | #endif 294 | #if defined(CL_NO_EXTENSION_PROTOTYPES) && ${"\\"} 295 | !defined(CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES) 296 | #define CL_NO_NON_ICD_DISPATCH_EXTENSION_PROTOTYPES 297 | #endif 298 | 299 | #ifdef __cplusplus 300 | extern "C" { 301 | #endif 302 | 303 | %for extension in sorted(spec.findall('extensions/extension'), key=getExtensionSortKey): 304 | % if shouldGenerate(extension.get('name')): 305 | <% 306 | name = extension.get('name') 307 | 308 | # Use re.match to parse semantic major.minor.patch version 309 | sem_ver = match('[0-9]+\.[0-9]+\.?[0-9]+', extension.get('revision')) 310 | if not sem_ver: 311 | raise TypeError(name + 312 | ' XML revision field is not semantically versioned as "major.minor.patch"') 313 | version = sem_ver[0].split('.') 314 | version_major = version[0] 315 | version_minor = version[1] 316 | version_patch = version[2] 317 | 318 | is_beta = extension.get('provisional') == 'true' 319 | beta_label = ' (beta)' if is_beta else '' 320 | %>/*************************************************************** 321 | * ${name}${beta_label} 322 | ***************************************************************/ 323 | %if is_beta: 324 | #if defined(CL_ENABLE_BETA_EXTENSIONS) 325 | 326 | %endif 327 | %if extension.get('condition'): 328 | #if ${extension.get('condition')} 329 | 330 | %endif 331 | #define ${name} 1 332 | #define ${name.upper()}_EXTENSION_NAME ${"\\"} 333 | "${name}" 334 | 335 | 336 | #define ${name.upper()}_EXTENSION_VERSION CL_MAKE_VERSION(${version_major}, ${version_minor}, ${version_patch}) 337 | 338 | %for block in extension.findall('require'): 339 | % if shouldEmit(block): 340 | % if block.get('condition'): 341 | #if ${block.get('condition')} 342 | % endif 343 | % if block.get('comment'): 344 | /* ${block.get('comment')} */ 345 | % endif 346 | % for type in block.findall('type'): 347 | % if isDuplicateName(type.get('name')): 348 | /* type ${type.get('name')} */ 349 | % else: 350 | % if type.get('name') in typedefs: 351 | ${typedefs[type.get('name')].Typedef.ljust(27)} ${type.get('name')}; 352 | % elif type.get('name') in macros: 353 | % if macros[type.get('name')].Macro == '': 354 | ${macros[type.get('name')].Define} 355 | % else: 356 | #define ${type.get('name')}${macros[type.get('name')].Macro} 357 | % endif 358 | % elif type.get('name') in structs: 359 | <% 360 | struct = structs[type.get('name')] 361 | %>typedef struct _${struct.Name} { 362 | % for i, member in enumerate(struct.Members): 363 | ${member.Type} ${member.Name}${member.TypeEnd}; 364 | % endfor 365 | } ${struct.Name}; 366 | % else: 367 | // type ${type.get('name')} not found! 368 | % endif 369 | % endif 370 | % endfor 371 | % for enum in sorted(block.findall('enum'), key=getEnumSortKey): 372 | % if isDuplicateName(enum.get('name')): 373 | /* enum ${enum.get('name')} */ 374 | % else: 375 | % if enum.get('name') in enums: 376 | % if enums[enum.get('name')].Value: 377 | #define ${enum.get('name').ljust(51)} ${enums[enum.get('name')].Value} 378 | % elif enums[enum.get('name')].Bitpos: 379 | #define ${enum.get('name').ljust(51)} ${getBitPosString(enums[enum.get('name')].Bitpos)} 380 | % else: 381 | // enum ${enum.get('name')} is unassigned! 382 | % endif 383 | % else: 384 | // enum ${enum.get('name')} not found! 385 | % endif 386 | % endif 387 | % endfor 388 | % if block.findall('command'): 389 | % for func in block.findall('command'): 390 | <% 391 | api = apisigs[func.get('name')] 392 | %> 393 | typedef ${api.RetType} CL_API_CALL 394 | ${api.Name}_t( 395 | % for i, paramStr in enumerate(getCParameterStrings(api.Params)): 396 | % if i < len(api.Params)-1: 397 | ${paramStr}, 398 | % else: 399 | ${paramStr}); 400 | % endif 401 | % endfor 402 | 403 | typedef ${api.Name}_t * 404 | ${api.Name}_fn ${api.Suffix}; 405 | % endfor 406 | % if generate_pfn_typedefs: 407 | 408 | /* 409 | ** The function pointer typedefs prefixed with "pfn_" are provided for 410 | ** compatibility with earlier versions of the headers. New code is 411 | ** encouraged to use the function pointer typedefs that are suffixed with 412 | ** "_fn" instead, for consistency. 413 | */ 414 | % for func in block.findall('command'): 415 | <% 416 | api = apisigs[func.get('name')] 417 | %> 418 | typedef ${api.Name}_t * 419 | pfn_${api.Name} ${api.Suffix}; 420 | % endfor 421 | % endif 422 | 423 | #if ${getPrototypeIfGuard(name)} 424 | % for func in block.findall('command'): 425 | <% 426 | api = apisigs[func.get('name')] 427 | %> 428 | extern CL_API_ENTRY ${api.RetType} CL_API_CALL 429 | ${api.Name}( 430 | % for i, paramStr in enumerate(getCParameterStrings(api.Params)): 431 | % if i < len(api.Params)-1: 432 | ${paramStr}, 433 | % else: 434 | ${paramStr}) ${api.Suffix}; 435 | % endif 436 | % endfor 437 | % endfor 438 | 439 | #endif /* ${getPrototypeIfGuard(name)} */ 440 | % endif 441 | % if block.get('condition'): 442 | 443 | #endif /* ${block.get('condition')} */ 444 | % endif 445 | 446 | % endif 447 | %endfor 448 | %if extension.get('condition'): 449 | #endif /* ${extension.get('condition')} */ 450 | 451 | %endif 452 | %if is_beta: 453 | #endif /* defined(CL_ENABLE_BETA_EXTENSIONS) */ 454 | 455 | %endif 456 | % endif 457 | %endfor 458 | #ifdef __cplusplus 459 | } 460 | #endif 461 | 462 | #endif /* ${guard} */ 463 | -------------------------------------------------------------------------------- /scripts/cl_function_types.h.mako: -------------------------------------------------------------------------------- 1 | <% 2 | # Gets C function parameter strings for the specified API params: 3 | import sys 4 | import json 5 | def getCParameterStrings(params): 6 | strings = [] 7 | if len(params) == 0: 8 | strings.append("void") 9 | else: 10 | for param in params: 11 | paramstr = param.Type + ' ' + param.Name + param.TypeEnd 12 | strings.append(paramstr) 13 | return strings 14 | 15 | %>/* 16 | * Copyright (c) 2023 The Khronos Group Inc. 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the "License"); 19 | * you may not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * http://www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an "AS IS" BASIS, 26 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | * 30 | * OpenCL is a trademark of Apple Inc. used under license by Khronos. 31 | */ 32 | 33 | #ifndef OPENCL_CL_FUNCTION_TYPES_H_ 34 | #define OPENCL_CL_FUNCTION_TYPES_H_ 35 | 36 | #include 37 | 38 | %for version, apis in coreapis.items(): 39 | % if version != "CL_VERSION_1_0": 40 | #ifdef ${version} 41 | 42 | % endif 43 | % for api in apis: 44 | typedef ${api.RetType} CL_API_CALL ${api.Name}_t( 45 | % for i, paramStr in enumerate(getCParameterStrings(api.Params)): 46 | % if i < len(api.Params)-1: 47 | ${paramStr}, 48 | % else: 49 | ${paramStr}); 50 | % endif 51 | % endfor 52 | 53 | typedef ${api.Name}_t * 54 | ${api.Name}_fn ${api.Suffix}; 55 | 56 | % endfor 57 | % if version != "CL_VERSION_1_0": 58 | #endif /* ${version} */ 59 | 60 | % endif 61 | %endfor 62 | #endif /* OPENCL_CL_FUNCTION_TYPES_H_ */ 63 | -------------------------------------------------------------------------------- /scripts/gen/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 The Khronos Group Inc. 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 | from collections import OrderedDict 16 | from collections import namedtuple 17 | 18 | import argparse 19 | import sys 20 | import urllib 21 | import xml.etree.ElementTree as etree 22 | import urllib.request 23 | 24 | # parse_xml - Helper function to parse the XML file from a URL or local file. 25 | def parse_xml(path): 26 | file = urllib.request.urlopen(path) if path.startswith("http") else open(path, 'r') 27 | with file: 28 | tree = etree.parse(file) 29 | return tree 30 | 31 | # noneStr - returns string argument, or "" if argument is None. 32 | def noneStr(s): 33 | if s: 34 | return s 35 | return "" 36 | 37 | def parse_args(): 38 | parser = argparse.ArgumentParser() 39 | 40 | # To pull the latest registry file from GitHub, pass: 41 | # -registry "https://raw.githubusercontent.com/KhronosGroup/OpenCL-Registry/master/xml/cl.xml" 42 | 43 | parser.add_argument('-registry', action='store', 44 | default='cl.xml', 45 | help='Use specified registry file instead of cl.xml') 46 | parser.add_argument('-o', action='store', dest='directory', 47 | default='.', 48 | help='Create target and related files in specified directory') 49 | 50 | args = parser.parse_args() 51 | return args 52 | 53 | def load_spec(args): 54 | specpath = args.registry 55 | 56 | print('Parsing XML file from: ' + specpath) 57 | spec = parse_xml(specpath) 58 | return spec 59 | 60 | def get_apitypedefs(spec): 61 | typedefs = OrderedDict() 62 | Typedef = namedtuple('Typedef', 'Typedef Name') 63 | print('Generating API typedef dictionary...') 64 | for type in spec.findall('types/type'): 65 | if type.get('category') == 'define': 66 | if noneStr(type.text).startswith("typedef"): 67 | typedef = noneStr(type.text) 68 | name = "" 69 | for elem in type: 70 | if elem.tag == 'name': 71 | name = noneStr(elem.text) 72 | else: 73 | typedef = typedef + noneStr(elem.text) + noneStr(elem.tail) 74 | typedef = typedef.strip() 75 | name = name.strip() 76 | typedefs[name] = Typedef(typedef, name) 77 | return typedefs 78 | 79 | def get_apimacros(spec): 80 | macros = OrderedDict() 81 | Macro = namedtuple('Macro', 'Define Name Macro') 82 | print('Generating API macro dictionary...') 83 | for type in spec.findall('types/type'): 84 | if type.get('category') == 'define': 85 | if noneStr(type.text).startswith("#define"): 86 | define = noneStr(type.text) 87 | name = "" 88 | macro = "" 89 | for elem in type: 90 | if elem.tag == 'name': 91 | name = noneStr(elem.text) 92 | macro = macro + noneStr(elem.tail) 93 | define = define.strip() 94 | name = name.strip() 95 | macro = macro.rstrip() # keep spaces on the left! 96 | macros[name] = Macro(define, name, macro) 97 | elif noneStr(type.text).strip().startswith("#if"): 98 | define = noneStr(type.text).strip() 99 | name = type.get('name') 100 | name = name.strip() 101 | macros[name] = Macro(define, name, '') 102 | return macros 103 | 104 | def get_apistructs(spec): 105 | structs = OrderedDict() 106 | Struct = namedtuple('Struct', 'Name Members') 107 | StructMember = namedtuple('StructMember', 'Type TypeEnd Name') 108 | print('Generating API struct dictionary...') 109 | for type in spec.findall('types/type'): 110 | if type.get('category') == 'struct': 111 | name = type.get('name') 112 | mlist = [] 113 | for member in type.findall('member'): 114 | mtype = noneStr(member.text) 115 | mtypeend = "" 116 | mname = "" 117 | for elem in member: 118 | if elem.tag == 'name': 119 | mname = noneStr(elem.text) 120 | mtypeend = noneStr(elem.tail) 121 | elif elem.tag == 'enum': 122 | # Assumes any additional enums are for array limits, e.g.: 123 | # charname[CL_NAME_VERSION_MAX_NAME_SIZE] 124 | mtypeend = mtypeend + noneStr(elem.text) + noneStr(elem.tail) 125 | else: 126 | mtype = mtype + noneStr(elem.text) + noneStr(elem.tail) 127 | mtype = mtype.strip() 128 | mtypeend = mtypeend.strip() 129 | mname = mname.strip() 130 | mlist.append(StructMember(mtype, mtypeend, mname)) 131 | structs[name] = Struct(name, mlist) 132 | return structs 133 | 134 | def get_apienums(spec): 135 | enums = OrderedDict() 136 | Enum = namedtuple('Enum', 'Value Bitpos Name') 137 | print('Generating API enum dictionary...') 138 | for enum in spec.findall('enums/enum'): 139 | value = enum.get('value') 140 | bitpos = enum.get('bitpos') 141 | name = enum.get('name') 142 | enums[name] = Enum(value, bitpos, name) 143 | return enums 144 | 145 | def get_apisigs(spec): 146 | apisigs = OrderedDict() 147 | ApiSignature = namedtuple('ApiSignature', 'Name RetType Params Suffix') 148 | ApiParam = namedtuple('ApiParam', 'Type TypeEnd Name') 149 | print('Generating API signatures dictionary...') 150 | for command in spec.findall('commands/command'): 151 | suffix = noneStr(command.get('suffix')) 152 | proto = command.find('proto') 153 | ret = noneStr(proto.text) 154 | name = "" 155 | params = "" 156 | for elem in proto: 157 | if elem.tag == 'name': 158 | name = noneStr(elem.text) + noneStr(elem.tail) 159 | else: 160 | ret = ret + noneStr(elem.text) + noneStr(elem.tail) 161 | ret = ret.strip() 162 | name = name.strip() 163 | 164 | plist = [] 165 | for param in command.findall('param'): 166 | ptype = noneStr(param.text) 167 | ptypeend = "" 168 | pname = "" 169 | for elem in param: 170 | if elem.tag == 'name': 171 | pname = noneStr(elem.text) 172 | ptypeend = noneStr(elem.tail) 173 | else: 174 | ptype = ptype + noneStr(elem.text) + noneStr(elem.tail) 175 | ptype = ptype.strip() 176 | ptypeend = ptypeend.strip() 177 | pname = pname.strip() 178 | plist.append(ApiParam(ptype, ptypeend, pname)) 179 | 180 | # For an empty parameter list (for e.g. clUnloadCompiler), add a single 181 | # unnamed void parameter to make generation easier. 182 | if len(plist) == 0: 183 | plist.append(ApiParam("void", "", "")) 184 | 185 | apisigs[name] = ApiSignature(name, ret, plist, suffix) 186 | return apisigs 187 | 188 | def get_coreapis(spec, apisigs): 189 | coreapis = OrderedDict() 190 | print('Generating core API dictionary...') 191 | for feature in spec.findall('feature'): 192 | version = noneStr(feature.get('name')) 193 | 194 | alist = [] 195 | for function in feature.findall('require/command'): 196 | name = function.get('name') 197 | alist.append(apisigs[name]) 198 | coreapis[version] = alist 199 | return coreapis 200 | 201 | def get_extapis(spec, apisigs): 202 | extapis = OrderedDict() 203 | print('Generating API extensions dictionary...') 204 | for feature in spec.findall('extensions/extension'): 205 | extension = noneStr(feature.get('name')) 206 | 207 | alist = [] 208 | for function in feature.findall('require/command'): 209 | name = function.get('name') 210 | alist.append(apisigs[name]) 211 | extapis[extension] = alist 212 | return extapis 213 | 214 | def get_apis(spec, apisigs): 215 | return (get_coreapis(spec, apisigs), get_extapis(spec, apisigs)) 216 | -------------------------------------------------------------------------------- /scripts/gen_headers.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # Copyright (c) 2021 The Khronos Group Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | import gen 18 | import re 19 | 20 | from mako.template import Template 21 | from mako.exceptions import RichTraceback 22 | 23 | from collections import OrderedDict 24 | from collections import namedtuple 25 | 26 | def getDisableWarningIncludeString(include): 27 | warningPush = """#if defined(_MSC_VER) 28 | #if _MSC_VER >=1500 29 | #pragma warning( push ) 30 | #pragma warning( disable : 4201 ) 31 | #pragma warning( disable : 5105 ) 32 | #endif 33 | #endif 34 | """ 35 | warningPop = """ 36 | #if defined(_MSC_VER) 37 | #if _MSC_VER >=1500 38 | #pragma warning( pop ) 39 | #endif 40 | #endif""" 41 | return warningPush + include + warningPop 42 | 43 | def getWin32OnlyIncludeString(include): 44 | return """#if defined(_WIN32) 45 | """ + include + """ 46 | #endif""" 47 | 48 | if __name__ == "__main__": 49 | args = gen.parse_args() 50 | spec = gen.load_spec(args) 51 | 52 | typedefs = gen.get_apitypedefs(spec) 53 | macros = gen.get_apimacros(spec) 54 | structs = gen.get_apistructs(spec) 55 | enums = gen.get_apienums(spec) 56 | apisigs = gen.get_apisigs(spec) 57 | 58 | coreapis = gen.get_coreapis(spec, apisigs) 59 | extapis = gen.get_extapis(spec, apisigs) 60 | 61 | try: 62 | cl_ext_h_template = Template(filename='cl_ext.h.mako', input_encoding='utf-8') 63 | cl_function_types_h_template = Template(filename='cl_function_types.h.mako', input_encoding='utf-8') 64 | 65 | print('Generating cl_dx9_media_sharing.h...') 66 | text = cl_ext_h_template.render( 67 | genExtensions={ 68 | 'cl_khr_dx9_media_sharing', 69 | 'cl_intel_dx9_media_sharing', 70 | 'cl_intel_sharing_format_query_dx9', 71 | }, 72 | guard="OPENCL_CL_DX9_MEDIA_SHARING_H_", 73 | includes=getWin32OnlyIncludeString(getDisableWarningIncludeString("#include ")), 74 | generate_pfn_typedefs=False, 75 | spec=spec, 76 | typedefs=typedefs, 77 | macros=macros, 78 | structs=structs, 79 | enums=enums, 80 | apisigs=apisigs, 81 | coreapis=coreapis, 82 | extapis=extapis) 83 | text = re.sub(r'\r\n', r'\n', text) 84 | with open(args.directory + '/cl_dx9_media_sharing.h', 'w') as gen: 85 | gen.write(text) 86 | 87 | print('Generating cl_d3d10.h...') 88 | text = cl_ext_h_template.render( 89 | genExtensions={ 90 | 'cl_khr_d3d10_sharing', 91 | 'cl_intel_sharing_format_query_d3d10', 92 | }, 93 | guard="OPENCL_CL_D3D10_H_", 94 | includes=getDisableWarningIncludeString("#include "), 95 | generate_pfn_typedefs=False, 96 | spec=spec, 97 | typedefs=typedefs, 98 | macros=macros, 99 | structs=structs, 100 | enums=enums, 101 | apisigs=apisigs, 102 | coreapis=coreapis, 103 | extapis=extapis) 104 | text = re.sub(r'\r\n', r'\n', text) 105 | with open(args.directory + '/cl_d3d10.h', 'w') as gen: 106 | gen.write(text) 107 | 108 | print('Generating cl_d3d11.h...') 109 | text = cl_ext_h_template.render( 110 | genExtensions={ 111 | 'cl_khr_d3d11_sharing', 112 | 'cl_intel_sharing_format_query_d3d11' 113 | }, 114 | guard="OPENCL_CL_D3D11_H_", 115 | includes=getDisableWarningIncludeString("#include "), 116 | generate_pfn_typedefs=False, 117 | spec=spec, 118 | typedefs=typedefs, 119 | macros=macros, 120 | structs=structs, 121 | enums=enums, 122 | apisigs=apisigs, 123 | coreapis=coreapis, 124 | extapis=extapis) 125 | text = re.sub(r'\r\n', r'\n', text) 126 | with open(args.directory + '/cl_d3d11.h', 'w') as gen: 127 | gen.write(text) 128 | 129 | print('Generating cl_egl.h...') 130 | text = cl_ext_h_template.render( 131 | genExtensions={'cl_khr_egl_event', 'cl_khr_egl_image'}, 132 | guard="OPENCL_CL_EGL_H_", 133 | generate_pfn_typedefs=False, 134 | spec=spec, 135 | typedefs=typedefs, 136 | macros=macros, 137 | structs=structs, 138 | enums=enums, 139 | apisigs=apisigs, 140 | coreapis=coreapis, 141 | extapis=extapis) 142 | text = re.sub(r'\r\n', r'\n', text) 143 | with open(args.directory + '/cl_egl.h', 'w') as gen: 144 | gen.write(text) 145 | 146 | print('Generating cl_gl.h...') 147 | text = cl_ext_h_template.render( 148 | genExtensions={ 149 | 'cl_khr_gl_depth_images', 150 | 'cl_khr_gl_event', 151 | 'cl_khr_gl_msaa_sharing', 152 | 'cl_khr_gl_sharing', 153 | 'cl_intel_sharing_format_query_gl', 154 | }, 155 | guard="OPENCL_CL_GL_H_", 156 | generate_pfn_typedefs=False, 157 | spec=spec, 158 | typedefs=typedefs, 159 | macros=macros, 160 | structs=structs, 161 | enums=enums, 162 | apisigs=apisigs, 163 | coreapis=coreapis, 164 | extapis=extapis) 165 | text = re.sub(r'\r\n', r'\n', text) 166 | with open(args.directory + '/cl_gl.h', 'w') as gen: 167 | gen.write(text) 168 | 169 | print('Generating cl_layer.h...') 170 | text = cl_ext_h_template.render( 171 | genExtensions={'cl_loader_layers'}, 172 | guard="OPENCL_CL_LAYER_H_", 173 | includes='#include ', 174 | generate_pfn_typedefs=True, 175 | spec=spec, 176 | typedefs=typedefs, 177 | macros=macros, 178 | structs=structs, 179 | enums=enums, 180 | apisigs=apisigs, 181 | coreapis=coreapis, 182 | extapis=extapis) 183 | text = re.sub(r'\r\n', r'\n', text) 184 | with open(args.directory + '/cl_layer.h', 'w') as gen: 185 | gen.write(text) 186 | 187 | print('Generating cl_va_api_media_sharing_intel.h...') 188 | text = cl_ext_h_template.render( 189 | genExtensions={ 190 | 'cl_intel_va_api_media_sharing', 191 | 'cl_intel_sharing_format_query_va_api', 192 | }, 193 | guard="OPENCL_CL_VA_API_MEDIA_SHARING_INTEL_H_", 194 | includes='#include ', 195 | generate_pfn_typedefs=False, 196 | spec=spec, 197 | typedefs=typedefs, 198 | macros=macros, 199 | structs=structs, 200 | enums=enums, 201 | apisigs=apisigs, 202 | coreapis=coreapis, 203 | extapis=extapis) 204 | text = re.sub(r'\r\n', r'\n', text) 205 | with open(args.directory + '/cl_va_api_media_sharing_intel.h', 'w') as gen: 206 | gen.write(text) 207 | 208 | print('Generating cl_ext.h...') 209 | text = cl_ext_h_template.render( 210 | genExtensions={}, 211 | guard="OPENCL_CL_EXT_H_", 212 | generate_pfn_typedefs=False, 213 | spec=spec, 214 | typedefs=typedefs, 215 | macros=macros, 216 | structs=structs, 217 | enums=enums, 218 | apisigs=apisigs, 219 | coreapis=coreapis, 220 | extapis=extapis) 221 | text = re.sub(r'\r\n', r'\n', text) 222 | with open(args.directory + '/cl_ext.h', 'w') as gen: 223 | gen.write(text) 224 | 225 | print('Generating cl_function_types.h...') 226 | text = cl_function_types_h_template.render( 227 | spec=spec, 228 | apisigs=apisigs, 229 | coreapis=coreapis, 230 | extapis=extapis) 231 | text = re.sub(r'\r\n', r'\n', text) 232 | with open(args.directory + '/cl_function_types.h', 'w') as gen: 233 | gen.write(text) 234 | 235 | except: 236 | traceback = RichTraceback() 237 | for (filename, lineno, function, line) in traceback.traceback: 238 | print('%s(%s) : error in %s' % (filename, lineno, function)) 239 | print(' ', line) 240 | print('%s: %s' % (str(traceback.error.__class__.__name__), traceback.error)) 241 | -------------------------------------------------------------------------------- /scripts/requirements.txt: -------------------------------------------------------------------------------- 1 | Mako>=1.2.2 2 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT DEFINED CMAKE_C_STANDARD) 2 | set(CMAKE_C_STANDARD 99) 3 | endif() 4 | if(NOT DEFINED CMAKE_C_STANDARD_REQUIRED) 5 | set(CMAKE_C_STANDARD_REQUIRED ON) 6 | endif() 7 | if(NOT DEFINED CMAKE_CXX_STANDARD) 8 | set(CMAKE_CXX_STANDARD 17) 9 | endif() 10 | if(NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) 11 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 12 | endif() 13 | 14 | 15 | # Add a test for a given source file for each version of OpenCL 16 | function(add_header_test NAME SOURCE) 17 | # Some headers include system files which require anonymous structs 18 | # so we cannot test them with /Za: 19 | set(TEST_SKIP_ANSI_TESTING 20 | cl_d3d10_h cl_d3d11_h cl_dx9_media_sharing_h cl_dx9_media_sharing_intel_h cl_icd_h cl_layer_h) 21 | get_filename_component(LANG_DIR "${CMAKE_CURRENT_SOURCE_DIR}" NAME) 22 | if(LANG_DIR MATCHES cpp) 23 | set(CPP_SOURCE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${SOURCE}pp") 24 | file(RELATIVE_PATH REL_SOURCE_PATH "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../${SOURCE}") 25 | file(TO_NATIVE_PATH "${REL_SOURCE_PATH}" NATIVE_SOURCE_PATH) 26 | file(WRITE 27 | "${CPP_SOURCE_PATH}" 28 | "#include \"${NATIVE_SOURCE_PATH}\"\n" 29 | ) 30 | set(SOURCE_PATH "${CPP_SOURCE_PATH}") 31 | set(LANG cpp) 32 | else() 33 | set(SOURCE_PATH "../${SOURCE}") 34 | set(LANG c) 35 | endif() 36 | foreach(VERSION 100 110 120 200 210 220 300) 37 | foreach(OPTION "" CL_ENABLE_BETA_EXTENSIONS) 38 | if(OPTION STREQUAL "") 39 | # The empty string means we're not setting any special option. 40 | set(UNDERSCORE_OPTION "${OPTION}") 41 | set(DEFINE_OPTION "") 42 | elseif(VERSION EQUAL 300) 43 | # Only test special options for OpenCL 3.0. 44 | set(UNDERSCORE_OPTION "_${OPTION}") 45 | set(DEFINE_OPTION "-D${OPTION}") 46 | else() 47 | continue() 48 | endif() 49 | set(TEST_EXE ${NAME}_${LANG}_${VERSION}${UNDERSCORE_OPTION}) 50 | list(FIND TEST_SKIP_ANSI_TESTING ${NAME} TEST_SKIP_INDEX) 51 | if(NOT (${TEST_SKIP_INDEX} GREATER -1 AND MSVC AND CMAKE_C_FLAGS MATCHES "/Za")) 52 | add_executable(${TEST_EXE} "${SOURCE_PATH}") 53 | target_compile_definitions(${TEST_EXE} 54 | PUBLIC -DCL_TARGET_OPENCL_VERSION=${VERSION} ${DEFINE_OPTION} 55 | ) 56 | target_include_directories(${TEST_EXE} 57 | PUBLIC ${PROJECT_SOURCE_DIR} 58 | ) 59 | add_test(NAME ${TEST_EXE} COMMAND ${TEST_EXE}) 60 | endif() 61 | endforeach(OPTION) 62 | endforeach(VERSION) 63 | endfunction(add_header_test) 64 | 65 | add_subdirectory(lang_c) 66 | if(OPENCL_HEADERS_BUILD_CXX_TESTS) 67 | enable_language(CXX) 68 | add_subdirectory(lang_cpp) 69 | endif() 70 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | OpenCL-Headers/tests README 2 | =========================== 3 | 4 | The test_headers.c test is designed to make sure that the various cl_typen types 5 | work and conform to expectation for recent versions of cl_platform.h. Conforming 6 | to these expectations make use of these types practical for developers writing 7 | portable code. 8 | 9 | The various tests ending in .h.c are there to verify that the various OpenCL 10 | headers can compile stand alone. That is to ensure that they may be used a la 11 | carte. This provides developers a lifeline in the case that some unneeded part 12 | of OpenCL (e.g. cl/gl sharing) brings in a pile of symbols (e.g. all of OpenGL) 13 | that collides with other headers needed by the application. It is also poor form 14 | to require headers to be included in a particular order, especially if multiple 15 | systems require they be included in mutually incompatible order. So, here we 16 | require that each header can be used standalone so that the order is irrelevant. 17 | 18 | We also check to make sure that the headers don't cause spurious warnings. These 19 | tests are intended to be compiled using the most stringent compiler flags 20 | available for the platform, within reason. All warnings should be errors and 21 | extra warnings that it is expected developers are likely to use should be turned 22 | on. 23 | -------------------------------------------------------------------------------- /tests/conan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(PackageTest C) 3 | 4 | include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) 5 | conan_basic_setup() 6 | 7 | find_package(OpenCLHeaders REQUIRED) 8 | 9 | add_executable(example example.c) 10 | target_link_libraries(example OpenCL::Headers) 11 | -------------------------------------------------------------------------------- /tests/conan/conanfile.py: -------------------------------------------------------------------------------- 1 | import os 2 | from conans import ConanFile, CMake, tools 3 | 4 | 5 | class OpenCLHeadersTestConan(ConanFile): 6 | settings = "os", "compiler", "build_type", "arch" 7 | generators = "cmake" 8 | 9 | def build(self): 10 | cmake = CMake(self) 11 | cmake.configure() 12 | cmake.build() 13 | 14 | def test(self): 15 | if not tools.cross_building(self.settings): 16 | os.chdir("bin") 17 | self.run(".%sexample" % os.sep) 18 | -------------------------------------------------------------------------------- /tests/conan/example.c: -------------------------------------------------------------------------------- 1 | #define CL_TARGET_OPENCL_VERSION 220 2 | #include 3 | 4 | int main(void) { 5 | cl_platform_id id; 6 | cl_int result; 7 | result = 0; 8 | return result; 9 | } 10 | -------------------------------------------------------------------------------- /tests/lang_c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Tests 2 | add_header_test(cl_h test_cl.h.c) 3 | add_header_test(cl_d3d10_h test_cl_d3d10.h.c) 4 | add_header_test(cl_d3d11_h test_cl_d3d11.h.c) 5 | add_header_test(cl_dx9_media_sharing_h test_cl_dx9_media_sharing.h.c) 6 | add_header_test(cl_dx9_media_sharing_intel_h test_cl_dx9_media_sharing.h.c) 7 | add_header_test(cl_egl_h test_cl_egl.h.c) 8 | add_header_test(cl_ext_h test_cl_ext.h.c) 9 | add_header_test(cl_ext_intel_h test_cl_ext_intel.h.c) 10 | add_header_test(cl_gl_h test_cl_gl.h.c) 11 | add_header_test(cl_gl_ext_h test_cl_gl_ext.h.c) 12 | add_header_test(cl_half_h test_cl_half.h.c) 13 | add_header_test(cl_icd_h test_cl_icd.h.c) 14 | add_header_test(cl_layer_h test_cl_layer.h.c) 15 | add_header_test(cl_platform_h test_cl_platform.h.c) 16 | add_header_test(cl_opencl_h test_opencl.h.c) 17 | add_header_test(cl_version_h test_cl_version.h.c) 18 | add_header_test(headers test_headers.c) 19 | add_header_test(ext_headers test_ext_headers.c) 20 | -------------------------------------------------------------------------------- /tests/lang_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Tests 2 | add_header_test(cl_h test_cl.h.c) 3 | add_header_test(cl_d3d10_h test_cl_d3d10.h.c) 4 | add_header_test(cl_d3d11_h test_cl_d3d11.h.c) 5 | add_header_test(cl_dx9_media_sharing_h test_cl_dx9_media_sharing.h.c) 6 | add_header_test(cl_dx9_media_sharing_intel_h test_cl_dx9_media_sharing.h.c) 7 | add_header_test(cl_egl_h test_cl_egl.h.c) 8 | add_header_test(cl_ext_h test_cl_ext.h.c) 9 | add_header_test(cl_ext_intel_h test_cl_ext_intel.h.c) 10 | add_header_test(cl_gl_h test_cl_gl.h.c) 11 | add_header_test(cl_gl_ext_h test_cl_gl_ext.h.c) 12 | add_header_test(cl_half_h test_cl_half.h.c) 13 | add_header_test(cl_icd_h test_cl_icd.h.c) 14 | add_header_test(cl_layer_h test_cl_layer.h.c) 15 | add_header_test(cl_platform_h test_cl_platform.h.c) 16 | add_header_test(cl_opencl_h test_opencl.h.c) 17 | add_header_test(cl_version_h test_cl_version.h.c) 18 | add_header_test(ext_headers test_ext_headers.c) 19 | -------------------------------------------------------------------------------- /tests/pkgconfig/bare/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(PkgConfigTest 4 | LANGUAGES C 5 | ) 6 | 7 | find_package(OpenCLHeaders 8 | REQUIRED 9 | CONFIG 10 | ) 11 | 12 | add_executable(${PROJECT_NAME} 13 | ../pkgconfig.c 14 | ) 15 | 16 | target_link_libraries(${PROJECT_NAME} 17 | OpenCL::Headers 18 | ) 19 | 20 | target_compile_definitions(${PROJECT_NAME} 21 | PRIVATE 22 | CL_TARGET_OPENCL_VERSION=120 23 | ) 24 | 25 | include(CTest) 26 | 27 | add_test( 28 | NAME ${PROJECT_NAME} 29 | COMMAND ${PROJECT_NAME} 30 | ) 31 | -------------------------------------------------------------------------------- /tests/pkgconfig/pkgconfig.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { return sizeof(cl_platform_id) - sizeof(cl_context); } 4 | -------------------------------------------------------------------------------- /tests/pkgconfig/sdk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(PkgConfigTest 4 | LANGUAGES C 5 | ) 6 | 7 | find_package(OpenCL 8 | REQUIRED 9 | CONFIG 10 | COMPONENTS Headers 11 | ) 12 | 13 | add_executable(${PROJECT_NAME} 14 | ../pkgconfig.c 15 | ) 16 | 17 | target_link_libraries(${PROJECT_NAME} 18 | OpenCL::Headers 19 | ) 20 | 21 | target_compile_definitions(${PROJECT_NAME} 22 | PRIVATE 23 | CL_TARGET_OPENCL_VERSION=120 24 | ) 25 | 26 | include(CTest) 27 | 28 | add_test( 29 | NAME ${PROJECT_NAME} 30 | COMMAND ${PROJECT_NAME} 31 | ) 32 | -------------------------------------------------------------------------------- /tests/test_cl.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/cl.h" 20 | 21 | int main( void ) 22 | { 23 | printf("cl.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_cl_d3d10.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #if defined(_WIN32) 20 | #include "CL/cl_d3d10.h" 21 | #endif 22 | 23 | int main( void ) 24 | { 25 | printf("cl_d3d10.h standalone test PASSED.\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /tests/test_cl_d3d11.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #if defined(_WIN32) 20 | #include "CL/cl_d3d11.h" 21 | #endif 22 | 23 | int main( void ) 24 | { 25 | printf("cl_d3d11.h standalone test PASSED.\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /tests/test_cl_dx9_media_sharing.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #if defined(_WIN32) 20 | #include "CL/cl_dx9_media_sharing.h" 21 | #endif 22 | 23 | int main( void ) 24 | { 25 | printf("cl_dx9_media_sharing.h standalone test PASSED.\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /tests/test_cl_dx9_media_sharing_intel.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #if defined(_WIN32) 20 | #include "CL/cl_dx9_media_sharing_intel.h" 21 | #endif 22 | 23 | int main( void ) 24 | { 25 | printf("cl_dx9_media_sharing_intel.h standalone test PASSED.\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /tests/test_cl_egl.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/cl_egl.h" 20 | 21 | int main( void ) 22 | { 23 | printf("cl_egl.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_cl_ext.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/cl_ext.h" 20 | 21 | int main( void ) 22 | { 23 | printf("cl_ext.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_cl_ext_intel.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/cl_ext_intel.h" 20 | 21 | int main( void ) 22 | { 23 | printf("cl_ext_intel.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_cl_gl.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/cl_gl.h" 20 | 21 | int main( void ) 22 | { 23 | printf("cl_gl.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_cl_gl_ext.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/cl_gl_ext.h" 20 | 21 | int main( void ) 22 | { 23 | printf("cl_gl_ext.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_cl_half.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | #include 19 | 20 | #include "CL/cl_half.h" 21 | 22 | union FI { 23 | float f; 24 | uint32_t i; 25 | }; 26 | 27 | int test_half_to_float(cl_half h, cl_float ref) 28 | { 29 | cl_float f = cl_half_to_float(h); 30 | if (f != ref) { 31 | union FI f_i, ref_i; 32 | f_i.f = f; 33 | ref_i.f = ref; 34 | printf("\nERROR: converting 0x%04x to float: expected 0x%08x, got 0x%08x\n", 35 | h, ref_i.i, f_i.i); 36 | return 0; 37 | } 38 | return 1; 39 | } 40 | 41 | int test_half_from_float(cl_float f, cl_half ref, 42 | cl_half_rounding_mode mode, const char *mode_str) 43 | { 44 | cl_half h = cl_half_from_float(f, mode); 45 | if (h != ref) { 46 | union FI f_i; 47 | f_i.f = f; 48 | printf( 49 | "\nERROR: converting 0x%08x to half (%s): expected 0x%04x, got 0x%04x\n", 50 | f_i.i, mode_str, ref, h); 51 | return 0; 52 | } 53 | return 1; 54 | } 55 | 56 | int main(void) 57 | { 58 | printf("\nChecking conversion routines in cl_half.h\n"); 59 | 60 | #define CHECK_TO_FLOAT(h, ref) \ 61 | if (!test_half_to_float(h, ref)) { \ 62 | printf("Test failed on line %d.\n", __LINE__); \ 63 | return 1; \ 64 | } 65 | 66 | // Check a handful of values 67 | CHECK_TO_FLOAT(0x0000, 0.f); 68 | CHECK_TO_FLOAT(0x3c00, 1.f); 69 | CHECK_TO_FLOAT(0xbc00, -1.f); 70 | CHECK_TO_FLOAT(0x7c00, INFINITY); 71 | CHECK_TO_FLOAT(0xfc00, -INFINITY); 72 | 73 | 74 | #define CHECK_FROM_FLOAT(f, ref, mode) \ 75 | if (!test_half_from_float(f, ref, CL_HALF_##mode, #mode)) { \ 76 | printf("Test failed on line %d.\n", __LINE__); \ 77 | return 1; \ 78 | } 79 | 80 | // Check a handful of normal values 81 | CHECK_FROM_FLOAT(0.f, 0x0000, RTE); 82 | CHECK_FROM_FLOAT(1.f, 0x3c00, RTE); 83 | CHECK_FROM_FLOAT(-1.f, 0xbc00, RTE); 84 | CHECK_FROM_FLOAT(CL_HALF_MAX, 0x7bff, RTE); 85 | CHECK_FROM_FLOAT(CL_HALF_MIN, 0x0400, RTE); 86 | 87 | // Check huge positive (non-inf) values round properly 88 | CHECK_FROM_FLOAT(CL_HALF_MAX + 1000.f, 0x7c00, RTE); 89 | CHECK_FROM_FLOAT(CL_HALF_MAX + 1000.f, 0x7c00, RTP); 90 | CHECK_FROM_FLOAT(CL_HALF_MAX + 1000.f, 0x7bff, RTN); 91 | CHECK_FROM_FLOAT(CL_HALF_MAX + 1000.f, 0x7bff, RTZ); 92 | 93 | // Check huge negative (non-inf) values round properly 94 | CHECK_FROM_FLOAT(-(CL_HALF_MAX + 1000.f), 0xfc00, RTE); 95 | CHECK_FROM_FLOAT(-(CL_HALF_MAX + 1000.f), 0xfbff, RTP); 96 | CHECK_FROM_FLOAT(-(CL_HALF_MAX + 1000.f), 0xfc00, RTN); 97 | CHECK_FROM_FLOAT(-(CL_HALF_MAX + 1000.f), 0xfbff, RTZ); 98 | #if 0 // Hexadecimal float constant is C++17 99 | // Check tiny positive values round properly 100 | CHECK_FROM_FLOAT(0x1.000000p-25, 0x0000, RTE); 101 | CHECK_FROM_FLOAT(0x1.000000p-25, 0x0001, RTP); 102 | CHECK_FROM_FLOAT(0x1.000000p-25, 0x0000, RTN); 103 | CHECK_FROM_FLOAT(0x1.000000p-25, 0x0000, RTZ); 104 | 105 | // Check tiny negative values round properly 106 | CHECK_FROM_FLOAT(-0x1.000000p-25, 0x8000, RTE); 107 | CHECK_FROM_FLOAT(-0x1.000000p-25, 0x8000, RTP); 108 | CHECK_FROM_FLOAT(-0x1.000000p-25, 0x8001, RTN); 109 | CHECK_FROM_FLOAT(-0x1.000000p-25, 0x8000, RTZ); 110 | #else 111 | // Check tiny positive values round properly 112 | CHECK_FROM_FLOAT(2.98023223876953125e-08, 0x0000, RTE); 113 | CHECK_FROM_FLOAT(2.98023223876953125e-08, 0x0001, RTP); 114 | CHECK_FROM_FLOAT(2.98023223876953125e-08, 0x0000, RTN); 115 | CHECK_FROM_FLOAT(2.98023223876953125e-08, 0x0000, RTZ); 116 | 117 | // Check tiny negative values round properly 118 | CHECK_FROM_FLOAT(-2.98023223876953125e-08, 0x8000, RTE); 119 | CHECK_FROM_FLOAT(-2.98023223876953125e-08, 0x8000, RTP); 120 | CHECK_FROM_FLOAT(-2.98023223876953125e-08, 0x8001, RTN); 121 | CHECK_FROM_FLOAT(-2.98023223876953125e-08, 0x8000, RTZ); 122 | #endif 123 | printf("\nAll tests passed!\n"); 124 | 125 | return 0; 126 | } 127 | -------------------------------------------------------------------------------- /tests/test_cl_icd.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #define CL_USE_DEPRECATED_OPENCL_1_0_APIS 20 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS 21 | #define CL_USE_DEPRECATED_OPENCL_1_2_APIS 22 | #define CL_USE_DEPRECATED_OPENCL_2_0_APIS 23 | #define CL_USE_DEPRECATED_OPENCL_2_1_APIS 24 | #define CL_USE_DEPRECATED_OPENCL_2_2_APIS 25 | #include "CL/cl_icd.h" 26 | 27 | int main( void ) 28 | { 29 | printf("cl_icd.h standalone test PASSED.\n"); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /tests/test_cl_layer.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #define CL_USE_DEPRECATED_OPENCL_1_0_APIS 20 | #define CL_USE_DEPRECATED_OPENCL_1_1_APIS 21 | #define CL_USE_DEPRECATED_OPENCL_1_2_APIS 22 | #define CL_USE_DEPRECATED_OPENCL_2_0_APIS 23 | #define CL_USE_DEPRECATED_OPENCL_2_1_APIS 24 | #define CL_USE_DEPRECATED_OPENCL_2_2_APIS 25 | #include "CL/cl_layer.h" 26 | 27 | int main( void ) 28 | { 29 | printf("cl_icd_layer.h standalone test PASSED.\n"); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /tests/test_cl_platform.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/cl_platform.h" 20 | 21 | int main( void ) 22 | { 23 | printf("cl_platform.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_cl_version.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/cl_version.h" 20 | 21 | int main( void ) 22 | { 23 | printf("cl_version.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_ext_headers.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2024 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 | #include "CL/cl_ext.h" 18 | #include 19 | #include 20 | 21 | int extVersionMacro(void) 22 | { 23 | // Test a non-beta extension with non-placeholder semantic version. 24 | printf("Checking version macro for the cl_khr_integer_dot_product " 25 | "extension\n"); 26 | 27 | cl_version ExtVersion = CL_KHR_INTEGER_DOT_PRODUCT_EXTENSION_VERSION; 28 | cl_version ExtMajorVersion = CL_VERSION_MAJOR(ExtVersion); 29 | cl_version ExtMinorVersion = CL_VERSION_MINOR(ExtVersion); 30 | cl_version ExtPatchVersion = CL_VERSION_PATCH(ExtVersion); 31 | 32 | printf("cl_khr_integer_dot_product version value %" PRIu32 33 | " which is semantic version %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", 34 | ExtVersion, ExtMajorVersion, ExtMinorVersion, ExtPatchVersion); 35 | 36 | // Test vendor extension which uses default semantic version. 37 | printf("Checking version macro for the cl_APPLE_SetMemObjectDestructor\n"); 38 | 39 | ExtVersion = CL_APPLE_SETMEMOBJECTDESTRUCTOR_EXTENSION_VERSION; 40 | ExtMajorVersion = CL_VERSION_MAJOR(ExtVersion); 41 | ExtMinorVersion = CL_VERSION_MINOR(ExtVersion); 42 | ExtPatchVersion = CL_VERSION_PATCH(ExtVersion); 43 | 44 | printf("cl_APPLE_SetMemObjectDestructor version value %" PRIu32 45 | " which is semantic version %" PRIu32 ".%" PRIu32 ".%" PRIu32 "\n", 46 | ExtVersion, ExtMajorVersion, ExtMinorVersion, ExtPatchVersion); 47 | 48 | return 0; 49 | } 50 | 51 | int main(void) 52 | { 53 | int Result = extVersionMacro(); 54 | 55 | return Result; 56 | } 57 | -------------------------------------------------------------------------------- /tests/test_opencl.h.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 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 | #include 18 | 19 | #include "CL/opencl.h" 20 | 21 | int main( void ) 22 | { 23 | printf("opencl.h standalone test PASSED.\n"); 24 | return 0; 25 | } 26 | --------------------------------------------------------------------------------