4e64c17b3d3eac0a3cff48f69bdf23a77e62e550
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"
43 #include "swrast/swrast.h"
44 #include "framebuffer.h"
48 #define DRIVER_DATE "20041008"
50 /* Return the width and height of the given buffer.
53 sisGetBufferSize( GLframebuffer
*buffer
,
54 GLuint
*width
, GLuint
*height
)
56 GET_CURRENT_CONTEXT(ctx
);
57 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
60 *width
= smesa
->driDrawable
->w
;
61 *height
= smesa
->driDrawable
->h
;
65 /* Return various strings for glGetString().
67 static const GLubyte
*
68 sisGetString( GLcontext
*ctx
, GLenum name
)
70 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
71 static char buffer
[128];
73 GLuint agp_mode
= (smesa
->AGPSize
> 0);
78 return (GLubyte
*)"Eric Anholt";
81 offset
= driGetRendererString( buffer
, "SiS", DRIVER_DATE
, agp_mode
);
83 return (GLubyte
*)buffer
;
90 /* Send all commands to the hardware.
93 sisFlush( GLcontext
*ctx
)
95 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
97 SIS_FIREVERTICES(smesa
);
100 /* Make sure all commands have been sent to the hardware and have
101 * completed processing.
104 sisFinish( GLcontext
*ctx
)
106 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
108 SIS_FIREVERTICES(smesa
);
110 WaitEngIdle( smesa
);
115 sisUpdateBufferSize( sisContextPtr smesa
)
117 __GLSiSHardware
*current
= &smesa
->current
;
118 __GLSiSHardware
*prev
= &smesa
->prev
;
121 /* XXX Should get the base offset of the frontbuffer from the X Server */
122 smesa
->frontOffset
= smesa
->driDrawable
->x
* smesa
->bytesPerPixel
+
123 smesa
->driDrawable
->y
* smesa
->frontPitch
;
125 if ( smesa
->width
== smesa
->driDrawable
->w
&&
126 smesa
->height
== smesa
->driDrawable
->h
)
131 smesa
->width
= smesa
->driDrawable
->w
;
132 smesa
->height
= smesa
->driDrawable
->h
;
133 smesa
->bottom
= smesa
->height
- 1;
135 if ( smesa
->backbuffer
)
136 sisFreeBackbuffer( smesa
);
137 if ( smesa
->depthbuffer
)
138 sisFreeZStencilBuffer( smesa
);
140 if ( smesa
->glCtx
->Visual
.depthBits
> 0 )
141 sisAllocZStencilBuffer( smesa
);
142 if ( smesa
->glCtx
->Visual
.doubleBufferMode
)
143 sisAllocBackbuffer( smesa
);
145 switch (smesa
->zFormat
)
147 case SiS_ZFORMAT_Z16
:
150 case SiS_ZFORMAT_Z32
:
151 case SiS_ZFORMAT_S8Z24
:
155 sis_fatal_error("Bad Z format\n");
158 current
->hwZ
&= ~MASK_ZBufferPitch
;
159 current
->hwZ
|= smesa
->width
* z_depth
>> 2;
160 current
->hwOffsetZ
= smesa
->depthOffset
>> 2;
162 if ((current
->hwOffsetZ
!= prev
->hwOffsetZ
) || (current
->hwZ
!= prev
->hwZ
)) {
163 prev
->hwOffsetZ
= current
->hwOffsetZ
;
164 prev
->hwZ
= current
->hwZ
;
165 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
168 sisUpdateClipping( smesa
->glCtx
);
171 /* Initialize the driver's misc functions.
174 sisInitDriverFuncs( struct dd_function_table
*functions
)
176 functions
->GetBufferSize
= sisGetBufferSize
;
177 functions
->ResizeBuffers
= _mesa_resize_framebuffer
;
178 functions
->GetString
= sisGetString
;
179 functions
->Finish
= sisFinish
;
180 functions
->Flush
= sisFlush
;