lavapipe: fix pipeline creation for blend and zs states
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 22 Feb 2022 20:25:06 +0000 (15:25 -0500)
committerMarge Bot <emma+marge@anholt.net>
Wed, 9 Mar 2022 01:13:42 +0000 (01:13 +0000)
these values are read based on the specified subpass containing the
required attachments, not on the overall renderpass

cc: mesa-stable

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

src/gallium/frontends/lavapipe/lvp_pass.c
src/gallium/frontends/lavapipe/lvp_pipeline.c
src/gallium/frontends/lavapipe/lvp_private.h

index 475a95e..97ddbd6 100644 (file)
@@ -85,10 +85,6 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateRenderPass2(
       att->load_op = pCreateInfo->pAttachments[i].loadOp;
       att->stencil_load_op = pCreateInfo->pAttachments[i].stencilLoadOp;
       att->attachment = i;
-
-      bool is_zs = util_format_is_depth_or_stencil(lvp_vk_format_to_pipe_format(att->format));
-      pass->has_zs_attachment |= is_zs;
-      pass->has_color_attachment |= !is_zs;
    }
 
    uint32_t subpass_attachment_idx = 0;
@@ -124,6 +120,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateRenderPass2(
 
          for (uint32_t j = 0; j < desc->colorAttachmentCount; j++) {
             CHECK_UNUSED_ATTACHMENT(pColorAttachments, color_attachments, j);
+            subpass->has_color_attachment |= !!subpass->color_attachments[j];
          }
       }
 
@@ -143,6 +140,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateRenderPass2(
          subpass_attachment_idx++;
 
          CHECK_UNUSED_ATTACHMENT(pDepthStencilAttachment, depth_stencil_attachment, 0);
+         subpass->has_zs_attachment = !!(*subpass->depth_stencil_attachment);
       }
 
       const VkSubpassDescriptionDepthStencilResolve *ds_resolve =
index 680c87c..a742358 100644 (file)
@@ -369,7 +369,7 @@ deep_copy_graphics_create_info(void *mem_ctx,
 
    /* pDepthStencilState */
    if (src->pDepthStencilState && !rasterization_disabled &&
-       (pass ? pass->has_zs_attachment : (rp_info->depthAttachmentFormat || rp_info->stencilAttachmentFormat))) {
+       (pass ? pass->subpasses[src->subpass].has_zs_attachment : (rp_info->depthAttachmentFormat || rp_info->stencilAttachmentFormat))) {
       LVP_PIPELINE_DUP(dst->pDepthStencilState,
                        src->pDepthStencilState,
                        VkPipelineDepthStencilStateCreateInfo,
@@ -379,7 +379,7 @@ deep_copy_graphics_create_info(void *mem_ctx,
 
    /* pColorBlendState */
    if (src->pColorBlendState && !rasterization_disabled &&
-       (pass ? pass->has_color_attachment : rp_info->colorAttachmentCount)) {
+       (pass ? pass->subpasses[src->subpass].has_color_attachment : rp_info->colorAttachmentCount)) {
       VkPipelineColorBlendStateCreateInfo*    cb_state;
 
       cb_state = ralloc(mem_ctx, VkPipelineColorBlendStateCreateInfo);
index 45bc17d..c6750f8 100644 (file)
@@ -284,6 +284,8 @@ struct lvp_subpass {
 
    /** Subpass has at least one color resolve attachment */
    bool                                         has_color_resolve;
+   bool has_color_attachment;
+   bool has_zs_attachment;
 
    uint32_t                                     view_mask;
 };
@@ -294,8 +296,6 @@ struct lvp_render_pass {
    uint32_t                                     subpass_count;
    struct lvp_subpass_attachment *              subpass_attachments;
    struct lvp_render_pass_attachment *          attachments;
-   bool has_color_attachment;
-   bool has_zs_attachment;
    struct lvp_subpass                           subpasses[0];
 };