1 /* -*- mode: c; c-basic-offset: 3 -*-
3 * Copyright 2000 VA Linux Systems Inc., Fremont, California.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 /* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h,v 1.3 2002/02/22 21:45:03 dawes Exp $ */
30 * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
33 * Gareth Hughes <gareth@valinux.com>
37 #ifndef __TDFX_LOCK_H__
38 #define __TDFX_LOCK_H__
40 #ifdef GLX_DIRECT_RENDERING
42 /* You can turn this on to find locking conflicts.
44 #define DEBUG_LOCKING 0
47 extern char *prevLockFile
;
48 extern int prevLockLine
;
50 #define DEBUG_LOCK() \
52 prevLockFile = (__FILE__); \
53 prevLockLine = (__LINE__); \
56 #define DEBUG_RESET() \
62 #define DEBUG_CHECK_LOCK() \
64 if ( prevLockFile ) { \
66 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
67 prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
76 #define DEBUG_CHECK_LOCK()
78 #endif /* DEBUG_LOCKING */
81 extern void tdfxGetLock( tdfxContextPtr fxMesa
);
84 /* !!! We may want to separate locks from locks with validation.
85 This could be used to improve performance for those things
86 commands that do not do any drawing !!! */
88 #define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret) \
90 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
91 if (__ret) drmGetLock(fd,context,0); \
94 #define LOCK_HARDWARE( fxMesa ) \
99 DRM_CAS( fxMesa->driHwLock, fxMesa->hHWContext, \
100 DRM_LOCK_HELD | fxMesa->hHWContext, __ret ); \
102 tdfxGetLock( fxMesa ); \
107 /* Unlock the hardware using the global current context */
108 #define UNLOCK_HARDWARE( fxMesa ) \
110 DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); \
115 * This pair of macros makes a loop over the drawing operations
116 * so it is not self contained and doesn't have the nice single
117 * statement semantics of most macros.
119 #define BEGIN_CLIP_LOOP(fxMesa) \
121 LOCK_HARDWARE( fxMesa ); \
122 BEGIN_CLIP_LOOP_LOCKED( fxMesa )
124 #define BEGIN_CLIP_LOOP_LOCKED(fxMesa) \
126 int _nc = fxMesa->numClipRects; \
128 if (fxMesa->numClipRects > 1) { \
129 int _height = fxMesa->screen_height; \
130 fxMesa->Glide.grClipWindow(fxMesa->pClipRects[_nc].x1, \
131 _height - fxMesa->pClipRects[_nc].y2, \
132 fxMesa->pClipRects[_nc].x2, \
133 _height - fxMesa->pClipRects[_nc].y1); \
137 #define END_CLIP_LOOP_LOCKED( fxMesa ) \
141 #define END_CLIP_LOOP( fxMesa ) \
142 END_CLIP_LOOP_LOCKED( fxMesa ); \
143 UNLOCK_HARDWARE( fxMesa ); \
147 #endif /* GLX_DIRECT_RENDERING */
149 #endif /* __TDFX_LOCK_H__ */