Fixed off by one errors in clipping.
[mesa.git] / src / mesa / drivers / dri / unichrome / via_ioctl.h
1 /*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
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:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
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.
23 */
24
25 #ifndef _VIAIOCTL_H
26 #define _VIAIOCTL_H
27
28 #include "via_context.h"
29
30
31 void viaEmitPrim(viaContextPtr vmesa);
32 void viaFlushPrims(viaContextPtr vmesa);
33 void viaFlushPrimsLocked(viaContextPtr vmesa);
34
35 void viaDmaFinish(viaContextPtr vmesa);
36 void viaRegetLockQuiescent(viaContextPtr vmesa);
37 void viaInitIoctlFuncs(GLcontext *ctx);
38 void viaCopyBuffer(const __DRIdrawablePrivate *dpriv);
39 void viaPageFlip(const __DRIdrawablePrivate *dpriv);
40 int via_check_copy(int fd);
41 void viaFillFrontBuffer(viaContextPtr vmesa);
42 void viaFillFrontBufferSaam(viaContextPtr vmesa);
43 void viaFillFrontPBuffer(viaContextPtr vmesa);
44 void viaFillBackBuffer(viaContextPtr vmesa);
45 void viaFillDepthBuffer(viaContextPtr vmesa, GLuint pixel);
46 void viaFillStencilBuffer(viaContextPtr vmesa, GLuint pixel);
47 void viaFillStencilDepthBuffer(viaContextPtr vmesa, GLuint pixel);
48 void viaDoSwapBuffers(viaContextPtr vmesa);
49 void viaDoSwapBuffersSaam(viaContextPtr vmesa);
50 void viaDoSwapPBuffers(viaContextPtr vmesa);
51
52 int flush_agp(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd);
53 int flush_agp_saam(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd);
54 int flush_sys(viaContextPtr vmesa, drm_via_flush_sys_t* buf);
55
56 #define VIA_STATECHANGE(vmesa, flag) \
57 do { \
58 if (vmesa->dmaLow != vmesa->dmaLastPrim) \
59 viaFlushPrims(vmesa); \
60 vmesa->dirty |= flag; \
61 } while (0) \
62
63
64 #define VIA_FIREVERTICES(vmesa) \
65 do { \
66 if (vmesa->dmaLow) { \
67 viaFlushPrims(vmesa); \
68 } \
69 } while (0)
70
71
72 static __inline GLuint *viaCheckDma(viaContextPtr vmesa, int bytes)
73 {
74 if (vmesa->dmaLow + bytes > vmesa->dmaHigh) {
75 #ifdef DEBUG
76 if (VIA_DEBUG) fprintf(stderr, "buffer overflow in check dma = %d + %d = %d\n", vmesa->dmaLow, bytes, vmesa->dmaLow + bytes);
77 #endif
78 viaFlushPrims(vmesa);
79 }
80
81 {
82 GLuint *start = (GLuint *)(vmesa->dmaAddr + vmesa->dmaLow);
83 return start;
84 }
85 }
86 #endif