diff options
author | Jason Ekstrand <[email protected]> | 2016-03-30 13:47:41 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-04-08 15:57:45 -0700 |
commit | 00e70868ee81f964bbdb33b40938eec7e4bef1f3 (patch) | |
tree | bdc9c1ed21fc9d524a8b21bc36946813f6d15b86 /src | |
parent | 43fbdd7156197518c2f2f8a1c0befa7f4ffd16e1 (diff) |
anv/blit2d: Enhance teardown and clean up init error paths
Reviewed-by: Nanley Chery <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/anv_meta_blit2d.c | 117 |
1 files changed, 57 insertions, 60 deletions
diff --git a/src/intel/vulkan/anv_meta_blit2d.c b/src/intel/vulkan/anv_meta_blit2d.c index 7424a00b7f2..3dc0c66d1cc 100644 --- a/src/intel/vulkan/anv_meta_blit2d.c +++ b/src/intel/vulkan/anv_meta_blit2d.c @@ -461,18 +461,29 @@ build_nir_copy_fragment_shader(struct anv_device *device, void anv_device_finish_meta_blit2d_state(struct anv_device *device) { - anv_DestroyRenderPass(anv_device_to_handle(device), - device->meta_state.blit2d.render_pass, - &device->meta_state.alloc); - anv_DestroyPipeline(anv_device_to_handle(device), - device->meta_state.blit2d.pipeline_2d_src, - &device->meta_state.alloc); - anv_DestroyPipelineLayout(anv_device_to_handle(device), - device->meta_state.blit2d.pipeline_layout, - &device->meta_state.alloc); - anv_DestroyDescriptorSetLayout(anv_device_to_handle(device), - device->meta_state.blit2d.ds_layout, - &device->meta_state.alloc); + if (device->meta_state.blit2d.render_pass) { + anv_DestroyRenderPass(anv_device_to_handle(device), + device->meta_state.blit2d.render_pass, + &device->meta_state.alloc); + } + + if (device->meta_state.blit2d.pipeline_2d_src) { + anv_DestroyPipeline(anv_device_to_handle(device), + device->meta_state.blit2d.pipeline_2d_src, + &device->meta_state.alloc); + } + + if (device->meta_state.blit2d.pipeline_layout) { + anv_DestroyPipelineLayout(anv_device_to_handle(device), + device->meta_state.blit2d.pipeline_layout, + &device->meta_state.alloc); + } + + if (device->meta_state.blit2d.ds_layout) { + anv_DestroyDescriptorSetLayout(anv_device_to_handle(device), + device->meta_state.blit2d.ds_layout, + &device->meta_state.alloc); + } } VkResult @@ -480,6 +491,8 @@ anv_device_init_meta_blit2d_state(struct anv_device *device) { VkResult result; + zero(device->meta_state.blit2d); + result = anv_CreateRenderPass(anv_device_to_handle(device), &(VkRenderPassCreateInfo) { .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, @@ -513,6 +526,33 @@ anv_device_init_meta_blit2d_state(struct anv_device *device) if (result != VK_SUCCESS) goto fail; + result = anv_CreateDescriptorSetLayout(anv_device_to_handle(device), + &(VkDescriptorSetLayoutCreateInfo) { + .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, + .bindingCount = 1, + .pBindings = (VkDescriptorSetLayoutBinding[]) { + { + .binding = 0, + .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, + .descriptorCount = 1, + .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT, + .pImmutableSamplers = NULL + }, + } + }, &device->meta_state.alloc, &device->meta_state.blit2d.ds_layout); + if (result != VK_SUCCESS) + goto fail; + + result = anv_CreatePipelineLayout(anv_device_to_handle(device), + &(VkPipelineLayoutCreateInfo) { + .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, + .setLayoutCount = 1, + .pSetLayouts = &device->meta_state.blit2d.ds_layout, + }, + &device->meta_state.alloc, &device->meta_state.blit2d.pipeline_layout); + if (result != VK_SUCCESS) + goto fail; + /* We don't use a vertex shader for blitting, but instead build and pass * the VUEs directly to the rasterization backend. However, we do need * to provide GLSL source for the vertex shader so that the compiler @@ -567,36 +607,6 @@ anv_device_init_meta_blit2d_state(struct anv_device *device) } }; - VkDescriptorSetLayoutCreateInfo ds_layout_info = { - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, - .bindingCount = 1, - .pBindings = (VkDescriptorSetLayoutBinding[]) { - { - .binding = 0, - .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, - .descriptorCount = 1, - .stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT, - .pImmutableSamplers = NULL - }, - } - }; - result = anv_CreateDescriptorSetLayout(anv_device_to_handle(device), - &ds_layout_info, - &device->meta_state.alloc, - &device->meta_state.blit2d.ds_layout); - if (result != VK_SUCCESS) - goto fail_render_pass; - - result = anv_CreatePipelineLayout(anv_device_to_handle(device), - &(VkPipelineLayoutCreateInfo) { - .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, - .setLayoutCount = 1, - .pSetLayouts = &device->meta_state.blit2d.ds_layout, - }, - &device->meta_state.alloc, &device->meta_state.blit2d.pipeline_layout); - if (result != VK_SUCCESS) - goto fail_descriptor_set_layout; - VkPipelineShaderStageCreateInfo pipeline_shader_stages[] = { { .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, @@ -687,29 +697,16 @@ anv_device_init_meta_blit2d_state(struct anv_device *device) VK_NULL_HANDLE, &vk_pipeline_info, &anv_pipeline_info, &device->meta_state.alloc, &device->meta_state.blit2d.pipeline_2d_src); - if (result != VK_SUCCESS) - goto fail_pipeline_layout; ralloc_free(vs.nir); ralloc_free(fs_2d.nir); - return VK_SUCCESS; + if (result != VK_SUCCESS) + goto fail; - fail_pipeline_layout: - anv_DestroyPipelineLayout(anv_device_to_handle(device), - device->meta_state.blit2d.pipeline_layout, - &device->meta_state.alloc); - fail_descriptor_set_layout: - anv_DestroyDescriptorSetLayout(anv_device_to_handle(device), - device->meta_state.blit2d.ds_layout, - &device->meta_state.alloc); - fail_render_pass: - anv_DestroyRenderPass(anv_device_to_handle(device), - device->meta_state.blit2d.render_pass, - &device->meta_state.alloc); + return VK_SUCCESS; - ralloc_free(vs.nir); - ralloc_free(fs_2d.nir); - fail: +fail: + anv_device_finish_meta_blit2d_state(device); return result; } |