venus: Use VkImageAspectFlags in vn_subpass
authorLina Versace <linyaa@google.com>
Fri, 9 Jun 2023 23:29:21 +0000 (16:29 -0700)
committerLina Versace <linyaa@google.com>
Wed, 18 Oct 2023 19:12:17 +0000 (12:12 -0700)
No intended change in behavior. This little improvement will help
vn_pipeline track its graphics state more accurately.

Signed-off-by: Lina Versace <linyaa@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22419>

src/virtio/vulkan/vn_pipeline.c
src/virtio/vulkan/vn_render_pass.c
src/virtio/vulkan/vn_render_pass.h

index 48db936..2ed1c18 100644 (file)
@@ -583,7 +583,9 @@ vn_fix_graphics_pipeline_create_info(
       /* Ignore pDepthStencilState? */
       if (info->pDepthStencilState) {
          const bool has_static_attachment =
-            subpass && subpass->has_depth_stencil_attachment;
+            subpass &&
+            (subpass->attachment_aspects &
+             (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
 
          /* VUID-VkGraphicsPipelineCreateInfo-renderPass-06043 */
          bool require_state =
@@ -610,7 +612,8 @@ vn_fix_graphics_pipeline_create_info(
       /* Ignore pColorBlendState? */
       if (info->pColorBlendState) {
          const bool has_static_attachment =
-            subpass && subpass->has_color_attachment;
+            subpass &&
+            (subpass->attachment_aspects & VK_IMAGE_ASPECT_COLOR_BIT);
 
          /* VUID-VkGraphicsPipelineCreateInfo-renderPass-06044 */
          bool require_state =
index 4e796e7..58ab0e7 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "venus-protocol/vn_protocol_driver_framebuffer.h"
 #include "venus-protocol/vn_protocol_driver_render_pass.h"
+#include "vk_format.h"
 
 #include "vn_device.h"
 #include "vn_image.h"
@@ -59,7 +60,7 @@
          for (uint32_t j = 0; j < subpass_desc->colorAttachmentCount; j++) { \
             if (subpass_desc->pColorAttachments[j].attachment !=             \
                 VK_ATTACHMENT_UNUSED) {                                      \
-               subpass->has_color_attachment = true;                         \
+               subpass->attachment_aspects |= VK_IMAGE_ASPECT_COLOR_BIT;     \
                break;                                                        \
             }                                                                \
          }                                                                   \
          if (subpass_desc->pDepthStencilAttachment &&                        \
              subpass_desc->pDepthStencilAttachment->attachment !=            \
                 VK_ATTACHMENT_UNUSED) {                                      \
-            subpass->has_depth_stencil_attachment = true;                    \
+            uint32_t att =                                                   \
+               subpass_desc->pDepthStencilAttachment->attachment;            \
+            subpass->attachment_aspects |=                                   \
+               vk_format_aspects(_pCreateInfo->pAttachments[att].format);    \
          }                                                                   \
       }                                                                      \
    } while (false)
index 3b09412..ffa565b 100644 (file)
@@ -24,8 +24,7 @@ struct vn_present_src_attachment {
 };
 
 struct vn_subpass {
-   bool has_color_attachment;
-   bool has_depth_stencil_attachment;
+   VkImageAspectFlags attachment_aspects;
    uint32_t view_mask;
 };