zink: add is_buffer flag to union zink_descriptor_surface
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Sun, 28 Mar 2021 15:31:06 +0000 (11:31 -0400)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 16 Jun 2021 00:14:36 +0000 (20:14 -0400)
Reviewed-by: Hoe Hao Cheng <haochengho12907@gmail.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11188>

src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_context.h

index 19d2541..1ea2594 100644 (file)
@@ -472,11 +472,13 @@ update_descriptor_state(struct zink_context *ctx, enum pipe_shader_type shader,
             struct zink_buffer_view *bv = get_bufferview_for_binding(ctx, shader, type, slot);
             ctx->di.tbos[shader][slot] = bv->buffer_view;
             ctx->di.sampler_surfaces[shader][slot].bufferview = bv;
+            ctx->di.sampler_surfaces[shader][slot].is_buffer = true;
          } else {
             struct zink_surface *surface = get_imageview_for_binding(ctx, shader, type, slot);
             ctx->di.textures[shader][slot].imageLayout = get_layout_for_binding(res, type);
             ctx->di.textures[shader][slot].imageView = surface->image_view;
             ctx->di.sampler_surfaces[shader][slot].surface = surface;
+            ctx->di.sampler_surfaces[shader][slot].is_buffer = false;
          }
       } else {
          if (have_null_descriptors) {
@@ -497,11 +499,13 @@ update_descriptor_state(struct zink_context *ctx, enum pipe_shader_type shader,
             struct zink_buffer_view *bv = get_bufferview_for_binding(ctx, shader, type, slot);
             ctx->di.texel_images[shader][slot] = bv->buffer_view;
             ctx->di.image_surfaces[shader][slot].bufferview = bv;
+            ctx->di.image_surfaces[shader][slot].is_buffer = true;
          } else {
             struct zink_surface *surface = get_imageview_for_binding(ctx, shader, type, slot);
             ctx->di.images[shader][slot].imageLayout = get_layout_for_binding(res, type);
             ctx->di.images[shader][slot].imageView = surface->image_view;
             ctx->di.image_surfaces[shader][slot].surface = surface;
+            ctx->di.image_surfaces[shader][slot].is_buffer = false;
          }
       } else {
          if (have_null_descriptors) {
@@ -1723,18 +1727,6 @@ get_access_flags_for_binding(struct zink_context *ctx, enum zink_descriptor_type
    return 0;
 }
 
-static inline void
-add_surface_ref(struct zink_context *ctx, struct zink_resource *res, union zink_descriptor_surface *surface)
-{
-   if (!surface)
-      return;
-   if (res->obj->is_buffer) {
-      if (surface->bufferview)
-         zink_batch_reference_bufferview(&ctx->batch, surface->bufferview);
-   } else if (surface->surface)
-         zink_batch_reference_surface(&ctx->batch, surface->surface);
-}
-
 static void
 update_resource_refs_for_stage(struct zink_context *ctx, enum pipe_shader_type stage)
 {
index 77b65af..1de31d7 100644 (file)
@@ -125,9 +125,12 @@ struct zink_viewport_state {
 };
 
 
-union zink_descriptor_surface {
-   struct zink_surface *surface;
-   struct zink_buffer_view *bufferview;
+struct zink_descriptor_surface {
+   union {
+      struct zink_surface *surface;
+      struct zink_buffer_view *bufferview;
+   };
+   bool is_buffer;
 };
 
 struct zink_context {
@@ -257,8 +260,8 @@ struct zink_context {
       uint8_t num_images[PIPE_SHADER_TYPES];
 
       struct zink_resource *descriptor_res[ZINK_DESCRIPTOR_TYPES][PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
-      union zink_descriptor_surface sampler_surfaces[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
-      union zink_descriptor_surface image_surfaces[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
+      struct zink_descriptor_surface sampler_surfaces[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+      struct zink_descriptor_surface image_surfaces[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
    } di;
    bool descriptor_refs_dirty[2];
    struct set *need_barriers[2]; //gfx, compute