Fixed off by one errors in clipping.
[mesa.git] / src / mesa / drivers / dri / i915 / intel_batchbuffer.h
1 /**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef INTEL_BATCHBUFFER_H
29 #define INTEL_BATCHBUFFER_H
30
31 #include "intel_context.h"
32 #include "intel_ioctl.h"
33
34
35 #define BATCH_LOCALS GLubyte *batch_ptr;
36
37 /* #define VERBOSE 0 */
38 #ifndef VERBOSE
39 extern int VERBOSE;
40 #endif
41
42
43 #define BEGIN_BATCH(n) \
44 do { \
45 if (VERBOSE) fprintf(stderr, \
46 "BEGIN_BATCH(%d) in %s, %d dwords free\n", \
47 (n), __FUNCTION__, intel->batch.space/4); \
48 if (intel->batch.space < (n)*4) \
49 intelFlushBatch(intel, GL_TRUE); \
50 batch_ptr = intel->batch.ptr; \
51 } while (0)
52
53 #define OUT_BATCH(n) \
54 do { \
55 *(GLuint *)batch_ptr = (n); \
56 if (VERBOSE) fprintf(stderr, " -- %08x at %s/%d\n", (n), __FILE__, __LINE__); \
57 batch_ptr += 4; \
58 } while (0)
59
60 #define ADVANCE_BATCH() \
61 do { \
62 if (VERBOSE) fprintf(stderr, "ADVANCE_BATCH()\n"); \
63 intel->batch.space -= (batch_ptr - intel->batch.ptr); \
64 intel->batch.ptr = batch_ptr; \
65 assert(intel->batch.space >= 0); \
66 } while(0)
67
68 extern void intelInitBatchBuffer( GLcontext *ctx );
69 extern void intelDestroyBatchBuffer( GLcontext *ctx );
70
71 extern void intelStartInlinePrimitive( intelContextPtr intel, GLuint prim );
72 extern void intelWrapInlinePrimitive( intelContextPtr intel );
73 extern void intelRestartInlinePrimitive( intelContextPtr intel );
74 extern GLuint *intelEmitInlinePrimitiveLocked(intelContextPtr intel,
75 int primitive, int dwords,
76 int vertex_size);
77 extern void intelCopyBuffer( const __DRIdrawablePrivate *dpriv );
78 extern void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all,
79 GLint cx1, GLint cy1, GLint cw, GLint ch);
80
81 extern void intelEmitCopyBlitLocked( intelContextPtr intel,
82 GLuint cpp,
83 GLshort src_pitch,
84 GLuint src_offset,
85 GLshort dst_pitch,
86 GLuint dst_offset,
87 GLshort srcx, GLshort srcy,
88 GLshort dstx, GLshort dsty,
89 GLshort w, GLshort h );
90
91 extern void intelEmitFillBlitLocked( intelContextPtr intel,
92 GLuint cpp,
93 GLshort dst_pitch,
94 GLuint dst_offset,
95 GLshort x, GLshort y,
96 GLshort w, GLshort h,
97 GLuint color );
98
99
100
101
102 static __inline GLuint *intelExtendInlinePrimitive( intelContextPtr intel,
103 GLuint dwords )
104 {
105 GLuint sz = dwords * sizeof(GLuint);
106 GLuint *ptr;
107
108 if (intel->batch.space < sz) {
109 intelWrapInlinePrimitive( intel );
110 /* assert(intel->batch.space >= sz); */
111 }
112
113 /* assert(intel->prim.primitive != ~0); */
114 ptr = (GLuint *)intel->batch.ptr;
115 intel->batch.ptr += sz;
116 intel->batch.space -= sz;
117
118 return ptr;
119 }
120
121
122
123 #endif