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.c,v 1.5 2002/12/16 16:19:00 dawes Exp $ */
30 * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
33 * Gareth Hughes <gareth@valinux.com>
37 #include "tdfx_context.h"
38 #include "tdfx_lock.h"
39 #include "tdfx_state.h"
40 #include "tdfx_render.h"
41 #include "tdfx_texman.h"
42 #include "tdfx_tris.h"
44 #include "drirenderbuffer.h"
47 void tdfxGetLock( tdfxContextPtr fxMesa
)
49 __DRIcontextPrivate
*cPriv
= fxMesa
->driContext
;
50 __DRIdrawablePrivate
*const drawable
= cPriv
->driDrawablePriv
;
51 __DRIdrawablePrivate
*const readable
= cPriv
->driReadablePriv
;
52 __DRIscreenPrivate
*sPriv
= drawable
->driScreenPriv
;
53 TDFXSAREAPriv
*saPriv
= (TDFXSAREAPriv
*) (((char *) sPriv
->pSAREA
) +
54 fxMesa
->fxScreen
->sarea_priv_offset
);
55 unsigned int stamp
= drawable
->lastStamp
;
57 drmGetLock( fxMesa
->driFd
, fxMesa
->hHWContext
, 0 );
59 /* This macro will update drawable's cliprects if needed */
60 DRI_VALIDATE_DRAWABLE_INFO(sPriv
, drawable
);
61 if (drawable
!= readable
) {
62 DRI_VALIDATE_DRAWABLE_INFO(sPriv
, readable
);
65 if ( saPriv
->fifoOwner
!= fxMesa
->hHWContext
) {
66 fxMesa
->Glide
.grDRIImportFifo( saPriv
->fifoPtr
, saPriv
->fifoRead
);
69 if ( saPriv
->ctxOwner
!= fxMesa
->hHWContext
) {
70 /* This sequence looks a little odd. Glide mirrors the state, and
71 * when you get the state you are forcing the mirror to be up to
72 * date, and then getting a copy from the mirror. You can then force
73 * that state onto the hardware when you set the state.
77 fxMesa
->Glide
.grGet(GR_GLIDE_STATE_SIZE
, 4, &stateSize
);
78 state
= malloc(stateSize
);
79 fxMesa
->Glide
.grGlideGetState( state
);
80 fxMesa
->Glide
.grGlideSetState( state
);
85 if ( saPriv
->texOwner
!= fxMesa
->hHWContext
) {
86 tdfxTMRestoreTextures_NoLock( fxMesa
);
90 if ((*drawable
->pStamp
!= stamp
)
91 || (saPriv
->ctxOwner
!= fxMesa
->hHWContext
)) {
92 driUpdateFramebufferSize(fxMesa
->glCtx
, drawable
);
93 if (drawable
!= readable
) {
94 driUpdateFramebufferSize(fxMesa
->glCtx
, readable
);
97 tdfxUpdateClipping(fxMesa
->glCtx
);
98 tdfxUploadClipping(fxMesa
);