Module: Mesa
Branch: main
Commit: 9056817a6c975168457758814d5e865505c63d8c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9056817a6c975168457758814d5e865505c63d8c

Author: Matt Coster <[email protected]>
Date:   Fri Oct 28 17:13:43 2022 +0100

pvr: Store format aspects on render pass attachments

This expands the existing has_stencil field on struct
pvr_render_pass_attachment to be a complete set of VkImageApsectFlags.

Signed-off-by: Matt Coster <[email protected]>
Reviewed-by: Karmjit Mahil <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19342>

---

 src/imagination/vulkan/pvr_hw_pass.c | 19 ++++++++++---------
 src/imagination/vulkan/pvr_pass.c    |  4 ++--
 src/imagination/vulkan/pvr_private.h |  5 ++---
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/imagination/vulkan/pvr_hw_pass.c 
b/src/imagination/vulkan/pvr_hw_pass.c
index 7a0d5cb9541..ba0ca947887 100644
--- a/src/imagination/vulkan/pvr_hw_pass.c
+++ b/src/imagination/vulkan/pvr_hw_pass.c
@@ -1009,7 +1009,7 @@ static void pvr_dereference_surface(struct 
pvr_renderpass_context *ctx,
          pvr_free_surface_storage(ctx, int_attach);
    }
 
-   if (int_attach->attachment->has_stencil) {
+   if (int_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
       assert(int_attach->stencil_remaining_count > 0U);
       int_attach->stencil_remaining_count--;
    }
@@ -1149,7 +1149,7 @@ static VkResult pvr_close_render(const struct pvr_device 
*device,
                              link) {
       assert(int_attach->resource.type != USC_MRT_RESOURCE_TYPE_INVALID);
       assert(int_attach->remaining_count > 0U);
-      if (int_attach->attachment->has_stencil)
+      if (int_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT)
          assert(int_attach->stencil_remaining_count > 0U);
 
       /* Copy the location of the source data for this attachment. */
@@ -1385,7 +1385,7 @@ pvr_depth_zls_conflict(struct pvr_renderpass_context *ctx,
       return true;
    }
 
-   if (ctx->int_ds_attach->attachment->has_stencil &&
+   if (ctx->int_ds_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT &&
        ctx->int_ds_attach->stencil_remaining_count > 0U) {
       return true;
    }
@@ -1396,7 +1396,7 @@ pvr_depth_zls_conflict(struct pvr_renderpass_context *ctx,
    if (int_ds_attach->load_op == VK_ATTACHMENT_LOAD_OP_LOAD)
       return true;
 
-   if (int_ds_attach->attachment->has_stencil &&
+   if (int_ds_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT &&
        int_ds_attach->stencil_load_op == VK_ATTACHMENT_LOAD_OP_LOAD) {
       return true;
    }
@@ -1867,12 +1867,13 @@ pvr_can_combine_with_render(const struct 
pvr_device_info *dev_info,
     * attachment.
     */
    if (sp_depth->existing_ds_is_input &&
-       ctx->int_ds_attach->attachment->has_stencil) {
+       ctx->int_ds_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
       return false;
    }
 
    if (sp_depth->incoming_ds_is_input && int_ds_attach &&
-       int_ds_attach->attachment->has_stencil && ctx->hw_render) {
+       int_ds_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT &&
+       ctx->hw_render) {
       return false;
    }
 
@@ -2111,7 +2112,7 @@ pvr_merge_subpass(const struct pvr_device *device,
          hw_subpass->depth_initop = VK_ATTACHMENT_LOAD_OP_CLEAR;
       }
 
-      if (int_ds_attach->attachment->has_stencil) {
+      if (int_ds_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
          if (int_ds_attach->stencil_load_op == VK_ATTACHMENT_LOAD_OP_LOAD) {
             stencil_load = true;
             setup_render_ds = true;
@@ -2338,7 +2339,7 @@ static VkResult pvr_schedule_subpass(const struct 
pvr_device *device,
             pvr_free_surface_storage(ctx, int_depth_attach);
       }
 
-      if (int_depth_attach->attachment->has_stencil) {
+      if (int_depth_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) 
{
          assert(int_depth_attach->stencil_remaining_count > 0U);
          int_depth_attach->stencil_remaining_count--;
       }
@@ -2576,7 +2577,7 @@ VkResult pvr_create_renderpass_hwsetup(
             int_attach->remaining_count++;
       }
 
-      if (int_attach->attachment->has_stencil) {
+      if (int_attach->attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
          int_attach->stencil_remaining_count = int_attach->remaining_count;
          if (pass->attachments[i].stencil_store_op ==
              VK_ATTACHMENT_STORE_OP_STORE) {
diff --git a/src/imagination/vulkan/pvr_pass.c 
b/src/imagination/vulkan/pvr_pass.c
index 4ab9c7d4350..f3dda723005 100644
--- a/src/imagination/vulkan/pvr_pass.c
+++ b/src/imagination/vulkan/pvr_pass.c
@@ -451,8 +451,8 @@ VkResult pvr_CreateRenderPass2(VkDevice _device,
       attachment->load_op = desc->loadOp;
       attachment->store_op = desc->storeOp;
 
-      attachment->has_stencil = vk_format_has_stencil(attachment->vk_format);
-      if (attachment->has_stencil) {
+      attachment->aspects = vk_format_aspects(desc->format);
+      if (attachment->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
          attachment->stencil_load_op = desc->stencilLoadOp;
          attachment->stencil_store_op = desc->stencilStoreOp;
       }
diff --git a/src/imagination/vulkan/pvr_private.h 
b/src/imagination/vulkan/pvr_private.h
index 9c88e6fa3da..b6837de5695 100644
--- a/src/imagination/vulkan/pvr_private.h
+++ b/src/imagination/vulkan/pvr_private.h
@@ -1342,9 +1342,8 @@ struct pvr_render_pass_attachment {
    uint32_t sample_count;
    VkImageLayout initial_layout;
 
-   /*  Derived and other state. */
-   /* True if the attachment format includes a stencil component. */
-   bool has_stencil;
+   /* Derived and other state. */
+   VkImageAspectFlags aspects;
 
    /* Can this surface be resolved by the PBE. */
    bool is_pbe_downscalable;

Reply via email to