diff options
author | Jason Ekstrand <[email protected]> | 2015-07-27 16:37:09 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-07-27 16:37:09 -0700 |
commit | 3c2743dcd10f2df459363a04a257b91ca7299092 (patch) | |
tree | bb0e1199c1282f909ebd4f056fc1c9b9eb5be03d | |
parent | 4ced8650d492c8a346bdc51c494b2268d7bf473d (diff) |
vk/cmd_buffer: Pull the execbuf stuff into a substruct
-rw-r--r-- | src/vulkan/anv_aub.c | 12 | ||||
-rw-r--r-- | src/vulkan/anv_cmd_buffer.c | 85 | ||||
-rw-r--r-- | src/vulkan/anv_cmd_emit.c | 2 | ||||
-rw-r--r-- | src/vulkan/anv_device.c | 6 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 22 |
5 files changed, 68 insertions, 59 deletions
diff --git a/src/vulkan/anv_aub.c b/src/vulkan/anv_aub.c index 97f124a0aad..c371cce1bb8 100644 --- a/src/vulkan/anv_aub.c +++ b/src/vulkan/anv_aub.c @@ -248,10 +248,10 @@ anv_cmd_buffer_dump(struct anv_cmd_buffer *cmd_buffer) if (writer == NULL) return; - aub_bos = malloc(cmd_buffer->exec2_bo_count * sizeof(aub_bos[0])); + aub_bos = malloc(cmd_buffer->execbuf2.bo_count * sizeof(aub_bos[0])); offset = writer->offset; - for (uint32_t i = 0; i < cmd_buffer->exec2_bo_count; i++) { - bo = cmd_buffer->exec2_bos[i]; + for (uint32_t i = 0; i < cmd_buffer->execbuf2.bo_count; i++) { + bo = cmd_buffer->execbuf2.bos[i]; if (bo->map) aub_bos[i].map = bo->map; else @@ -282,9 +282,9 @@ anv_cmd_buffer_dump(struct anv_cmd_buffer *cmd_buffer) bbo->num_relocs, aub_bos); } - for (uint32_t i = 0; i < cmd_buffer->exec2_bo_count; i++) { - bo = cmd_buffer->exec2_bos[i]; - if (i == cmd_buffer->exec2_bo_count - 1) { + for (uint32_t i = 0; i < cmd_buffer->execbuf2.bo_count; i++) { + bo = cmd_buffer->execbuf2.bos[i]; + if (i == cmd_buffer->execbuf2.bo_count - 1) { assert(bo == &first_bbo->bo); aub_write_trace_block(writer, AUB_TRACE_TYPE_BATCH, aub_bos[i].relocated, diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index bb58338c85f..1c891e19ac6 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -381,9 +381,9 @@ anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer) /* Start surface_next at 1 so surface offset 0 is invalid. */ cmd_buffer->surface_next = 1; - cmd_buffer->exec2_objects = NULL; - cmd_buffer->exec2_bos = NULL; - cmd_buffer->exec2_array_length = 0; + cmd_buffer->execbuf2.objects = NULL; + cmd_buffer->execbuf2.bos = NULL; + cmd_buffer->execbuf2.array_length = 0; return VK_SUCCESS; @@ -420,8 +420,8 @@ anv_cmd_buffer_fini_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer) } anv_reloc_list_finish(&cmd_buffer->surface_relocs, device); - anv_device_free(device, cmd_buffer->exec2_objects); - anv_device_free(device, cmd_buffer->exec2_bos); + anv_device_free(device, cmd_buffer->execbuf2.objects); + anv_device_free(device, cmd_buffer->execbuf2.bos); } void @@ -461,13 +461,13 @@ anv_cmd_buffer_add_bo(struct anv_cmd_buffer *cmd_buffer, { struct drm_i915_gem_exec_object2 *obj; - if (bo->index < cmd_buffer->exec2_bo_count && - cmd_buffer->exec2_bos[bo->index] == bo) + if (bo->index < cmd_buffer->execbuf2.bo_count && + cmd_buffer->execbuf2.bos[bo->index] == bo) return VK_SUCCESS; - if (cmd_buffer->exec2_bo_count >= cmd_buffer->exec2_array_length) { - uint32_t new_len = cmd_buffer->exec2_objects ? - cmd_buffer->exec2_array_length * 2 : 64; + if (cmd_buffer->execbuf2.bo_count >= cmd_buffer->execbuf2.array_length) { + uint32_t new_len = cmd_buffer->execbuf2.objects ? + cmd_buffer->execbuf2.array_length * 2 : 64; struct drm_i915_gem_exec_object2 *new_objects = anv_device_alloc(cmd_buffer->device, new_len * sizeof(*new_objects), @@ -483,23 +483,23 @@ anv_cmd_buffer_add_bo(struct anv_cmd_buffer *cmd_buffer, return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); } - if (cmd_buffer->exec2_objects) { - memcpy(new_objects, cmd_buffer->exec2_objects, - cmd_buffer->exec2_bo_count * sizeof(*new_objects)); - memcpy(new_bos, cmd_buffer->exec2_bos, - cmd_buffer->exec2_bo_count * sizeof(*new_bos)); + if (cmd_buffer->execbuf2.objects) { + memcpy(new_objects, cmd_buffer->execbuf2.objects, + cmd_buffer->execbuf2.bo_count * sizeof(*new_objects)); + memcpy(new_bos, cmd_buffer->execbuf2.bos, + cmd_buffer->execbuf2.bo_count * sizeof(*new_bos)); } - cmd_buffer->exec2_objects = new_objects; - cmd_buffer->exec2_bos = new_bos; - cmd_buffer->exec2_array_length = new_len; + cmd_buffer->execbuf2.objects = new_objects; + cmd_buffer->execbuf2.bos = new_bos; + cmd_buffer->execbuf2.array_length = new_len; } - assert(cmd_buffer->exec2_bo_count < cmd_buffer->exec2_array_length); + assert(cmd_buffer->execbuf2.bo_count < cmd_buffer->execbuf2.array_length); - bo->index = cmd_buffer->exec2_bo_count++; - obj = &cmd_buffer->exec2_objects[bo->index]; - cmd_buffer->exec2_bos[bo->index] = bo; + bo->index = cmd_buffer->execbuf2.bo_count++; + obj = &cmd_buffer->execbuf2.objects[bo->index]; + cmd_buffer->execbuf2.bos[bo->index] = bo; obj->handle = bo->gem_handle; obj->relocation_count = 0; @@ -543,7 +543,7 @@ anv_cmd_buffer_process_relocs(struct anv_cmd_buffer *cmd_buffer, for (size_t i = 0; i < list->num_relocs; i++) { bo = list->reloc_bos[i]; if (bo->offset != list->relocs[i].presumed_offset) - cmd_buffer->need_reloc = true; + cmd_buffer->execbuf2.need_reloc = true; list->relocs[i].target_handle = bo->index; } @@ -561,12 +561,12 @@ anv_cmd_buffer_emit_batch_buffer_end(struct anv_cmd_buffer *cmd_buffer) } void -anv_cmd_buffer_compute_validate_list(struct anv_cmd_buffer *cmd_buffer) +anv_cmd_buffer_prepare_execbuf(struct anv_cmd_buffer *cmd_buffer) { struct anv_batch *batch = &cmd_buffer->batch; - cmd_buffer->exec2_bo_count = 0; - cmd_buffer->need_reloc = false; + cmd_buffer->execbuf2.bo_count = 0; + cmd_buffer->execbuf2.need_reloc = false; /* Add surface state bos first so we can add them with their relocs. */ for (struct anv_batch_bo *bbo = cmd_buffer->surface_batch_bo; @@ -596,24 +596,25 @@ anv_cmd_buffer_compute_validate_list(struct anv_cmd_buffer *cmd_buffer) anv_cmd_buffer_add_bo(cmd_buffer, &batch_bo->bo, &batch->relocs.relocs[batch_bo->first_reloc], batch_bo->num_relocs); - assert(batch_bo->bo.index == cmd_buffer->exec2_bo_count - 1); + assert(batch_bo->bo.index == cmd_buffer->execbuf2.bo_count - 1); anv_cmd_buffer_process_relocs(cmd_buffer, &cmd_buffer->surface_relocs); anv_cmd_buffer_process_relocs(cmd_buffer, &batch->relocs); - cmd_buffer->execbuf.buffers_ptr = (uintptr_t) cmd_buffer->exec2_objects; - cmd_buffer->execbuf.buffer_count = cmd_buffer->exec2_bo_count; - cmd_buffer->execbuf.batch_start_offset = 0; - cmd_buffer->execbuf.batch_len = batch->next - batch->start; - cmd_buffer->execbuf.cliprects_ptr = 0; - cmd_buffer->execbuf.num_cliprects = 0; - cmd_buffer->execbuf.DR1 = 0; - cmd_buffer->execbuf.DR4 = 0; - - cmd_buffer->execbuf.flags = I915_EXEC_HANDLE_LUT; - if (!cmd_buffer->need_reloc) - cmd_buffer->execbuf.flags |= I915_EXEC_NO_RELOC; - cmd_buffer->execbuf.flags |= I915_EXEC_RENDER; - cmd_buffer->execbuf.rsvd1 = cmd_buffer->device->context_id; - cmd_buffer->execbuf.rsvd2 = 0; + cmd_buffer->execbuf2.execbuf = (struct drm_i915_gem_execbuffer2) { + .buffers_ptr = (uintptr_t) cmd_buffer->execbuf2.objects, + .buffer_count = cmd_buffer->execbuf2.bo_count, + .batch_start_offset = 0, + .batch_len = batch->next - batch->start, + .cliprects_ptr = 0, + .num_cliprects = 0, + .DR1 = 0, + .DR4 = 0, + .flags = I915_EXEC_HANDLE_LUT | I915_EXEC_RENDER, + .rsvd1 = cmd_buffer->device->context_id, + .rsvd2 = 0, + }; + + if (!cmd_buffer->execbuf2.need_reloc) + cmd_buffer->execbuf2.execbuf.flags |= I915_EXEC_NO_RELOC; } diff --git a/src/vulkan/anv_cmd_emit.c b/src/vulkan/anv_cmd_emit.c index c624906ae36..8178e697964 100644 --- a/src/vulkan/anv_cmd_emit.c +++ b/src/vulkan/anv_cmd_emit.c @@ -189,7 +189,7 @@ VkResult anv_EndCommandBuffer( * Fortunately, the chances for contention here are probably very low. */ pthread_mutex_lock(&device->mutex); - anv_cmd_buffer_compute_validate_list(cmd_buffer); + anv_cmd_buffer_prepare_execbuf(cmd_buffer); pthread_mutex_unlock(&device->mutex); return VK_SUCCESS; diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 0bcf9b04b45..ee7682a5d9a 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -742,7 +742,7 @@ VkResult anv_QueueSubmit( anv_cmd_buffer_dump(cmd_buffer); if (!device->no_hw) { - ret = anv_gem_execbuffer(device, &cmd_buffer->execbuf); + ret = anv_gem_execbuffer(device, &cmd_buffer->execbuf2.execbuf); if (ret != 0) return vk_error(VK_ERROR_UNKNOWN); @@ -752,8 +752,8 @@ VkResult anv_QueueSubmit( return vk_error(VK_ERROR_UNKNOWN); } - for (uint32_t i = 0; i < cmd_buffer->exec2_bo_count; i++) - cmd_buffer->exec2_bos[i]->offset = cmd_buffer->exec2_objects[i].offset; + for (uint32_t i = 0; i < cmd_buffer->execbuf2.bo_count; i++) + cmd_buffer->execbuf2.bos[i]->offset = cmd_buffer->execbuf2.objects[i].offset; } else { *(uint32_t *)queue->completed_serial.map = cmd_buffer->serial; } diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index f8def1108cb..3d364ef30d4 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -706,12 +706,20 @@ struct anv_cmd_buffer { /* Information needed for execbuf that's generated when the command * buffer is ended. */ - struct drm_i915_gem_execbuffer2 execbuf; - struct drm_i915_gem_exec_object2 * exec2_objects; - uint32_t exec2_bo_count; - struct anv_bo ** exec2_bos; - uint32_t exec2_array_length; - bool need_reloc; + struct { + struct drm_i915_gem_execbuffer2 execbuf; + + struct drm_i915_gem_exec_object2 * objects; + uint32_t bo_count; + struct anv_bo ** bos; + + /* Allocated length of the 'objects' and 'bos' arrays */ + uint32_t array_length; + + bool need_reloc; + } execbuf2; + + /* Serial for tracking buffer completion */ uint32_t serial; /* Stream objects for storing temporary data */ @@ -725,7 +733,7 @@ VkResult anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer); void anv_cmd_buffer_fini_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer); void anv_cmd_buffer_reset_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer); void anv_cmd_buffer_emit_batch_buffer_end(struct anv_cmd_buffer *cmd_buffer); -void anv_cmd_buffer_compute_validate_list(struct anv_cmd_buffer *cmd_buffer); +void anv_cmd_buffer_prepare_execbuf(struct anv_cmd_buffer *cmd_buffer); struct anv_state anv_cmd_buffer_alloc_surface_state(struct anv_cmd_buffer *cmd_buffer, |