iris: Enable compression for image load/store in more cases
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 6 Oct 2022 17:19:20 +0000 (10:19 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 14 Dec 2022 13:01:27 +0000 (13:01 +0000)
We were calling iris_resource_texture_aux_usage here, which disables
auxiliary support if color happens to already be resolved.  This makes
sense for read only images, where if we know ahead of time that aux
doesn't contain any useful information, we can just tell the hardware
to not bother looking at it.  However, it makes no sense for mutable
images, as even if the aux currently has no useful data, we want to
produce that data when doing our image writes.

Import the bits of logic we need from there and shed the rest.  We don't
need to consider HiZ, MCS, or MC, nor do we need to do format-based
CCS compatibility checks on Gfx12+, so it's actually very little code.

Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19060>

src/gallium/drivers/iris/iris_resolve.c

index b299b5b9339491f5df2a13f83b86df40ede3e7dc..082cd08931e9123567f8a844b275855503c4c02c 100644 (file)
@@ -1021,19 +1021,24 @@ iris_image_view_aux_usage(struct iris_context *ice,
    const unsigned level = res->base.b.target != PIPE_BUFFER ?
                           pview->u.tex.level : 0;
 
-   enum isl_format view_format = iris_image_view_get_format(ice, pview);
-   enum isl_aux_usage aux_usage =
-      iris_resource_texture_aux_usage(ice, res, view_format, level, 1);
-
    bool uses_atomic_load_store =
       ice->shaders.uncompiled[info->stage]->uses_atomic_load_store;
 
    /* On GFX12, compressed surfaces supports non-atomic operations. GFX12HP and
     * further, add support for all the operations.
     */
-   if (aux_usage == ISL_AUX_USAGE_GFX12_CCS_E &&
-       (devinfo->verx10 >= 125 || !uses_atomic_load_store))
-      return ISL_AUX_USAGE_GFX12_CCS_E;
+   if (devinfo->verx10 < 125 && uses_atomic_load_store)
+      return ISL_AUX_USAGE_NONE;
+
+   /* If the image is read-only, and doesn't have any unresolved color,
+    * report ISL_AUX_USAGE_NONE.  Bypassing useless aux can save bandwidth.
+    */
+   if (!(pview->access & PIPE_IMAGE_ACCESS_WRITE) &&
+       !iris_has_invalid_primary(res, level, 1, 0, INTEL_REMAINING_LAYERS))
+      return ISL_AUX_USAGE_NONE;
+
+   if (res->aux.usage == ISL_AUX_USAGE_GFX12_CCS_E)
+      return res->aux.usage;
 
    return ISL_AUX_USAGE_NONE;
 }