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
{
VkResult result;
+ zero(device->meta_state.blit2d);
+
result = anv_CreateRenderPass(anv_device_to_handle(device),
&(VkRenderPassCreateInfo) {
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
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
}
};
- 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,
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;
}