1 #ifndef BRW_BATCHBUFFER_H
2 #define BRW_BATCHBUFFER_H
5 #include "brw_winsys.h"
7 #include "util/u_debug.h"
10 #define BATCH_RESERVED 16
21 void brw_batchbuffer_free(struct brw_batchbuffer
*batch
);
23 void _brw_batchbuffer_flush(struct brw_batchbuffer
*batch
,
24 const char *file
, int line
);
26 #define brw_batchbuffer_flush(batch) \
27 _brw_batchbuffer_flush(batch, __FILE__, __LINE__)
29 void brw_batchbuffer_reset(struct brw_batchbuffer
*batch
);
32 /* Unlike bmBufferData, this currently requires the buffer be mapped.
33 * Consider it a convenience function wrapping multple
34 * intel_buffer_dword() calls.
36 void brw_batchbuffer_data(struct brw_batchbuffer
*batch
,
37 const void *data
, GLuint bytes
,
38 enum cliprect_mode cliprect_mode
);
40 void brw_batchbuffer_release_space(struct brw_batchbuffer
*batch
,
43 GLboolean
brw_batchbuffer_emit_reloc(struct brw_batchbuffer
*batch
,
44 struct brw_winsys_buffer
*buffer
,
45 uint32_t read_domains
,
46 uint32_t write_domain
,
49 /* Inline functions - might actually be better off with these
50 * non-inlined. Certainly better off switching all command packets to
51 * be passed as structs rather than dwords, but that's a little bit of
55 brw_batchbuffer_space(struct brw_batchbuffer
*batch
)
57 return (batch
->size
- BATCH_RESERVED
) - (batch
->ptr
- batch
->map
);
62 brw_batchbuffer_emit_dword(struct brw_batchbuffer
*batch
, GLuint dword
)
65 assert(brw_batchbuffer_space(batch
) >= 4);
66 *(GLuint
*) (batch
->ptr
) = dword
;
71 brw_batchbuffer_require_space(struct brw_batchbuffer
*batch
,
74 assert(sz
< batch
->size
- 8);
75 if (brw_batchbuffer_space(batch
) < sz
) {
80 batch
->emit
.end_ptr
= batch
->ptr
+ sz
;
85 /* Here are the crusty old macros, to be removed:
87 #define BEGIN_BATCH(n, cliprect_mode) do { \
88 brw_batchbuffer_require_space(brw->batch, (n)*4); \
91 #define OUT_BATCH(d) brw_batchbuffer_emit_dword(brw->batch, d)
93 #define OUT_RELOC(buf, read_domains, write_domain, delta) do { \
94 assert((unsigned) (delta) < buf->size); \
95 brw_batchbuffer_emit_reloc(brw->batch, buf, \
96 read_domains, write_domain, delta); \
100 #define ADVANCE_BATCH() do { \
101 unsigned int _n = brw->batch->ptr - brw->batch->emit.end_ptr; \
103 debug_printf("%s: %d too many bytes emitted to batch\n", __FUNCTION__, _n); \
106 brw->batch->emit.end_ptr = NULL; \
109 #define ADVANCE_BATCH()
113 brw_batchbuffer_emit_mi_flush(struct brw_batchbuffer
*batch
)
115 brw_batchbuffer_require_space(batch
, 4);
116 brw_batchbuffer_emit_dword(batch
, MI_FLUSH
);