anv: Add a ralloc context to anv_pipeline
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 24 Apr 2019 07:21:01 +0000 (02:21 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Mon, 12 Aug 2019 22:56:07 +0000 (22:56 +0000)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_pipeline.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_pipeline.c

index 1d02266..fc49284 100644 (file)
@@ -297,6 +297,9 @@ void anv_DestroyPipeline(
 
    anv_reloc_list_finish(&pipeline->batch_relocs,
                          pAllocator ? pAllocator : &device->alloc);
+
+   ralloc_free(pipeline->mem_ctx);
+
    if (pipeline->blend_state.map)
       anv_state_pool_free(&device->dynamic_state_pool, pipeline->blend_state);
 
@@ -1794,6 +1797,7 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
    pipeline->batch.relocs = &pipeline->batch_relocs;
    pipeline->batch.status = VK_SUCCESS;
 
+   pipeline->mem_ctx = ralloc_context(NULL);
    pipeline->flags = pCreateInfo->flags;
 
    copy_non_dynamic_state(pipeline, pCreateInfo);
@@ -1822,6 +1826,7 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
 
    result = anv_pipeline_compile_graphics(pipeline, cache, pCreateInfo);
    if (result != VK_SUCCESS) {
+      ralloc_free(pipeline->mem_ctx);
       anv_reloc_list_finish(&pipeline->batch_relocs, alloc);
       return result;
    }
index ad2de7f..5682e83 100644 (file)
@@ -2802,6 +2802,8 @@ struct anv_pipeline {
    anv_cmd_dirty_mask_t                         dynamic_state_mask;
    struct anv_dynamic_state                     dynamic_state;
 
+   void *                                       mem_ctx;
+
    VkPipelineCreateFlags                        flags;
    struct anv_subpass *                         subpass;
 
index 0fc25f8..e0e723c 100644 (file)
@@ -2226,6 +2226,7 @@ compute_pipeline_create(
    pipeline->batch.relocs = &pipeline->batch_relocs;
    pipeline->batch.status = VK_SUCCESS;
 
+   pipeline->mem_ctx = ralloc_context(NULL);
    pipeline->flags = pCreateInfo->flags;
 
    /* When we free the pipeline, we detect stages based on the NULL status
@@ -2242,6 +2243,7 @@ compute_pipeline_create(
                                     pCreateInfo->stage.pName,
                                     pCreateInfo->stage.pSpecializationInfo);
    if (result != VK_SUCCESS) {
+      ralloc_free(pipeline->mem_ctx);
       vk_free2(&device->alloc, pAllocator, pipeline);
       return result;
    }