anv: Add an anv_batch_set_storage helper
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 16 Jun 2020 15:50:19 +0000 (10:50 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 16 Jun 2020 17:02:44 +0000 (17:02 +0000)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5457>

src/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_pipeline.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_pipeline.c

index 67202307b54a6c98ee30bfcfd9c5eed383cc4b49..d4cd56dc1770cecc274730ce3a248a284ba9a495 100644 (file)
@@ -409,9 +409,8 @@ static void
 anv_batch_bo_start(struct anv_batch_bo *bbo, struct anv_batch *batch,
                    size_t batch_padding)
 {
-   batch->start_addr = (struct anv_address) { .bo = bbo->bo, };
-   batch->next = batch->start = bbo->bo->map;
-   batch->end = bbo->bo->map + bbo->bo->size - batch_padding;
+   anv_batch_set_storage(batch, (struct anv_address) { .bo = bbo->bo, },
+                         bbo->bo->map, bbo->bo->size - batch_padding);
    batch->relocs = &bbo->relocs;
    anv_reloc_list_clear(&bbo->relocs);
 }
index 62a0c5a0b1617a8d127459c9b48ca5133f8c150a..b3469518884c763b541fbab48049ede5b47048c3 100644 (file)
@@ -2001,10 +2001,10 @@ anv_pipeline_init(struct anv_graphics_pipeline *pipeline,
       return result;
 
    pipeline->base.batch.alloc = alloc;
-   pipeline->base.batch.next = pipeline->base.batch.start = pipeline->batch_data;
-   pipeline->base.batch.end = pipeline->base.batch.start + sizeof(pipeline->batch_data);
    pipeline->base.batch.relocs = &pipeline->base.batch_relocs;
    pipeline->base.batch.status = VK_SUCCESS;
+   anv_batch_set_storage(&pipeline->base.batch, ANV_NULL_ADDRESS,
+                         pipeline->batch_data, sizeof(pipeline->batch_data));
 
    pipeline->base.mem_ctx = ralloc_context(NULL);
    pipeline->base.flags = pCreateInfo->flags;
index 8f5dcd37fbc5af9750d905ce1870353dc4c594f1..be0cc9bc59ec58f7100a9aa77db8748c90df7a07 100644 (file)
@@ -1648,6 +1648,15 @@ uint64_t anv_batch_emit_reloc(struct anv_batch *batch,
                               void *location, struct anv_bo *bo, uint32_t offset);
 struct anv_address anv_batch_address(struct anv_batch *batch, void *batch_location);
 
+static inline void
+anv_batch_set_storage(struct anv_batch *batch, struct anv_address addr,
+                      void *map, size_t size)
+{
+   batch->start_addr = addr;
+   batch->next = batch->start = map;
+   batch->end = map + size;
+}
+
 static inline VkResult
 anv_batch_set_error(struct anv_batch *batch, VkResult error)
 {
index 49ccc5ea9e375515e86df2971b7aa047623e17af..d83716bfedf82c7126f4de5328ebf8cb020a686f 100644 (file)
@@ -2299,10 +2299,10 @@ compute_pipeline_create(
       return result;
    }
    pipeline->base.batch.alloc = alloc;
-   pipeline->base.batch.next = pipeline->base.batch.start = pipeline->batch_data;
-   pipeline->base.batch.end = pipeline->base.batch.start + sizeof(pipeline->batch_data);
    pipeline->base.batch.relocs = &pipeline->base.batch_relocs;
    pipeline->base.batch.status = VK_SUCCESS;
+   anv_batch_set_storage(&pipeline->base.batch, ANV_NULL_ADDRESS,
+                         pipeline->batch_data, sizeof(pipeline->batch_data));
 
    pipeline->base.mem_ctx = ralloc_context(NULL);
    pipeline->base.flags = pCreateInfo->flags;