[Mesa-dev] [PATCH v5 14/16] anv: Take an image in can_sample_with_hiz

Lionel Landwerlin lionel.g.landwerlin at intel.com
Fri Oct 6 13:31:27 UTC 2017


From: Jason Ekstrand <jason.ekstrand at intel.com>

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/intel/vulkan/anv_blorp.c   |  3 +--
 src/intel/vulkan/anv_image.c   |  2 +-
 src/intel/vulkan/anv_private.h | 14 ++++++++------
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index f5ace287e4c..27ab7ef9d90 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -1228,8 +1228,7 @@ anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer)
                clear_with_hiz = false;
             } else if (gen == 8 &&
                        anv_can_sample_with_hiz(&cmd_buffer->device->info,
-                                               iview->aspect_mask,
-                                               iview->image->samples)) {
+                                               iview->image)) {
                /* Only gen9+ supports returning ANV_HZ_FC_VAL when sampling a
                 * fast-cleared portion of a HiZ buffer. Testing has revealed
                 * that Gen8 only supports returning 0.0f. Gens prior to gen8 do
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index a56f732e276..1328f4cc27b 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -682,7 +682,7 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
    case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
    case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR:
       assert(aspect == VK_IMAGE_ASPECT_DEPTH_BIT);
-      if (anv_can_sample_with_hiz(devinfo, aspect, image->samples))
+      if (anv_can_sample_with_hiz(devinfo, image))
          return ISL_AUX_USAGE_HIZ;
       else
          return ISL_AUX_USAGE_NONE;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 77106ca68a1..0513780ede5 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2381,13 +2381,15 @@ anv_fast_clear_state_entry_size(const struct anv_device *device)
 /* Returns true if a HiZ-enabled depth buffer can be sampled from. */
 static inline bool
 anv_can_sample_with_hiz(const struct gen_device_info * const devinfo,
-                        const VkImageAspectFlags aspect_mask,
-                        const uint32_t samples)
+                        const struct anv_image *image)
 {
-   /* Validate the inputs. */
-   assert(devinfo && aspect_mask && samples);
-   return devinfo->gen >= 8 && (aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) &&
-          samples == 1;
+   if (!(image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT))
+      return false;
+
+   if (devinfo->gen < 8)
+      return false;
+
+   return image->samples == 1;
 }
 
 void
-- 
2.14.2



More information about the mesa-dev mailing list