1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef INTEL_BATCHBUFFER_H
29 #define INTEL_BATCHBUFFER_H
31 #include "intel_context.h"
32 #include "intel_ioctl.h"
35 #define BATCH_LOCALS GLubyte *batch_ptr;
37 /* #define VERBOSE 0 */
43 #define BEGIN_BATCH(n) \
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; \
53 #define OUT_BATCH(n) \
55 *(GLuint *)batch_ptr = (n); \
56 if (VERBOSE) fprintf(stderr, " -- %08x at %s/%d\n", (n), __FILE__, __LINE__); \
60 #define ADVANCE_BATCH() \
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); \
68 extern void intelInitBatchBuffer( GLcontext
*ctx
);
69 extern void intelDestroyBatchBuffer( GLcontext
*ctx
);
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
,
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
);
81 extern void intelEmitCopyBlitLocked( intelContextPtr intel
,
87 GLshort srcx
, GLshort srcy
,
88 GLshort dstx
, GLshort dsty
,
89 GLshort w
, GLshort h
);
91 extern void intelEmitFillBlitLocked( intelContextPtr intel
,
102 static __inline GLuint
*intelExtendInlinePrimitive( intelContextPtr intel
,
105 GLuint sz
= dwords
* sizeof(GLuint
);
108 if (intel
->batch
.space
< sz
) {
109 intelWrapInlinePrimitive( intel
);
110 /* assert(intel->batch.space >= sz); */
113 /* assert(intel->prim.primitive != ~0); */
114 ptr
= (GLuint
*)intel
->batch
.ptr
;
115 intel
->batch
.ptr
+= sz
;
116 intel
->batch
.space
-= sz
;