R300: set the number of GB pipes on all r3xx-r5xx chips
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_lock.h
1 /**************************************************************************
2
3 Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
4 VA Linux Systems Inc., Fremont, California.
5 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
6
7 The Weather Channel (TM) funded Tungsten Graphics to develop the
8 initial release of the Radeon 8500 driver under the XFree86 license.
9 This notice must be preserved.
10
11 All Rights Reserved.
12
13 Permission is hereby granted, free of charge, to any person obtaining
14 a copy of this software and associated documentation files (the
15 "Software"), to deal in the Software without restriction, including
16 without limitation the rights to use, copy, modify, merge, publish,
17 distribute, sublicense, and/or sell copies of the Software, and to
18 permit persons to whom the Software is furnished to do so, subject to
19 the following conditions:
20
21 The above copyright notice and this permission notice (including the
22 next paragraph) shall be included in all copies or substantial
23 portions of the Software.
24
25 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
29 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
33 **************************************************************************/
34
35 /*
36 * Authors:
37 * Gareth Hughes <gareth@valinux.com>
38 * Keith Whitwell <keith@tungstengraphics.com>
39 * Kevin E. Martin <martin@valinux.com>
40 */
41
42 #ifndef COMMON_LOCK_H
43 #define COMMON_LOCK_H
44
45 #include "main/colormac.h"
46 #include "radeon_screen.h"
47 #include "radeon_common.h"
48
49 extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags);
50
51 /* Turn DEBUG_LOCKING on to find locking conflicts.
52 */
53 #define DEBUG_LOCKING 0
54
55 #if DEBUG_LOCKING
56 extern char *prevLockFile;
57 extern int prevLockLine;
58
59 #define DEBUG_LOCK() \
60 do { \
61 prevLockFile = (__FILE__); \
62 prevLockLine = (__LINE__); \
63 } while (0)
64
65 #define DEBUG_RESET() \
66 do { \
67 prevLockFile = 0; \
68 prevLockLine = 0; \
69 } while (0)
70
71 #define DEBUG_CHECK_LOCK() \
72 do { \
73 if ( prevLockFile ) { \
74 fprintf( stderr, \
75 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
76 prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
77 exit( 1 ); \
78 } \
79 } while (0)
80
81 #else
82
83 #define DEBUG_LOCK()
84 #define DEBUG_RESET()
85 #define DEBUG_CHECK_LOCK()
86
87 #endif
88
89 /*
90 * !!! We may want to separate locks from locks with validation. This
91 * could be used to improve performance for those things commands that
92 * do not do any drawing !!!
93 */
94
95 /* Lock the hardware and validate our state.
96 */
97 #define LOCK_HARDWARE( rmesa ) \
98 do { \
99 char __ret = 0; \
100 DEBUG_CHECK_LOCK(); \
101 if (!(rmesa)->radeonScreen->driScreen->dri2.enabled) { \
102 DRM_CAS( (rmesa)->dri.hwLock, (rmesa)->dri.hwContext, \
103 (DRM_LOCK_HELD | (rmesa)->dri.hwContext), __ret ); \
104 if ( __ret ) \
105 radeonGetLock( (rmesa), 0 ); \
106 } \
107 DEBUG_LOCK(); \
108 } while (0)
109
110 #define UNLOCK_HARDWARE( rmesa ) \
111 do { \
112 if (!(rmesa)->radeonScreen->driScreen->dri2.enabled) { \
113 DRM_UNLOCK( (rmesa)->dri.fd, \
114 (rmesa)->dri.hwLock, \
115 (rmesa)->dri.hwContext ); \
116 DEBUG_RESET(); \
117 } \
118 } while (0)
119
120 #endif