1 #ifndef INTEL_BATCHBUFFER_H
2 #define INTEL_BATCHBUFFER_H
5 #include "ws_dri_bufmgr.h"
10 #define BATCH_RESERVED 16
12 #define INTEL_DEFAULT_RELOCS 100
13 #define INTEL_MAX_RELOCS 400
15 #define INTEL_BATCH_NO_CLIPRECTS 0x1
16 #define INTEL_BATCH_CLIPRECTS 0x2
18 struct intel_batchbuffer
21 struct intel_screen
*intel_screen
;
23 struct _DriBufferObject
*buffer
;
24 struct _DriFenceObject
*last_fence
;
27 struct _DriBufferList
*list
;
42 uint8_t *drmBOVirtual
;
43 struct _drmBONode
*node
; /* Validation list node for this buffer */
44 int dest_location
; /* Validation list sequence for this buffer */
47 struct intel_batchbuffer
*intel_batchbuffer_alloc(struct intel_screen
50 void intel_batchbuffer_free(struct intel_batchbuffer
*batch
);
53 void intel_batchbuffer_finish(struct intel_batchbuffer
*batch
);
55 struct _DriFenceObject
*intel_batchbuffer_flush(struct intel_batchbuffer
58 void intel_batchbuffer_reset(struct intel_batchbuffer
*batch
);
61 /* Unlike bmBufferData, this currently requires the buffer be mapped.
62 * Consider it a convenience function wrapping multple
63 * intel_buffer_dword() calls.
65 void intel_batchbuffer_data(struct intel_batchbuffer
*batch
,
66 const void *data
, GLuint bytes
, GLuint flags
);
68 void intel_batchbuffer_release_space(struct intel_batchbuffer
*batch
,
72 intel_offset_relocation(struct intel_batchbuffer
*batch
,
74 struct _DriBufferObject
*driBO
,
78 /* Inline functions - might actually be better off with these
79 * non-inlined. Certainly better off switching all command packets to
80 * be passed as structs rather than dwords, but that's a little bit of
84 intel_batchbuffer_space(struct intel_batchbuffer
*batch
)
86 return (batch
->size
- BATCH_RESERVED
) - (batch
->ptr
- batch
->map
);
91 intel_batchbuffer_emit_dword(struct intel_batchbuffer
*batch
, GLuint dword
)
94 assert(intel_batchbuffer_space(batch
) >= 4);
95 *(GLuint
*) (batch
->ptr
) = dword
;
100 intel_batchbuffer_require_space(struct intel_batchbuffer
*batch
,
101 GLuint sz
, GLuint flags
)
103 struct _DriFenceObject
*fence
;
105 assert(sz
< batch
->size
- 8);
106 if (intel_batchbuffer_space(batch
) < sz
||
107 (batch
->flags
!= 0 && flags
!= 0 && batch
->flags
!= flags
)) {
108 fence
= intel_batchbuffer_flush(batch
);
109 driFenceUnReference(&fence
);
112 batch
->flags
|= flags
;
115 /* Here are the crusty old macros, to be removed:
119 #define BEGIN_BATCH(n, flags) do { \
120 assert(!intel->prim.flush); \
121 intel_batchbuffer_require_space(intel->batch, (n)*4, flags); \
124 #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
126 #define OUT_RELOC(buf,flags,mask,delta) do { \
127 assert((delta) >= 0); \
128 intel_offset_relocation(intel->batch, delta, buf, flags, mask); \
131 #define ADVANCE_BATCH() do { } while(0)