Implemented support for software-based AUX color buffers.
[mesa.git] / src / mesa / drivers / dri / gamma / gamma_lock.h
1 #ifndef __GAMMA_LOCK_H__
2 #define __GAMMA_LOCK_H__
3
4 #ifdef GLX_DIRECT_RENDERING
5
6 extern void gammaGetLock( gammaContextPtr gmesa, GLuint flags );
7
8 /* Turn DEBUG_LOCKING on to find locking conflicts.
9 */
10 #define DEBUG_LOCKING 0
11
12 #if DEBUG_LOCKING
13 extern char *prevLockFile;
14 extern int prevLockLine;
15
16 #define DEBUG_LOCK() \
17 do { \
18 prevLockFile = (__FILE__); \
19 prevLockLine = (__LINE__); \
20 } while (0)
21
22 #define DEBUG_RESET() \
23 do { \
24 prevLockFile = 0; \
25 prevLockLine = 0; \
26 } while (0)
27
28 #define DEBUG_CHECK_LOCK() \
29 do { \
30 if ( prevLockFile ) { \
31 fprintf( stderr, \
32 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
33 prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
34 exit( 1 ); \
35 } \
36 } while (0)
37
38 #else
39
40 #define DEBUG_LOCK()
41 #define DEBUG_RESET()
42 #define DEBUG_CHECK_LOCK()
43
44 #endif
45
46 /*
47 * !!! We may want to separate locks from locks with validation. This
48 * could be used to improve performance for those things commands that
49 * do not do any drawing !!!
50 */
51
52 /* Lock the hardware and validate our state.
53 */
54 #define LOCK_HARDWARE( gmesa ) \
55 do { \
56 char __ret = 0; \
57 DEBUG_CHECK_LOCK(); \
58 DRM_CAS( gmesa->driHwLock, gmesa->hHWContext, \
59 (DRM_LOCK_HELD | gmesa->hHWContext), __ret ); \
60 if ( __ret ) \
61 gammaGetLock( gmesa, 0 ); \
62 DEBUG_LOCK(); \
63 } while (0)
64
65 /* Unlock the hardware.
66 */
67 #define UNLOCK_HARDWARE( gmesa ) \
68 do { \
69 DRM_UNLOCK( gmesa->driFd, \
70 gmesa->driHwLock, \
71 gmesa->hHWContext ); \
72 DEBUG_RESET(); \
73 } while (0)
74
75 #endif
76
77 #define GAMMAHW_LOCK( gmesa ) \
78 DRM_UNLOCK(gmesa->driFd, gmesa->driHwLock, gmesa->hHWContext); \
79 DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
80 gmesa->driScreen->drawLockID); \
81 VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
82
83 #define GAMMAHW_UNLOCK( gmesa ) \
84 DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
85 gmesa->driScreen->drawLockID); \
86 VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
87
88 #endif /* __GAMMA_LOCK_H__ */