1 #ifndef INTEL_BATCHBUFFER_H
2 #define INTEL_BATCHBUFFER_H
6 #include "dri_bufmgr.h"
10 //#define BATCH_SZ 16384
12 #define BATCH_RESERVED 16
14 #define INTEL_BATCH_NO_CLIPRECTS 0x1
15 #define INTEL_BATCH_CLIPRECTS 0x2
17 struct intel_batchbuffer
19 struct intel_context
*intel
;
22 dri_fence
*last_fence
;
31 struct intel_batchbuffer
*intel_batchbuffer_alloc(struct intel_context
34 void intel_batchbuffer_free(struct intel_batchbuffer
*batch
);
37 void intel_batchbuffer_finish(struct intel_batchbuffer
*batch
);
39 void intel_batchbuffer_flush(struct intel_batchbuffer
*batch
);
41 void intel_batchbuffer_reset(struct intel_batchbuffer
*batch
);
44 /* Unlike bmBufferData, this currently requires the buffer be mapped.
45 * Consider it a convenience function wrapping multple
46 * intel_buffer_dword() calls.
48 void intel_batchbuffer_data(struct intel_batchbuffer
*batch
,
49 const void *data
, GLuint bytes
, GLuint flags
);
51 void intel_batchbuffer_release_space(struct intel_batchbuffer
*batch
,
54 GLboolean
intel_batchbuffer_emit_reloc(struct intel_batchbuffer
*batch
,
56 GLuint flags
, GLuint offset
);
58 /* Inline functions - might actually be better off with these
59 * non-inlined. Certainly better off switching all command packets to
60 * be passed as structs rather than dwords, but that's a little bit of
64 intel_batchbuffer_space(struct intel_batchbuffer
*batch
)
66 return (batch
->size
- BATCH_RESERVED
) - (batch
->ptr
- batch
->map
);
71 intel_batchbuffer_emit_dword(struct intel_batchbuffer
*batch
, GLuint dword
)
74 assert(intel_batchbuffer_space(batch
) >= 4);
75 *(GLuint
*) (batch
->ptr
) = dword
;
80 intel_batchbuffer_require_space(struct intel_batchbuffer
*batch
,
81 GLuint sz
, GLuint flags
)
83 assert(sz
< batch
->size
- 8);
84 if (intel_batchbuffer_space(batch
) < sz
||
85 (batch
->flags
!= 0 && flags
!= 0 && batch
->flags
!= flags
))
86 intel_batchbuffer_flush(batch
);
88 batch
->flags
|= flags
;
91 /* Here are the crusty old macros, to be removed:
95 #define BEGIN_BATCH(n, flags) do { \
96 assert(!intel->prim.flush); \
97 intel_batchbuffer_require_space(intel->batch, (n)*4, flags); \
100 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
102 #define OUT_RELOC(buf, flags, delta) do { \
103 assert((delta) >= 0); \
104 intel_batchbuffer_emit_reloc(intel->batch, buf, flags, delta); \
107 #define ADVANCE_BATCH() do { } while(0)