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 #ifndef __OPENCL_CL_DX9_MEDIA_SHARING_H 18 #define __OPENCL_CL_DX9_MEDIA_SHARING_H 19 20 #include <CL/cl.h> 21 #include <CL/cl_platform.h> 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /******************************************************************************/ 28 /* cl_khr_dx9_media_sharing */ 29 #define cl_khr_dx9_media_sharing 1 30 31 typedef cl_uint cl_dx9_media_adapter_type_khr; 32 typedef cl_uint cl_dx9_media_adapter_set_khr; 33 34 #if defined(_WIN32) 35 #if defined(_MSC_VER) 36 #if _MSC_VER >=1500 37 #pragma warning( push ) 38 #pragma warning( disable : 4201 ) 39 #pragma warning( disable : 5105 ) 40 #endif 41 #endif 42 #include <d3d9.h> 43 #if defined(_MSC_VER) 44 #if _MSC_VER >=1500 45 #pragma warning( pop ) 46 #endif 47 #endif 48 typedef struct _cl_dx9_surface_info_khr 49 { 50 IDirect3DSurface9 *resource; 51 HANDLE shared_handle; 52 } cl_dx9_surface_info_khr; 53 #endif 54 55 56 /******************************************************************************/ 57 58 /* Error Codes */ 59 #define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010 60 #define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011 61 #define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012 62 #define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013 63 64 /* cl_media_adapter_type_khr */ 65 #define CL_ADAPTER_D3D9_KHR 0x2020 66 #define CL_ADAPTER_D3D9EX_KHR 0x2021 67 #define CL_ADAPTER_DXVA_KHR 0x2022 68 69 /* cl_media_adapter_set_khr */ 70 #define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023 71 #define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024 72 73 /* cl_context_info */ 74 #define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025 75 #define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026 76 #define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027 77 78 /* cl_mem_info */ 79 #define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028 80 #define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029 81 82 /* cl_image_info */ 83 #define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A 84 85 /* cl_command_type */ 86 #define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B 87 #define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C 88 89 /******************************************************************************/ 90 91 typedef cl_int (CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)( 92 cl_platform_id platform, 93 cl_uint num_media_adapters, 94 cl_dx9_media_adapter_type_khr * media_adapter_type, 95 void * media_adapters, 96 cl_dx9_media_adapter_set_khr media_adapter_set, 97 cl_uint num_entries, 98 cl_device_id * devices, 99 cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; 100 101 typedef cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)( 102 cl_context context, 103 cl_mem_flags flags, 104 cl_dx9_media_adapter_type_khr adapter_type, 105 void * surface_info, 106 cl_uint plane, 107 cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; 108 109 typedef cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)( 110 cl_command_queue command_queue, 111 cl_uint num_objects, 112 const cl_mem * mem_objects, 113 cl_uint num_events_in_wait_list, 114 const cl_event * event_wait_list, 115 cl_event * event) CL_API_SUFFIX__VERSION_1_2; 116 117 typedef cl_int (CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)( 118 cl_command_queue command_queue, 119 cl_uint num_objects, 120 const cl_mem * mem_objects, 121 cl_uint num_events_in_wait_list, 122 const cl_event * event_wait_list, 123 cl_event * event) CL_API_SUFFIX__VERSION_1_2; 124 125 /*************************************** 126 * cl_intel_dx9_media_sharing extension * 127 ****************************************/ 128 129 #define cl_intel_dx9_media_sharing 1 130 131 typedef cl_uint cl_dx9_device_source_intel; 132 typedef cl_uint cl_dx9_device_set_intel; 133 134 /* error codes */ 135 #define CL_INVALID_DX9_DEVICE_INTEL -1010 136 #define CL_INVALID_DX9_RESOURCE_INTEL -1011 137 #define CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL -1012 138 #define CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL -1013 139 140 /* cl_dx9_device_source_intel */ 141 #define CL_D3D9_DEVICE_INTEL 0x4022 142 #define CL_D3D9EX_DEVICE_INTEL 0x4070 143 #define CL_DXVA_DEVICE_INTEL 0x4071 144 145 /* cl_dx9_device_set_intel */ 146 #define CL_PREFERRED_DEVICES_FOR_DX9_INTEL 0x4024 147 #define CL_ALL_DEVICES_FOR_DX9_INTEL 0x4025 148 149 /* cl_context_info */ 150 #define CL_CONTEXT_D3D9_DEVICE_INTEL 0x4026 151 #define CL_CONTEXT_D3D9EX_DEVICE_INTEL 0x4072 152 #define CL_CONTEXT_DXVA_DEVICE_INTEL 0x4073 153 154 /* cl_mem_info */ 155 #define CL_MEM_DX9_RESOURCE_INTEL 0x4027 156 #define CL_MEM_DX9_SHARED_HANDLE_INTEL 0x4074 157 158 /* cl_image_info */ 159 #define CL_IMAGE_DX9_PLANE_INTEL 0x4075 160 161 /* cl_command_type */ 162 #define CL_COMMAND_ACQUIRE_DX9_OBJECTS_INTEL 0x402A 163 #define CL_COMMAND_RELEASE_DX9_OBJECTS_INTEL 0x402B 164 /******************************************************************************/ 165 166 extern CL_API_ENTRY cl_int CL_API_CALL 167 clGetDeviceIDsFromDX9INTEL( 168 cl_platform_id platform, 169 cl_dx9_device_source_intel dx9_device_source, 170 void* dx9_object, 171 cl_dx9_device_set_intel dx9_device_set, 172 cl_uint num_entries, 173 cl_device_id* devices, 174 cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; 175 176 typedef cl_int (CL_API_CALL* clGetDeviceIDsFromDX9INTEL_fn)( 177 cl_platform_id platform, 178 cl_dx9_device_source_intel dx9_device_source, 179 void* dx9_object, 180 cl_dx9_device_set_intel dx9_device_set, 181 cl_uint num_entries, 182 cl_device_id* devices, 183 cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; 184 185 extern CL_API_ENTRY cl_mem CL_API_CALL 186 clCreateFromDX9MediaSurfaceINTEL( 187 cl_context context, 188 cl_mem_flags flags, 189 IDirect3DSurface9* resource, 190 HANDLE sharedHandle, 191 UINT plane, 192 cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; 193 194 typedef cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceINTEL_fn)( 195 cl_context context, 196 cl_mem_flags flags, 197 IDirect3DSurface9* resource, 198 HANDLE sharedHandle, 199 UINT plane, 200 cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; 201 202 extern CL_API_ENTRY cl_int CL_API_CALL 203 clEnqueueAcquireDX9ObjectsINTEL( 204 cl_command_queue command_queue, 205 cl_uint num_objects, 206 const cl_mem* mem_objects, 207 cl_uint num_events_in_wait_list, 208 const cl_event* event_wait_list, 209 cl_event* event) CL_API_SUFFIX__VERSION_1_1; 210 211 typedef cl_int (CL_API_CALL *clEnqueueAcquireDX9ObjectsINTEL_fn)( 212 cl_command_queue command_queue, 213 cl_uint num_objects, 214 const cl_mem* mem_objects, 215 cl_uint num_events_in_wait_list, 216 const cl_event* event_wait_list, 217 cl_event* event) CL_API_SUFFIX__VERSION_1_1; 218 219 extern CL_API_ENTRY cl_int CL_API_CALL 220 clEnqueueReleaseDX9ObjectsINTEL( 221 cl_command_queue command_queue, 222 cl_uint num_objects, 223 cl_mem* mem_objects, 224 cl_uint num_events_in_wait_list, 225 const cl_event* event_wait_list, 226 cl_event* event) CL_API_SUFFIX__VERSION_1_1; 227 228 typedef cl_int (CL_API_CALL *clEnqueueReleaseDX9ObjectsINTEL_fn)( 229 cl_command_queue command_queue, 230 cl_uint num_objects, 231 cl_mem* mem_objects, 232 cl_uint num_events_in_wait_list, 233 const cl_event* event_wait_list, 234 cl_event* event) CL_API_SUFFIX__VERSION_1_1; 235 236 /*************************************************************** 237 * cl_intel_sharing_format_query_dx9 238 ***************************************************************/ 239 #define cl_intel_sharing_format_query_dx9 1 240 241 /* when cl_khr_dx9_media_sharing or cl_intel_dx9_media_sharing is supported */ 242 243 extern CL_API_ENTRY cl_int CL_API_CALL 244 clGetSupportedDX9MediaSurfaceFormatsINTEL( 245 cl_context context, 246 cl_mem_flags flags, 247 cl_mem_object_type image_type, 248 cl_uint plane, 249 cl_uint num_entries, 250 D3DFORMAT* dx9_formats, 251 cl_uint* num_surface_formats) ; 252 253 typedef cl_int (CL_API_CALL * 254 clGetSupportedDX9MediaSurfaceFormatsINTEL_fn)( 255 cl_context context, 256 cl_mem_flags flags, 257 cl_mem_object_type image_type, 258 cl_uint plane, 259 cl_uint num_entries, 260 D3DFORMAT* dx9_formats, 261 cl_uint* num_surface_formats) ; 262 263 #ifdef __cplusplus 264 } 265 #endif 266 267 #endif /* __OPENCL_CL_DX9_MEDIA_SHARING_H */ 268 269