remove CVS/XFree86 keywords
[mesa.git] / src / mesa / drivers / dri / r200 / r200_lock.c
1 /*
2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
3
4 The Weather Channel (TM) funded Tungsten Graphics to develop the
5 initial release of the Radeon 8500 driver under the XFree86 license.
6 This notice must be preserved.
7
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
15
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 **************************************************************************/
29
30 /*
31 * Authors:
32 * Keith Whitwell <keith@tungstengraphics.com>
33 */
34
35 #include "r200_context.h"
36 #include "r200_lock.h"
37 #include "r200_tex.h"
38 #include "r200_state.h"
39 #include "r200_ioctl.h"
40
41 #include "drirenderbuffer.h"
42
43
44 #if DEBUG_LOCKING
45 char *prevLockFile = NULL;
46 int prevLockLine = 0;
47 #endif
48
49 /* Turn on/off page flipping according to the flags in the sarea:
50 */
51 static void
52 r200UpdatePageFlipping( r200ContextPtr rmesa )
53 {
54 rmesa->doPageFlip = rmesa->sarea->pfState;
55 if (rmesa->glCtx->WinSysDrawBuffer) {
56 driFlipRenderbuffers(rmesa->glCtx->WinSysDrawBuffer,
57 rmesa->sarea->pfCurrentPage);
58 }
59 }
60
61
62
63 /* Update the hardware state. This is called if another context has
64 * grabbed the hardware lock, which includes the X server. This
65 * function also updates the driver's window state after the X server
66 * moves, resizes or restacks a window -- the change will be reflected
67 * in the drawable position and clip rects. Since the X server grabs
68 * the hardware lock when it changes the window state, this routine will
69 * automatically be called after such a change.
70 */
71 void r200GetLock( r200ContextPtr rmesa, GLuint flags )
72 {
73 __DRIdrawablePrivate *drawable = rmesa->dri.drawable;
74 __DRIdrawablePrivate *readable = rmesa->dri.readable;
75 __DRIscreenPrivate *sPriv = rmesa->dri.screen;
76 drm_radeon_sarea_t *sarea = rmesa->sarea;
77 int i;
78
79 drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );
80
81 /* The window might have moved, so we might need to get new clip
82 * rects.
83 *
84 * NOTE: This releases and regrabs the hw lock to allow the X server
85 * to respond to the DRI protocol request for new drawable info.
86 * Since the hardware state depends on having the latest drawable
87 * clip rects, all state checking must be done _after_ this call.
88 */
89 DRI_VALIDATE_DRAWABLE_INFO( sPriv, drawable );
90 if (drawable != readable) {
91 DRI_VALIDATE_DRAWABLE_INFO( sPriv, readable );
92 }
93
94 if ( rmesa->lastStamp != drawable->lastStamp ) {
95 r200UpdatePageFlipping( rmesa );
96 r200SetCliprects( rmesa );
97 r200UpdateViewportOffset( rmesa->glCtx );
98 driUpdateFramebufferSize(rmesa->glCtx, drawable);
99 }
100
101 R200_STATECHANGE( rmesa, ctx );
102 if (rmesa->sarea->tiling_enabled) {
103 rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
104 }
105 else rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~R200_COLOR_TILE_ENABLE;
106
107 if ( sarea->ctx_owner != rmesa->dri.hwContext ) {
108 sarea->ctx_owner = rmesa->dri.hwContext;
109 }
110
111 for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
112 DRI_AGE_TEXTURES( rmesa->texture_heaps[ i ] );
113 }
114
115 rmesa->lost_context = GL_TRUE;
116 }