1 #ifndef INTEL_BATCHBUFFER_H
2 #define INTEL_BATCHBUFFER_H
5 #include "dri_bufmgr.h"
10 #define BATCH_RESERVED 16
12 #define MAX_RELOCS 100
14 #define INTEL_BATCH_NO_CLIPRECTS 0x1
15 #define INTEL_BATCH_CLIPRECTS 0x2
19 struct _DriBufferObject
*buf
;
21 GLuint delta
; /* not needed? */
24 struct intel_batchbuffer
27 struct intel_context
*intel
;
29 struct _DriBufferObject
*buffer
;
30 struct _DriFenceObject
*last_fence
;
38 struct buffer_reloc reloc
[MAX_RELOCS
];
43 struct intel_batchbuffer
*intel_batchbuffer_alloc(struct intel_context
46 void intel_batchbuffer_free(struct intel_batchbuffer
*batch
);
49 void intel_batchbuffer_finish(struct intel_batchbuffer
*batch
);
51 struct _DriFenceObject
*intel_batchbuffer_flush(struct intel_batchbuffer
54 void intel_batchbuffer_reset(struct intel_batchbuffer
*batch
);
57 /* Unlike bmBufferData, this currently requires the buffer be mapped.
58 * Consider it a convenience function wrapping multple
59 * intel_buffer_dword() calls.
61 void intel_batchbuffer_data(struct intel_batchbuffer
*batch
,
62 const void *data
, GLuint bytes
, GLuint flags
);
64 void intel_batchbuffer_release_space(struct intel_batchbuffer
*batch
,
67 GLboolean
intel_batchbuffer_emit_reloc(struct intel_batchbuffer
*batch
,
68 struct _DriBufferObject
*buffer
,
70 GLuint mask
, GLuint offset
);
72 /* Inline functions - might actually be better off with these
73 * non-inlined. Certainly better off switching all command packets to
74 * be passed as structs rather than dwords, but that's a little bit of
78 intel_batchbuffer_space(struct intel_batchbuffer
*batch
)
80 return (batch
->size
- BATCH_RESERVED
) - (batch
->ptr
- batch
->map
);
85 intel_batchbuffer_emit_dword(struct intel_batchbuffer
*batch
, GLuint dword
)
88 assert(intel_batchbuffer_space(batch
) >= 4);
89 *(GLuint
*) (batch
->ptr
) = dword
;
94 intel_batchbuffer_require_space(struct intel_batchbuffer
*batch
,
95 GLuint sz
, GLuint flags
)
97 assert(sz
< batch
->size
- 8);
98 if (intel_batchbuffer_space(batch
) < sz
||
99 (batch
->flags
!= 0 && flags
!= 0 && batch
->flags
!= flags
))
100 intel_batchbuffer_flush(batch
);
102 batch
->flags
|= flags
;
105 /* Here are the crusty old macros, to be removed:
109 #define BEGIN_BATCH(n, flags) do { \
110 assert(!intel->prim.flush); \
111 intel_batchbuffer_require_space(intel->batch, (n)*4, flags); \
114 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
116 #define OUT_RELOC(buf,flags,mask,delta) do { \
117 assert((delta) >= 0); \
118 intel_batchbuffer_emit_reloc(intel->batch, buf, flags, mask, delta); \
121 #define ADVANCE_BATCH() do { } while(0)