577d07137ffe701a19ee0c41894bd8088c86c2dc
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(%ld) in %s, %d dwords free\n", \
47 ((unsigned long)n), __FUNCTION__, \
48 intel->batch.space/4); \
49 if (intel->batch.space < (n)*4) \
50 intelFlushBatch(intel, GL_TRUE); \
51 if (intel->batch.space == intel->batch.size) intel->batch.func = __FUNCTION__; \
52 batch_ptr = intel->batch.ptr; \
55 #define OUT_BATCH(n) \
57 *(GLuint *)batch_ptr = (n); \
58 if (VERBOSE) fprintf(stderr, " -- %08x at %s/%d\n", (n), __FILE__, __LINE__); \
62 #define ADVANCE_BATCH() \
64 if (VERBOSE) fprintf(stderr, "ADVANCE_BATCH()\n"); \
65 intel->batch.space -= (batch_ptr - intel->batch.ptr); \
66 intel->batch.ptr = batch_ptr; \
67 assert(intel->batch.space >= 0); \
70 extern void intelInitBatchBuffer( GLcontext
*ctx
);
71 extern void intelDestroyBatchBuffer( GLcontext
*ctx
);
73 extern void intelStartInlinePrimitive( intelContextPtr intel
, GLuint prim
);
74 extern void intelWrapInlinePrimitive( intelContextPtr intel
);
75 extern void intelRestartInlinePrimitive( intelContextPtr intel
);
76 extern GLuint
*intelEmitInlinePrimitiveLocked(intelContextPtr intel
,
77 int primitive
, int dwords
,
79 extern void intelCopyBuffer( const __DRIdrawablePrivate
*dpriv
,
80 const drm_clip_rect_t
*rect
);
81 extern void intelClearWithBlit(GLcontext
*ctx
, GLbitfield mask
, GLboolean all
,
82 GLint cx1
, GLint cy1
, GLint cw
, GLint ch
);
84 extern void intelEmitCopyBlitLocked( intelContextPtr intel
,
90 GLshort srcx
, GLshort srcy
,
91 GLshort dstx
, GLshort dsty
,
92 GLshort w
, GLshort h
);
94 extern void intelEmitFillBlitLocked( intelContextPtr intel
,
105 static __inline GLuint
*intelExtendInlinePrimitive( intelContextPtr intel
,
108 GLuint sz
= dwords
* sizeof(GLuint
);
111 if (intel
->batch
.space
< sz
) {
112 intelWrapInlinePrimitive( intel
);
113 /* assert(intel->batch.space >= sz); */
116 /* assert(intel->prim.primitive != ~0); */
117 ptr
= (GLuint
*)intel
->batch
.ptr
;
118 intel
->batch
.ptr
+= sz
;
119 intel
->batch
.space
-= sz
;