anv: Handle null in all destructors
This fixes a bunch of new CTS tests which look for exactly this. Even in the cases where we just call vk_free to free a CPU data structure, we still handle NULL explicitly. This way we're less likely to forget to handle NULL later should we actually do something less trivial. Cc: "13.0" <mesa-stable@lists.freedesktop.org> Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -262,6 +262,9 @@ void anv_FreeCommandBuffers(
|
|||||||
for (uint32_t i = 0; i < commandBufferCount; i++) {
|
for (uint32_t i = 0; i < commandBufferCount; i++) {
|
||||||
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, pCommandBuffers[i]);
|
ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, pCommandBuffers[i]);
|
||||||
|
|
||||||
|
if (!cmd_buffer)
|
||||||
|
continue;
|
||||||
|
|
||||||
anv_cmd_buffer_destroy(cmd_buffer);
|
anv_cmd_buffer_destroy(cmd_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -758,6 +761,9 @@ void anv_DestroyCommandPool(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_cmd_pool, pool, commandPool);
|
ANV_FROM_HANDLE(anv_cmd_pool, pool, commandPool);
|
||||||
|
|
||||||
|
if (!pool)
|
||||||
|
return;
|
||||||
|
|
||||||
list_for_each_entry_safe(struct anv_cmd_buffer, cmd_buffer,
|
list_for_each_entry_safe(struct anv_cmd_buffer, cmd_buffer,
|
||||||
&pool->cmd_buffers, pool_link) {
|
&pool->cmd_buffers, pool_link) {
|
||||||
anv_cmd_buffer_destroy(cmd_buffer);
|
anv_cmd_buffer_destroy(cmd_buffer);
|
||||||
|
@@ -200,6 +200,9 @@ void anv_DestroyDescriptorSetLayout(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_descriptor_set_layout, set_layout, _set_layout);
|
ANV_FROM_HANDLE(anv_descriptor_set_layout, set_layout, _set_layout);
|
||||||
|
|
||||||
|
if (!set_layout)
|
||||||
|
return;
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, set_layout);
|
vk_free2(&device->alloc, pAllocator, set_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,6 +285,9 @@ void anv_DestroyPipelineLayout(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_pipeline_layout, pipeline_layout, _pipelineLayout);
|
ANV_FROM_HANDLE(anv_pipeline_layout, pipeline_layout, _pipelineLayout);
|
||||||
|
|
||||||
|
if (!pipeline_layout)
|
||||||
|
return;
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, pipeline_layout);
|
vk_free2(&device->alloc, pAllocator, pipeline_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,6 +361,9 @@ void anv_DestroyDescriptorPool(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_descriptor_pool, pool, _pool);
|
ANV_FROM_HANDLE(anv_descriptor_pool, pool, _pool);
|
||||||
|
|
||||||
|
if (!pool)
|
||||||
|
return;
|
||||||
|
|
||||||
anv_state_stream_finish(&pool->surface_state_stream);
|
anv_state_stream_finish(&pool->surface_state_stream);
|
||||||
vk_free2(&device->alloc, pAllocator, pool);
|
vk_free2(&device->alloc, pAllocator, pool);
|
||||||
}
|
}
|
||||||
@@ -546,6 +555,9 @@ VkResult anv_FreeDescriptorSets(
|
|||||||
for (uint32_t i = 0; i < count; i++) {
|
for (uint32_t i = 0; i < count; i++) {
|
||||||
ANV_FROM_HANDLE(anv_descriptor_set, set, pDescriptorSets[i]);
|
ANV_FROM_HANDLE(anv_descriptor_set, set, pDescriptorSets[i]);
|
||||||
|
|
||||||
|
if (!set)
|
||||||
|
continue;
|
||||||
|
|
||||||
anv_descriptor_set_destroy(device, pool, set);
|
anv_descriptor_set_destroy(device, pool, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1569,6 +1569,9 @@ void anv_DestroyFence(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_fence, fence, _fence);
|
ANV_FROM_HANDLE(anv_fence, fence, _fence);
|
||||||
|
|
||||||
|
if (!fence)
|
||||||
|
return;
|
||||||
|
|
||||||
assert(fence->bo.map == fence);
|
assert(fence->bo.map == fence);
|
||||||
anv_bo_pool_free(&device->batch_bo_pool, &fence->bo);
|
anv_bo_pool_free(&device->batch_bo_pool, &fence->bo);
|
||||||
}
|
}
|
||||||
@@ -1808,6 +1811,9 @@ void anv_DestroyEvent(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_event, event, _event);
|
ANV_FROM_HANDLE(anv_event, event, _event);
|
||||||
|
|
||||||
|
if (!event)
|
||||||
|
return;
|
||||||
|
|
||||||
anv_state_pool_free(&device->dynamic_state_pool, event->state);
|
anv_state_pool_free(&device->dynamic_state_pool, event->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1900,6 +1906,9 @@ void anv_DestroyBuffer(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
|
ANV_FROM_HANDLE(anv_buffer, buffer, _buffer);
|
||||||
|
|
||||||
|
if (!buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, buffer);
|
vk_free2(&device->alloc, pAllocator, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1927,6 +1936,9 @@ void anv_DestroySampler(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_sampler, sampler, _sampler);
|
ANV_FROM_HANDLE(anv_sampler, sampler, _sampler);
|
||||||
|
|
||||||
|
if (!sampler)
|
||||||
|
return;
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, sampler);
|
vk_free2(&device->alloc, pAllocator, sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1971,5 +1983,8 @@ void anv_DestroyFramebuffer(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_framebuffer, fb, _fb);
|
ANV_FROM_HANDLE(anv_framebuffer, fb, _fb);
|
||||||
|
|
||||||
|
if (!fb)
|
||||||
|
return;
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, fb);
|
vk_free2(&device->alloc, pAllocator, fb);
|
||||||
}
|
}
|
||||||
|
@@ -275,8 +275,12 @@ anv_DestroyImage(VkDevice _device, VkImage _image,
|
|||||||
const VkAllocationCallbacks *pAllocator)
|
const VkAllocationCallbacks *pAllocator)
|
||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
|
ANV_FROM_HANDLE(anv_image, image, _image);
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, anv_image_from_handle(_image));
|
if (!image)
|
||||||
|
return;
|
||||||
|
|
||||||
|
vk_free2(&device->alloc, pAllocator, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult anv_BindImageMemory(
|
VkResult anv_BindImageMemory(
|
||||||
@@ -548,6 +552,9 @@ anv_DestroyImageView(VkDevice _device, VkImageView _iview,
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_image_view, iview, _iview);
|
ANV_FROM_HANDLE(anv_image_view, iview, _iview);
|
||||||
|
|
||||||
|
if (!iview)
|
||||||
|
return;
|
||||||
|
|
||||||
if (iview->sampler_surface_state.alloc_size > 0) {
|
if (iview->sampler_surface_state.alloc_size > 0) {
|
||||||
anv_state_pool_free(&device->surface_state_pool,
|
anv_state_pool_free(&device->surface_state_pool,
|
||||||
iview->sampler_surface_state);
|
iview->sampler_surface_state);
|
||||||
@@ -633,6 +640,9 @@ anv_DestroyBufferView(VkDevice _device, VkBufferView bufferView,
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_buffer_view, view, bufferView);
|
ANV_FROM_HANDLE(anv_buffer_view, view, bufferView);
|
||||||
|
|
||||||
|
if (!view)
|
||||||
|
return;
|
||||||
|
|
||||||
if (view->surface_state.alloc_size > 0)
|
if (view->surface_state.alloc_size > 0)
|
||||||
anv_state_pool_free(&device->surface_state_pool,
|
anv_state_pool_free(&device->surface_state_pool,
|
||||||
view->surface_state);
|
view->surface_state);
|
||||||
|
@@ -146,6 +146,9 @@ void anv_DestroyRenderPass(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_render_pass, pass, _pass);
|
ANV_FROM_HANDLE(anv_render_pass, pass, _pass);
|
||||||
|
|
||||||
|
if (!pass)
|
||||||
|
return;
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, pass->subpass_attachments);
|
vk_free2(&device->alloc, pAllocator, pass->subpass_attachments);
|
||||||
vk_free2(&device->alloc, pAllocator, pass);
|
vk_free2(&device->alloc, pAllocator, pass);
|
||||||
}
|
}
|
||||||
|
@@ -75,6 +75,9 @@ void anv_DestroyShaderModule(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_shader_module, module, _module);
|
ANV_FROM_HANDLE(anv_shader_module, module, _module);
|
||||||
|
|
||||||
|
if (!module)
|
||||||
|
return;
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, module);
|
vk_free2(&device->alloc, pAllocator, module);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +192,9 @@ void anv_DestroyPipeline(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_pipeline, pipeline, _pipeline);
|
ANV_FROM_HANDLE(anv_pipeline, pipeline, _pipeline);
|
||||||
|
|
||||||
|
if (!pipeline)
|
||||||
|
return;
|
||||||
|
|
||||||
anv_reloc_list_finish(&pipeline->batch_relocs,
|
anv_reloc_list_finish(&pipeline->batch_relocs,
|
||||||
pAllocator ? pAllocator : &device->alloc);
|
pAllocator ? pAllocator : &device->alloc);
|
||||||
if (pipeline->blend_state.map)
|
if (pipeline->blend_state.map)
|
||||||
|
@@ -454,6 +454,9 @@ void anv_DestroyPipelineCache(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_pipeline_cache, cache, _cache);
|
ANV_FROM_HANDLE(anv_pipeline_cache, cache, _cache);
|
||||||
|
|
||||||
|
if (!cache)
|
||||||
|
return;
|
||||||
|
|
||||||
anv_pipeline_cache_finish(cache);
|
anv_pipeline_cache_finish(cache);
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, cache);
|
vk_free2(&device->alloc, pAllocator, cache);
|
||||||
|
@@ -87,6 +87,9 @@ void anv_DestroyQueryPool(
|
|||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(anv_query_pool, pool, _pool);
|
ANV_FROM_HANDLE(anv_query_pool, pool, _pool);
|
||||||
|
|
||||||
|
if (!pool)
|
||||||
|
return;
|
||||||
|
|
||||||
anv_gem_munmap(pool->bo.map, pool->bo.size);
|
anv_gem_munmap(pool->bo.map, pool->bo.size);
|
||||||
anv_gem_close(device, pool->bo.gem_handle);
|
anv_gem_close(device, pool->bo.gem_handle);
|
||||||
vk_free2(&device->alloc, pAllocator, pool);
|
vk_free2(&device->alloc, pAllocator, pool);
|
||||||
|
@@ -76,6 +76,9 @@ void anv_DestroySurfaceKHR(
|
|||||||
ANV_FROM_HANDLE(anv_instance, instance, _instance);
|
ANV_FROM_HANDLE(anv_instance, instance, _instance);
|
||||||
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
ANV_FROM_HANDLE(_VkIcdSurfaceBase, surface, _surface);
|
||||||
|
|
||||||
|
if (!surface)
|
||||||
|
return;
|
||||||
|
|
||||||
vk_free2(&instance->alloc, pAllocator, surface);
|
vk_free2(&instance->alloc, pAllocator, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,6 +297,9 @@ void anv_DestroySwapchainKHR(
|
|||||||
ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
|
ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
|
||||||
const VkAllocationCallbacks *alloc;
|
const VkAllocationCallbacks *alloc;
|
||||||
|
|
||||||
|
if (!swapchain)
|
||||||
|
return;
|
||||||
|
|
||||||
if (pAllocator)
|
if (pAllocator)
|
||||||
alloc = pAllocator;
|
alloc = pAllocator;
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user