1 #ifndef INTEL_BATCHBUFFER_H
2 #define INTEL_BATCHBUFFER_H
5 #include "dri_bufmgr.h"
10 #define BATCH_RESERVED 16
12 #define MAX_RELOCS 4096
14 #define INTEL_BATCH_NO_CLIPRECTS 0x1
15 #define INTEL_BATCH_CLIPRECTS 0x2
21 GLuint delta
; /* not needed? */
22 GLuint validate_flags
;
25 struct intel_batchbuffer
27 struct intel_context
*intel
;
30 dri_fence
*last_fence
;
38 struct buffer_reloc reloc
[MAX_RELOCS
];
43 struct intel_batchbuffer
*intel_batchbuffer_alloc(struct intel_context
46 void intel_batchbuffer_free(struct intel_batchbuffer
*batch
);
49 void intel_batchbuffer_finish(struct intel_batchbuffer
*batch
);
51 void intel_batchbuffer_flush(struct intel_batchbuffer
*batch
);
53 void intel_batchbuffer_reset(struct intel_batchbuffer
*batch
);
56 /* Unlike bmBufferData, this currently requires the buffer be mapped.
57 * Consider it a convenience function wrapping multple
58 * intel_buffer_dword() calls.
60 void intel_batchbuffer_data(struct intel_batchbuffer
*batch
,
61 const void *data
, GLuint bytes
, GLuint flags
);
63 void intel_batchbuffer_release_space(struct intel_batchbuffer
*batch
,
66 GLboolean
intel_batchbuffer_emit_reloc(struct intel_batchbuffer
*batch
,
68 GLuint flags
, GLuint offset
);
70 /* Inline functions - might actually be better off with these
71 * non-inlined. Certainly better off switching all command packets to
72 * be passed as structs rather than dwords, but that's a little bit of
76 intel_batchbuffer_space(struct intel_batchbuffer
*batch
)
78 return (batch
->size
- BATCH_RESERVED
) - (batch
->ptr
- batch
->map
);
83 intel_batchbuffer_emit_dword(struct intel_batchbuffer
*batch
, GLuint dword
)
86 assert(intel_batchbuffer_space(batch
) >= 4);
87 *(GLuint
*) (batch
->ptr
) = dword
;
92 intel_batchbuffer_require_space(struct intel_batchbuffer
*batch
,
93 GLuint sz
, GLuint flags
)
95 assert(sz
< batch
->size
- 8);
96 if (intel_batchbuffer_space(batch
) < sz
||
97 (batch
->flags
!= 0 && flags
!= 0 && batch
->flags
!= flags
))
98 intel_batchbuffer_flush(batch
);
100 batch
->flags
|= flags
;
103 /* Here are the crusty old macros, to be removed:
107 #define BEGIN_BATCH(n, flags) do { \
108 assert(!intel->prim.flush); \
109 intel_batchbuffer_require_space(intel->batch, (n)*4, flags); \
112 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
114 #define OUT_RELOC(buf, flags, delta) do { \
115 assert((delta) >= 0); \
116 intel_batchbuffer_emit_reloc(intel->batch, buf, flags, delta); \
119 #define ADVANCE_BATCH() do { } while(0)