1 #ifndef INTEL_BATCHBUFFER_H
2 #define INTEL_BATCHBUFFER_H
6 #include "dri_bufmgr.h"
10 #define BATCH_SZ 16384
11 #define BATCH_RESERVED 16
15 * Batchbuffer contents may be looped over per cliprect, but do not
20 * Batchbuffer contents require looping over per cliprect at batch submit
25 * Batchbuffer contents contain drawing that should not be executed multiple
30 * Batchbuffer contents contain drawing that already handles cliprects, such
31 * as 2D drawing to front/back/depth that doesn't respect DRAWING_RECTANGLE.
32 * Equivalent behavior to NO_LOOP_CLIPRECTS, but may not persist in batch
33 * outside of LOCK/UNLOCK.
38 struct intel_batchbuffer
40 struct intel_context
*intel
;
47 enum cliprect_mode cliprect_mode
;
54 struct intel_batchbuffer
*intel_batchbuffer_alloc(struct intel_context
57 void intel_batchbuffer_free(struct intel_batchbuffer
*batch
);
60 void _intel_batchbuffer_flush(struct intel_batchbuffer
*batch
,
61 const char *file
, int line
);
63 #define intel_batchbuffer_flush(batch) \
64 _intel_batchbuffer_flush(batch, __FILE__, __LINE__)
66 void intel_batchbuffer_reset(struct intel_batchbuffer
*batch
);
69 /* Unlike bmBufferData, this currently requires the buffer be mapped.
70 * Consider it a convenience function wrapping multple
71 * intel_buffer_dword() calls.
73 void intel_batchbuffer_data(struct intel_batchbuffer
*batch
,
74 const void *data
, GLuint bytes
,
75 enum cliprect_mode cliprect_mode
);
77 void intel_batchbuffer_release_space(struct intel_batchbuffer
*batch
,
80 GLboolean
intel_batchbuffer_emit_reloc(struct intel_batchbuffer
*batch
,
82 uint32_t read_domains
,
83 uint32_t write_domain
,
86 /* Inline functions - might actually be better off with these
87 * non-inlined. Certainly better off switching all command packets to
88 * be passed as structs rather than dwords, but that's a little bit of
92 intel_batchbuffer_space(struct intel_batchbuffer
*batch
)
94 return (batch
->size
- BATCH_RESERVED
) - (batch
->ptr
- batch
->map
);
99 intel_batchbuffer_emit_dword(struct intel_batchbuffer
*batch
, GLuint dword
)
102 assert(intel_batchbuffer_space(batch
) >= 4);
103 *(GLuint
*) (batch
->ptr
) = dword
;
108 intel_batchbuffer_require_space(struct intel_batchbuffer
*batch
,
110 enum cliprect_mode cliprect_mode
)
112 assert(sz
< batch
->size
- 8);
113 if (intel_batchbuffer_space(batch
) < sz
)
114 intel_batchbuffer_flush(batch
);
116 if (cliprect_mode
!= IGNORE_CLIPRECTS
) {
117 if (batch
->cliprect_mode
== IGNORE_CLIPRECTS
) {
118 batch
->cliprect_mode
= cliprect_mode
;
120 if (batch
->cliprect_mode
!= cliprect_mode
)
121 intel_batchbuffer_flush(batch
);
126 /* Here are the crusty old macros, to be removed:
130 #define BEGIN_BATCH(n, cliprect_mode) do { \
131 intel_batchbuffer_require_space(intel->batch, (n)*4, cliprect_mode); \
134 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
136 #define OUT_RELOC(buf, read_domains, write_domain, delta) do { \
137 assert((delta) >= 0); \
138 intel_batchbuffer_emit_reloc(intel->batch, buf, \
139 read_domains, write_domain, delta); \
142 #define ADVANCE_BATCH() do { } while(0)