aboutsummaryrefslogtreecommitdiff
path: root/src/wld/intel/batch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wld/intel/batch.c')
-rw-r--r--src/wld/intel/batch.c102
1 files changed, 49 insertions, 53 deletions
diff --git a/src/wld/intel/batch.c b/src/wld/intel/batch.c
index 61d9ecf..ce15ef1 100644
--- a/src/wld/intel/batch.c
+++ b/src/wld/intel/batch.c
@@ -27,73 +27,69 @@
#include <i915_drm.h>
#include <stdlib.h>
-static const struct intel_device_info device_info_i965 = { .gen = 4 };
-static const struct intel_device_info device_info_g4x = { .gen = 4 };
-static const struct intel_device_info device_info_ilk = { .gen = 5 };
-static const struct intel_device_info device_info_snb_gt1 = { .gen = 6 };
-static const struct intel_device_info device_info_snb_gt2 = { .gen = 6 };
-static const struct intel_device_info device_info_ivb_gt1 = { .gen = 7 };
-static const struct intel_device_info device_info_ivb_gt2 = { .gen = 7 };
-static const struct intel_device_info device_info_byt = { .gen = 7 };
-static const struct intel_device_info device_info_hsw_gt1 = { .gen = 7 };
-static const struct intel_device_info device_info_hsw_gt2 = { .gen = 7 };
-static const struct intel_device_info device_info_hsw_gt3 = { .gen = 7 };
-
-static const struct intel_device_info * device_info(int device_id)
-{
- switch (device_id)
- {
-#define CHIPSET(device_id, type, name) \
- case device_id: return &device_info_ ## type;
+static const struct intel_device_info device_info_i965 = {.gen = 4};
+static const struct intel_device_info device_info_g4x = {.gen = 4};
+static const struct intel_device_info device_info_ilk = {.gen = 5};
+static const struct intel_device_info device_info_snb_gt1 = {.gen = 6};
+static const struct intel_device_info device_info_snb_gt2 = {.gen = 6};
+static const struct intel_device_info device_info_ivb_gt1 = {.gen = 7};
+static const struct intel_device_info device_info_ivb_gt2 = {.gen = 7};
+static const struct intel_device_info device_info_byt = {.gen = 7};
+static const struct intel_device_info device_info_hsw_gt1 = {.gen = 7};
+static const struct intel_device_info device_info_hsw_gt2 = {.gen = 7};
+static const struct intel_device_info device_info_hsw_gt3 = {.gen = 7};
+
+static const struct intel_device_info *device_info(int device_id) {
+ switch (device_id) {
+#define CHIPSET(device_id, type, name) \
+ case device_id: \
+ return &device_info_##type;
#include "i965_pci_ids.h"
#undef CHIPSET
- default: return NULL;
- }
+ default:
+ return NULL;
+ }
}
-bool intel_batch_initialize(struct intel_batch * batch,
- drm_intel_bufmgr * bufmgr)
-{
- int device_id = drm_intel_bufmgr_gem_get_devid(bufmgr);
+bool intel_batch_initialize(struct intel_batch *batch,
+ drm_intel_bufmgr *bufmgr) {
+ int device_id = drm_intel_bufmgr_gem_get_devid(bufmgr);
- batch->command_count = 0;
- batch->device_info = device_info(device_id);
+ batch->command_count = 0;
+ batch->device_info = device_info(device_id);
- if (!batch->device_info)
- return false;
+ if (!batch->device_info)
+ return false;
- /* Alignment argument (4096) is not used */
- batch->bo = drm_intel_bo_alloc(bufmgr, "batchbuffer",
- sizeof batch->commands, 4096);
+ /* Alignment argument (4096) is not used */
+ batch->bo =
+ drm_intel_bo_alloc(bufmgr, "batchbuffer", sizeof batch->commands, 4096);
- if (!batch->bo)
- return false;
+ if (!batch->bo)
+ return false;
- return true;
+ return true;
}
-void intel_batch_finalize(struct intel_batch * batch)
-{
- drm_intel_bo_unreference(batch->bo);
+void intel_batch_finalize(struct intel_batch *batch) {
+ drm_intel_bo_unreference(batch->bo);
}
-void intel_batch_flush(struct intel_batch * batch)
-{
- if (batch->command_count == 0)
- return;
+void intel_batch_flush(struct intel_batch *batch) {
+ if (batch->command_count == 0)
+ return;
- intel_batch_add_dword(batch, MI_BATCH_BUFFER_END);
+ intel_batch_add_dword(batch, MI_BATCH_BUFFER_END);
- /* Pad the batch buffer to the next quad-word. */
- if (batch->command_count & 1)
- intel_batch_add_dword(batch, MI_NOOP);
+ /* Pad the batch buffer to the next quad-word. */
+ if (batch->command_count & 1)
+ intel_batch_add_dword(batch, MI_NOOP);
- drm_intel_bo_subdata(batch->bo, 0, batch->command_count << 2,
- batch->commands);
- drm_intel_bo_mrb_exec(batch->bo, batch->command_count << 2, NULL, 0, 0,
- batch->device_info->gen >= 6 ? I915_EXEC_BLT
- : I915_EXEC_DEFAULT);
- drm_intel_gem_bo_clear_relocs(batch->bo, 0);
- batch->command_count = 0;
+ drm_intel_bo_subdata(batch->bo, 0, batch->command_count << 2,
+ batch->commands);
+ drm_intel_bo_mrb_exec(batch->bo, batch->command_count << 2, NULL, 0, 0,
+ batch->device_info->gen >= 6 ? I915_EXEC_BLT
+ : I915_EXEC_DEFAULT);
+ drm_intel_gem_bo_clear_relocs(batch->bo, 0);
+ batch->command_count = 0;
}
-