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 #include <d3d9.h> 36 typedef struct _cl_dx9_surface_info_khr 37 { 38 IDirect3DSurface9 *resource; 39 HANDLE shared_handle; 40 } cl_dx9_surface_info_khr; 41 #endif 42 43 44 /******************************************************************************/ 45 46 /* Error Codes */ 47 #define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010 48 #define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011 49 #define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012 50 #define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013 51 52 /* cl_media_adapter_type_khr */ 53 #define CL_ADAPTER_D3D9_KHR 0x2020 54 #define CL_ADAPTER_D3D9EX_KHR 0x2021 55 #define CL_ADAPTER_DXVA_KHR 0x2022 56 57 /* cl_media_adapter_set_khr */ 58 #define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023 59 #define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024 60 61 /* cl_context_info */ 62 #define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025 63 #define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026 64 #define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027 65 66 /* cl_mem_info */ 67 #define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028 68 #define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029 69 70 /* cl_image_info */ 71 #define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A 72 73 /* cl_command_type */ 74 #define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B 75 #define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C 76 77 /******************************************************************************/ 78 79 typedef cl_int (CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)( 80 cl_platform_id platform, 81 cl_uint num_media_adapters, 82 cl_dx9_media_adapter_type_khr * media_adapter_type, 83 void * media_adapters, 84 cl_dx9_media_adapter_set_khr media_adapter_set, 85 cl_uint num_entries, 86 cl_device_id * devices, 87 cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; 88 89 typedef cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)( 90 cl_context context, 91 cl_mem_flags flags, 92 cl_dx9_media_adapter_type_khr adapter_type, 93 void * surface_info, 94 cl_uint plane, 95 cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; 96 97 typedef cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)( 98 cl_command_queue command_queue, 99 cl_uint num_objects, 100 const cl_mem * mem_objects, 101 cl_uint num_events_in_wait_list, 102 const cl_event * event_wait_list, 103 cl_event * event) CL_API_SUFFIX__VERSION_1_2; 104 105 typedef cl_int (CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)( 106 cl_command_queue command_queue, 107 cl_uint num_objects, 108 const cl_mem * mem_objects, 109 cl_uint num_events_in_wait_list, 110 const cl_event * event_wait_list, 111 cl_event * event) CL_API_SUFFIX__VERSION_1_2; 112 113 /*************************************** 114 * cl_intel_dx9_media_sharing extension * 115 ****************************************/ 116 117 #define cl_intel_dx9_media_sharing 1 118 119 typedef cl_uint cl_dx9_device_source_intel; 120 typedef cl_uint cl_dx9_device_set_intel; 121 122 /* error codes */ 123 #define CL_INVALID_DX9_DEVICE_INTEL -1010 124 #define CL_INVALID_DX9_RESOURCE_INTEL -1011 125 #define CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL -1012 126 #define CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL -1013 127 128 /* cl_dx9_device_source_intel */ 129 #define CL_D3D9_DEVICE_INTEL 0x4022 130 #define CL_D3D9EX_DEVICE_INTEL 0x4070 131 #define CL_DXVA_DEVICE_INTEL 0x4071 132 133 /* cl_dx9_device_set_intel */ 134 #define CL_PREFERRED_DEVICES_FOR_DX9_INTEL 0x4024 135 #define CL_ALL_DEVICES_FOR_DX9_INTEL 0x4025 136 137 /* cl_context_info */ 138 #define CL_CONTEXT_D3D9_DEVICE_INTEL 0x4026 139 #define CL_CONTEXT_D3D9EX_DEVICE_INTEL 0x4072 140 #define CL_CONTEXT_DXVA_DEVICE_INTEL 0x4073 141 142 /* cl_mem_info */ 143 #define CL_MEM_DX9_RESOURCE_INTEL 0x4027 144 #define CL_MEM_DX9_SHARED_HANDLE_INTEL 0x4074 145 146 /* cl_image_info */ 147 #define CL_IMAGE_DX9_PLANE_INTEL 0x4075 148 149 /* cl_command_type */ 150 #define CL_COMMAND_ACQUIRE_DX9_OBJECTS_INTEL 0x402A 151 #define CL_COMMAND_RELEASE_DX9_OBJECTS_INTEL 0x402B 152 /******************************************************************************/ 153 154 extern CL_API_ENTRY cl_int CL_API_CALL 155 clGetDeviceIDsFromDX9INTEL( 156 cl_platform_id platform, 157 cl_dx9_device_source_intel dx9_device_source, 158 void* dx9_object, 159 cl_dx9_device_set_intel dx9_device_set, 160 cl_uint num_entries, 161 cl_device_id* devices, 162 cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; 163 164 typedef cl_int (CL_API_CALL* clGetDeviceIDsFromDX9INTEL_fn)( 165 cl_platform_id platform, 166 cl_dx9_device_source_intel dx9_device_source, 167 void* dx9_object, 168 cl_dx9_device_set_intel dx9_device_set, 169 cl_uint num_entries, 170 cl_device_id* devices, 171 cl_uint* num_devices) CL_API_SUFFIX__VERSION_1_1; 172 173 extern CL_API_ENTRY cl_mem CL_API_CALL 174 clCreateFromDX9MediaSurfaceINTEL( 175 cl_context context, 176 cl_mem_flags flags, 177 IDirect3DSurface9* resource, 178 HANDLE sharedHandle, 179 UINT plane, 180 cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; 181 182 typedef cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceINTEL_fn)( 183 cl_context context, 184 cl_mem_flags flags, 185 IDirect3DSurface9* resource, 186 HANDLE sharedHandle, 187 UINT plane, 188 cl_int* errcode_ret) CL_API_SUFFIX__VERSION_1_1; 189 190 extern CL_API_ENTRY cl_int CL_API_CALL 191 clEnqueueAcquireDX9ObjectsINTEL( 192 cl_command_queue command_queue, 193 cl_uint num_objects, 194 const cl_mem* mem_objects, 195 cl_uint num_events_in_wait_list, 196 const cl_event* event_wait_list, 197 cl_event* event) CL_API_SUFFIX__VERSION_1_1; 198 199 typedef cl_int (CL_API_CALL *clEnqueueAcquireDX9ObjectsINTEL_fn)( 200 cl_command_queue command_queue, 201 cl_uint num_objects, 202 const cl_mem* mem_objects, 203 cl_uint num_events_in_wait_list, 204 const cl_event* event_wait_list, 205 cl_event* event) CL_API_SUFFIX__VERSION_1_1; 206 207 extern CL_API_ENTRY cl_int CL_API_CALL 208 clEnqueueReleaseDX9ObjectsINTEL( 209 cl_command_queue command_queue, 210 cl_uint num_objects, 211 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_1; 215 216 typedef cl_int (CL_API_CALL *clEnqueueReleaseDX9ObjectsINTEL_fn)( 217 cl_command_queue command_queue, 218 cl_uint num_objects, 219 cl_mem* mem_objects, 220 cl_uint num_events_in_wait_list, 221 const cl_event* event_wait_list, 222 cl_event* event) CL_API_SUFFIX__VERSION_1_1; 223 224 #ifdef __cplusplus 225 } 226 #endif 227 228 #endif /* __OPENCL_CL_DX9_MEDIA_SHARING_H */ 229 230