Module: Mesa
Branch: master
Commit: 5acbba4e41a9ffbf764315d76fd4bb1c8c82c1a9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5acbba4e41a9ffbf764315d76fd4bb1c8c82c1a9

Author: Mike Blumenkrantz <[email protected]>
Date:   Thu Nov  5 10:24:53 2020 -0500

zink: explicitly use zink_surface objects for sampler/image view objects

we can reuse this codepath instead of NIHing it

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9543>

---

 src/gallium/drivers/zink/zink_context.c | 14 +++++++++++---
 src/gallium/drivers/zink/zink_context.h |  4 ++--
 src/gallium/drivers/zink/zink_draw.c    |  2 +-
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index e194e7d919e..5a4355e5405 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -629,7 +629,13 @@ zink_create_sampler_view(struct pipe_context *pctx, struct 
pipe_resource *pres,
             ivci.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
       }
 
-      err = vkCreateImageView(screen->dev, &ivci, NULL, 
&sampler_view->image_view) != VK_SUCCESS;
+      struct pipe_surface templ = {};
+      templ.u.tex.level = state->u.tex.first_level;
+      templ.format = state->format;
+      templ.u.tex.first_layer = state->u.tex.first_layer;
+      templ.u.tex.last_layer = state->u.tex.last_layer;
+      sampler_view->image_view = (struct 
zink_surface*)zink_get_surface(zink_context(pctx), pres, &templ, &ivci);
+      err = !sampler_view->image_view;
    } else {
       sampler_view->buffer_view = get_buffer_view(zink_context(pctx), res, 
state->format, state->u.buf.offset, state->u.buf.size);
       err = !sampler_view->buffer_view;
@@ -658,8 +664,10 @@ zink_sampler_view_destroy(struct pipe_context *pctx,
    zink_descriptor_set_refs_clear(&view->desc_set_refs, view);
    if (pview->texture->target == PIPE_BUFFER)
       zink_buffer_view_reference(zink_context(pctx), &view->buffer_view, NULL);
-   else
-      vkDestroyImageView(zink_screen(pctx->screen)->dev, view->image_view, 
NULL);
+   else {
+      struct pipe_surface *psurf = &view->image_view->base;
+      pipe_surface_reference(&psurf, NULL);
+   }
    pipe_resource_reference(&pview->texture, NULL);
    FREE(view);
 }
diff --git a/src/gallium/drivers/zink/zink_context.h 
b/src/gallium/drivers/zink/zink_context.h
index 62af1a9cfc4..026dff75b48 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -37,6 +37,7 @@
 #include "zink_batch.h"
 #include "zink_compiler.h"
 #include "zink_descriptors.h"
+#include "zink_surface.h"
 
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
@@ -56,7 +57,6 @@ struct zink_depth_stencil_alpha_state;
 struct zink_gfx_program;
 struct zink_rasterizer_state;
 struct zink_resource;
-struct zink_surface;
 struct zink_vertex_elements_state;
 
 enum zink_blit_flags {
@@ -83,7 +83,7 @@ struct zink_sampler_view {
    struct pipe_sampler_view base;
    struct zink_descriptor_refs desc_set_refs;
    union {
-      VkImageView image_view;
+      struct zink_surface *image_view;
       struct zink_buffer_view *buffer_view;
    };
    uint32_t hash;
diff --git a/src/gallium/drivers/zink/zink_draw.c 
b/src/gallium/drivers/zink/zink_draw.c
index 2d15fea9175..d8413d1295f 100644
--- a/src/gallium/drivers/zink/zink_draw.c
+++ b/src/gallium/drivers/zink/zink_draw.c
@@ -608,7 +608,7 @@ update_sampler_descriptors(struct zink_context *ctx, struct 
zink_descriptor_set
             if (res && res->base.target == PIPE_BUFFER) {
                bufferview = sampler_view->buffer_view->buffer_view;
             } else if (res) {
-               imageview = sampler_view->image_view;
+               imageview = sampler_view->image_view->image_view;
                layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
                sampler = ctx->sampler_states[stage][index + k];
             }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to