1 /* -*- mode: c; c-basic-offset: 3 -*- */
3 * Copyright 2000 Gareth Hughes
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Gareth Hughes <gareth@valinux.com>
28 * Leif Delgass <ldelgass@retinalburn.net>
29 * José Fonseca <j_r_fonseca@yahoo.co.uk>
32 #include "mach64_context.h"
33 #include "mach64_state.h"
34 #include "mach64_lock.h"
35 #include "drirenderbuffer.h"
38 char *prevLockFile
= NULL
;
43 /* Update the hardware state. This is called if another context has
44 * grabbed the hardware lock, which includes the X server. This
45 * function also updates the driver's window state after the X server
46 * moves, resizes or restacks a window -- the change will be reflected
47 * in the drawable position and clip rects. Since the X server grabs
48 * the hardware lock when it changes the window state, this routine will
49 * automatically be called after such a change.
51 void mach64GetLock( mach64ContextPtr mmesa
, GLuint flags
)
53 __DRIdrawable
*dPriv
= mmesa
->driDrawable
;
54 __DRIscreen
*sPriv
= mmesa
->driScreen
;
55 drm_mach64_sarea_t
*sarea
= mmesa
->sarea
;
58 drmGetLock( mmesa
->driFd
, mmesa
->hHWContext
, flags
);
60 /* The window might have moved, so we might need to get new clip
63 * NOTE: This releases and regrabs the hw lock to allow the X server
64 * to respond to the DRI protocol request for new drawable info.
65 * Since the hardware state depends on having the latest drawable
66 * clip rects, all state checking must be done _after_ this call.
68 DRI_VALIDATE_DRAWABLE_INFO( sPriv
, dPriv
);
70 if ( mmesa
->lastStamp
!= dPriv
->lastStamp
) {
71 mmesa
->lastStamp
= dPriv
->lastStamp
;
72 if (mmesa
->glCtx
->DrawBuffer
->_ColorDrawBufferIndexes
[0] == BUFFER_BACK_LEFT
)
73 mach64SetCliprects( mmesa
->glCtx
, GL_BACK_LEFT
);
75 mach64SetCliprects( mmesa
->glCtx
, GL_FRONT_LEFT
);
76 driUpdateFramebufferSize( mmesa
->glCtx
, dPriv
);
77 mach64CalcViewport( mmesa
->glCtx
);
80 mmesa
->dirty
|= (MACH64_UPLOAD_CONTEXT
82 | MACH64_UPLOAD_CLIPRECTS
);
84 /* EXA render acceleration uses the texture engine, so restore it */
85 mmesa
->dirty
|= (MACH64_UPLOAD_TEXTURE
);
87 if ( sarea
->ctx_owner
!= mmesa
->hHWContext
) {
88 sarea
->ctx_owner
= mmesa
->hHWContext
;
89 mmesa
->dirty
= MACH64_UPLOAD_ALL
;
92 for ( i
= mmesa
->firstTexHeap
; i
< mmesa
->lastTexHeap
; i
++ ) {
93 DRI_AGE_TEXTURES( mmesa
->texture_heaps
[i
] );