From c1ef225d18332ed4800191d686dc1527e8156544 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 23 Apr 2020 16:02:59 +0200 Subject: [PATCH] radv: handle NULL descriptors All fields must be zero, otherwise the HW hangs. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_descriptor_set.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c index dff774ace69..126176a9706 100644 --- a/src/amd/vulkan/radv_descriptor_set.c +++ b/src/amd/vulkan/radv_descriptor_set.c @@ -830,6 +830,11 @@ static void write_texel_buffer_descriptor(struct radv_device *device, { RADV_FROM_HANDLE(radv_buffer_view, buffer_view, _buffer_view); + if (!buffer_view) { + memset(dst, 0, 4 * 4); + return; + } + memcpy(dst, buffer_view->state, 4 * 4); if (cmd_buffer) @@ -845,6 +850,12 @@ static void write_buffer_descriptor(struct radv_device *device, const VkDescriptorBufferInfo *buffer_info) { RADV_FROM_HANDLE(radv_buffer, buffer, buffer_info->buffer); + + if (!buffer) { + memset(dst, 0, 4 * 4); + return; + } + uint64_t va = radv_buffer_get_va(buffer->bo); uint32_t range = buffer_info->range; @@ -898,8 +909,14 @@ static void write_dynamic_buffer_descriptor(struct radv_device *device, const VkDescriptorBufferInfo *buffer_info) { RADV_FROM_HANDLE(radv_buffer, buffer, buffer_info->buffer); - uint64_t va = radv_buffer_get_va(buffer->bo); - unsigned size = buffer_info->range; + uint64_t va; + unsigned size; + + if (!buffer) + return; + + va = radv_buffer_get_va(buffer->bo); + size = buffer_info->range; if (buffer_info->range == VK_WHOLE_SIZE) size = buffer->size - buffer_info->offset; @@ -928,6 +945,11 @@ write_image_descriptor(struct radv_device *device, RADV_FROM_HANDLE(radv_image_view, iview, image_info->imageView); union radv_descriptor *descriptor; + if (!iview) { + memset(dst, 0, size); + return; + } + if (descriptor_type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) { descriptor = &iview->storage_descriptor; } else { -- 2.30.2