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 Copyright (c) 2013-2019 Intel Corporation All Rights Reserved.
19 
20 THESE MATERIALS ARE PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THESE
30 MATERIALS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 File Name: cl_dx9_media_sharing_intel.h
33 
34 Abstract:
35 
36 Notes:
37 
38 \*****************************************************************************/
39 
40 #ifndef __OPENCL_CL_DX9_MEDIA_SHARING_INTEL_H
41 #define __OPENCL_CL_DX9_MEDIA_SHARING_INTEL_H
42 
43 #include <CL/cl.h>
44 #include <CL/cl_platform.h>
45 #include <d3d9.h>
46 #include <dxvahd.h>
47 #include <wtypes.h>
48 #include <d3d9types.h>
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 /***************************************
55 * cl_intel_dx9_media_sharing extension *
56 ****************************************/
57 
58 #define cl_intel_dx9_media_sharing 1
59 
60 typedef cl_uint cl_dx9_device_source_intel;
61 typedef cl_uint cl_dx9_device_set_intel;
62 
63 /* error codes */
64 #define CL_INVALID_DX9_DEVICE_INTEL                   -1010
65 #define CL_INVALID_DX9_RESOURCE_INTEL                 -1011
66 #define CL_DX9_RESOURCE_ALREADY_ACQUIRED_INTEL        -1012
67 #define CL_DX9_RESOURCE_NOT_ACQUIRED_INTEL            -1013
68 
69 /* cl_dx9_device_source_intel */
70 #define CL_D3D9_DEVICE_INTEL                          0x4022
71 #define CL_D3D9EX_DEVICE_INTEL                        0x4070
72 #define CL_DXVA_DEVICE_INTEL                          0x4071
73 
74 /* cl_dx9_device_set_intel */
75 #define CL_PREFERRED_DEVICES_FOR_DX9_INTEL            0x4024
76 #define CL_ALL_DEVICES_FOR_DX9_INTEL                  0x4025
77 
78 /* cl_context_info */
79 #define CL_CONTEXT_D3D9_DEVICE_INTEL                  0x4026
80 #define CL_CONTEXT_D3D9EX_DEVICE_INTEL                0x4072
81 #define CL_CONTEXT_DXVA_DEVICE_INTEL                  0x4073
82 
83 /* cl_mem_info */
84 #define CL_MEM_DX9_RESOURCE_INTEL                     0x4027
85 #define CL_MEM_DX9_SHARED_HANDLE_INTEL                0x4074
86 
87 /* cl_image_info */
88 #define CL_IMAGE_DX9_PLANE_INTEL                      0x4075
89 
90 /* cl_command_type */
91 #define CL_COMMAND_ACQUIRE_DX9_OBJECTS_INTEL          0x402A
92 #define CL_COMMAND_RELEASE_DX9_OBJECTS_INTEL          0x402B
93 /******************************************************************************/
94 
95 extern CL_API_ENTRY cl_int CL_API_CALL
96 clGetDeviceIDsFromDX9INTEL(
97     cl_platform_id              platform,
98     cl_dx9_device_source_intel  dx9_device_source,
99     void*                       dx9_object,
100     cl_dx9_device_set_intel     dx9_device_set,
101     cl_uint                     num_entries,
102     cl_device_id*               devices,
103     cl_uint*                    num_devices) CL_EXT_SUFFIX__VERSION_1_1;
104 
105 typedef CL_API_ENTRY cl_int (CL_API_CALL* clGetDeviceIDsFromDX9INTEL_fn)(
106     cl_platform_id              platform,
107     cl_dx9_device_source_intel  dx9_device_source,
108     void*                       dx9_object,
109     cl_dx9_device_set_intel     dx9_device_set,
110     cl_uint                     num_entries,
111     cl_device_id*               devices,
112     cl_uint*                    num_devices) CL_EXT_SUFFIX__VERSION_1_1;
113 
114 extern CL_API_ENTRY cl_mem CL_API_CALL
115 clCreateFromDX9MediaSurfaceINTEL(
116     cl_context                  context,
117     cl_mem_flags                flags,
118     IDirect3DSurface9*          resource,
119     HANDLE                      sharedHandle,
120     UINT                        plane,
121     cl_int*                     errcode_ret) CL_EXT_SUFFIX__VERSION_1_1;
122 
123 typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceINTEL_fn)(
124     cl_context                  context,
125     cl_mem_flags                flags,
126     IDirect3DSurface9*          resource,
127     HANDLE                      sharedHandle,
128     UINT                        plane,
129     cl_int*                     errcode_ret) CL_EXT_SUFFIX__VERSION_1_1;
130 
131 extern CL_API_ENTRY cl_int CL_API_CALL
132 clEnqueueAcquireDX9ObjectsINTEL(
133     cl_command_queue            command_queue,
134     cl_uint                     num_objects,
135     const cl_mem*               mem_objects,
136     cl_uint                     num_events_in_wait_list,
137     const cl_event*             event_wait_list,
138     cl_event*                   event) CL_EXT_SUFFIX__VERSION_1_1;
139 
140 typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireDX9ObjectsINTEL_fn)(
141     cl_command_queue            command_queue,
142     cl_uint                     num_objects,
143     const cl_mem*               mem_objects,
144     cl_uint                     num_events_in_wait_list,
145     const cl_event*             event_wait_list,
146     cl_event*                   event) CL_EXT_SUFFIX__VERSION_1_1;
147 
148 extern CL_API_ENTRY cl_int CL_API_CALL
149 clEnqueueReleaseDX9ObjectsINTEL(
150     cl_command_queue            command_queue,
151     cl_uint                     num_objects,
152     cl_mem*                     mem_objects,
153     cl_uint                     num_events_in_wait_list,
154     const cl_event*             event_wait_list,
155     cl_event*                   event) CL_EXT_SUFFIX__VERSION_1_1;
156 
157 typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseDX9ObjectsINTEL_fn)(
158     cl_command_queue            command_queue,
159     cl_uint                     num_objects,
160     cl_mem*                     mem_objects,
161     cl_uint                     num_events_in_wait_list,
162     const cl_event*             event_wait_list,
163     cl_event*                   event) CL_EXT_SUFFIX__VERSION_1_1;
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif  /* __OPENCL_CL_DX9_MEDIA_SHARING_INTEL_H */
170 
171