zink: store VkImageViewUsageCreateInfo for surface creation
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 1 Sep 2022 00:37:21 +0000 (20:37 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 1 Sep 2022 23:27:28 +0000 (23:27 +0000)
this otherwise breaks surface rebinds if used since the pointer
will be a garbage stack value

cc: mesa-stable

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18358>

src/gallium/drivers/zink/zink_surface.c
src/gallium/drivers/zink/zink_types.h

index 29dda52..a30de9b 100644 (file)
@@ -139,14 +139,13 @@ create_surface(struct pipe_context *pctx,
    if (!surface)
       return NULL;
 
-   VkImageViewUsageCreateInfo usage_info;
-   usage_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO;
-   usage_info.pNext = NULL;
+   surface->usage_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO;
+   surface->usage_info.pNext = NULL;
    VkFormatFeatureFlags feats = res->linear ?
                                 screen->format_props[templ->format].linearTilingFeatures :
                                 screen->format_props[templ->format].optimalTilingFeatures;
    VkImageUsageFlags attachment = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
-   usage_info.usage = res->obj->vkusage & ~attachment;
+   surface->usage_info.usage = res->obj->vkusage & ~attachment;
    if (res->obj->modifier_aspect) {
       feats = res->obj->vkfeats;
       /* intersect format features for current modifier */
@@ -157,7 +156,7 @@ create_surface(struct pipe_context *pctx,
    }
    if ((res->obj->vkusage & attachment) &&
        !(feats & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))) {
-      ivci->pNext = &usage_info;
+      ivci->pNext = &surface->usage_info;
    }
 
    pipe_resource_reference(&surface->base.texture, pres);
index db75226..66e4c21 100644 (file)
@@ -1153,6 +1153,7 @@ struct zink_surface_info {
 struct zink_surface {
    struct pipe_surface base;
    VkImageViewCreateInfo ivci;
+   VkImageViewUsageCreateInfo usage_info;
    struct zink_surface_info info; //TODO: union with fb refs
    uint32_t info_hash;
    bool is_swapchain;