aboutsummaryrefslogtreecommitdiff
path: root/src/wld/intel/batch.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wld/intel/batch.h')
-rw-r--r--src/wld/intel/batch.h88
1 files changed, 51 insertions, 37 deletions
diff --git a/src/wld/intel/batch.h b/src/wld/intel/batch.h
index 682b41c..cc9d1d9 100644
--- a/src/wld/intel/batch.h
+++ b/src/wld/intel/batch.h
@@ -24,69 +24,83 @@
#ifndef WLD_INTEL_BATCH_H
#define WLD_INTEL_BATCH_H
-#include <intel_bufmgr.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
+#include <intel_bufmgr.h>
#define INTEL_BATCH_MAX_COMMANDS (1 << 13)
#define INTEL_BATCH_RESERVED_COMMANDS 2
#define INTEL_BATCH_SIZE (INTEL_BATCH_MAX_COMMANDS << 2)
-enum intel_batch_result { INTEL_BATCH_SUCCESS, INTEL_BATCH_NO_SPACE };
+enum intel_batch_result
+{
+ INTEL_BATCH_SUCCESS,
+ INTEL_BATCH_NO_SPACE
+};
-struct intel_device_info {
- int gen;
+struct intel_device_info
+{
+ int gen;
};
-struct intel_batch {
- const struct intel_device_info *device_info;
- drm_intel_bo *bo;
- uint32_t commands[INTEL_BATCH_MAX_COMMANDS];
- uint32_t command_count;
+#define GEN(b, m) ((b)->device_info->gen >= (m))
+
+struct intel_batch
+{
+ const struct intel_device_info * device_info;
+ drm_intel_bo * bo;
+ uint32_t commands[INTEL_BATCH_MAX_COMMANDS];
+ uint32_t command_count;
};
-bool intel_batch_initialize(struct intel_batch *batch,
- drm_intel_bufmgr *bufmgr);
+bool intel_batch_initialize(struct intel_batch * batch,
+ drm_intel_bufmgr * bufmgr);
-void intel_batch_finalize(struct intel_batch *batch);
+void intel_batch_finalize(struct intel_batch * batch);
-void intel_batch_flush(struct intel_batch *batch);
+void intel_batch_flush(struct intel_batch * batch);
-static inline uint32_t intel_batch_check_space(struct intel_batch *batch,
- uint32_t size) {
- return (INTEL_BATCH_MAX_COMMANDS - INTEL_BATCH_RESERVED_COMMANDS -
- batch->command_count) >= size;
+static inline uint32_t intel_batch_check_space(struct intel_batch * batch,
+ uint32_t size)
+{
+ return (INTEL_BATCH_MAX_COMMANDS - INTEL_BATCH_RESERVED_COMMANDS
+ - batch->command_count) >= size;
}
-static inline void intel_batch_ensure_space(struct intel_batch *batch,
- uint32_t size) {
- if (!intel_batch_check_space(batch, size))
- intel_batch_flush(batch);
+static inline void intel_batch_ensure_space(struct intel_batch * batch, uint32_t size)
+{
+ if (!intel_batch_check_space(batch, size))
+ intel_batch_flush(batch);
}
-static inline void intel_batch_add_dword(struct intel_batch *batch,
- uint32_t dword) {
- batch->commands[batch->command_count++] = dword;
+static inline void intel_batch_add_dword(struct intel_batch * batch,
+ uint32_t dword)
+{
+ batch->commands[batch->command_count++] = dword;
}
-static inline void intel_batch_add_dwords_va(struct intel_batch *batch,
- uint32_t count, va_list dwords) {
- while (count--)
- intel_batch_add_dword(batch, va_arg(dwords, uint32_t));
+static inline void intel_batch_add_dwords_va(struct intel_batch * batch,
+ uint32_t count, va_list dwords)
+{
+ while (count--)
+ intel_batch_add_dword(batch, va_arg(dwords, uint32_t));
}
-static inline void intel_batch_add_dwords(struct intel_batch *batch,
- uint32_t count, ...) {
- va_list dwords;
- va_start(dwords, count);
- intel_batch_add_dwords_va(batch, count, dwords);
- va_end(dwords);
+static inline void intel_batch_add_dwords(struct intel_batch * batch,
+ uint32_t count, ...)
+{
+ va_list dwords;
+ va_start(dwords, count);
+ intel_batch_add_dwords_va(batch, count, dwords);
+ va_end(dwords);
}
-static inline uint32_t intel_batch_offset(struct intel_batch *batch,
- uint32_t command_index) {
- return (batch->command_count + command_index) << 2;
+static inline uint32_t intel_batch_offset(struct intel_batch * batch,
+ uint32_t command_index)
+{
+ return (batch->command_count + command_index) << 2;
}
#endif
+