summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-11-20 09:48:39 -0800
committerJason Ekstrand <[email protected]>2018-02-08 16:35:31 -0800
commitb09464db42f31be768cb79ef623ea2ed9398c6a9 (patch)
tree6324a49815d8a74974b6fe476f01be480fd05346 /src
parent1f7eee6bc15f93d859ba134e9264354c3e79d05d (diff)
anv/image: Add a helper for determining when fast clears are supported
v2 (Jason Ekstrand): - Return an enum instead of a boolean v3 (Jason Ekstrand): - Return ANV_FAST_CLEAR_NONE instead of false (Topi) - Rename ANV_FAST_CLEAR_ANY to ANV_FAST_CLEAR_DEFAULT_VALUE - Add documentation for the enum values v4 (Jason Ekstrand): - Remove a dead comment Reviewed-by: Topi Pohjolainen <[email protected]> Reviewed-by: Nanley Chery <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/intel/vulkan/anv_image.c67
-rw-r--r--src/intel/vulkan/anv_private.h16
2 files changed, 83 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 0aa8cd94d6b..32ec24701da 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -861,6 +861,73 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
unreachable("layout is not a VkImageLayout enumeration member.");
}
+/**
+ * This function returns the level of unresolved fast-clear support of the
+ * given image in the given VkImageLayout.
+ *
+ * @param devinfo The device information of the Intel GPU.
+ * @param image The image that may contain a collection of buffers.
+ * @param aspect The aspect of the image to be accessed.
+ * @param layout The current layout of the image aspect(s).
+ */
+enum anv_fast_clear_type
+anv_layout_to_fast_clear_type(const struct gen_device_info * const devinfo,
+ const struct anv_image * const image,
+ const VkImageAspectFlagBits aspect,
+ const VkImageLayout layout)
+{
+ /* The aspect must be exactly one of the image aspects. */
+ assert(_mesa_bitcount(aspect) == 1 && (aspect & image->aspects));
+
+ uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
+
+ /* If there is no auxiliary surface allocated, there are no fast-clears */
+ if (image->planes[plane].aux_surface.isl.size == 0)
+ return ANV_FAST_CLEAR_NONE;
+
+ /* All images that use an auxiliary surface are required to be tiled. */
+ assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
+
+ /* Stencil has no aux */
+ assert(aspect != VK_IMAGE_ASPECT_STENCIL_BIT);
+
+ if (aspect == VK_IMAGE_ASPECT_DEPTH_BIT) {
+ /* For depth images (with HiZ), the layout supports fast-clears if and
+ * only if it supports HiZ. However, we only support fast-clears to the
+ * default depth value.
+ */
+ enum isl_aux_usage aux_usage =
+ anv_layout_to_aux_usage(devinfo, image, aspect, layout);
+ return aux_usage == ISL_AUX_USAGE_HIZ ?
+ ANV_FAST_CLEAR_DEFAULT_VALUE : ANV_FAST_CLEAR_NONE;
+ }
+
+ assert(image->aspects & VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV);
+
+ /* Multisample fast-clear is not yet supported. */
+ if (image->samples > 1)
+ return ANV_FAST_CLEAR_NONE;
+
+ switch (layout) {
+ case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
+ return ANV_FAST_CLEAR_ANY;
+
+ case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
+ return ANV_FAST_CLEAR_NONE;
+
+ default:
+ /* If the image has CCS_E enabled all the time then we can use
+ * fast-clear as long as the clear color is the default value of zero
+ * since this is the default value we program into every surface state
+ * used for texturing.
+ */
+ if (image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E)
+ return ANV_FAST_CLEAR_DEFAULT_VALUE;
+ else
+ return ANV_FAST_CLEAR_NONE;
+ }
+}
+
static struct anv_state
alloc_surface_state(struct anv_device *device)
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index c3ab9ebb09f..17bfa0f90a7 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2490,6 +2490,16 @@ struct anv_image {
} planes[3];
};
+/* The ordering of this enum is important */
+enum anv_fast_clear_type {
+ /** Image does not have/support any fast-clear blocks */
+ ANV_FAST_CLEAR_NONE = 0,
+ /** Image has/supports fast-clear but only to the default value */
+ ANV_FAST_CLEAR_DEFAULT_VALUE = 1,
+ /** Image has/supports fast-clear with an arbitrary fast-clear value */
+ ANV_FAST_CLEAR_ANY = 2,
+};
+
/* Returns the number of auxiliary buffer levels attached to an image. */
static inline uint8_t
anv_image_aux_levels(const struct anv_image * const image,
@@ -2612,6 +2622,12 @@ anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
const VkImageAspectFlagBits aspect,
const VkImageLayout layout);
+enum anv_fast_clear_type
+anv_layout_to_fast_clear_type(const struct gen_device_info * const devinfo,
+ const struct anv_image * const image,
+ const VkImageAspectFlagBits aspect,
+ const VkImageLayout layout);
+
/* This is defined as a macro so that it works for both
* VkImageSubresourceRange and VkImageSubresourceLayers
*/