summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-07-29 14:05:06 -0700
committerJason Ekstrand <[email protected]>2015-07-30 08:24:02 -0700
commite39d0b635c3d6fdce81496ca859b0bdd9de68724 (patch)
tree75df1ee00b947250ee10b5b8611e45cd101b0468
parent82548a3acac29cc0fcf492a7dc743bedb11e2df2 (diff)
CLONE
-rw-r--r--src/vulkan/anv_cmd_buffer.c66
1 files changed, 61 insertions, 5 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c
index a0a67af676c..5126f4a981c 100644
--- a/src/vulkan/anv_cmd_buffer.c
+++ b/src/vulkan/anv_cmd_buffer.c
@@ -42,11 +42,19 @@
* Functions related to anv_reloc_list
*-----------------------------------------------------------------------*/
-VkResult
-anv_reloc_list_init(struct anv_reloc_list *list, struct anv_device *device)
+static VkResult
+anv_reloc_list_init_clone(struct anv_reloc_list *list,
+ struct anv_device *device,
+ const struct anv_reloc_list *other_list)
{
- list->num_relocs = 0;
- list->array_length = 256;
+ if (other_list) {
+ list->num_relocs = other_list->num_relocs;
+ list->array_length = other_list->array_length;
+ } else {
+ list->num_relocs = 0;
+ list->array_length = 256;
+ }
+
list->relocs =
anv_device_alloc(device, list->array_length * sizeof(*list->relocs), 8,
VK_SYSTEM_ALLOC_TYPE_INTERNAL);
@@ -58,14 +66,27 @@ anv_reloc_list_init(struct anv_reloc_list *list, struct anv_device *device)
anv_device_alloc(device, list->array_length * sizeof(*list->reloc_bos), 8,
VK_SYSTEM_ALLOC_TYPE_INTERNAL);
- if (list->relocs == NULL) {
+ if (list->reloc_bos == NULL) {
anv_device_free(device, list->relocs);
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
}
+ if (other_list) {
+ memcpy(list->relocs, other_list->relocs,
+ list->array_length * sizeof(*list->relocs));
+ memcpy(list->reloc_bos, other_list->reloc_bos,
+ list->array_length * sizeof(*list->reloc_bos));
+ }
+
return VK_SUCCESS;
}
+VkResult
+anv_reloc_list_init(struct anv_reloc_list *list, struct anv_device *device)
+{
+ return anv_reloc_list_init_clone(list, device, NULL);
+}
+
void
anv_reloc_list_finish(struct anv_reloc_list *list, struct anv_device *device)
{
@@ -236,6 +257,41 @@ anv_batch_bo_create(struct anv_device *device, struct anv_batch_bo **bbo_out)
return result;
}
+static VkResult
+anv_batch_bo_clone(struct anv_device *device,
+ const struct anv_batch_bo *other_bbo,
+ struct anv_batch_bo **bbo_out)
+{
+ VkResult result;
+
+ struct anv_batch_bo *bbo =
+ anv_device_alloc(device, sizeof(*bbo), 8, VK_SYSTEM_ALLOC_TYPE_INTERNAL);
+ if (bbo == NULL)
+ return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+
+ result = anv_bo_pool_alloc(&device->batch_bo_pool, &bbo->bo);
+ if (result != VK_SUCCESS)
+ goto fail_alloc;
+
+ result = anv_reloc_list_init_clone(&bbo->relocs, device, &other_bbo->relocs);
+ if (result != VK_SUCCESS)
+ goto fail_bo_alloc;
+
+ bbo->length = other_bbo->length;
+ memcpy(bbo->bo.map, other_bbo->bo.map, other_bbo->length);
+
+ *bbo_out = bbo;
+
+ return VK_SUCCESS;
+
+ fail_bo_alloc:
+ anv_bo_pool_free(&device->batch_bo_pool, &bbo->bo);
+ fail_alloc:
+ anv_device_free(device, bbo);
+
+ return result;
+}
+
static void
anv_batch_bo_start(struct anv_batch_bo *bbo, struct anv_batch *batch,
size_t batch_padding)