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
;
39 #include "via_screen.h"
41 #include "via_common.h"
42 #include "xf86drmVIA.h"
43 #define VIA_FALLBACK_TEXTURE 0x1
44 #define VIA_FALLBACK_DRAW_BUFFER 0x2
45 #define VIA_FALLBACK_READ_BUFFER 0x4
46 #define VIA_FALLBACK_COLORMASK 0x8
47 #define VIA_FALLBACK_SPECULAR 0x20
48 #define VIA_FALLBACK_LOGICOP 0x40
49 #define VIA_FALLBACK_RENDERMODE 0x80
50 #define VIA_FALLBACK_STENCIL 0x100
51 #define VIA_FALLBACK_BLEND_EQ 0x200
52 #define VIA_FALLBACK_BLEND_FUNC 0x400
53 #define VIA_FALLBACK_USER_DISABLE 0x800
55 #define VIA_DMA_BUFSIZ 5000
56 #define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 256)
58 #define VIA_NO_CLIPRECTS 0x1
61 /* Use the templated vertex formats:
64 #include "tnl_dd/t_dd_vertex.h"
67 typedef void (*via_tri_func
)(viaContextPtr
, viaVertex
*, viaVertex
*,
69 typedef void (*via_line_func
)(viaContextPtr
, viaVertex
*, viaVertex
*);
70 typedef void (*via_point_func
)(viaContextPtr
, viaVertex
*);
80 GLuint orig
; /* The drawing origin,
81 * at (drawX,drawY) in screen space.
84 } viaBuffer
, *viaBufferPtr
;
87 struct via_context_t
{
101 GLboolean have_hw_stencil
;
103 GLuint depth_clear_mask
;
104 GLuint stencil_clear_mask
;
106 GLfloat polygon_offset_scale
;
115 viaTextureObjectPtr CurrentTexObj
[2];
116 struct via_texture_object_t TexObjList
;
117 struct via_texture_object_t SwappedOut
;
120 /* Bit flag to keep 0track of fallbacks.
124 /* State for via_vb.c and via_tris.c.
126 GLuint newState
; /* _NEW_* flags */
127 GLuint newEmitState
; /* _NEW_* flags */
128 GLuint setupNewInputs
;
131 GLmatrix ViewportMatrix
;
132 GLenum renderPrimitive
;
134 unsigned char *verts
;
136 /* drmBufPtr dma_buffer;
139 GLuint dmaCliprectAddr
;
144 /* Fallback rasterization functions
146 via_point_func drawPoint
;
147 via_line_func drawLine
;
148 via_tri_func drawTri
;
171 GLuint regHABLRCbias
;
184 GLuint regHTXnMPMD_0
;
185 GLuint regHTXnTBLCsat_0
;
186 GLuint regHTXnTBLCop_0
;
187 GLuint regHTXnTBLMPfog_0
;
188 GLuint regHTXnTBLAsat_0
;
189 GLuint regHTXnTBLRCb_0
;
190 GLuint regHTXnTBLRAa_0
;
191 GLuint regHTXnTBLRFog_0
;
192 /*=* John Sheng [2003.7.18] texture combine *=*/
193 GLuint regHTXnTBLRCa_0
;
194 GLuint regHTXnTBLRCc_0
;
195 GLuint regHTXnTBLRCbias_0
;
198 GLuint regHTXnMPMD_1
;
199 GLuint regHTXnTBLCsat_1
;
200 GLuint regHTXnTBLCop_1
;
201 GLuint regHTXnTBLMPfog_1
;
202 GLuint regHTXnTBLAsat_1
;
203 GLuint regHTXnTBLRCb_1
;
204 GLuint regHTXnTBLRAa_1
;
205 GLuint regHTXnTBLRFog_1
;
214 GLenum TexEnvImageFmt
[2];
221 GLframebuffer
*glBuffer
;
222 GLboolean doPageFlip
;
223 /*=* John Sheng [2003.5.31] flip *=*/
226 viaBuffer
*drawBuffer
;
227 viaBuffer
*readBuffer
;
228 int drawX
; /* origin of drawable in draw buffer */
235 GLuint numClipRects
; /* cliprects for that buffer */
236 drm_clip_rect_t
*pClipRects
;
244 drm_clip_rect_t drawRect
;
245 drm_clip_rect_t scissorRect
;
247 drm_context_t hHWContext
;
248 drm_hw_lock_t
*driHwLock
;
250 __DRInativeDisplay
*display
;
252 __DRIdrawablePrivate
*driDrawable
;
253 __DRIscreenPrivate
*driScreen
;
254 viaScreenPrivate
*viaScreen
;
255 drm_via_sarea_t
*sarea
;
256 volatile GLuint
* regMMIOBase
;
257 volatile GLuint
* pnGEMode
;
258 volatile GLuint
* regEngineStatus
;
259 volatile GLuint
* regTranSet
;
260 volatile GLuint
* regTranSpace
;
264 GLuint nDoneFirstFlip
;
267 /* Configuration cache
269 driOptionCache optionCache
;
275 int64_t swap_missed_ust
;
278 GLuint swap_missed_count
;
280 PFNGLXGETUSTPROC get_ust
;
286 #define VIA_CONTEXT(ctx) ((viaContextPtr)(ctx->DriverCtx))
288 #define GET_DISPATCH_AGE(vmesa) vmesa->sarea->lastDispatch
289 #define GET_ENQUEUE_AGE(vmesa) vmesa->sarea->lastEnqueue
292 /* Lock the hardware and validate our state.
294 #define LOCK_HARDWARE(vmesa) \
297 DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \
298 (DRM_LOCK_HELD|vmesa->hHWContext), __ret); \
300 viaGetLock(vmesa, 0); \
304 /* Release the kernel lock.
306 #define UNLOCK_HARDWARE(vmesa) \
307 DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext);
309 #define WAIT_IDLE(vmesa) \
311 if ((((GLuint)*vmesa->regEngineStatus) & 0xFFFEFFFF) == 0x00020000) \
317 extern GLuint VIA_DEBUG
;
323 extern void viaGetLock(viaContextPtr vmesa
, GLuint flags
);
324 extern void viaLock(viaContextPtr vmesa
, GLuint flags
);
325 extern void viaUnLock(viaContextPtr vmesa
, GLuint flags
);
326 extern void viaEmitHwStateLocked(viaContextPtr vmesa
);
327 extern void viaEmitScissorValues(viaContextPtr vmesa
, int box_nr
, int emit
);
328 extern void viaXMesaSetBackClipRects(viaContextPtr vmesa
);
329 extern void viaXMesaSetFrontClipRects(viaContextPtr vmesa
);
330 extern void viaReAllocateBuffers(GLframebuffer
*drawbuffer
);
331 extern void viaXMesaWindowMoved(viaContextPtr vmesa
);
333 extern void viaTexCombineState(viaContextPtr vmesa
,
334 const struct gl_tex_env_combine_state
* combine
, unsigned unit
);
336 /* Via hw already adjusted for GL pixel centers:
341 /* TODO XXX _SOLO temp defines to make code compilable */
342 #ifndef GLX_PBUFFER_BIT
343 #define GLX_PBUFFER_BIT 0x00000004
345 #ifndef GLX_WINDOW_BIT
346 #define GLX_WINDOW_BIT 0x00000001
348 #ifndef VERT_BIT_CLIP
349 #define VERT_BIT_CLIP 0x1000000