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 /* You can turn this on to find locking conflicts.
42 #define DEBUG_LOCKING 0
45 extern char *prevLockFile;
46 extern int prevLockLine;
48 #define DEBUG_LOCK() \
50 prevLockFile = (__FILE__); \
51 prevLockLine = (__LINE__); \
54 #define DEBUG_RESET() \
60 #define DEBUG_CHECK_LOCK() \
62 if ( prevLockFile ) { \
64 "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
65 prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
74 #define DEBUG_CHECK_LOCK()
76 #endif /* DEBUG_LOCKING */
79 extern void tdfxGetLock( tdfxContextPtr fxMesa );
82 /* !!! We may want to separate locks from locks with validation.
83 This could be used to improve performance for those things
84 commands that do not do any drawing !!! */
86 #define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret) \
88 DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
89 if (__ret) drmGetLock(fd,context,0); \
92 #define LOCK_HARDWARE( fxMesa ) \
97 DRM_CAS( fxMesa->driHwLock, fxMesa->hHWContext, \
98 DRM_LOCK_HELD | fxMesa->hHWContext, __ret ); \
100 tdfxGetLock( fxMesa ); \
105 /* Unlock the hardware using the global current context */
106 #define UNLOCK_HARDWARE( fxMesa ) \
108 DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); \
113 * This pair of macros makes a loop over the drawing operations
114 * so it is not self contained and doesn't have the nice single
115 * statement semantics of most macros.
117 #define BEGIN_CLIP_LOOP(fxMesa) \
119 LOCK_HARDWARE( fxMesa ); \
120 BEGIN_CLIP_LOOP_LOCKED( fxMesa )
122 #define BEGIN_CLIP_LOOP_LOCKED(fxMesa) \
124 int _nc = fxMesa->numClipRects; \
126 if (fxMesa->numClipRects > 1) { \
127 int _height = fxMesa->screen_height; \
128 fxMesa->Glide.grClipWindow(fxMesa->pClipRects[_nc].x1, \
129 _height - fxMesa->pClipRects[_nc].y2, \
130 fxMesa->pClipRects[_nc].x2, \
131 _height - fxMesa->pClipRects[_nc].y1); \
135 #define END_CLIP_LOOP_LOCKED( fxMesa ) \
139 #define END_CLIP_LOOP( fxMesa ) \
140 END_CLIP_LOOP_LOCKED( fxMesa ); \
141 UNLOCK_HARDWARE( fxMesa ); \
144 #endif /* __TDFX_LOCK_H__ */