Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
cudaD3D9.h887 linesDownload Raw Back to include
1/*
2 * Copyright 1993-2014 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#ifndef CUDAD3D9_H
51#define CUDAD3D9_H
52
53#if defined(__CUDA_API_VERSION_INTERNAL) || defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
54#define __CUDA_DEPRECATED
55#elif defined(_MSC_VER)
56#define __CUDA_DEPRECATED __declspec(deprecated)
57#elif defined(__GNUC__)
58#define __CUDA_DEPRECATED __attribute__((deprecated))
59#else
60#define __CUDA_DEPRECATED
61#endif
62
63#ifdef CUDA_FORCE_API_VERSION
64#error "CUDA_FORCE_API_VERSION is no longer supported."
65#endif
66
67#define cuD3D9CtxCreate                    cuD3D9CtxCreate_v2
68#define cuD3D9ResourceGetSurfaceDimensions cuD3D9ResourceGetSurfaceDimensions_v2
69#define cuD3D9ResourceGetMappedPointer     cuD3D9ResourceGetMappedPointer_v2
70#define cuD3D9ResourceGetMappedSize        cuD3D9ResourceGetMappedSize_v2
71#define cuD3D9ResourceGetMappedPitch       cuD3D9ResourceGetMappedPitch_v2
72#define cuD3D9MapVertexBuffer              cuD3D9MapVertexBuffer_v2
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78/**
79 * \file cudaD3D9.h
80 * \brief Header file for the Direct3D 9 interoperability functions of the
81 * low-level CUDA driver application programming interface.
82 */
83
84/**
85 * \defgroup CUDA_D3D9 Direct3D 9 Interoperability
86 * \ingroup CUDA_DRIVER
87 *
88 * ___MANBRIEF___ Direct3D 9 interoperability functions of the low-level CUDA
89 * driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
90 *
91 * This section describes the Direct3D 9 interoperability functions of the
92 * low-level CUDA driver application programming interface. Note that mapping 
93 * of Direct3D 9 resources is performed with the graphics API agnostic, resource 
94 * mapping interface described in \ref CUDA_GRAPHICS "Graphics Interoperability".
95 *
96 * @{
97 */
98
99/**
100 * CUDA devices corresponding to a D3D9 device
101 */
102typedef enum CUd3d9DeviceList_enum {
103    CU_D3D9_DEVICE_LIST_ALL            = 0x01, /**< The CUDA devices for all GPUs used by a D3D9 device */
104    CU_D3D9_DEVICE_LIST_CURRENT_FRAME  = 0x02, /**< The CUDA devices for the GPUs used by a D3D9 device in its currently rendering frame */
105    CU_D3D9_DEVICE_LIST_NEXT_FRAME     = 0x03, /**< The CUDA devices for the GPUs to be used by a D3D9 device in the next frame */
106} CUd3d9DeviceList;
107
108/**
109 * \brief Gets the CUDA device corresponding to a display adapter.
110 *
111 * Returns in \p *pCudaDevice the CUDA-compatible device corresponding to the
112 * adapter name \p pszAdapterName obtained from ::EnumDisplayDevices() or
113 * ::IDirect3D9::GetAdapterIdentifier().
114 *
115 * If no device on the adapter with name \p pszAdapterName is CUDA-compatible,
116 * then the call will fail.
117 *
118 * \param pCudaDevice    - Returned CUDA device corresponding to pszAdapterName
119 * \param pszAdapterName - Adapter name to query for device
120 *
121 * \return
122 * ::CUDA_SUCCESS,
123 * ::CUDA_ERROR_DEINITIALIZED,
124 * ::CUDA_ERROR_NOT_INITIALIZED,
125 * ::CUDA_ERROR_INVALID_VALUE,
126 * ::CUDA_ERROR_NOT_FOUND,
127 * ::CUDA_ERROR_UNKNOWN
128 * \notefnerr
129 *
130 * \sa
131 * ::cuD3D9CtxCreate,
132 * ::cudaD3D9GetDevice
133 */
134CUresult CUDAAPI cuD3D9GetDevice(CUdevice *pCudaDevice, const char *pszAdapterName);
135
136/**
137 * \brief Gets the CUDA devices corresponding to a Direct3D 9 device
138 *
139 * Returns in \p *pCudaDeviceCount the number of CUDA-compatible device corresponding
140 * to the Direct3D 9 device \p pD3D9Device.
141 * Also returns in \p *pCudaDevices at most \p cudaDeviceCount of the CUDA-compatible devices
142 * corresponding to the Direct3D 9 device \p pD3D9Device.
143 *
144 * If any of the GPUs being used to render \p pDevice are not CUDA capable then the
145 * call will return ::CUDA_ERROR_NO_DEVICE.
146 *
147 * \param pCudaDeviceCount - Returned number of CUDA devices corresponding to \p pD3D9Device
148 * \param pCudaDevices     - Returned CUDA devices corresponding to \p pD3D9Device
149 * \param cudaDeviceCount  - The size of the output device array \p pCudaDevices
150 * \param pD3D9Device      - Direct3D 9 device to query for CUDA devices
151 * \param deviceList       - The set of devices to return.  This set may be
152 *                           ::CU_D3D9_DEVICE_LIST_ALL for all devices,
153 *                           ::CU_D3D9_DEVICE_LIST_CURRENT_FRAME for the devices used to
154 *                           render the current frame (in SLI), or
155 *                           ::CU_D3D9_DEVICE_LIST_NEXT_FRAME for the devices used to
156 *                           render the next frame (in SLI).
157 *
158 * \return
159 * ::CUDA_SUCCESS,
160 * ::CUDA_ERROR_DEINITIALIZED,
161 * ::CUDA_ERROR_NOT_INITIALIZED,
162 * ::CUDA_ERROR_NO_DEVICE,
163 * ::CUDA_ERROR_INVALID_VALUE,
164 * ::CUDA_ERROR_NOT_FOUND,
165 * ::CUDA_ERROR_UNKNOWN
166 * \notefnerr
167 *
168 * \sa
169 * ::cuD3D9CtxCreate,
170 * ::cudaD3D9GetDevices
171 */
172CUresult CUDAAPI cuD3D9GetDevices(unsigned int *pCudaDeviceCount, CUdevice *pCudaDevices, unsigned int cudaDeviceCount, IDirect3DDevice9 *pD3D9Device, CUd3d9DeviceList deviceList);
173
174/**
175 * \brief Create a CUDA context for interoperability with Direct3D 9
176 *
177 * Creates a new CUDA context, enables interoperability for that context with
178 * the Direct3D device \p pD3DDevice, and associates the created CUDA context
179 * with the calling thread.
180 * The created ::CUcontext will be returned in \p *pCtx.
181 * Direct3D resources from this device may be registered and mapped through the
182 * lifetime of this CUDA context.
183 * If \p pCudaDevice is non-NULL then the ::CUdevice on which this CUDA context was
184 * created will be returned in \p *pCudaDevice.
185 *
186 * On success, this call will increase the internal reference count on
187 * \p pD3DDevice. This reference count will be decremented upon destruction of
188 * this context through ::cuCtxDestroy().
189 * This context will cease to function if \p pD3DDevice is destroyed or encounters
190 * an error.
191 *
192 * Note that this function is never required for correct functionality.  Use of 
193 * this function will result in accelerated interoperability only when the
194 * operating system is Windows Vista or Windows 7, and the device \p pD3DDdevice 
195 * is not an IDirect3DDevice9Ex.  In all other circumstances, this function is 
196 * not necessary.
197 *
198 * \param pCtx        - Returned newly created CUDA context
199 * \param pCudaDevice - Returned pointer to the device on which the context was created
200 * \param Flags       - Context creation flags (see ::cuCtxCreate() for details)
201 * \param pD3DDevice  - Direct3D device to create interoperability context with
202 *
203 * \return
204 * ::CUDA_SUCCESS,
205 * ::CUDA_ERROR_DEINITIALIZED,
206 * ::CUDA_ERROR_NOT_INITIALIZED,
207 * ::CUDA_ERROR_INVALID_VALUE,
208 * ::CUDA_ERROR_OUT_OF_MEMORY,
209 * ::CUDA_ERROR_UNKNOWN
210 * \notefnerr
211 *
212 * \sa
213 * ::cuD3D9GetDevice,
214 * ::cuGraphicsD3D9RegisterResource
215 */
216CUresult CUDAAPI cuD3D9CtxCreate(CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, IDirect3DDevice9 *pD3DDevice);
217
218/**
219 * \brief Create a CUDA context for interoperability with Direct3D 9
220 *
221 * Creates a new CUDA context, enables interoperability for that context with
222 * the Direct3D device \p pD3DDevice, and associates the created CUDA context
223 * with the calling thread.
224 * The created ::CUcontext will be returned in \p *pCtx.
225 * Direct3D resources from this device may be registered and mapped through the
226 * lifetime of this CUDA context.
227 *
228 * On success, this call will increase the internal reference count on
229 * \p pD3DDevice. This reference count will be decremented upon destruction of
230 * this context through ::cuCtxDestroy().
231 * This context will cease to function if \p pD3DDevice is destroyed or encounters
232 * an error.
233 *
234 * Note that this function is never required for correct functionality.  Use of 
235 * this function will result in accelerated interoperability only when the
236 * operating system is Windows Vista or Windows 7, and the device \p pD3DDdevice 
237 * is not an IDirect3DDevice9Ex.  In all other circumstances, this function is 
238 * not necessary.
239 *
240 * \param pCtx        - Returned newly created CUDA context
241 * \param flags       - Context creation flags (see ::cuCtxCreate() for details)
242 * \param pD3DDevice  - Direct3D device to create interoperability context with
243 * \param cudaDevice  - The CUDA device on which to create the context.  This device
244 *                      must be among the devices returned when querying
245 *                      ::CU_D3D9_DEVICES_ALL from  ::cuD3D9GetDevices.
246 *
247 * \return
248 * ::CUDA_SUCCESS,
249 * ::CUDA_ERROR_DEINITIALIZED,
250 * ::CUDA_ERROR_NOT_INITIALIZED,
251 * ::CUDA_ERROR_INVALID_VALUE,
252 * ::CUDA_ERROR_OUT_OF_MEMORY,
253 * ::CUDA_ERROR_UNKNOWN
254 * \notefnerr
255 *
256 * \sa
257 * ::cuD3D9GetDevices,
258 * ::cuGraphicsD3D9RegisterResource
259 */
260CUresult CUDAAPI cuD3D9CtxCreateOnDevice(CUcontext *pCtx, unsigned int flags, IDirect3DDevice9 *pD3DDevice, CUdevice cudaDevice);
261
262/**
263 * \brief Get the Direct3D 9 device against which the current CUDA context was
264 * created
265 *
266 * Returns in \p *ppD3DDevice the Direct3D device against which this CUDA context
267 * was created in ::cuD3D9CtxCreate().
268 *
269 * \param ppD3DDevice - Returned Direct3D device corresponding to CUDA context
270 *
271 * \return
272 * ::CUDA_SUCCESS,
273 * ::CUDA_ERROR_DEINITIALIZED,
274 * ::CUDA_ERROR_NOT_INITIALIZED,
275 * ::CUDA_ERROR_INVALID_CONTEXT
276 * ::CUDA_ERROR_INVALID_GRAPHICS_CONTEXT
277 * \notefnerr
278 *
279 * \sa
280 * ::cuD3D9GetDevice,
281 * ::cudaD3D9GetDirect3DDevice
282 */
283CUresult CUDAAPI cuD3D9GetDirect3DDevice(IDirect3DDevice9 **ppD3DDevice);
284
285/**
286 * \brief Register a Direct3D 9 resource for access by CUDA
287 *
288 * Registers the Direct3D 9 resource \p pD3DResource for access by CUDA and
289 * returns a CUDA handle to \p pD3Dresource in \p pCudaResource.
290 * The handle returned in \p pCudaResource may be used to map and unmap this
291 * resource until it is unregistered.
292 * On success this call will increase the internal reference count on
293 * \p pD3DResource. This reference count will be decremented when this
294 * resource is unregistered through ::cuGraphicsUnregisterResource().
295 *
296 * This call is potentially high-overhead and should not be called every frame
297 * in interactive applications.
298 *
299 * The type of \p pD3DResource must be one of the following.
300 * - ::IDirect3DVertexBuffer9: may be accessed through a device pointer
301 * - ::IDirect3DIndexBuffer9: may be accessed through a device pointer
302 * - ::IDirect3DSurface9: may be accessed through an array.
303 *     Only stand-alone objects of type ::IDirect3DSurface9
304 *     may be explicitly shared. In particular, individual mipmap levels and faces
305 *     of cube maps may not be registered directly. To access individual surfaces
306 *     associated with a texture, one must register the base texture object.
307 * - ::IDirect3DBaseTexture9: individual surfaces on this texture may be accessed
308 *     through an array.
309 *
310 * The \p Flags argument may be used to specify additional parameters at register
311 * time.  The valid values for this parameter are
312 * - ::CU_GRAPHICS_REGISTER_FLAGS_NONE: Specifies no hints about how this
313 *   resource will be used.
314 * - ::CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST: Specifies that CUDA will
315 *   bind this resource to a surface reference.
316 * - ::CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER: Specifies that CUDA will perform
317 *   texture gather operations on this resource.
318 *
319 * Not all Direct3D resources of the above types may be used for
320 * interoperability with CUDA.  The following are some limitations.
321 * - The primary rendertarget may not be registered with CUDA.
322 * - Resources allocated as shared may not be registered with CUDA.
323 * - Textures which are not of a format which is 1, 2, or 4 channels of 8, 16,
324 *   or 32-bit integer or floating-point data cannot be shared.
325 * - Surfaces of depth or stencil formats cannot be shared.
326 *
327 * A complete list of supported formats is as follows:
328 * - D3DFMT_L8
329 * - D3DFMT_L16
330 * - D3DFMT_A8R8G8B8
331 * - D3DFMT_X8R8G8B8
332 * - D3DFMT_G16R16
333 * - D3DFMT_A8B8G8R8
334 * - D3DFMT_A8
335 * - D3DFMT_A8L8
336 * - D3DFMT_Q8W8V8U8
337 * - D3DFMT_V16U16
338 * - D3DFMT_A16B16G16R16F
339 * - D3DFMT_A16B16G16R16
340 * - D3DFMT_R32F
341 * - D3DFMT_G16R16F
342 * - D3DFMT_A32B32G32R32F
343 * - D3DFMT_G32R32F
344 * - D3DFMT_R16F
345 *
346 * If Direct3D interoperability is not initialized for this context using
347 * ::cuD3D9CtxCreate then ::CUDA_ERROR_INVALID_CONTEXT is returned.
348 * If \p pD3DResource is of incorrect type or is already registered then
349 * ::CUDA_ERROR_INVALID_HANDLE is returned.
350 * If \p pD3DResource cannot be registered then ::CUDA_ERROR_UNKNOWN is returned.
351 * If \p Flags is not one of the above specified value then ::CUDA_ERROR_INVALID_VALUE
352 * is returned.
353 *
354 * \param pCudaResource - Returned graphics resource handle
355 * \param pD3DResource  - Direct3D resource to register
356 * \param Flags         - Parameters for resource registration
357 *
358 * \return
359 * ::CUDA_SUCCESS,
360 * ::CUDA_ERROR_DEINITIALIZED,
361 * ::CUDA_ERROR_NOT_INITIALIZED,
362 * ::CUDA_ERROR_INVALID_CONTEXT,
363 * ::CUDA_ERROR_INVALID_VALUE,
364 * ::CUDA_ERROR_INVALID_HANDLE,
365 * ::CUDA_ERROR_OUT_OF_MEMORY,
366 * ::CUDA_ERROR_UNKNOWN
367 * \notefnerr
368 *
369 * \sa
370 * ::cuD3D9CtxCreate,
371 * ::cuGraphicsUnregisterResource,
372 * ::cuGraphicsMapResources,
373 * ::cuGraphicsSubResourceGetMappedArray,
374 * ::cuGraphicsResourceGetMappedPointer,
375 * ::cudaGraphicsD3D9RegisterResource
376 */
377CUresult CUDAAPI cuGraphicsD3D9RegisterResource(CUgraphicsResource *pCudaResource, IDirect3DResource9 *pD3DResource, unsigned int Flags);
378
379/**
380 * \defgroup CUDA_D3D9_DEPRECATED Direct3D 9 Interoperability [DEPRECATED]
381 *
382 * ___MANBRIEF___ deprecated Direct3D 9 interoperability functions of the
383 * low-level CUDA driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
384 *
385 * This section describes deprecated Direct3D 9 interoperability functionality.
386 * @{
387 */
388
389/** Flags to register a resource */
390typedef enum CUd3d9register_flags_enum {
391    CU_D3D9_REGISTER_FLAGS_NONE  = 0x00,
392    CU_D3D9_REGISTER_FLAGS_ARRAY = 0x01,
393} CUd3d9register_flags;
394
395/** Flags to map or unmap a resource */
396typedef enum CUd3d9map_flags_enum {
397    CU_D3D9_MAPRESOURCE_FLAGS_NONE         = 0x00,
398    CU_D3D9_MAPRESOURCE_FLAGS_READONLY     = 0x01,
399    CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD = 0x02,
400} CUd3d9map_flags;
401
402/**
403 * \brief Register a Direct3D resource for access by CUDA
404 *
405 * \deprecated This function is deprecated as of CUDA 3.0.
406 *
407 * Registers the Direct3D resource \p pResource for access by CUDA.
408 *
409 * If this call is successful, then the application will be able to map and
410 * unmap this resource until it is unregistered through
411 * ::cuD3D9UnregisterResource(). Also on success, this call will increase the
412 * internal reference count on \p pResource. This reference count will be
413 * decremented when this resource is unregistered through
414 * ::cuD3D9UnregisterResource().
415 *
416 * This call is potentially high-overhead and should not be called every frame
417 * in interactive applications.
418 *
419 * The type of \p pResource must be one of the following.
420 *
421 * - ::IDirect3DVertexBuffer9: Cannot be used with \p Flags set to
422 *   ::CU_D3D9_REGISTER_FLAGS_ARRAY.
423 * - ::IDirect3DIndexBuffer9: Cannot be used with \p Flags set to
424 *   ::CU_D3D9_REGISTER_FLAGS_ARRAY.
425 * - ::IDirect3DSurface9: Only stand-alone objects of type ::IDirect3DSurface9
426 *   may be explicitly shared. In particular, individual mipmap levels and
427 *   faces of cube maps may not be registered directly. To access individual
428 *   surfaces associated with a texture, one must register the base texture
429 *   object. For restrictions on the \p Flags parameter, see type
430 *   ::IDirect3DBaseTexture9.
431 * - ::IDirect3DBaseTexture9: When a texture is registered, all surfaces
432 *   associated with the all mipmap levels of all faces of the texture will be
433 *   accessible to CUDA.
434 *
435 * The \p Flags argument specifies the mechanism through which CUDA will access
436 * the Direct3D resource. The following values are allowed.
437 *
438 * - CU_D3D9_REGISTER_FLAGS_NONE: Specifies that CUDA will access this resource
439 *   through a ::CUdeviceptr. The pointer, size, and (for textures), pitch for
440 *   each subresource of this allocation may be queried through
441 *   ::cuD3D9ResourceGetMappedPointer(), ::cuD3D9ResourceGetMappedSize(), and
442 *   ::cuD3D9ResourceGetMappedPitch() respectively. This option is valid for
443 *   all resource types.
444 * - ::CU_D3D9_REGISTER_FLAGS_ARRAY: Specifies that CUDA will access this
445 *   resource through a ::CUarray queried on a sub-resource basis through
446 *   ::cuD3D9ResourceGetMappedArray(). This option is only valid for resources
447 *   of type ::IDirect3DSurface9 and subtypes of ::IDirect3DBaseTexture9.
448 *
449 * Not all Direct3D resources of the above types may be used for
450 * interoperability with CUDA. The following are some limitations.
451 *
452 * - The primary rendertarget may not be registered with CUDA.
453 * - Resources allocated as shared may not be registered with CUDA.
454 * - Any resources allocated in ::D3DPOOL_SYSTEMMEM or ::D3DPOOL_MANAGED may
455 *   not be registered with CUDA.
456 * - Textures which are not of a format which is 1, 2, or 4 channels of 8, 16,
457 *   or 32-bit integer or floating-point data cannot be shared.
458 * - Surfaces of depth or stencil formats cannot be shared.
459 *
460 * If Direct3D interoperability is not initialized on this context, then
461 * ::CUDA_ERROR_INVALID_CONTEXT is returned. If \p pResource is of incorrect
462 * type (e.g. is a non-stand-alone ::IDirect3DSurface9) or is already
463 * registered, then ::CUDA_ERROR_INVALID_HANDLE is returned. If \p pResource
464 * cannot be registered then ::CUDA_ERROR_UNKNOWN is returned.
465 *
466 * \param pResource - Resource to register for CUDA access
467 * \param Flags     - Flags for resource registration
468 *
469 * \return
470 * ::CUDA_SUCCESS,
471 * ::CUDA_ERROR_DEINITIALIZED,
472 * ::CUDA_ERROR_NOT_INITIALIZED,
473 * ::CUDA_ERROR_INVALID_CONTEXT,
474 * ::CUDA_ERROR_INVALID_VALUE,
475 * ::CUDA_ERROR_INVALID_HANDLE,
476 * ::CUDA_ERROR_OUT_OF_MEMORY,
477 * ::CUDA_ERROR_UNKNOWN
478 * \notefnerr
479 *
480 * \sa
481 * ::cuGraphicsD3D9RegisterResource
482 */
483__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9RegisterResource(IDirect3DResource9 *pResource, unsigned int Flags);
484
485/**
486 * \brief Unregister a Direct3D resource
487 *
488 * \deprecated This function is deprecated as of CUDA 3.0.
489 *
490 * Unregisters the Direct3D resource \p pResource so it is not accessible by
491 * CUDA unless registered again.
492 *
493 * If \p pResource is not registered, then ::CUDA_ERROR_INVALID_HANDLE is
494 * returned.
495 *
496 * \param pResource - Resource to unregister
497 *
498 * \return
499 * ::CUDA_SUCCESS,
500 * ::CUDA_ERROR_DEINITIALIZED,
501 * ::CUDA_ERROR_NOT_INITIALIZED,
502 * ::CUDA_ERROR_INVALID_CONTEXT,
503 * ::CUDA_ERROR_INVALID_HANDLE,
504 * ::CUDA_ERROR_UNKNOWN
505 * \notefnerr
506 *
507 * \sa
508 * ::cuGraphicsUnregisterResource
509 */
510__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9UnregisterResource(IDirect3DResource9 *pResource);
511
512/**
513 * \brief Map Direct3D resources for access by CUDA
514 *
515 * \deprecated This function is deprecated as of CUDA 3.0.
516 *
517 * Maps the \p count Direct3D resources in \p ppResource for access by CUDA.
518 *
519 * The resources in \p ppResource may be accessed in CUDA kernels until they
520 * are unmapped. Direct3D should not access any resources while they are mapped
521 * by CUDA. If an application does so the results are undefined.
522 *
523 * This function provides the synchronization guarantee that any Direct3D calls
524 * issued before ::cuD3D9MapResources() will complete before any CUDA kernels
525 * issued after ::cuD3D9MapResources() begin.
526 *
527 * If any of \p ppResource have not been registered for use with CUDA or if
528 * \p ppResource contains any duplicate entries, then
529 * ::CUDA_ERROR_INVALID_HANDLE is returned.  If any of \p ppResource are
530 * presently mapped for access by CUDA, then ::CUDA_ERROR_ALREADY_MAPPED is
531 * returned.
532 *
533 * \param count      - Number of resources in ppResource
534 * \param ppResource - Resources to map for CUDA usage
535 *
536 * \return
537 * ::CUDA_SUCCESS,
538 * ::CUDA_ERROR_DEINITIALIZED,
539 * ::CUDA_ERROR_NOT_INITIALIZED,
540 * ::CUDA_ERROR_INVALID_CONTEXT,
541 * ::CUDA_ERROR_INVALID_HANDLE,
542 * ::CUDA_ERROR_ALREADY_MAPPED,
543 * ::CUDA_ERROR_UNKNOWN
544 * \notefnerr
545 *
546 * \sa
547 * ::cuGraphicsMapResources
548 */
549__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9MapResources(unsigned int count, IDirect3DResource9 **ppResource);
550
551/**
552 * \brief Unmaps Direct3D resources
553 *
554 * \deprecated This function is deprecated as of CUDA 3.0.
555 *
556 * Unmaps the \p count Direct3D resources in \p ppResource.
557 *
558 * This function provides the synchronization guarantee that any CUDA kernels
559 * issued before ::cuD3D9UnmapResources() will complete before any Direct3D
560 * calls issued after ::cuD3D9UnmapResources() begin.
561 *
562 * If any of \p ppResource have not been registered for use with CUDA or if
563 * \p ppResource contains any duplicate entries, then
564 * ::CUDA_ERROR_INVALID_HANDLE is returned. If any of \p ppResource are not
565 * presently mapped for access by CUDA, then ::CUDA_ERROR_NOT_MAPPED is
566 * returned.
567 *
568 * \param count      - Number of resources to unmap for CUDA
569 * \param ppResource - Resources to unmap for CUDA
570 *
571 * \return
572 * ::CUDA_SUCCESS,
573 * ::CUDA_ERROR_DEINITIALIZED,
574 * ::CUDA_ERROR_NOT_INITIALIZED,
575 * ::CUDA_ERROR_INVALID_CONTEXT,
576 * ::CUDA_ERROR_INVALID_HANDLE,
577 * ::CUDA_ERROR_NOT_MAPPED,
578 * ::CUDA_ERROR_UNKNOWN
579 * \notefnerr
580 *
581 * \sa
582 * ::cuGraphicsUnmapResources
583 */
584__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9UnmapResources(unsigned int count, IDirect3DResource9 **ppResource);
585
586/**
587 * \brief Set usage flags for mapping a Direct3D resource
588 *
589 * \deprecated This function is deprecated as of Cuda 3.0.
590 *
591 * Set \p Flags for mapping the Direct3D resource \p pResource.
592 *
593 * Changes to \p Flags will take effect the next time \p pResource is mapped.
594 * The \p Flags argument may be any of the following:
595 * - ::CU_D3D9_MAPRESOURCE_FLAGS_NONE: Specifies no hints about how this
596 *   resource will be used. It is therefore assumed that this resource will be
597 *   read from and written to by CUDA kernels. This is the default value.
598 * - ::CU_D3D9_MAPRESOURCE_FLAGS_READONLY: Specifies that CUDA kernels which
599 *   access this resource will not write to this resource.
600 * - ::CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD: Specifies that CUDA kernels
601 *   which access this resource will not read from this resource and will
602 *   write over the entire contents of the resource, so none of the data
603 *   previously stored in the resource will be preserved.
604 *
605 * If \p pResource has not been registered for use with CUDA, then
606 * ::CUDA_ERROR_INVALID_HANDLE is returned. If \p pResource is presently
607 * mapped for access by CUDA, then ::CUDA_ERROR_ALREADY_MAPPED is returned.
608 *
609 * \param pResource - Registered resource to set flags for
610 * \param Flags     - Parameters for resource mapping
611 *
612 * \return
613 * ::CUDA_SUCCESS,
614 * ::CUDA_ERROR_DEINITIALIZED,
615 * ::CUDA_ERROR_NOT_INITIALIZED,
616 * ::CUDA_ERROR_INVALID_CONTEXT,
617 * ::CUDA_ERROR_INVALID_VALUE,
618 * ::CUDA_ERROR_INVALID_HANDLE,
619 * ::CUDA_ERROR_ALREADY_MAPPED
620 * \notefnerr
621 *
622 * \sa ::cuGraphicsResourceSetMapFlags
623 */
624__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9ResourceSetMapFlags(IDirect3DResource9 *pResource, unsigned int Flags);
625
626/**
627 * \brief Get the dimensions of a registered surface
628 *
629 * \deprecated This function is deprecated as of CUDA 3.0.
630 *
631 * Returns in \p *pWidth, \p *pHeight, and \p *pDepth the dimensions of the
632 * subresource of the mapped Direct3D resource \p pResource, which corresponds
633 * to \p Face and \p Level.
634 *
635 * Because anti-aliased surfaces may have multiple samples per pixel, it is
636 * possible that the dimensions of a resource will be an integer factor larger
637 * than the dimensions reported by the Direct3D runtime.
638 *
639 * The parameters \p pWidth, \p pHeight, and \p pDepth are optional. For 2D
640 * surfaces, the value returned in \p *pDepth will be 0.
641 *
642 * If \p pResource is not of type ::IDirect3DBaseTexture9 or
643 * ::IDirect3DSurface9 or if \p pResource has not been registered for use with
644 * CUDA, then ::CUDA_ERROR_INVALID_HANDLE is returned.
645 *
646 * For usage requirements of \p Face and \p Level parameters, see
647 * ::cuD3D9ResourceGetMappedPointer().
648 *
649 * \param pWidth    - Returned width of surface
650 * \param pHeight   - Returned height of surface
651 * \param pDepth    - Returned depth of surface
652 * \param pResource - Registered resource to access
653 * \param Face      - Face of resource to access
654 * \param Level     - Level of resource to access
655 *
656 * \return
657 * ::CUDA_SUCCESS,
658 * ::CUDA_ERROR_DEINITIALIZED,
659 * ::CUDA_ERROR_NOT_INITIALIZED,
660 * ::CUDA_ERROR_INVALID_CONTEXT,
661 * ::CUDA_ERROR_INVALID_VALUE,
662 * ::CUDA_ERROR_INVALID_HANDLE
663 * \notefnerr
664 *
665 * \sa ::cuGraphicsSubResourceGetMappedArray
666 */
667__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9ResourceGetSurfaceDimensions(size_t *pWidth, size_t *pHeight, size_t *pDepth, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
668
669/**
670 * \brief Get an array through which to access a subresource of a Direct3D
671 * resource which has been mapped for access by CUDA
672 *
673 * \deprecated This function is deprecated as of CUDA 3.0.
674 *
675 * Returns in \p *pArray an array through which the subresource of the mapped
676 * Direct3D resource \p pResource which corresponds to \p Face and \p Level may
677 * be accessed. The value set in \p pArray may change every time that
678 * \p pResource is mapped.
679 *
680 * If \p pResource is not registered then ::CUDA_ERROR_INVALID_HANDLE is
681 * returned. If \p pResource was not registered with usage flags
682 * ::CU_D3D9_REGISTER_FLAGS_ARRAY then ::CUDA_ERROR_INVALID_HANDLE is
683 * returned. If \p pResource is not mapped then ::CUDA_ERROR_NOT_MAPPED is
684 * returned.
685 *
686 * For usage requirements of \p Face and \p Level parameters, see
687 * ::cuD3D9ResourceGetMappedPointer().
688 *
689 * \param pArray    - Returned array corresponding to subresource
690 * \param pResource - Mapped resource to access
691 * \param Face      - Face of resource to access
692 * \param Level     - Level of resource to access
693 *
694 * \return
695 * ::CUDA_SUCCESS,
696 * ::CUDA_ERROR_DEINITIALIZED,
697 * ::CUDA_ERROR_NOT_INITIALIZED,
698 * ::CUDA_ERROR_INVALID_CONTEXT,
699 * ::CUDA_ERROR_INVALID_VALUE,
700 * ::CUDA_ERROR_INVALID_HANDLE,
701 * ::CUDA_ERROR_NOT_MAPPED
702 * \notefnerr
703 *
704 * \sa ::cuGraphicsSubResourceGetMappedArray
705 */
706__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9ResourceGetMappedArray(CUarray *pArray, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
707
708/**
709 * \brief Get the pointer through which to access a subresource of a Direct3D
710 * resource which has been mapped for access by CUDA
711 *
712 * \deprecated This function is deprecated as of CUDA 3.0.
713 *
714 * Returns in \p *pDevPtr the base pointer of the subresource of the mapped
715 * Direct3D resource \p pResource, which corresponds to \p Face and \p Level.
716 * The value set in \p pDevPtr may change every time that \p pResource is
717 * mapped.
718 *
719 * If \p pResource is not registered, then ::CUDA_ERROR_INVALID_HANDLE is
720 * returned. If \p pResource was not registered with usage flags
721 * ::CU_D3D9_REGISTER_FLAGS_NONE, then ::CUDA_ERROR_INVALID_HANDLE is returned.
722 * If \p pResource is not mapped, then ::CUDA_ERROR_NOT_MAPPED is returned.
723 *
724 * If \p pResource is of type ::IDirect3DCubeTexture9, then \p Face must one
725 * of the values enumerated by type ::D3DCUBEMAP_FACES.  For all other types
726 * \p Face must be 0. If \p Face is invalid, then ::CUDA_ERROR_INVALID_VALUE
727 * is returned.
728 *
729 * If \p pResource is of type ::IDirect3DBaseTexture9, then \p Level must
730 * correspond to a valid mipmap level. At present only mipmap level 0 is
731 * supported. For all other types \p Level must be 0. If \p Level is invalid,
732 * then ::CUDA_ERROR_INVALID_VALUE is returned.
733 *
734 * \param pDevPtr     - Returned pointer corresponding to subresource
735 * \param pResource   - Mapped resource to access
736 * \param Face        - Face of resource to access
737 * \param Level       - Level of resource to access
738 *
739 * \return
740 * ::CUDA_SUCCESS,
741 * ::CUDA_ERROR_DEINITIALIZED,
742 * ::CUDA_ERROR_NOT_INITIALIZED,
743 * ::CUDA_ERROR_INVALID_CONTEXT,
744 * ::CUDA_ERROR_INVALID_VALUE,
745 * ::CUDA_ERROR_INVALID_HANDLE,
746 * ::CUDA_ERROR_NOT_MAPPED
747 * \notefnerr
748 *
749 * \sa ::cuGraphicsResourceGetMappedPointer
750 */
751__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9ResourceGetMappedPointer(CUdeviceptr *pDevPtr, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
752
753/**
754 * \brief Get the size of a subresource of a Direct3D resource which has been
755 * mapped for access by CUDA
756 *
757 * \deprecated This function is deprecated as of CUDA 3.0.
758 *
759 * Returns in \p *pSize the size of the subresource of the mapped Direct3D
760 * resource \p pResource, which corresponds to \p Face and \p Level. The value
761 * set in \p pSize may change every time that \p pResource is mapped.
762 *
763 * If \p pResource has not been registered for use with CUDA, then
764 * ::CUDA_ERROR_INVALID_HANDLE is returned. If \p pResource was not registered
765 * with usage flags ::CU_D3D9_REGISTER_FLAGS_NONE, then
766 * ::CUDA_ERROR_INVALID_HANDLE is returned. If \p pResource is not mapped for
767 * access by CUDA, then ::CUDA_ERROR_NOT_MAPPED is returned.
768 *
769 * For usage requirements of \p Face and \p Level parameters, see
770 * ::cuD3D9ResourceGetMappedPointer.
771 *
772 * \param pSize       - Returned size of subresource
773 * \param pResource   - Mapped resource to access
774 * \param Face        - Face of resource to access
775 * \param Level       - Level of resource to access
776 *
777 * \return
778 * ::CUDA_SUCCESS,
779 * ::CUDA_ERROR_DEINITIALIZED,
780 * ::CUDA_ERROR_NOT_INITIALIZED,
781 * ::CUDA_ERROR_INVALID_CONTEXT,
782 * ::CUDA_ERROR_INVALID_VALUE,
783 * ::CUDA_ERROR_INVALID_HANDLE,
784 * ::CUDA_ERROR_NOT_MAPPED
785 * \notefnerr
786 *
787 * \sa ::cuGraphicsResourceGetMappedPointer
788 */
789__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9ResourceGetMappedSize(size_t *pSize, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
790
791/**
792 * \brief Get the pitch of a subresource of a Direct3D resource which has been
793 * mapped for access by CUDA
794 *
795 * \deprecated This function is deprecated as of CUDA 3.0.
796 *
797 * Returns in \p *pPitch and \p *pPitchSlice the pitch and Z-slice pitch of
798 * the subresource of the mapped Direct3D resource \p pResource, which
799 * corresponds to \p Face and \p Level. The values set in \p pPitch and
800 * \p pPitchSlice may change every time that \p pResource is mapped.
801 *
802 * The pitch and Z-slice pitch values may be used to compute the location of a
803 * sample on a surface as follows.
804 *
805 * For a 2D surface, the byte offset of the sample at position \b x, \b y from
806 * the base pointer of the surface is:
807 *
808 * \b y * \b pitch + (<b>bytes per pixel</b>) * \b x
809 *
810 * For a 3D surface, the byte offset of the sample at position \b x, \b y,
811 * \b z from the base pointer of the surface is:
812 *
813 * \b z* \b slicePitch + \b y * \b pitch + (<b>bytes per pixel</b>) * \b x
814 *
815 * Both parameters \p pPitch and \p pPitchSlice are optional and may be set to
816 * NULL.
817 *
818 * If \p pResource is not of type ::IDirect3DBaseTexture9 or one of its
819 * sub-types or if \p pResource has not been registered for use with CUDA,
820 * then ::cudaErrorInvalidResourceHandle is returned. If \p pResource was not
821 * registered with usage flags ::CU_D3D9_REGISTER_FLAGS_NONE, then
822 * ::CUDA_ERROR_INVALID_HANDLE is returned. If \p pResource is not mapped
823 * for access by CUDA then ::CUDA_ERROR_NOT_MAPPED is returned.
824 *
825 * For usage requirements of \p Face and \p Level parameters, see
826 * ::cuD3D9ResourceGetMappedPointer().
827 *
828 * \param pPitch      - Returned pitch of subresource
829 * \param pPitchSlice - Returned Z-slice pitch of subresource
830 * \param pResource   - Mapped resource to access
831 * \param Face        - Face of resource to access
832 * \param Level       - Level of resource to access
833 *
834 * \return
835 * ::CUDA_SUCCESS,
836 * ::CUDA_ERROR_DEINITIALIZED,
837 * ::CUDA_ERROR_NOT_INITIALIZED,
838 * ::CUDA_ERROR_INVALID_CONTEXT,
839 * ::CUDA_ERROR_INVALID_VALUE,
840 * ::CUDA_ERROR_INVALID_HANDLE,
841 * ::CUDA_ERROR_NOT_MAPPED
842 * \notefnerr
843 *
844 * \sa ::cuGraphicsSubResourceGetMappedArray
845 */
846__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9ResourceGetMappedPitch(size_t *pPitch, size_t *pPitchSlice, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
847
848/* CUDA 1.x compatibility API. These functions are deprecated, please use the ones above. */
849__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9Begin(IDirect3DDevice9 *pDevice);
850__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9End(void);
851__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9RegisterVertexBuffer(IDirect3DVertexBuffer9 *pVB);
852__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9MapVertexBuffer(CUdeviceptr *pDevPtr, size_t *pSize, IDirect3DVertexBuffer9 *pVB);
853__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9UnmapVertexBuffer(IDirect3DVertexBuffer9 *pVB);
854__CUDA_DEPRECATED CUresult CUDAAPI cuD3D9UnregisterVertexBuffer(IDirect3DVertexBuffer9 *pVB);
855
856/** @} */ /* END CUDA_D3D9_DEPRECATED */
857/** @} */ /* END CUDA_D3D9 */
858
859
860/**
861 * CUDA API versioning support
862 */
863#if defined(__CUDA_API_VERSION_INTERNAL)
864    #undef cuD3D9CtxCreate
865    #undef cuD3D9ResourceGetSurfaceDimensions
866    #undef cuD3D9ResourceGetMappedPointer
867    #undef cuD3D9ResourceGetMappedSize
868    #undef cuD3D9ResourceGetMappedPitch
869    #undef cuD3D9MapVertexBuffer
870
871    CUresult CUDAAPI cuD3D9CtxCreate(CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, IDirect3DDevice9 *pD3DDevice);
872    CUresult CUDAAPI cuD3D9ResourceGetSurfaceDimensions(unsigned int *pWidth, unsigned int *pHeight, unsigned int *pDepth, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
873    CUresult CUDAAPI cuD3D9ResourceGetMappedPointer(CUdeviceptr_v1 *pDevPtr, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
874    CUresult CUDAAPI cuD3D9ResourceGetMappedSize(unsigned int *pSize, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
875    CUresult CUDAAPI cuD3D9ResourceGetMappedPitch(unsigned int *pPitch, unsigned int *pPitchSlice, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);
876    CUresult CUDAAPI cuD3D9MapVertexBuffer(CUdeviceptr_v1 *pDevPtr, unsigned int *pSize, IDirect3DVertexBuffer9 *pVB);
877#endif /* __CUDA_API_VERSION_INTERNAL */
878
879#ifdef __cplusplus
880};
881#endif
882
883#undef __CUDA_DEPRECATED
884
885#endif
886
887 
codekingpro/portable-devtools · Team Ai