summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2017-03-28 16:13:41 -0700
committerKenneth Graunke <kenneth@whitecape.org>2017-04-04 14:53:24 -0700
commitc55113d2c8bd73f4bcf5d1e9bdf100a5b9c65c89 (patch)
tree18e610988e4e171712d0e6afbb04523dd9e99ba2
parent8b3885ae41d93d867ab7ef6c40ab5ab0d52ed239 (diff)
i965/drm: Make register write check handle execbuffer directly.
I'm about to rewrite how relocation handling works, at which point drm_bacon_bo_emit_reloc() and drm_bacon_bo_mrb_exec() won't exist anymore. This code is already largely not using the batchbuffer infrastructure, so just go all the way and handle relocations, the validation list, and execbuffer ourselves. That way, we don't have to think the weird case where we only have a screen, and no context, when redesigning the relocation handling.
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 4cecd52f36..42baadf25e 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1367,6 +1367,9 @@ static bool
intel_detect_pipelined_register(struct intel_screen *screen,
int reg, uint32_t expected_value, bool reset)
{
+ if (screen->no_hw)
+ return false;
+
drm_bacon_bo *results, *bo;
uint32_t *batch;
uint32_t offset = 0;
@@ -1394,11 +1397,14 @@ intel_detect_pipelined_register(struct intel_screen *screen,
/* Save the register's value back to the buffer. */
*batch++ = MI_STORE_REGISTER_MEM | (3 - 2);
*batch++ = reg;
- drm_bacon_bo_emit_reloc(bo, (char *)batch -(char *)bo->virtual,
- results, offset*sizeof(uint32_t),
- I915_GEM_DOMAIN_INSTRUCTION,
- I915_GEM_DOMAIN_INSTRUCTION);
- *batch++ = ((uint32_t) results->offset64) + offset*sizeof(uint32_t);
+ struct drm_i915_gem_relocation_entry reloc = {
+ .offset = (char *) batch - (char *) bo->virtual,
+ .delta = offset * sizeof(uint32_t),
+ .target_handle = results->handle,
+ .read_domains = I915_GEM_DOMAIN_INSTRUCTION,
+ .write_domain = I915_GEM_DOMAIN_INSTRUCTION,
+ };
+ *batch++ = offset * sizeof(uint32_t);
/* And afterwards clear the register */
if (reset) {
@@ -1409,8 +1415,26 @@ intel_detect_pipelined_register(struct intel_screen *screen,
*batch++ = MI_BATCH_BUFFER_END;
- drm_bacon_bo_mrb_exec(bo, ALIGN((char *)batch - (char *)bo->virtual, 8),
- I915_EXEC_RENDER);
+ struct drm_i915_gem_exec_object2 exec_objects[2] = {
+ {
+ .handle = results->handle,
+ },
+ {
+ .handle = bo->handle,
+ .relocation_count = 1,
+ .relocs_ptr = (uintptr_t) &reloc,
+ }
+ };
+
+ struct drm_i915_gem_execbuffer2 execbuf = {
+ .buffers_ptr = (uintptr_t) exec_objects,
+ .buffer_count = 2,
+ .batch_len = ALIGN((char *) batch - (char *) bo->virtual, 8),
+ .flags = I915_EXEC_RENDER,
+ };
+
+ __DRIscreen *dri_screen = screen->driScrnPriv;
+ drmIoctl(dri_screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
/* Check whether the value got written. */
if (drm_bacon_bo_map(results, false) == 0) {