radv: configure the VRS HTILE encoding size
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 9 Apr 2021 11:30:01 +0000 (13:30 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 14 Apr 2021 09:31:13 +0000 (09:31 +0000)
Any depth buffer can potentially use VRS.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10187>

src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h

index e51e14a..de83b49 100644 (file)
@@ -6629,6 +6629,10 @@ radv_initialise_ds_surface(struct radv_device *device, struct radv_ds_buffer_inf
          if (device->physical_device->rad_info.chip_class == GFX9) {
             ds->db_htile_surface |= S_028ABC_RB_ALIGNED(1);
          }
+
+         if (radv_image_has_vrs_htile(device, iview->image)) {
+            ds->db_htile_surface |= S_028ABC_VRS_HTILE_ENCODING(V_028ABC_VRS_HTILE_4BIT_ENCODING);
+         }
       }
    } else {
       const struct legacy_surf_level *level_info = &surf->u.legacy.level[level];
index 3bb1bbc..a8241a8 100644 (file)
@@ -1921,6 +1921,17 @@ radv_image_has_htile(const struct radv_image *image)
 }
 
 /**
+ * Return whether the image has VRS HTILE metadata for depth surfaces
+ */
+static inline bool
+radv_image_has_vrs_htile(const struct radv_device *device, const struct radv_image *image)
+{
+   /* Any depth buffer can potentially use VRS. */
+   return device->attachment_vrs_enabled && radv_image_has_htile(image) &&
+          (image->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
+}
+
+/**
  * Return whether HTILE metadata is enabled for a level.
  */
 static inline bool