codekingpro/portable-devtools
114k
1/*
2 * Copyright 1993-2019 NVIDIA Corporation. All rights reserved.
3 *
4 * NOTICE TO LICENSEE:
5 *
6 * This source code and/or documentation ("Licensed Deliverables") are
7 * subject to NVIDIA intellectual property rights under U.S. and
8 * international Copyright laws.
9 *
10 * These Licensed Deliverables contained herein is PROPRIETARY and
11 * CONFIDENTIAL to NVIDIA and is being provided under the terms and
12 * conditions of a form of NVIDIA software license agreement by and
13 * between NVIDIA and Licensee ("License Agreement") or electronically
14 * accepted by Licensee. Notwithstanding any terms or conditions to
15 * the contrary in the License Agreement, reproduction or disclosure
16 * of the Licensed Deliverables to any third party without the express
17 * written consent of NVIDIA is prohibited.
18 *
19 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
20 * LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
21 * SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
22 * PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
23 * NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
24 * DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
25 * NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
26 * NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
27 * LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
28 * SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
29 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
30 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
31 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
32 * OF THESE LICENSED DELIVERABLES.
33 *
34 * U.S. Government End Users. These Licensed Deliverables are a
35 * "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
36 * 1995), consisting of "commercial computer software" and "commercial
37 * computer software documentation" as such terms are used in 48
38 * C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
39 * only as a commercial end item. Consistent with 48 C.F.R.12.212 and
40 * 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
41 * U.S. Government End Users acquire the Licensed Deliverables with
42 * only those rights set forth herein.
43 *
44 * Any use of the Licensed Deliverables in individual and commercial
45 * software must include, in the user documentation and internal
46 * comments to the code, the above Disclaimer and U.S. Government End
47 * Users Notice.
48 */
49
50#if !defined(__CUDA_EGL_INTEROP_H__)
51#define __CUDA_EGL_INTEROP_H__
52
53#include "cuda_runtime_api.h"
54#include "cuda_runtime.h"
55#include "cudart_platform.h"
56#include "EGL/egl.h"
57#include "EGL/eglext.h"
58
59#if defined(__cplusplus)
60extern "C" {
61#endif /* __cplusplus */
62
63/**
64 * \addtogroup CUDART_TYPES
65 * @{
66 */
67
68 /**
69 * Maximum number of planes per frame
70 */
71#define CUDA_EGL_MAX_PLANES 3
72
73/**
74 * CUDA EglFrame type - array or pointer
75 */
76typedef enum cudaEglFrameType_enum
77{
78 cudaEglFrameTypeArray = 0, /**< Frame type CUDA array */
79 cudaEglFrameTypePitch = 1, /**< Frame type CUDA pointer */
80} cudaEglFrameType;
81
82/**
83 * Resource location flags- sysmem or vidmem
84 *
85 * For CUDA context on iGPU, since video and system memory are equivalent -
86 * these flags will not have an effect on the execution.
87 *
88 * For CUDA context on dGPU, applications can use the flag ::cudaEglResourceLocationFlags
89 * to give a hint about the desired location.
90 *
91 * ::cudaEglResourceLocationSysmem - the frame data is made resident on the system memory
92 * to be accessed by CUDA.
93 *
94 * ::cudaEglResourceLocationVidmem - the frame data is made resident on the dedicated
95 * video memory to be accessed by CUDA.
96 *
97 * There may be an additional latency due to new allocation and data migration,
98 * if the frame is produced on a different memory.
99 */
100typedef enum cudaEglResourceLocationFlags_enum {
101 cudaEglResourceLocationSysmem = 0x00, /**< Resource location sysmem */
102 cudaEglResourceLocationVidmem = 0x01, /**< Resource location vidmem */
103} cudaEglResourceLocationFlags;
104
105/**
106 * CUDA EGL Color Format - The different planar and multiplanar formats currently supported for CUDA_EGL interops.
107 */
108typedef enum cudaEglColorFormat_enum {
109 cudaEglColorFormatYUV420Planar = 0, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
110 cudaEglColorFormatYUV420SemiPlanar = 1, /**< Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV420Planar. */
111 cudaEglColorFormatYUV422Planar = 2, /**< Y, U, V each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height. */
112 cudaEglColorFormatYUV422SemiPlanar = 3, /**< Y, UV in two surfaces with VU byte ordering, width, height ratio same as YUV422Planar. */
113 cudaEglColorFormatARGB = 6, /**< R/G/B/A four channels in one surface with BGRA byte ordering. */
114 cudaEglColorFormatRGBA = 7, /**< R/G/B/A four channels in one surface with ABGR byte ordering. */
115 cudaEglColorFormatL = 8, /**< single luminance channel in one surface. */
116 cudaEglColorFormatR = 9, /**< single color channel in one surface. */
117 cudaEglColorFormatYUV444Planar = 10, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height. */
118 cudaEglColorFormatYUV444SemiPlanar = 11, /**< Y, UV in two surfaces (UV as one surface) with VU byte ordering, width, height ratio same as YUV444Planar. */
119 cudaEglColorFormatYUYV422 = 12, /**< Y, U, V in one surface, interleaved as UYVY in one channel. */
120 cudaEglColorFormatUYVY422 = 13, /**< Y, U, V in one surface, interleaved as YUYV in one channel. */
121 cudaEglColorFormatABGR = 14, /**< R/G/B/A four channels in one surface with RGBA byte ordering. */
122 cudaEglColorFormatBGRA = 15, /**< R/G/B/A four channels in one surface with ARGB byte ordering. */
123 cudaEglColorFormatA = 16, /**< Alpha color format - one channel in one surface. */
124 cudaEglColorFormatRG = 17, /**< R/G color format - two channels in one surface with GR byte ordering */
125 cudaEglColorFormatAYUV = 18, /**< Y, U, V, A four channels in one surface, interleaved as VUYA. */
126 cudaEglColorFormatYVU444SemiPlanar = 19, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
127 cudaEglColorFormatYVU422SemiPlanar = 20, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
128 cudaEglColorFormatYVU420SemiPlanar = 21, /**< Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
129 cudaEglColorFormatY10V10U10_444SemiPlanar = 22, /**< Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
130 cudaEglColorFormatY10V10U10_420SemiPlanar = 23, /**< Y10, V10U10 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
131 cudaEglColorFormatY12V12U12_444SemiPlanar = 24, /**< Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
132 cudaEglColorFormatY12V12U12_420SemiPlanar = 25, /**< Y12, V12U12 in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
133 cudaEglColorFormatVYUY_ER = 26, /**< Extended Range Y, U, V in one surface, interleaved as YVYU in one channel. */
134 cudaEglColorFormatUYVY_ER = 27, /**< Extended Range Y, U, V in one surface, interleaved as YUYV in one channel. */
135 cudaEglColorFormatYUYV_ER = 28, /**< Extended Range Y, U, V in one surface, interleaved as UYVY in one channel. */
136 cudaEglColorFormatYVYU_ER = 29, /**< Extended Range Y, U, V in one surface, interleaved as VYUY in one channel. */
137 cudaEglColorFormatYUVA_ER = 31, /**< Extended Range Y, U, V, A four channels in one surface, interleaved as AVUY. */
138 cudaEglColorFormatAYUV_ER = 32, /**< Extended Range Y, U, V, A four channels in one surface, interleaved as VUYA. */
139 cudaEglColorFormatYUV444Planar_ER = 33, /**< Extended Range Y, U, V in three surfaces, U/V width = Y width, U/V height = Y height. */
140 cudaEglColorFormatYUV422Planar_ER = 34, /**< Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = Y height. */
141 cudaEglColorFormatYUV420Planar_ER = 35, /**< Extended Range Y, U, V in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
142 cudaEglColorFormatYUV444SemiPlanar_ER = 36, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = Y width, U/V height = Y height. */
143 cudaEglColorFormatYUV422SemiPlanar_ER = 37, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
144 cudaEglColorFormatYUV420SemiPlanar_ER = 38, /**< Extended Range Y, UV in two surfaces (UV as one surface) with VU byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
145 cudaEglColorFormatYVU444Planar_ER = 39, /**< Extended Range Y, V, U in three surfaces, U/V width = Y width, U/V height = Y height. */
146 cudaEglColorFormatYVU422Planar_ER = 40, /**< Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = Y height. */
147 cudaEglColorFormatYVU420Planar_ER = 41, /**< Extended Range Y, V, U in three surfaces, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
148 cudaEglColorFormatYVU444SemiPlanar_ER = 42, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = Y width, U/V height = Y height. */
149 cudaEglColorFormatYVU422SemiPlanar_ER = 43, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = Y height. */
150 cudaEglColorFormatYVU420SemiPlanar_ER = 44, /**< Extended Range Y, VU in two surfaces (VU as one surface) with UV byte ordering, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
151 cudaEglColorFormatBayerRGGB = 45, /**< Bayer format - one channel in one surface with interleaved RGGB ordering. */
152 cudaEglColorFormatBayerBGGR = 46, /**< Bayer format - one channel in one surface with interleaved BGGR ordering. */
153 cudaEglColorFormatBayerGRBG = 47, /**< Bayer format - one channel in one surface with interleaved GRBG ordering. */
154 cudaEglColorFormatBayerGBRG = 48, /**< Bayer format - one channel in one surface with interleaved GBRG ordering. */
155 cudaEglColorFormatBayer10RGGB = 49, /**< Bayer10 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
156 cudaEglColorFormatBayer10BGGR = 50, /**< Bayer10 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
157 cudaEglColorFormatBayer10GRBG = 51, /**< Bayer10 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
158 cudaEglColorFormatBayer10GBRG = 52, /**< Bayer10 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
159 cudaEglColorFormatBayer12RGGB = 53, /**< Bayer12 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
160 cudaEglColorFormatBayer12BGGR = 54, /**< Bayer12 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
161 cudaEglColorFormatBayer12GRBG = 55, /**< Bayer12 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
162 cudaEglColorFormatBayer12GBRG = 56, /**< Bayer12 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
163 cudaEglColorFormatBayer14RGGB = 57, /**< Bayer14 format - one channel in one surface with interleaved RGGB ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
164 cudaEglColorFormatBayer14BGGR = 58, /**< Bayer14 format - one channel in one surface with interleaved BGGR ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
165 cudaEglColorFormatBayer14GRBG = 59, /**< Bayer14 format - one channel in one surface with interleaved GRBG ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
166 cudaEglColorFormatBayer14GBRG = 60, /**< Bayer14 format - one channel in one surface with interleaved GBRG ordering. Out of 16 bits, 14 bits used 2 bits No-op. */
167 cudaEglColorFormatBayer20RGGB = 61, /**< Bayer20 format - one channel in one surface with interleaved RGGB ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
168 cudaEglColorFormatBayer20BGGR = 62, /**< Bayer20 format - one channel in one surface with interleaved BGGR ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
169 cudaEglColorFormatBayer20GRBG = 63, /**< Bayer20 format - one channel in one surface with interleaved GRBG ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
170 cudaEglColorFormatBayer20GBRG = 64, /**< Bayer20 format - one channel in one surface with interleaved GBRG ordering. Out of 32 bits, 20 bits used 12 bits No-op. */
171 cudaEglColorFormatYVU444Planar = 65, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = Y width, U/V height = Y height. */
172 cudaEglColorFormatYVU422Planar = 66, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = Y height. */
173 cudaEglColorFormatYVU420Planar = 67, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
174 cudaEglColorFormatBayerIspRGGB = 68, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved RGGB ordering and mapped to opaque integer datatype. */
175 cudaEglColorFormatBayerIspBGGR = 69, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved BGGR ordering and mapped to opaque integer datatype. */
176 cudaEglColorFormatBayerIspGRBG = 70, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GRBG ordering and mapped to opaque integer datatype. */
177 cudaEglColorFormatBayerIspGBRG = 71, /**< Nvidia proprietary Bayer ISP format - one channel in one surface with interleaved GBRG ordering and mapped to opaque integer datatype. */
178 cudaEglColorFormatBayerBCCR = 72, /**< Bayer format - one channel in one surface with interleaved BCCR ordering. */
179 cudaEglColorFormatBayerRCCB = 73, /**< Bayer format - one channel in one surface with interleaved RCCB ordering. */
180 cudaEglColorFormatBayerCRBC = 74, /**< Bayer format - one channel in one surface with interleaved CRBC ordering. */
181 cudaEglColorFormatBayerCBRC = 75, /**< Bayer format - one channel in one surface with interleaved CBRC ordering. */
182 cudaEglColorFormatBayer10CCCC = 76, /**< Bayer10 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 10 bits used 6 bits No-op. */
183 cudaEglColorFormatBayer12BCCR = 77, /**< Bayer12 format - one channel in one surface with interleaved BCCR ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
184 cudaEglColorFormatBayer12RCCB = 78, /**< Bayer12 format - one channel in one surface with interleaved RCCB ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
185 cudaEglColorFormatBayer12CRBC = 79, /**< Bayer12 format - one channel in one surface with interleaved CRBC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
186 cudaEglColorFormatBayer12CBRC = 80, /**< Bayer12 format - one channel in one surface with interleaved CBRC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
187 cudaEglColorFormatBayer12CCCC = 81, /**< Bayer12 format - one channel in one surface with interleaved CCCC ordering. Out of 16 bits, 12 bits used 4 bits No-op. */
188 cudaEglColorFormatY = 82, /**< Color format for single Y plane. */
189 cudaEglColorFormatYUV420SemiPlanar_2020 = 83, /**< Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
190 cudaEglColorFormatYVU420SemiPlanar_2020 = 84, /**< Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
191 cudaEglColorFormatYUV420Planar_2020 = 85, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
192 cudaEglColorFormatYVU420Planar_2020 = 86, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
193 cudaEglColorFormatYUV420SemiPlanar_709 = 87, /**< Y, UV in two surfaces (UV as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
194 cudaEglColorFormatYVU420SemiPlanar_709 = 88, /**< Y, VU in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
195 cudaEglColorFormatYUV420Planar_709 = 89, /**< Y, U, V in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
196 cudaEglColorFormatYVU420Planar_709 = 90, /**< Y, V, U in three surfaces, each in a separate surface, U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
197 cudaEglColorFormatY10V10U10_420SemiPlanar_709 = 91, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
198 cudaEglColorFormatY10V10U10_420SemiPlanar_2020 = 92, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
199 cudaEglColorFormatY10V10U10_422SemiPlanar_2020 = 93, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
200 cudaEglColorFormatY10V10U10_422SemiPlanar = 94, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
201 cudaEglColorFormatY10V10U10_422SemiPlanar_709 = 95, /**< Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = Y height. */
202 cudaEglColorFormatY_ER = 96, /**< Extended Range Color format for single Y plane. */
203 cudaEglColorFormatY_709_ER = 97, /**< Extended Range Color format for single Y plane. */
204 cudaEglColorFormatY10_ER = 98, /**< Extended Range Color format for single Y10 plane. */
205 cudaEglColorFormatY10_709_ER = 99, /**< Extended Range Color format for single Y10 plane. */
206 cudaEglColorFormatY12_ER = 100, /**< Extended Range Color format for single Y12 plane. */
207 cudaEglColorFormatY12_709_ER = 101, /**< Extended Range Color format for single Y12 plane. */
208 cudaEglColorFormatYUVA = 102, /**< Y, U, V, A four channels in one surface, interleaved as AVUY. */
209 cudaEglColorFormatYVYU = 104, /**< Y, U, V in one surface, interleaved as YVYU in one channel. */
210 cudaEglColorFormatVYUY = 105, /**< Y, U, V in one surface, interleaved as VYUY in one channel. */
211 cudaEglColorFormatY10V10U10_420SemiPlanar_ER = 106, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
212 cudaEglColorFormatY10V10U10_420SemiPlanar_709_ER = 107, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
213 cudaEglColorFormatY10V10U10_444SemiPlanar_ER = 108, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
214 cudaEglColorFormatY10V10U10_444SemiPlanar_709_ER = 109, /**< Extended Range Y10, V10U10 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
215 cudaEglColorFormatY12V12U12_420SemiPlanar_ER = 110, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
216 cudaEglColorFormatY12V12U12_420SemiPlanar_709_ER = 111, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = 1/2 Y width, U/V height = 1/2 Y height. */
217 cudaEglColorFormatY12V12U12_444SemiPlanar_ER = 112, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
218 cudaEglColorFormatY12V12U12_444SemiPlanar_709_ER = 113, /**< Extended Range Y12, V12U12 in two surfaces (VU as one surface) U/V width = Y width, U/V height = Y height. */
219} cudaEglColorFormat;
220
221/**
222 * CUDA EGL Plane Descriptor - structure defining each plane of a CUDA EGLFrame
223 */
224typedef struct cudaEglPlaneDesc_st {
225 unsigned int width; /**< Width of plane */
226 unsigned int height; /**< Height of plane */
227 unsigned int depth; /**< Depth of plane */
228 unsigned int pitch; /**< Pitch of plane */
229 unsigned int numChannels; /**< Number of channels for the plane */
230 struct cudaChannelFormatDesc channelDesc; /**< Channel Format Descriptor */
231 unsigned int reserved[4]; /**< Reserved for future use */
232} cudaEglPlaneDesc;
233
234/**
235 * CUDA EGLFrame Descriptor - structure defining one frame of EGL.
236 *
237 * Each frame may contain one or more planes depending on whether the surface is Multiplanar or not.
238 * Each plane of EGLFrame is represented by ::cudaEglPlaneDesc which is defined as:
239 * \code
240 * typedef struct cudaEglPlaneDesc_st {
241 * unsigned int width;
242 * unsigned int height;
243 * unsigned int depth;
244 * unsigned int pitch;
245 * unsigned int numChannels;
246 * struct cudaChannelFormatDesc channelDesc;
247 * unsigned int reserved[4];
248 * } cudaEglPlaneDesc;
249 * \endcode
250
251*/
252typedef struct cudaEglFrame_st {
253 union {
254 cudaArray_t pArray[CUDA_EGL_MAX_PLANES]; /**< Array of CUDA arrays corresponding to each plane*/
255 struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES]; /**< Array of Pointers corresponding to each plane*/
256 } frame;
257 cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES]; /**< CUDA EGL Plane Descriptor ::cudaEglPlaneDesc*/
258 unsigned int planeCount; /**< Number of planes */
259 cudaEglFrameType frameType; /**< Array or Pitch */
260 cudaEglColorFormat eglColorFormat; /**< CUDA EGL Color Format*/
261} cudaEglFrame;
262
263/**
264 * CUDA EGLSream Connection
265 */
266typedef struct CUeglStreamConnection_st *cudaEglStreamConnection;
267
268/** @} */ /* END CUDART_TYPES */
269
270/**
271 * \addtogroup CUDART_EGL EGL Interoperability
272 * This section describes the EGL interoperability functions of the CUDA
273 * runtime application programming interface.
274 *
275 * @{
276 */
277
278/**
279 * \brief Registers an EGL image
280 *
281 * Registers the EGLImageKHR specified by \p image for access by
282 * CUDA. A handle to the registered object is returned as \p pCudaResource.
283 * Additional Mapping/Unmapping is not required for the registered resource and
284 * ::cudaGraphicsResourceGetMappedEglFrame can be directly called on the \p pCudaResource.
285 *
286 * The application will be responsible for synchronizing access to shared objects.
287 * The application must ensure that any pending operation which access the objects have completed
288 * before passing control to CUDA. This may be accomplished by issuing and waiting for
289 * glFinish command on all GLcontexts (for OpenGL and likewise for other APIs).
290 * The application will be also responsible for ensuring that any pending operation on the
291 * registered CUDA resource has completed prior to executing subsequent commands in other APIs
292 * accesing the same memory objects.
293 * This can be accomplished by calling cuCtxSynchronize or cuEventSynchronize (preferably).
294 *
295 * The surface's intended usage is specified using \p flags, as follows:
296 *
297 * - ::cudaGraphicsRegisterFlagsNone: Specifies no hints about how this
298 * resource will be used. It is therefore assumed that this resource will be
299 * read from and written to by CUDA. This is the default value.
300 * - ::cudaGraphicsRegisterFlagsReadOnly: Specifies that CUDA
301 * will not write to this resource.
302 * - ::cudaGraphicsRegisterFlagsWriteDiscard: Specifies that
303 * CUDA will not read from this resource and will write over the
304 * entire contents of the resource, so none of the data previously
305 * stored in the resource will be preserved.
306 *
307 * The EGLImageKHR is an object which can be used to create EGLImage target resource. It is defined as a void pointer.
308 * typedef void* EGLImageKHR
309 *
310 * \param pCudaResource - Pointer to the returned object handle
311 * \param image - An EGLImageKHR image which can be used to create target resource.
312 * \param flags - Map flags
313 *
314 * \return
315 * ::cudaSuccess,
316 * ::cudaErrorInvalidResourceHandle,
317 * ::cudaErrorInvalidValue,
318 * ::cudaErrorUnknown
319 *
320 * \sa
321 * ::cudaGraphicsUnregisterResource,
322 * ::cudaGraphicsResourceGetMappedEglFrame,
323 * ::cuGraphicsEGLRegisterImage
324 */
325extern __host__ cudaError_t CUDARTAPI cudaGraphicsEGLRegisterImage(struct cudaGraphicsResource **pCudaResource, EGLImageKHR image, unsigned int flags);
326
327/**
328 * \brief Connect CUDA to EGLStream as a consumer.
329 *
330 * Connect CUDA as a consumer to EGLStreamKHR specified by \p eglStream.
331 *
332 * The EGLStreamKHR is an EGL object that transfers a sequence of image frames from one
333 * API to another.
334 *
335 * \param conn - Pointer to the returned connection handle
336 * \param eglStream - EGLStreamKHR handle
337 *
338 * \return
339 * ::cudaSuccess,
340 * ::cudaErrorInvalidValue,
341 * ::cudaErrorUnknown
342 *
343 * \sa
344 * ::cudaEGLStreamConsumerDisconnect,
345 * ::cudaEGLStreamConsumerAcquireFrame,
346 * ::cudaEGLStreamConsumerReleaseFrame,
347 * ::cuEGLStreamConsumerConnect
348 */
349extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerConnect(cudaEglStreamConnection *conn, EGLStreamKHR eglStream);
350
351/**
352 * \brief Connect CUDA to EGLStream as a consumer with given flags.
353 *
354 * Connect CUDA as a consumer to EGLStreamKHR specified by \p stream with specified \p flags defined by
355 * ::cudaEglResourceLocationFlags.
356 *
357 * The flags specify whether the consumer wants to access frames from system memory or video memory.
358 * Default is ::cudaEglResourceLocationVidmem.
359 *
360 * \param conn - Pointer to the returned connection handle
361 * \param eglStream - EGLStreamKHR handle
362 * \param flags - Flags denote intended location - system or video.
363 *
364 * \return
365 * ::cudaSuccess,
366 * ::cudaErrorInvalidValue,
367 * ::cudaErrorUnknown
368 *
369 * \sa
370 * ::cudaEGLStreamConsumerDisconnect,
371 * ::cudaEGLStreamConsumerAcquireFrame,
372 * ::cudaEGLStreamConsumerReleaseFrame,
373 * ::cuEGLStreamConsumerConnectWithFlags
374 */
375extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerConnectWithFlags(cudaEglStreamConnection *conn, EGLStreamKHR eglStream, unsigned int flags);
376
377/**
378 * \brief Disconnect CUDA as a consumer to EGLStream .
379 *
380 * Disconnect CUDA as a consumer to EGLStreamKHR.
381 *
382 * \param conn - Conection to disconnect.
383 *
384 * \return
385 * ::cudaSuccess,
386 * ::cudaErrorInvalidValue,
387 * ::cudaErrorUnknown
388 *
389 * \sa
390 * ::cudaEGLStreamConsumerConnect,
391 * ::cudaEGLStreamConsumerAcquireFrame,
392 * ::cudaEGLStreamConsumerReleaseFrame,
393 * ::cuEGLStreamConsumerDisconnect
394 */
395extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerDisconnect(cudaEglStreamConnection *conn);
396
397/**
398 * \brief Acquire an image frame from the EGLStream with CUDA as a consumer.
399 *
400 * Acquire an image frame from EGLStreamKHR.
401 * ::cudaGraphicsResourceGetMappedEglFrame can be called on \p pCudaResource to get
402 * ::cudaEglFrame.
403 *
404 * \param conn - Connection on which to acquire
405 * \param pCudaResource - CUDA resource on which the EGLStream frame will be mapped for use.
406 * \param pStream - CUDA stream for synchronization and any data migrations
407 * implied by ::cudaEglResourceLocationFlags.
408 * \param timeout - Desired timeout in usec.
409 *
410 * \return
411 * ::cudaSuccess,
412 * ::cudaErrorInvalidValue,
413 * ::cudaErrorUnknown,
414 * ::cudaErrorLaunchTimeout
415 *
416 * \sa
417 * ::cudaEGLStreamConsumerConnect,
418 * ::cudaEGLStreamConsumerDisconnect,
419 * ::cudaEGLStreamConsumerReleaseFrame,
420 * ::cuEGLStreamConsumerAcquireFrame
421 */
422
423extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerAcquireFrame(cudaEglStreamConnection *conn,
424 cudaGraphicsResource_t *pCudaResource, cudaStream_t *pStream, unsigned int timeout);
425/**
426 * \brief Releases the last frame acquired from the EGLStream.
427 *
428 * Release the acquired image frame specified by \p pCudaResource to EGLStreamKHR.
429 *
430 * \param conn - Connection on which to release
431 * \param pCudaResource - CUDA resource whose corresponding frame is to be released
432 * \param pStream - CUDA stream on which release will be done.
433 *
434 * \return
435 * ::cudaSuccess,
436 * ::cudaErrorInvalidValue,
437 * ::cudaErrorUnknown
438 *
439 * \sa
440 * ::cudaEGLStreamConsumerConnect,
441 * ::cudaEGLStreamConsumerDisconnect,
442 * ::cudaEGLStreamConsumerAcquireFrame,
443 * ::cuEGLStreamConsumerReleaseFrame
444 */
445extern __host__ cudaError_t CUDARTAPI cudaEGLStreamConsumerReleaseFrame(cudaEglStreamConnection *conn,
446 cudaGraphicsResource_t pCudaResource, cudaStream_t *pStream);
447
448/**
449 * \brief Connect CUDA to EGLStream as a producer.
450 *
451 * Connect CUDA as a producer to EGLStreamKHR specified by \p stream.
452 *
453 * The EGLStreamKHR is an EGL object that transfers a sequence of image frames from one
454 * API to another.
455 *
456 * \param conn - Pointer to the returned connection handle
457 * \param eglStream - EGLStreamKHR handle
458 * \param width - width of the image to be submitted to the stream
459 * \param height - height of the image to be submitted to the stream
460 *
461 * \return
462 * ::cudaSuccess,
463 * ::cudaErrorInvalidValue,
464 * ::cudaErrorUnknown
465 *
466 * \sa
467 * ::cudaEGLStreamProducerDisconnect,
468 * ::cudaEGLStreamProducerPresentFrame,
469 * ::cudaEGLStreamProducerReturnFrame,
470 * ::cuEGLStreamProducerConnect
471 */
472extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerConnect(cudaEglStreamConnection *conn,
473 EGLStreamKHR eglStream, EGLint width, EGLint height);
474
475/**
476 * \brief Disconnect CUDA as a producer to EGLStream .
477 *
478 * Disconnect CUDA as a producer to EGLStreamKHR.
479 *
480 * \param conn - Conection to disconnect.
481 *
482 * \return
483 * ::cudaSuccess,
484 * ::cudaErrorInvalidValue,
485 * ::cudaErrorUnknown
486 *
487 * \sa
488 * ::cudaEGLStreamProducerConnect,
489 * ::cudaEGLStreamProducerPresentFrame,
490 * ::cudaEGLStreamProducerReturnFrame,
491 * ::cuEGLStreamProducerDisconnect
492 */
493extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerDisconnect(cudaEglStreamConnection *conn);
494
495/**
496 * \brief Present a CUDA eglFrame to the EGLStream with CUDA as a producer.
497 *
498 * The ::cudaEglFrame is defined as:
499 * \code
500 * typedef struct cudaEglFrame_st {
501 * union {
502 * cudaArray_t pArray[CUDA_EGL_MAX_PLANES];
503 * struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES];
504 * } frame;
505 * cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES];
506 * unsigned int planeCount;
507 * cudaEglFrameType frameType;
508 * cudaEglColorFormat eglColorFormat;
509 * } cudaEglFrame;
510 * \endcode
511 *
512 * For ::cudaEglFrame of type ::cudaEglFrameTypePitch, the application may present sub-region of a memory
513 * allocation. In that case, ::cudaPitchedPtr::ptr will specify the start address of the sub-region in
514 * the allocation and ::cudaEglPlaneDesc will specify the dimensions of the sub-region.
515 *
516 * \param conn - Connection on which to present the CUDA array
517 * \param eglframe - CUDA Eglstream Proucer Frame handle to be sent to the consumer over EglStream.
518 * \param pStream - CUDA stream on which to present the frame.
519 *
520 * \return
521 * ::cudaSuccess,
522 * ::cudaErrorInvalidValue,
523 * ::cudaErrorUnknown
524 *
525 * \sa
526 * ::cudaEGLStreamProducerConnect,
527 * ::cudaEGLStreamProducerDisconnect,
528 * ::cudaEGLStreamProducerReturnFrame,
529 * ::cuEGLStreamProducerPresentFrame
530 */
531extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerPresentFrame(cudaEglStreamConnection *conn,
532 cudaEglFrame eglframe, cudaStream_t *pStream);
533
534/**
535 * \brief Return the CUDA eglFrame to the EGLStream last released by the consumer.
536 *
537 * This API can potentially return cudaErrorLaunchTimeout if the consumer has not
538 * returned a frame to EGL stream. If timeout is returned the application can retry.
539 *
540 * \param conn - Connection on which to present the CUDA array
541 * \param eglframe - CUDA Eglstream Proucer Frame handle returned from the consumer over EglStream.
542 * \param pStream - CUDA stream on which to return the frame.
543 *
544 * \return
545 * ::cudaSuccess,
546 * ::cudaErrorLaunchTimeout,
547 * ::cudaErrorInvalidValue,
548 * ::cudaErrorUnknown
549 *
550 * \sa
551 * ::cudaEGLStreamProducerConnect,
552 * ::cudaEGLStreamProducerDisconnect,
553 * ::cudaEGLStreamProducerPresentFrame,
554 * ::cuEGLStreamProducerReturnFrame
555 */
556extern __host__ cudaError_t CUDARTAPI cudaEGLStreamProducerReturnFrame(cudaEglStreamConnection *conn,
557 cudaEglFrame *eglframe, cudaStream_t *pStream);
558
559/**
560 * \brief Get an eglFrame through which to access a registered EGL graphics resource.
561 *
562 * Returns in \p *eglFrame an eglFrame pointer through which the registered graphics resource
563 * \p resource may be accessed.
564 * This API can only be called for EGL graphics resources.
565 *
566 * The ::cudaEglFrame is defined as
567 * \code
568 * typedef struct cudaEglFrame_st {
569 * union {
570 * cudaArray_t pArray[CUDA_EGL_MAX_PLANES];
571 * struct cudaPitchedPtr pPitch[CUDA_EGL_MAX_PLANES];
572 * } frame;
573 * cudaEglPlaneDesc planeDesc[CUDA_EGL_MAX_PLANES];
574 * unsigned int planeCount;
575 * cudaEglFrameType frameType;
576 * cudaEglColorFormat eglColorFormat;
577 * } cudaEglFrame;
578 * \endcode
579 *
580 *
581 * \param eglFrame - Returned eglFrame.
582 * \param resource - Registered resource to access.
583 * \param index - Index for cubemap surfaces.
584 * \param mipLevel - Mipmap level for the subresource to access.
585 *
586 * \return
587 * ::cudaSuccess,
588 * ::cudaErrorInvalidValue,
589 * ::cudaErrorUnknown
590 *
591 * \note Note that in case of multiplanar \p *eglFrame, pitch of only first plane (unsigned int cudaEglPlaneDesc::pitch) is to be considered by the application.
592 *
593 * \sa
594 * ::cudaGraphicsSubResourceGetMappedArray,
595 * ::cudaGraphicsResourceGetMappedPointer,
596 * ::cuGraphicsResourceGetMappedEglFrame
597 */
598extern __host__ cudaError_t CUDARTAPI cudaGraphicsResourceGetMappedEglFrame(cudaEglFrame* eglFrame,
599 cudaGraphicsResource_t resource, unsigned int index, unsigned int mipLevel);
600
601/**
602 * \brief Creates an event from EGLSync object
603 *
604 * Creates an event *phEvent from an EGLSyncKHR eglSync with the flages specified
605 * via \p flags. Valid flags include:
606 * - ::cudaEventDefault: Default event creation flag.
607 * - ::cudaEventBlockingSync: Specifies that the created event should use blocking
608 * synchronization. A CPU thread that uses ::cudaEventSynchronize() to wait on
609 * an event created with this flag will block until the event has actually
610 * been completed.
611 *
612 * ::cudaEventRecord and TimingData are not supported for events created from EGLSync.
613 *
614 * The EGLSyncKHR is an opaque handle to an EGL sync object.
615 * typedef void* EGLSyncKHR
616 *
617 * \param phEvent - Returns newly created event
618 * \param eglSync - Opaque handle to EGLSync object
619 * \param flags - Event creation flags
620 *
621 * \return
622 * ::cudaSuccess,
623 * ::cudaErrorInitializationError,
624 * ::cudaErrorInvalidValue,
625 * ::cudaErrorLaunchFailure,
626 * ::cudaErrorMemoryAllocation
627 *
628 * \sa
629 * ::cudaEventQuery,
630 * ::cudaEventSynchronize,
631 * ::cudaEventDestroy
632 */
633extern __host__ cudaError_t CUDARTAPI cudaEventCreateFromEGLSync(cudaEvent_t *phEvent, EGLSyncKHR eglSync, unsigned int flags);
634
635/** @} */ /* END CUDART_EGL */
636
637#if defined(__cplusplus)
638}
639#endif /* __cplusplus */
640
641#endif /* __CUDA_EGL_INTEROP_H__ */
642
643 