From ebab5c8ff47e089bca3626adce7a8cc4801b4c16 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 10 Nov 2017 09:18:02 +0100 Subject: [PATCH] radv: use vk_zalloc instead of vk_alloc+memset Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- src/amd/vulkan/radv_cmd_buffer.c | 5 ++--- src/amd/vulkan/radv_device.c | 14 +++++--------- src/amd/vulkan/radv_image.c | 5 ++--- src/amd/vulkan/radv_pipeline.c | 10 ++++------ 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index 8d69d2935a0..8fa935131f2 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -198,12 +198,11 @@ static VkResult radv_create_cmd_buffer( { struct radv_cmd_buffer *cmd_buffer; unsigned ring; - cmd_buffer = vk_alloc(&pool->alloc, sizeof(*cmd_buffer), 8, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + cmd_buffer = vk_zalloc(&pool->alloc, sizeof(*cmd_buffer), 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (cmd_buffer == NULL) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - memset(cmd_buffer, 0, sizeof(*cmd_buffer)); cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC; cmd_buffer->device = device; cmd_buffer->pool = pool; diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index aa0511fd8d5..929082182c2 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -372,13 +372,11 @@ VkResult radv_CreateInstance( return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT); } - instance = vk_alloc2(&default_alloc, pAllocator, sizeof(*instance), 8, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); + instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE); if (!instance) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - memset(instance, 0, sizeof(*instance)); - instance->_loader_data.loaderMagic = ICD_LOADER_MAGIC; if (pAllocator) @@ -995,14 +993,12 @@ VkResult radv_CreateDevice( } } - device = vk_alloc2(&physical_device->instance->alloc, pAllocator, - sizeof(*device), 8, - VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); + device = vk_zalloc2(&physical_device->instance->alloc, pAllocator, + sizeof(*device), 8, + VK_SYSTEM_ALLOCATION_SCOPE_DEVICE); if (!device) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - memset(device, 0, sizeof(*device)); - device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; device->instance = physical_device->instance; device->physical_device = physical_device; diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index 0564454c776..163d35d76bd 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -863,12 +863,11 @@ radv_image_create(VkDevice _device, radv_assert(pCreateInfo->extent.height > 0); radv_assert(pCreateInfo->extent.depth > 0); - image = vk_alloc2(&device->alloc, alloc, sizeof(*image), 8, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + image = vk_zalloc2(&device->alloc, alloc, sizeof(*image), 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!image) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - memset(image, 0, sizeof(*image)); image->type = pCreateInfo->imageType; image->info.width = pCreateInfo->extent.width; image->info.height = pCreateInfo->extent.height; diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 954bc2cd02a..f006dc98c05 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -2312,12 +2312,11 @@ radv_graphics_pipeline_create( struct radv_pipeline *pipeline; VkResult result; - pipeline = vk_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + pipeline = vk_zalloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (pipeline == NULL) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - memset(pipeline, 0, sizeof(*pipeline)); result = radv_pipeline_init(pipeline, device, cache, pCreateInfo, extra, pAllocator); if (result != VK_SUCCESS) { @@ -2369,12 +2368,11 @@ static VkResult radv_compute_pipeline_create( struct radv_pipeline *pipeline; VkResult result; - pipeline = vk_alloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + pipeline = vk_zalloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (pipeline == NULL) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - memset(pipeline, 0, sizeof(*pipeline)); pipeline->device = device; pipeline->layout = radv_pipeline_layout_from_handle(pCreateInfo->layout); -- 2.30.2