2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
29 typedef struct via_context_t viaContext
;
30 typedef struct via_context_t
*viaContextPtr
;
31 typedef struct via_texture_object_t
*viaTextureObjectPtr
;
38 #include "tnl/t_vertex.h"
40 #include "via_screen.h"
42 #include "via_common.h"
44 /* Chip tags. These are used to group the adapters into
56 #define VIA_FALLBACK_TEXTURE 0x1
57 #define VIA_FALLBACK_DRAW_BUFFER 0x2
58 #define VIA_FALLBACK_READ_BUFFER 0x4
59 #define VIA_FALLBACK_COLORMASK 0x8
60 #define VIA_FALLBACK_SPECULAR 0x20
61 #define VIA_FALLBACK_LOGICOP 0x40
62 #define VIA_FALLBACK_RENDERMODE 0x80
63 #define VIA_FALLBACK_STENCIL 0x100
64 #define VIA_FALLBACK_BLEND_EQ 0x200
65 #define VIA_FALLBACK_BLEND_FUNC 0x400
66 #define VIA_FALLBACK_USER_DISABLE 0x800
67 #define VIA_FALLBACK_PROJ_TEXTURE 0x1000
68 #define VIA_FALLBACK_STIPPLE 0x2000
69 #define VIA_FALLBACK_ALPHATEST 0x4000
71 #define VIA_DMA_BUFSIZ 4096
72 #define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 128)
74 #define VIA_NO_CLIPRECTS 0x1
77 /* Use the templated vertex formats:
80 #include "tnl_dd/t_dd_vertex.h"
83 typedef void (*via_tri_func
)(viaContextPtr
, viaVertex
*, viaVertex
*,
85 typedef void (*via_line_func
)(viaContextPtr
, viaVertex
*, viaVertex
*);
86 typedef void (*via_point_func
)(viaContextPtr
, viaVertex
*);
96 GLuint orig
; /* The drawing origin,
97 * at (drawX,drawY) in screen space.
100 } viaBuffer
, *viaBufferPtr
;
103 struct via_context_t
{
112 GLboolean hasStencil
;
117 GLboolean have_hw_stencil
;
119 GLuint depth_clear_mask
;
120 GLuint stencil_clear_mask
;
122 GLfloat polygon_offset_scale
;
131 viaTextureObjectPtr CurrentTexObj
[2];
132 struct via_texture_object_t TexObjList
;
133 struct via_texture_object_t SwappedOut
;
136 /* Bit flag to keep 0track of fallbacks.
140 /* State for via_tris.c.
142 GLuint newState
; /* _NEW_* flags */
143 GLuint newEmitState
; /* _NEW_* flags */
144 GLuint newRenderState
; /* _NEW_* flags */
146 struct tnl_attr_map vertex_attrs
[VERT_ATTRIB_MAX
];
147 GLuint vertex_attr_count
;
151 GLmatrix ViewportMatrix
;
152 GLenum renderPrimitive
;
154 unsigned char *verts
;
156 /* drmBufPtr dma_buffer;
159 GLuint dmaCliprectAddr
;
164 /* Fallback rasterization functions
166 via_point_func drawPoint
;
167 via_line_func drawLine
;
168 via_tri_func drawTri
;
191 GLuint regHABLRCbias
;
204 GLuint regHTXnMPMD_0
;
205 GLuint regHTXnTBLCsat_0
;
206 GLuint regHTXnTBLCop_0
;
207 GLuint regHTXnTBLMPfog_0
;
208 GLuint regHTXnTBLAsat_0
;
209 GLuint regHTXnTBLRCb_0
;
210 GLuint regHTXnTBLRAa_0
;
211 GLuint regHTXnTBLRFog_0
;
212 /*=* John Sheng [2003.7.18] texture combine *=*/
213 GLuint regHTXnTBLRCa_0
;
214 GLuint regHTXnTBLRCc_0
;
215 GLuint regHTXnTBLRCbias_0
;
218 GLuint regHTXnMPMD_1
;
219 GLuint regHTXnTBLCsat_1
;
220 GLuint regHTXnTBLCop_1
;
221 GLuint regHTXnTBLMPfog_1
;
222 GLuint regHTXnTBLAsat_1
;
223 GLuint regHTXnTBLRCb_1
;
224 GLuint regHTXnTBLRAa_1
;
225 GLuint regHTXnTBLRFog_1
;
235 GLenum TexEnvImageFmt
[2];
242 GLframebuffer
*glBuffer
;
243 GLboolean doPageFlip
;
244 /*=* John Sheng [2003.5.31] flip *=*/
247 viaBuffer
*drawBuffer
;
248 viaBuffer
*readBuffer
;
249 int drawX
; /* origin of drawable in draw buffer */
256 GLuint numClipRects
; /* cliprects for that buffer */
257 drm_clip_rect_t
*pClipRects
;
265 drm_clip_rect_t drawRect
;
266 drm_clip_rect_t scissorRect
;
268 drm_context_t hHWContext
;
269 drm_hw_lock_t
*driHwLock
;
271 __DRInativeDisplay
*display
;
273 __DRIdrawablePrivate
*driDrawable
;
274 __DRIscreenPrivate
*driScreen
;
275 viaScreenPrivate
*viaScreen
;
276 drm_via_sarea_t
*sarea
;
277 volatile GLuint
* regMMIOBase
;
278 volatile GLuint
* pnGEMode
;
279 volatile GLuint
* regEngineStatus
;
280 volatile GLuint
* regTranSet
;
281 volatile GLuint
* regTranSpace
;
285 GLuint nDoneFirstFlip
;
288 GLboolean strictConformance
;
289 GLboolean clearTexCache
;
291 /* Configuration cache
293 driOptionCache optionCache
;
299 int64_t swap_missed_ust
;
302 GLuint swap_missed_count
;
306 PFNGLXGETUSTPROC get_ust
;
312 #define VIA_CONTEXT(ctx) ((viaContextPtr)(ctx->DriverCtx))
314 #define GET_DISPATCH_AGE(vmesa) vmesa->sarea->lastDispatch
315 #define GET_ENQUEUE_AGE(vmesa) vmesa->sarea->lastEnqueue
318 /* Lock the hardware and validate our state.
320 #define LOCK_HARDWARE(vmesa) \
323 DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \
324 (DRM_LOCK_HELD|vmesa->hHWContext), __ret); \
326 viaGetLock(vmesa, 0); \
330 /* Release the kernel lock.
332 #define UNLOCK_HARDWARE(vmesa) \
333 DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext);
335 #define WAIT_IDLE(vmesa) \
337 if ((((GLuint)*vmesa->regEngineStatus) & 0xFFFEFFFF) == 0x00020000) \
343 extern GLuint VIA_DEBUG
;
349 extern void viaGetLock(viaContextPtr vmesa
, GLuint flags
);
350 extern void viaLock(viaContextPtr vmesa
, GLuint flags
);
351 extern void viaUnLock(viaContextPtr vmesa
, GLuint flags
);
352 extern void viaEmitHwStateLocked(viaContextPtr vmesa
);
353 extern void viaEmitScissorValues(viaContextPtr vmesa
, int box_nr
, int emit
);
354 extern void viaXMesaSetBackClipRects(viaContextPtr vmesa
);
355 extern void viaXMesaSetFrontClipRects(viaContextPtr vmesa
);
356 extern void viaReAllocateBuffers(GLframebuffer
*drawbuffer
);
357 extern void viaXMesaWindowMoved(viaContextPtr vmesa
);
359 extern void viaTexCombineState(viaContextPtr vmesa
,
360 const struct gl_tex_env_combine_state
* combine
, unsigned unit
);
362 /* Via hw already adjusted for GL pixel centers:
367 /* TODO XXX _SOLO temp defines to make code compilable */
368 #ifndef GLX_PBUFFER_BIT
369 #define GLX_PBUFFER_BIT 0x00000004
371 #ifndef GLX_WINDOW_BIT
372 #define GLX_WINDOW_BIT 0x00000001
374 #ifndef VERT_BIT_CLIP
375 #define VERT_BIT_CLIP 0x1000000