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 "mach64_tex.h"
36 #include "drirenderbuffer.h"
39 char *prevLockFile
= NULL
;
44 /* Update the hardware state. This is called if another context has
45 * grabbed the hardware lock, which includes the X server. This
46 * function also updates the driver's window state after the X server
47 * moves, resizes or restacks a window -- the change will be reflected
48 * in the drawable position and clip rects. Since the X server grabs
49 * the hardware lock when it changes the window state, this routine will
50 * automatically be called after such a change.
52 void mach64GetLock( mach64ContextPtr mmesa
, GLuint flags
)
54 __DRIdrawablePrivate
*dPriv
= mmesa
->driDrawable
;
55 __DRIscreenPrivate
*sPriv
= mmesa
->driScreen
;
56 drm_mach64_sarea_t
*sarea
= mmesa
->sarea
;
59 drmGetLock( mmesa
->driFd
, mmesa
->hHWContext
, flags
);
61 /* The window might have moved, so we might need to get new clip
64 * NOTE: This releases and regrabs the hw lock to allow the X server
65 * to respond to the DRI protocol request for new drawable info.
66 * Since the hardware state depends on having the latest drawable
67 * clip rects, all state checking must be done _after_ this call.
69 DRI_VALIDATE_DRAWABLE_INFO( sPriv
, dPriv
);
71 if ( mmesa
->lastStamp
!= dPriv
->lastStamp
) {
72 mmesa
->lastStamp
= dPriv
->lastStamp
;
73 if (mmesa
->glCtx
->DrawBuffer
->_ColorDrawBufferIndexes
[0] == BUFFER_BACK_LEFT
)
74 mach64SetCliprects( mmesa
->glCtx
, GL_BACK_LEFT
);
76 mach64SetCliprects( mmesa
->glCtx
, GL_FRONT_LEFT
);
77 driUpdateFramebufferSize( mmesa
->glCtx
, dPriv
);
78 mach64CalcViewport( mmesa
->glCtx
);
81 mmesa
->dirty
|= (MACH64_UPLOAD_CONTEXT
83 | MACH64_UPLOAD_CLIPRECTS
);
85 /* EXA render acceleration uses the texture engine, so restore it */
86 mmesa
->dirty
|= (MACH64_UPLOAD_TEXTURE
);
88 if ( sarea
->ctx_owner
!= mmesa
->hHWContext
) {
89 sarea
->ctx_owner
= mmesa
->hHWContext
;
90 mmesa
->dirty
= MACH64_UPLOAD_ALL
;
93 for ( i
= mmesa
->firstTexHeap
; i
< mmesa
->lastTexHeap
; i
++ ) {
94 DRI_AGE_TEXTURES( mmesa
->texture_heaps
[i
] );