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