1 #ifndef INTEL_BATCHBUFFER_H
2 #define INTEL_BATCHBUFFER_H
6 #include "dri_bufmgr.h"
11 #define BATCH_SZ 16384
12 #define BATCH_RESERVED 16
16 * Batchbuffer contents may be looped over per cliprect, but do not
21 * Batchbuffer contents require looping over per cliprect at batch submit
26 * Batchbuffer contents contain drawing that should not be executed multiple
31 * Batchbuffer contents contain drawing that already handles cliprects, such
32 * as 2D drawing to front/back/depth that doesn't respect DRAWING_RECTANGLE.
33 * Equivalent behavior to NO_LOOP_CLIPRECTS, but may not persist in batch
34 * outside of LOCK/UNLOCK.
39 struct intel_batchbuffer
41 struct intel_context
*intel
;
50 enum cliprect_mode cliprect_mode
;
57 struct intel_batchbuffer
*intel_batchbuffer_alloc(struct intel_context
60 void intel_batchbuffer_free(struct intel_batchbuffer
*batch
);
63 void _intel_batchbuffer_flush(struct intel_batchbuffer
*batch
,
64 const char *file
, int line
);
66 #define intel_batchbuffer_flush(batch) \
67 _intel_batchbuffer_flush(batch, __FILE__, __LINE__)
69 void intel_batchbuffer_reset(struct intel_batchbuffer
*batch
);
72 /* Unlike bmBufferData, this currently requires the buffer be mapped.
73 * Consider it a convenience function wrapping multple
74 * intel_buffer_dword() calls.
76 void intel_batchbuffer_data(struct intel_batchbuffer
*batch
,
77 const void *data
, GLuint bytes
,
78 enum cliprect_mode cliprect_mode
);
80 void intel_batchbuffer_release_space(struct intel_batchbuffer
*batch
,
83 GLboolean
intel_batchbuffer_emit_reloc(struct intel_batchbuffer
*batch
,
85 uint32_t read_domains
,
86 uint32_t write_domain
,
89 /* Inline functions - might actually be better off with these
90 * non-inlined. Certainly better off switching all command packets to
91 * be passed as structs rather than dwords, but that's a little bit of
95 intel_batchbuffer_space(struct intel_batchbuffer
*batch
)
97 return (batch
->size
- BATCH_RESERVED
) - (batch
->ptr
- batch
->map
);
102 intel_batchbuffer_emit_dword(struct intel_batchbuffer
*batch
, GLuint dword
)
105 assert(intel_batchbuffer_space(batch
) >= 4);
106 *(GLuint
*) (batch
->ptr
) = dword
;
111 intel_batchbuffer_require_space(struct intel_batchbuffer
*batch
,
113 enum cliprect_mode cliprect_mode
)
115 assert(sz
< batch
->size
- 8);
116 if (intel_batchbuffer_space(batch
) < sz
)
117 intel_batchbuffer_flush(batch
);
119 if (cliprect_mode
!= IGNORE_CLIPRECTS
) {
120 if (batch
->cliprect_mode
== IGNORE_CLIPRECTS
) {
121 batch
->cliprect_mode
= cliprect_mode
;
123 if (batch
->cliprect_mode
!= cliprect_mode
)
124 intel_batchbuffer_flush(batch
);
129 /* Here are the crusty old macros, to be removed:
133 #define BEGIN_BATCH(n, cliprect_mode) do { \
134 intel_batchbuffer_require_space(intel->batch, (n)*4, cliprect_mode); \
137 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
139 #define OUT_RELOC(buf, read_domains, write_domain, delta) do { \
140 assert((delta) >= 0); \
141 intel_batchbuffer_emit_reloc(intel->batch, buf, \
142 read_domains, write_domain, delta); \
145 #define ADVANCE_BATCH() do { } while(0)
149 intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer
*batch
)
151 intel_batchbuffer_require_space(batch
, 4, IGNORE_CLIPRECTS
);
152 intel_batchbuffer_emit_dword(batch
, MI_FLUSH
);