1 /**************************************************************************
3 Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
4 Copyright 2003 Eric Anholt
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 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
21 ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
27 /* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
31 * Sung-Ching Lin <sclin@sis.com.tw>
32 * Eric Anholt <anholt@FreeBSD.org>
36 #include "sis_context.h"
39 #include "sis_alloc.h"
40 #include "sis_state.h"
42 #include "swrast/swrast.h"
46 #define DRIVER_DATE "20030810"
48 /* Return the width and height of the given buffer.
51 sisDDGetBufferSize( GLframebuffer
*buffer
,
52 GLuint
*width
, GLuint
*height
)
54 GET_CURRENT_CONTEXT(ctx
);
55 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
58 *width
= smesa
->driDrawable
->w
;
59 *height
= smesa
->driDrawable
->h
;
63 /* Return various strings for glGetString().
65 static const GLubyte
*
66 sisDDGetString( GLcontext
*ctx
, GLenum name
)
68 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
69 static char buffer
[128];
71 GLuint agp_mode
= (smesa
->AGPSize
> 0);
76 return (GLubyte
*)"Eric Anholt";
79 offset
= driGetRendererString( buffer
, "SiS", DRIVER_DATE
, agp_mode
);
81 return (GLubyte
*)buffer
;
88 /* Send all commands to the hardware. No-op, due to mmio.
91 sisDDFlush( GLcontext
*ctx
)
96 /* Make sure all commands have been sent to the hardware and have
97 * completed processing.
100 sisDDFinish( GLcontext
*ctx
)
102 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
105 WaitEngIdle( smesa
);
109 sisUpdateBufferSize( sisContextPtr smesa
)
111 __GLSiSHardware
*current
= &smesa
->current
;
112 __GLSiSHardware
*prev
= &smesa
->prev
;
115 /* XXX Should get the base offset of the frontbuffer from the X Server */
116 smesa
->frontOffset
= smesa
->driDrawable
->x
* smesa
->bytesPerPixel
+
117 smesa
->driDrawable
->y
* smesa
->frontPitch
;
119 if ( smesa
->width
== smesa
->driDrawable
->w
&&
120 smesa
->height
== smesa
->driDrawable
->h
)
125 smesa
->width
= smesa
->driDrawable
->w
;
126 smesa
->height
= smesa
->driDrawable
->h
;
127 smesa
->bottom
= smesa
->height
- 1;
129 if ( smesa
->backbuffer
)
130 sisFreeBackbuffer( smesa
);
131 if ( smesa
->depthbuffer
)
132 sisFreeZStencilBuffer( smesa
);
134 if ( smesa
->glCtx
->Visual
.depthBits
> 0 )
135 sisAllocZStencilBuffer( smesa
);
136 if ( smesa
->glCtx
->Visual
.doubleBufferMode
)
137 sisAllocBackbuffer( smesa
);
139 switch (smesa
->zFormat
)
141 case SiS_ZFORMAT_Z16
:
144 case SiS_ZFORMAT_Z32
:
145 case SiS_ZFORMAT_S8Z24
:
152 current
->hwZ
&= ~MASK_ZBufferPitch
;
153 current
->hwZ
|= smesa
->width
* z_depth
>> 2;
154 current
->hwOffsetZ
= smesa
->depthOffset
>> 2;
156 if ((current
->hwOffsetZ
!= prev
->hwOffsetZ
) || (current
->hwZ
!= prev
->hwZ
)) {
157 prev
->hwOffsetZ
= current
->hwOffsetZ
;
158 prev
->hwZ
= current
->hwZ
;
159 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
162 sisUpdateClipping( smesa
->glCtx
);
165 /* Initialize the driver's misc functions.
168 sisDDInitDriverFuncs( GLcontext
*ctx
)
170 ctx
->Driver
.GetBufferSize
= sisDDGetBufferSize
;
171 ctx
->Driver
.ResizeBuffers
= _swrast_alloc_buffers
;
172 ctx
->Driver
.GetString
= sisDDGetString
;
173 ctx
->Driver
.Finish
= sisDDFinish
;
174 ctx
->Driver
.Flush
= sisDDFlush
;
175 ctx
->Driver
.Error
= NULL
;