b5c7a783a726b5fe8e75659ce8ebda8250b219f8
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
13 #define INTEL_BATCH_NO_CLIPRECTS 0x1
14 #define INTEL_BATCH_CLIPRECTS 0x2
16 struct intel_batchbuffer
18 struct intel_context
*intel
;
21 dri_fence
*last_fence
;
30 struct intel_batchbuffer
*intel_batchbuffer_alloc(struct intel_context
33 void intel_batchbuffer_free(struct intel_batchbuffer
*batch
);
36 void intel_batchbuffer_finish(struct intel_batchbuffer
*batch
);
38 void intel_batchbuffer_flush(struct intel_batchbuffer
*batch
);
40 void intel_batchbuffer_reset(struct intel_batchbuffer
*batch
);
43 /* Unlike bmBufferData, this currently requires the buffer be mapped.
44 * Consider it a convenience function wrapping multple
45 * intel_buffer_dword() calls.
47 void intel_batchbuffer_data(struct intel_batchbuffer
*batch
,
48 const void *data
, GLuint bytes
, GLuint flags
);
50 void intel_batchbuffer_release_space(struct intel_batchbuffer
*batch
,
53 GLboolean
intel_batchbuffer_emit_reloc(struct intel_batchbuffer
*batch
,
55 GLuint flags
, GLuint offset
);
57 /* Inline functions - might actually be better off with these
58 * non-inlined. Certainly better off switching all command packets to
59 * be passed as structs rather than dwords, but that's a little bit of
63 intel_batchbuffer_space(struct intel_batchbuffer
*batch
)
65 return (batch
->size
- BATCH_RESERVED
) - (batch
->ptr
- batch
->map
);
70 intel_batchbuffer_emit_dword(struct intel_batchbuffer
*batch
, GLuint dword
)
73 assert(intel_batchbuffer_space(batch
) >= 4);
74 *(GLuint
*) (batch
->ptr
) = dword
;
79 intel_batchbuffer_require_space(struct intel_batchbuffer
*batch
,
80 GLuint sz
, GLuint flags
)
82 assert(sz
< batch
->size
- 8);
83 if (intel_batchbuffer_space(batch
) < sz
||
84 (batch
->flags
!= 0 && flags
!= 0 && batch
->flags
!= flags
))
85 intel_batchbuffer_flush(batch
);
87 batch
->flags
|= flags
;
90 /* Here are the crusty old macros, to be removed:
94 #define BEGIN_BATCH(n, flags) do { \
95 assert(!intel->prim.flush); \
96 intel_batchbuffer_require_space(intel->batch, (n)*4, flags); \
99 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
101 #define OUT_RELOC(buf, flags, delta) do { \
102 assert((delta) >= 0); \
103 intel_batchbuffer_emit_reloc(intel->batch, buf, flags, delta); \
106 #define ADVANCE_BATCH() do { } while(0)