• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_API_ENTRY 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_API_ENTRY 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_API_ENTRY 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_API_ENTRY 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 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif  /* __OPENCL_CL_DX9_MEDIA_SHARING_H */
118 
119