Mesa (main): lavapipe: tolerate NULL image view descriptors

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 10 21:08:01 UTC 2022


Module: Mesa
Branch: main
Commit: aabf614f9bb44e8003e2f5ff63bd66289f092f1b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=aabf614f9bb44e8003e2f5ff63bd66289f092f1b

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Mon Apr 26 17:10:36 2021 +0200

lavapipe: tolerate NULL image view descriptors

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16137>

---

 src/gallium/frontends/lavapipe/lvp_execute.c | 34 +++++++++++++++++-----------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c
index 2052e3a0fb9..0b06ca1f2cb 100644
--- a/src/gallium/frontends/lavapipe/lvp_execute.c
+++ b/src/gallium/frontends/lavapipe/lvp_execute.c
@@ -1196,22 +1196,30 @@ static void fill_image_view_stage(struct rendering_state *state,
       return;
    idx += array_idx;
    idx += dyn_info->stage[stage].image_count;
-   state->iv[p_stage][idx].resource = iv->image->bo;
-   if (iv->vk.aspects == VK_IMAGE_ASPECT_DEPTH_BIT)
-      state->iv[p_stage][idx].format = lvp_vk_format_to_pipe_format(iv->vk.format);
-   else if (iv->vk.aspects == VK_IMAGE_ASPECT_STENCIL_BIT)
-      state->iv[p_stage][idx].format = util_format_stencil_only(lvp_vk_format_to_pipe_format(iv->vk.format));
-   else
-      state->iv[p_stage][idx].format = lvp_vk_format_to_pipe_format(iv->vk.format);
+   if (iv) {
+      state->iv[p_stage][idx].resource = iv->image->bo;
+      if (iv->vk.aspects == VK_IMAGE_ASPECT_DEPTH_BIT)
+         state->iv[p_stage][idx].format = lvp_vk_format_to_pipe_format(iv->vk.format);
+      else if (iv->vk.aspects == VK_IMAGE_ASPECT_STENCIL_BIT)
+         state->iv[p_stage][idx].format = util_format_stencil_only(lvp_vk_format_to_pipe_format(iv->vk.format));
+      else
+         state->iv[p_stage][idx].format = lvp_vk_format_to_pipe_format(iv->vk.format);
 
-   if (iv->vk.view_type == VK_IMAGE_VIEW_TYPE_3D) {
-      state->iv[p_stage][idx].u.tex.first_layer = 0;
-      state->iv[p_stage][idx].u.tex.last_layer = iv->vk.extent.depth - 1;
+      if (iv->vk.view_type == VK_IMAGE_VIEW_TYPE_3D) {
+         state->iv[p_stage][idx].u.tex.first_layer = 0;
+         state->iv[p_stage][idx].u.tex.last_layer = iv->vk.extent.depth - 1;
+      } else {
+         state->iv[p_stage][idx].u.tex.first_layer = iv->vk.base_array_layer,
+         state->iv[p_stage][idx].u.tex.last_layer = iv->vk.base_array_layer + iv->vk.layer_count - 1;
+      }
+      state->iv[p_stage][idx].u.tex.level = iv->vk.base_mip_level;
    } else {
-      state->iv[p_stage][idx].u.tex.first_layer = iv->vk.base_array_layer,
-      state->iv[p_stage][idx].u.tex.last_layer = iv->vk.base_array_layer + iv->vk.layer_count - 1;
+      state->iv[p_stage][idx].resource = NULL;
+      state->iv[p_stage][idx].format = PIPE_FORMAT_NONE;
+      state->iv[p_stage][idx].u.tex.first_layer = 0;
+      state->iv[p_stage][idx].u.tex.last_layer = 0;
+      state->iv[p_stage][idx].u.tex.level = 0;
    }
-   state->iv[p_stage][idx].u.tex.level = iv->vk.base_mip_level;
    state->iv[p_stage][idx].access = PIPE_IMAGE_ACCESS_READ_WRITE;
    state->iv[p_stage][idx].shader_access = PIPE_IMAGE_ACCESS_READ_WRITE;
    if (state->num_shader_images[p_stage] <= idx)



More information about the mesa-commit mailing list