v3dv: don't assume that bound descriptors have been written
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 12 Sep 2023 08:09:12 +0000 (10:09 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 12 Sep 2023 11:42:58 +0000 (11:42 +0000)
The pipeline layout lifetime tests in CTS allocate some descriptors
and bind them to the command buffer without actually ever writing
valid resources to them since they never actually execute the command
buffers, so we want to be careful at bind time and not assume the
resources exist.

Fixes crashes in dEQP-VK.api.pipeline.pipeline_layout.lifetime.*

Fixes: 95f881adbd ('v3dv: add support for sampling simple 2D linear textures')
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25172>

src/broadcom/vulkan/v3dv_cmd_buffer.c

index a8349de..d43ca16 100644 (file)
@@ -3442,6 +3442,9 @@ handle_sample_from_linear_image(struct v3dv_cmd_buffer *cmd_buffer,
          continue;
 
       struct v3dv_descriptor *desc = &set->descriptors[blayout->descriptor_index];
+      if (!desc->image_view)
+         continue;
+
       struct v3dv_image *image = (struct v3dv_image *) desc->image_view->vk.image;
       struct v3dv_image_view *view = (struct v3dv_image_view *) desc->image_view;
       if (image->tiled || view->vk.view_type == VK_IMAGE_VIEW_TYPE_1D)