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.
28 #include "via_context.h"
31 void viaFinishPrimitive(viaContextPtr vmesa
);
32 void viaFlushDma(viaContextPtr vmesa
);
33 void viaFlushDmaLocked(viaContextPtr vmesa
, GLuint flags
);
35 void viaInitIoctlFuncs(GLcontext
*ctx
);
36 void viaCopyBuffer(const __DRIdrawablePrivate
*dpriv
);
37 void viaPageFlip(const __DRIdrawablePrivate
*dpriv
);
38 void viaCheckDma(viaContextPtr vmesa
, GLuint bytes
);
40 #define VIA_FINISH_PRIM(vmesa) do { \
41 if (vmesa->dmaLastPrim) \
42 viaFinishPrimitive( vmesa ); \
45 #define VIA_FLUSH_DMA(vmesa) do { \
46 VIA_FINISH_PRIM(vmesa); \
52 void viaWrapPrimitive( viaContextPtr vmesa
);
54 static __inline__ GLuint
*viaAllocDma(viaContextPtr vmesa
, int bytes
)
56 if (vmesa
->dmaLow
+ bytes
> VIA_DMA_HIGHWATER
) {
61 GLuint
*start
= (GLuint
*)(vmesa
->dma
+ vmesa
->dmaLow
);
62 vmesa
->dmaLow
+= bytes
;
68 static GLuint __inline__
*viaExtendPrimitive(viaContextPtr vmesa
, int bytes
)
70 if (vmesa
->dmaLow
+ bytes
> VIA_DMA_HIGHWATER
) {
71 viaWrapPrimitive(vmesa
);
75 GLuint
*start
= (GLuint
*)(vmesa
->dma
+ vmesa
->dmaLow
);
76 vmesa
->dmaLow
+= bytes
;
84 #define RING_VARS GLuint *_vb = 0, _nr, _x;
86 #define BEGIN_RING(n) do { \
87 if (_vb != 0) abort(); \
88 _vb = viaAllocDma(vmesa, (n) * sizeof(GLuint)); \
93 #define BEGIN_RING_NOCHECK(n) do { \
94 if (_vb != 0) abort(); \
95 _vb = (GLuint *)(vmesa->dma + vmesa->dmaLow); \
96 vmesa->dmaLow += (n) * sizeof(GLuint); \
101 #define OUT_RING(n) _vb[_x++] = (n)
103 #define ADVANCE_RING() do { \
104 if (_x != _nr) abort(); \
108 #define ADVANCE_RING_VARIABLE() do { \
109 if (_x > _nr) abort(); \
110 vmesa->dmaLow -= (_nr - _x) * sizeof(GLuint); \
115 #define QWORD_PAD_RING() do { \
116 if (vmesa->dmaLow & 0x4) { \
118 OUT_RING(HC_DUMMY); \