Fix T54105: random walk SSS missing in branched indirect paths.
[blender-staging.git] / intern / gpudirect / dvpapi.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2015, Blender Foundation
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): Blender Foundation.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file gpudirect/dvpapi.h
29  *  \ingroup gpudirect
30  */
31
32 #ifndef __DVPAPI_H__
33 #define __DVPAPI_H__
34
35 #ifdef WIN32
36
37 #include <stdlib.h>
38 #include <stdint.h>
39
40 #include "GL/glew.h"
41
42 #if defined(__GNUC__) && __GNUC__>=4
43 # define DVPAPI extern __attribute__ ((visibility("default")))
44 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
45 # define DVPAPI extern __global
46 #else
47 # define DVPAPI extern
48 #endif
49
50 #define DVPAPIENTRY
51 #define DVP_MAJOR_VERSION  1
52 #define DVP_MINOR_VERSION  63
53
54 typedef uint64_t DVPBufferHandle;
55 typedef uint64_t DVPSyncObjectHandle;
56
57 typedef enum {
58         DVP_STATUS_OK                        =  0, 
59         DVP_STATUS_INVALID_PARAMETER         =  1,
60         DVP_STATUS_UNSUPPORTED               =  2,
61         DVP_STATUS_END_ENUMERATION           =  3,
62         DVP_STATUS_INVALID_DEVICE            =  4,
63         DVP_STATUS_OUT_OF_MEMORY             =  5,
64         DVP_STATUS_INVALID_OPERATION         =  6,
65         DVP_STATUS_TIMEOUT                   =  7,
66         DVP_STATUS_INVALID_CONTEXT           =  8,
67         DVP_STATUS_INVALID_RESOURCE_TYPE     =  9,
68         DVP_STATUS_INVALID_FORMAT_OR_TYPE    =  10,
69         DVP_STATUS_DEVICE_UNINITIALIZED      =  11,
70         DVP_STATUS_UNSIGNALED                =  12,
71         DVP_STATUS_SYNC_ERROR                =  13,
72         DVP_STATUS_SYNC_STILL_BOUND          =  14,
73         DVP_STATUS_ERROR                     = -1, 
74 } DVPStatus;
75
76 // Pixel component formats stored in the system memory buffer
77 // analogous to those defined in the OpenGL API, except for 
78 // DVP_BUFFER and the DVP_CUDA_* types. DVP_BUFFER provides 
79 // an unspecified format type to allow for general interpretation
80 // of the bytes at a later stage (in GPU shader). Note that not 
81 // all paths will achieve optimal speeds due to lack of HW support 
82 // for the transformation. The CUDA types are to be used when
83 // copying to/from a system memory buffer from-to a CUDA array, as the 
84 // CUDA array implies a memory layout that matches the array.
85 typedef enum {
86         DVP_BUFFER,                   // Buffer treated as a raw buffer 
87                                       // and copied directly into GPU buffer
88                                       // without any interpretation of the
89                                       // stored bytes.
90         DVP_DEPTH_COMPONENT,
91         DVP_RGBA,
92         DVP_BGRA,
93         DVP_RED,
94         DVP_GREEN,
95         DVP_BLUE,
96         DVP_ALPHA,
97         DVP_RGB,
98         DVP_BGR,
99         DVP_LUMINANCE,
100         DVP_LUMINANCE_ALPHA,
101         DVP_CUDA_1_CHANNEL,
102         DVP_CUDA_2_CHANNELS,
103         DVP_CUDA_4_CHANNELS,
104         DVP_RGBA_INTEGER,
105         DVP_BGRA_INTEGER,
106         DVP_RED_INTEGER,
107         DVP_GREEN_INTEGER,
108         DVP_BLUE_INTEGER,
109         DVP_ALPHA_INTEGER,
110         DVP_RGB_INTEGER,
111         DVP_BGR_INTEGER,
112         DVP_LUMINANCE_INTEGER,
113         DVP_LUMINANCE_ALPHA_INTEGER,
114 } DVPBufferFormats;
115
116 // Possible pixel component storage types for system memory buffers
117 typedef enum {
118         DVP_UNSIGNED_BYTE,
119         DVP_BYTE,
120         DVP_UNSIGNED_SHORT,
121         DVP_SHORT,
122         DVP_UNSIGNED_INT,
123         DVP_INT,
124         DVP_FLOAT,
125         DVP_HALF_FLOAT,
126         DVP_UNSIGNED_BYTE_3_3_2,
127         DVP_UNSIGNED_BYTE_2_3_3_REV,
128         DVP_UNSIGNED_SHORT_5_6_5,
129         DVP_UNSIGNED_SHORT_5_6_5_REV,
130         DVP_UNSIGNED_SHORT_4_4_4_4,
131         DVP_UNSIGNED_SHORT_4_4_4_4_REV,
132         DVP_UNSIGNED_SHORT_5_5_5_1,
133         DVP_UNSIGNED_SHORT_1_5_5_5_REV,
134         DVP_UNSIGNED_INT_8_8_8_8,
135         DVP_UNSIGNED_INT_8_8_8_8_REV,
136         DVP_UNSIGNED_INT_10_10_10_2,
137         DVP_UNSIGNED_INT_2_10_10_10_REV,
138 } DVPBufferTypes;
139
140 // System memory descriptor describing the size and storage formats
141 // of the buffer
142 typedef struct DVPSysmemBufferDescRec {
143         uint32_t width;                     // Buffer Width
144         uint32_t height;                    // Buffer Height
145         uint32_t stride;                    // Stride
146         uint32_t size;                      // Specifies the surface size if 
147                                             // format == DVP_BUFFER
148         DVPBufferFormats format;            // see enum above
149         DVPBufferTypes type;                // see enum above
150         void *bufAddr;                      // Buffer memory address
151 } DVPSysmemBufferDesc;
152
153 // Flags specified at sync object creation:
154 // ----------------------------------------
155 // Tells the implementation to use events wherever
156 // possible instead of software spin loops. Note if HW
157 // wait operations are supported by the implementation
158 // then events will not be used in the dvpMemcpy*
159 // functions. In such a case, events may still be used
160 // in dvpSyncObjClientWait* functions.
161 #define DVP_SYNC_OBJECT_FLAGS_USE_EVENTS      0x00000001
162
163 typedef struct DVPSyncObjectDescRec {
164         uint32_t *sem;               // Location to write semaphore value
165         uint32_t  flags;             // See above DVP_SYNC_OBJECT_FLAGS_* bits
166         DVPStatus (*externalClientWaitFunc) (DVPSyncObjectHandle sync, 
167                                              uint32_t value,
168                                              bool GEQ, // If true then the function should wait for the sync value to be 
169                                                        // greater than or equal to the value parameter. Otherwise just a
170                                                        // straight forward equality comparison should be performed.
171                                              uint64_t timeout);
172                                              // If non-null, externalClientWaitFunc allows the DVP library
173                                              // to call the application to wait for a sync object to be
174                                              // released. This allows the application to create events, 
175                                              // which can be triggered on device interrupts instead of
176                                              // using spin loops inside the DVP library. Upon succeeding
177                                              // the function must return DVP_STATUS_OK, non-zero for failure 
178                                              // and DVP_STATUS_TIMEOUT on timeout. The externalClientWaitFunc should
179                                              // not alter the current GL or CUDA context state
180 } DVPSyncObjectDesc;
181
182 // Time used when event timeouts should be ignored
183 #define DVP_TIMEOUT_IGNORED                   0xFFFFFFFFFFFFFFFFull
184
185 typedef DVPStatus (DVPAPIENTRY * PFNDVPBEGIN) (void);
186 typedef DVPStatus (DVPAPIENTRY * PFNDVPEND)   (void);
187 typedef DVPStatus (DVPAPIENTRY * PFNDVPCREATEBUFFER)(DVPSysmemBufferDesc *desc, DVPBufferHandle *hBuf);
188 typedef DVPStatus (DVPAPIENTRY * PFNDVPDESTROYBUFFER)(DVPBufferHandle  hBuf);
189 typedef DVPStatus (DVPAPIENTRY * PFNDVPFREEBUFFER)(DVPBufferHandle gpuBufferHandle);
190 typedef DVPStatus (DVPAPIENTRY * PFNDVPMEMCPYLINED)(DVPBufferHandle      srcBuffer,
191                                                     DVPSyncObjectHandle  srcSync,
192                                                     uint32_t             srcAcquireValue,
193                                                     uint64_t             timeout,
194                                                     DVPBufferHandle      dstBuffer,
195                                                     DVPSyncObjectHandle  dstSync,
196                                                     uint32_t             dstReleaseValue,
197                                                     uint32_t             startingLine,
198                                                     uint32_t             numberOfLines);
199 typedef DVPStatus (DVPAPIENTRY * PFNDVPMEMCPY)(DVPBufferHandle srcBuffer,
200                                                DVPSyncObjectHandle  srcSync,
201                                                uint32_t             srcAcquireValue,
202                                                uint64_t             timeout,
203                                                DVPBufferHandle      dstBuffer,
204                                                DVPSyncObjectHandle  dstSync,
205                                                uint32_t             dstReleaseValue,
206                                                uint32_t             srcOffset,
207                                                uint32_t             dstOffset,
208                                                uint32_t             count);
209 typedef DVPStatus (DVPAPIENTRY * PFNDVPIMPORTSYNCOBJECT)(DVPSyncObjectDesc *desc, 
210                                                          DVPSyncObjectHandle *syncObject);
211 typedef DVPStatus (DVPAPIENTRY * PFNDVPFREESYNCOBJECT)(DVPSyncObjectHandle syncObject);
212 typedef DVPStatus (DVPAPIENTRY * PFNDVPGETREQUIREDCONSTANTSGLCTX)(uint32_t *bufferAddrAlignment,
213                                                                   uint32_t *bufferGPUStrideAlignment,
214                                                                   uint32_t *semaphoreAddrAlignment,
215                                                                   uint32_t *semaphoreAllocSize,
216                                                                   uint32_t *semaphorePayloadOffset,
217                                                                   uint32_t *semaphorePayloadSize);
218 typedef DVPStatus (DVPAPIENTRY * PFNDVPBINDTOGLCTX)(DVPBufferHandle hBuf);
219 typedef DVPStatus (DVPAPIENTRY * PFNDVPUNBINDFROMGLCTX)(DVPBufferHandle hBuf);
220 typedef DVPStatus (DVPAPIENTRY * PFNDVPMAPBUFFERENDAPI)(DVPBufferHandle gpuBufferHandle);
221 typedef DVPStatus (DVPAPIENTRY * PFNDVPMAPBUFFERWAITDVP)(DVPBufferHandle gpuBufferHandle);
222 typedef DVPStatus (DVPAPIENTRY * PFNDVPMAPBUFFERENDDVP)(DVPBufferHandle gpuBufferHandle);
223 typedef DVPStatus (DVPAPIENTRY * PFNDVPMAPBUFFERWAITAPI)(DVPBufferHandle gpuBufferHandle);
224 typedef DVPStatus (DVPAPIENTRY * PFNDVPCREATEGPUTEXTUREGL)(GLuint texID, 
225                                                            DVPBufferHandle *bufferHandle);
226
227 // Flags supplied to the dvpInit* functions:
228 //
229 // DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT is only supported for OpenGL
230 // contexts and is the only supported flag for CUDA. It allows for 
231 // certain cases to be optimized by sharing the context 
232 // of the application for the DVP operations. This removes the
233 // need to do certain synchronizations. See issue 5 for parallel
234 // issues. When used, the app's GL context must be current for all calls 
235 // to the DVP library.
236 // the DVP library.
237 #define DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT    0x000000001
238
239 //------------------------------------------------------------------------
240 // Function:      dvpInitGLContext
241 //
242 //                To be called before any DVP resources are allocated.
243 //                This call allows for specification of flags that may
244 //                change the way DVP operations are performed. See above
245 //                for the list of flags.
246 //
247 //                The OpenGL context must be current at time of call.
248 //
249 // Parameters:    flags[IN]  - Buffer description structure
250 // 
251 // Returns:       DVP_STATUS_OK
252 //                DVP_STATUS_INVALID_PARAMETER 
253 //                DVP_STATUS_ERROR
254 //------------------------------------------------------------------------
255 extern DVPStatus dvpInitGLContext(uint32_t flags);
256
257 //------------------------------------------------------------------------
258 // Function:      dvpCloseGLContext
259 //
260 //                Function to be called when app closes to allow freeing
261 //                of any DVP library allocated resources.
262 //
263 //                The OpenGL context must be current at time of call.
264 //
265 // Parameters:    none
266 // 
267 // Returns:       DVP_STATUS_OK
268 //                DVP_STATUS_INVALID_PARAMETER    
269 //                DVP_STATUS_ERROR
270 //------------------------------------------------------------------------
271 extern DVPStatus dvpCloseGLContext();
272
273 //------------------------------------------------------------------------
274 // Function:      dvpGetLibrayVersion
275 //
276 // Description:   Returns the current version of the library
277 //
278 // Parameters:    major[OUT]     - returned major version
279 //                minor[OUT]     - returned minor version
280 //
281 // Returns:       DVP_STATUS_OK
282 //------------------------------------------------------------------------
283 extern DVPStatus dvpGetLibrayVersion(uint32_t *major, uint32_t *minor);
284
285 //------------------------------------------------------------------------
286 // Function:      dvpBegin 
287 //
288 // Description:   dvpBegin must be called before any combination of DVP
289 //                function calls dvpMemCpy*, dvpMapBufferWaitDVP,
290 //                dvpSyncObjClientWait*, and dvpMapBufferEndDVP. After 
291 //                the last of these functions has been called is dvpEnd
292 //                must be called. This allows for more efficient batched 
293 //                DVP operations.
294 //
295 // Parameters:    none
296 // 
297 // Returns:       DVP_STATUS_OK
298 //                DVP_STATUS_ERROR
299 //------------------------------------------------------------------------
300 #define dvpBegin DVPAPI_GET_FUN(__dvpBegin)
301
302 //------------------------------------------------------------------------
303 // Function:      dvpEnd
304 //
305 // Description:   dvpEnd signals the end of a batch of DVP function calls
306 //                that began with dvpBegin
307 //
308 // Parameters:    none
309 // 
310 // Returns:       DVP_STATUS_OK
311 //                DVP_STATUS_ERROR
312 //------------------------------------------------------------------------
313 #define dvpEnd DVPAPI_GET_FUN(__dvpEnd)
314
315
316 //------------------------------------------------------------------------
317 // Function:      dvpCreateBuffer
318 //
319 // Description:   Create a DVP buffer using system memory, wrapping a user
320 //                passed pointer. The pointer must be aligned 
321 //                to values returned by dvpGetRequiredAlignments*
322 //
323 // Parameters:    desc[IN]  - Buffer description structure
324 //                hBuf[OUT] - DVP Buffer handle
325 // 
326 // Returns:       DVP_STATUS_OK                
327 //                DVP_STATUS_INVALID_PARAMETER 
328 //                DVP_STATUS_ERROR           
329 //------------------------------------------------------------------------
330 #define dvpCreateBuffer DVPAPI_GET_FUN(__dvpCreateBuffer)
331
332
333 //------------------------------------------------------------------------
334 // Function:      dvpDestroyBuffer
335 //
336 // Description:   Destroy a previously created DVP buffer.
337 //
338 // Parameters:    hBuf[IN] - DVP Buffer handle
339 // 
340 // Returns:       DVP_STATUS_OK                
341 //                DVP_STATUS_INVALID_PARAMETER
342 //                DVP_STATUS_ERROR  
343 //------------------------------------------------------------------------
344 #define dvpDestroyBuffer DVPAPI_GET_FUN(__dvpDestroyBuffer)
345
346 //------------------------------------------------------------------------
347 // Function:      dvpFreeBuffer
348 //
349 // Description:   dvpFreeBuffer frees the DVP buffer reference
350 //
351 // Parameters:    gpuBufferHandle[IN] - DVP Buffer handle
352 // 
353 // Returns:       DVP_STATUS_OK
354 //                DVP_STATUS_INVALID_PARAMETER
355 //                DVP_STATUS_ERROR
356 //------------------------------------------------------------------------
357 #define dvpFreeBuffer DVPAPI_GET_FUN(__dvpFreeBuffer)
358
359 //------------------------------------------------------------------------
360 // Function:      dvpMemcpyLined
361 //
362 // Description:   dvpMemcpyLined provides buffer copies between a
363 //                DVP sysmem buffer and a graphics API texture (as opposed to
364 //                a buffer type). Other buffer types (such
365 //                as graphics API buffers) return DVP_STATUS_INVALID_PARAMETER.
366 //
367 //                In addition, see "dvpMemcpy* general comments" above.
368 //
369 // Parameters:    srcBuffer[IN]        - src buffer handle
370 //                srcSync[IN]          - sync to acquire on before transfer
371 //                srcAcquireValue[IN]  - value to acquire on before transfer
372 //                timeout[IN]          - time out value in nanoseconds.
373 //                dstBuffer[IN]        - src buffer handle
374 //                dstSync[IN]          - sync to release on transfer completion
375 //                dstReleaseValue[IN]  - value to release on completion
376 //                startingLine[IN]     - starting line of buffer
377 //                numberOfLines[IN]    - number of lines to copy
378 //
379 // Returns:       DVP_STATUS_OK
380 //                DVP_STATUS_INVALID_PARAMETER
381 //                DVP_STATUS_ERROR
382 //
383 // GL state effected: The following GL state may be altered by this
384 //               function (not relevant if no GL source or destination
385 //               is used):
386 //                -GL_PACK_SKIP_ROWS, GL_PACK_SKIP_PIXELS, 
387 //                 GL_PACK_ROW_LENGTH
388 //                -The buffer bound to GL_PIXEL_PACK_BUFFER
389 //                -The current bound framebuffer (GL_FRAMEBUFFER_EXT)
390 //                -GL_UNPACK_SKIP_ROWS, GL_UNPACK_SKIP_PIXELS,
391 //                 GL_UNPACK_ROW_LENGTH
392 //                -The buffer bound to GL_PIXEL_UNPACK_BUFFER
393 //                -The texture bound to GL_TEXTURE_2D
394 //------------------------------------------------------------------------
395 #define dvpMemcpyLined DVPAPI_GET_FUN(__dvpMemcpyLined)
396
397
398 //------------------------------------------------------------------------
399 // Function:      dvpMemcpy
400 //
401 // Description:   dvpMemcpy provides buffer copies between a
402 //                DVP sysmem buffer and a graphics API pure buffer (as 
403 //                opposed to a texture type). Other buffer types (such
404 //                as graphics API textures) return 
405 //                DVP_STATUS_INVALID_PARAMETER.
406 //
407 //                The start address of the srcBuffer is given by srcOffset
408 //                and the dstBuffer start address is given by dstOffset.
409 //
410 //                In addition, see "dvpMemcpy* general comments" above.
411 //
412 // Parameters:    srcBuffer[IN]             - src buffer handle
413 //                srcSync[IN]               - sync to acquire on before transfer
414 //                srcAcquireValue[IN]       - value to acquire on before transfer
415 //                timeout[IN]               - time out value in nanoseconds.
416 //                dstBuffer[IN]             - src buffer handle
417 //                dstSync[IN]               - sync to release on completion
418 //                dstReleaseValue[IN]       - value to release on completion
419 //                uint32_t srcOffset[IN]    - byte offset of srcBuffer
420 //                uint32_t dstOffset[IN]    - byte offset of dstBuffer
421 //                uint32_t count[IN]        - number of bytes to copy
422 //
423 // Returns:       DVP_STATUS_OK
424 //                DVP_STATUS_INVALID_PARAMETER
425 //                DVP_STATUS_ERROR
426 //
427 // GL state effected: The following GL state may be altered by this
428 //               function (not relevant if no GL source or destination
429 //               is used):
430 //                 - The buffer bound to GL_COPY_WRITE_BUFFER
431 //                 - The buffer bound to GL_COPY_READ_BUFFER
432 // 
433 //------------------------------------------------------------------------
434 #define dvpMemcpy DVPAPI_GET_FUN(__dvpMemcpy)
435
436 //------------------------------------------------------------------------
437 // Function:      dvpImportSyncObject
438 //
439 // Description:   dvpImportSyncObject creates a DVPSyncObject from the 
440 //                DVPSyncObjectDesc. Note that a sync object is not 
441 //                supported for copy operations targeting different APIs.
442 //                This means, for example, it is illegal to call dvpMemCpy*
443 //                for source or target GL texture with sync object A and 
444 //                then later use that same sync object in dvpMemCpy* 
445 //                operation for a source or target CUDA buffer. The same
446 //                semaphore memory can still be used for two different sync
447 //                objects.
448 //
449 // Parameters:    desc[IN]        - data describing the sync object
450 //                syncObject[OUT] - handle to sync object
451 //
452 // Returns:       DVP_STATUS_OK
453 //                DVP_STATUS_INVALID_PARAMETER
454 //                DVP_STATUS_ERROR
455 //------------------------------------------------------------------------
456 #define dvpImportSyncObject DVPAPI_GET_FUN(__dvpImportSyncObject)
457
458 //------------------------------------------------------------------------
459 // Function:      dvpFreeSyncObject
460 //
461 // Description:   dvpFreeSyncObject waits for any outstanding releases on 
462 //                this sync object before freeing the resources allocated for
463 //                the specified sync object. The application must make sure
464 //                any outstanding acquire operations have already been
465 //                completed.
466 //
467 //                If OpenGL is being used and the app's GL context is being
468 //                shared (via the DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT flag),
469 //                then dvpFreeSyncObject needs to be called while each context,
470 //                on which the sync object was used, is current. If 
471 //                DVP_DEVICE_FLAGS_SHARE_APP_CONTEXT is used and there are out
472 //                standing contexts from which this sync object must be free'd
473 //                then dvpFreeSyncObject will return DVP_STATUS_SYNC_STILL_BOUND.
474 //
475 // Parameters:    syncObject[IN] - handle to sync object to be free'd
476 //
477 // Returns:       DVP_STATUS_OK
478 //                DVP_STATUS_INVALID_PARAMETER
479 //                DVP_STATUS_ERROR
480 //                DVP_STATUS_SYNC_STILL_BOUND
481 //------------------------------------------------------------------------
482 #define dvpFreeSyncObject DVPAPI_GET_FUN(__dvpFreeSyncObject)
483
484
485 //------------------------------------------------------------------------
486 // Function:      dvpMapBufferEndAPI
487 //
488 // Description:   Tells DVP to setup a signal for this buffer in the
489 //                callers API context or device. The signal follows all
490 //                previous API operations up to this point and, thus,
491 //                allows subsequent DVP calls to know when then this buffer
492 //                is ready for use within the DVP library. This function
493 //                would be followed by a call to dvpMapBufferWaitDVP to
494 //                synchronize rendering in the API stream and the DVP 
495 //                stream.
496 //
497 //                If OpenGL or CUDA is used, the OpenGL/CUDA context
498 //                must be current at time of call.
499 //
500 //                The use of dvpMapBufferEndAPI is NOT recommended for
501 //                CUDA synchronisation, as it is more optimal to use a
502 //                applcation CUDA stream in conjunction with 
503 //                dvpMapBufferEndCUDAStream. This allows the driver to 
504 //                do optimisations, such as parllelise the copy operations
505 //                and compute.
506 //
507 //                This must be called outside the dvpBegin/dvpEnd pair. In
508 //                addition, this call is not thread safe and must be called
509 //                from or fenced against the rendering thread associated with
510 //                the context or device.
511 //
512 // Parameters:    gpuBufferHandle[IN] - buffer to track
513 //
514 // Returns:       DVP_STATUS_OK
515 //                DVP_STATUS_INVALID_PARAMETER
516 //                DVP_STATUS_ERROR
517 //                DVP_STATUS_UNSIGNALED     - returned if the API is 
518 //                     unable to place a signal in the API context queue
519 //------------------------------------------------------------------------
520 #define dvpMapBufferEndAPI DVPAPI_GET_FUN(__dvpMapBufferEndAPI)
521
522 //------------------------------------------------------------------------
523 // Function:      dvpMapBufferEndAPI
524 //
525 // Description:   Tells DVP to setup a signal for this buffer in the
526 //                callers API context or device. The signal follows all
527 //                previous API operations up to this point and, thus,
528 //                allows subsequent DVP calls to know when then this buffer
529 //                is ready for use within the DVP library. This function
530 //                would be followed by a call to dvpMapBufferWaitDVP to
531 //                synchronize rendering in the API stream and the DVP 
532 //                stream.
533 //
534 //                If OpenGL or CUDA is used, the OpenGL/CUDA context
535 //                must be current at time of call.
536 //
537 //                The use of dvpMapBufferEndAPI is NOT recommended for
538 //                CUDA synchronisation, as it is more optimal to use a
539 //                applcation CUDA stream in conjunction with 
540 //                dvpMapBufferEndCUDAStream. This allows the driver to 
541 //                do optimisations, such as parllelise the copy operations
542 //                and compute.
543 //
544 //                This must be called outside the dvpBegin/dvpEnd pair. In
545 //                addition, this call is not thread safe and must be called
546 //                from or fenced against the rendering thread associated with
547 //                the context or device.
548 //
549 // Parameters:    gpuBufferHandle[IN] - buffer to track
550 //
551 // Returns:       DVP_STATUS_OK
552 //                DVP_STATUS_INVALID_PARAMETER
553 //                DVP_STATUS_ERROR
554 //                DVP_STATUS_UNSIGNALED     - returned if the API is 
555 //                     unable to place a signal in the API context queue
556 //------------------------------------------------------------------------
557 #define dvpMapBufferEndAPI DVPAPI_GET_FUN(__dvpMapBufferEndAPI)
558
559 //------------------------------------------------------------------------
560 // Function:      dvpMapBufferWaitDVP
561 //
562 // Description:   Tells DVP to make the DVP stream wait for a previous 
563 //                signal triggered by a dvpMapBufferEndAPI call.
564 //
565 //                This must be called inside the dvpBegin/dvpEnd pair.
566 //
567 // Parameters:    gpuBufferHandle[IN] - buffer to track
568 //
569 // Returns:       DVP_STATUS_OK
570 //                DVP_STATUS_INVALID_PARAMETER
571 //                DVP_STATUS_ERROR
572 //------------------------------------------------------------------------
573 #define dvpMapBufferWaitDVP DVPAPI_GET_FUN(__dvpMapBufferWaitDVP)
574
575 //------------------------------------------------------------------------
576 // Function:      dvpMapBufferEndDVP
577 //
578 // Description:   Tells DVP to setup a signal for this buffer after
579 //                DVP operations are complete. The signal allows 
580 //                the API to know when then this buffer is 
581 //                ready for use within a API stream. This function would
582 //                be followed by a call to dvpMapBufferWaitAPI to
583 //                synchronize copies in the DVP stream and the API 
584 //                rendering stream.
585 //
586 //                This must be called inside the dvpBegin/dvpEnd pair.
587 //
588 // Parameters:    gpuBufferHandle[IN] - buffer to track
589 //
590 // Returns:       DVP_STATUS_OK
591 //                DVP_STATUS_INVALID_PARAMETER
592 //                DVP_STATUS_ERROR
593 //------------------------------------------------------------------------
594 #define dvpMapBufferEndDVP DVPAPI_GET_FUN(__dvpMapBufferEndDVP)
595
596 //------------------------------------------------------------------------
597 // Function:      dvpMapBufferWaitAPI
598 //
599 // Description:   Tells DVP to make the current API context or device to 
600 //                wait for a previous signal triggered by a 
601 //                dvpMapBufferEndDVP call.
602 //
603 //                The use of dvpMapBufferWaitCUDAStream is NOT recommended for
604 //                CUDA synchronisation, as it is more optimal to use a
605 //                applcation CUDA stream in conjunction with 
606 //                dvpMapBufferEndCUDAStream. This allows the driver to 
607 //                do optimisations, such as parllelise the copy operations
608 //                and compute.
609 //
610 //                If OpenGL or CUDA is used, the OpenGL/CUDA context
611 //                must be current at time of call.
612 //
613 //                This must be called outside the dvpBegin/dvpEnd pair. In
614 //                addition, this call is not thread safe and must be called
615 //                from or fenced against the rendering thread associated with
616 //                the context or device.
617 //
618 // Parameters:    gpuBufferHandle[IN] - buffer to track
619 //
620 // Returns:       DVP_STATUS_OK
621 //                DVP_STATUS_INVALID_PARAMETER
622 //                DVP_STATUS_ERROR
623 //------------------------------------------------------------------------
624 #define dvpMapBufferWaitAPI DVPAPI_GET_FUN(__dvpMapBufferWaitAPI)
625
626 //------------------------------------------------------------------------
627 // If the multiple GL contexts used in the application access the same
628 // sysmem buffers, then application must create those GL contexts with
629 // display list shared.
630 //------------------------------------------------------------------------
631 #define dvpBindToGLCtx DVPAPI_GET_FUN(__dvpBindToGLCtx)
632 #define dvpGetRequiredConstantsGLCtx DVPAPI_GET_FUN(__dvpGetRequiredConstantsGLCtx)
633 #define dvpCreateGPUTextureGL DVPAPI_GET_FUN(__dvpCreateGPUTextureGL)
634 #define dvpUnbindFromGLCtx DVPAPI_GET_FUN(__dvpUnbindFromGLCtx)
635
636
637 DVPAPI PFNDVPBEGIN __dvpBegin;
638 DVPAPI PFNDVPEND __dvpEnd;
639 DVPAPI PFNDVPCREATEBUFFER __dvpCreateBuffer;
640 DVPAPI PFNDVPDESTROYBUFFER __dvpDestroyBuffer;
641 DVPAPI PFNDVPFREEBUFFER __dvpFreeBuffer;
642 DVPAPI PFNDVPMEMCPYLINED __dvpMemcpyLined;
643 DVPAPI PFNDVPMEMCPY __dvpMemcpy;
644 DVPAPI PFNDVPIMPORTSYNCOBJECT __dvpImportSyncObject;
645 DVPAPI PFNDVPFREESYNCOBJECT __dvpFreeSyncObject;
646 DVPAPI PFNDVPMAPBUFFERENDAPI __dvpMapBufferEndAPI;
647 DVPAPI PFNDVPMAPBUFFERWAITDVP __dvpMapBufferWaitDVP;
648 DVPAPI PFNDVPMAPBUFFERENDDVP __dvpMapBufferEndDVP;
649 DVPAPI PFNDVPMAPBUFFERWAITAPI __dvpMapBufferWaitAPI;
650
651
652 //------------------------------------------------------------------------
653 // If the multiple GL contexts used in the application access the same
654 // sysmem buffers, then application must create those GL contexts with
655 // display list shared.
656 //------------------------------------------------------------------------
657 DVPAPI PFNDVPBINDTOGLCTX __dvpBindToGLCtx;
658 DVPAPI PFNDVPGETREQUIREDCONSTANTSGLCTX __dvpGetRequiredConstantsGLCtx;
659 DVPAPI PFNDVPCREATEGPUTEXTUREGL __dvpCreateGPUTextureGL;
660 DVPAPI PFNDVPUNBINDFROMGLCTX __dvpUnbindFromGLCtx;
661
662 #define DVPAPI_GET_FUN(x)       x
663
664 #endif  // WIN32
665
666 #endif  // __DVPAPI_H__
667