Re: [Mesa-dev] [PATCH v3 08/16] anv: Transition more color buffer layouts

2017-07-18 Thread Nanley Chery
On Mon, Jul 17, 2017 at 02:41:32PM -0700, Jason Ekstrand wrote:
> On Fri, Jul 14, 2017 at 2:42 AM, Nanley Chery  wrote:
> 
> > On Mon, Jul 10, 2017 at 10:14:21AM -0700, Jason Ekstrand wrote:
> > > On Wed, Jun 28, 2017 at 2:14 PM, Nanley Chery 
> > wrote:
> > >
> > > > v2: Expound on comment for the pipe controls (Jason Ekstrand).
> > > >
> > > > Signed-off-by: Nanley Chery 
> > > > ---
> > > >  src/intel/vulkan/anv_blorp.c   |   4 +-
> > > >  src/intel/vulkan/genX_cmd_buffer.c | 183
> > ++
> > > > +++
> > > >  2 files changed, 167 insertions(+), 20 deletions(-)
> > > >
> > > > diff --git a/src/intel/vulkan/anv_blorp.c
> > b/src/intel/vulkan/anv_blorp.c
> > > > index 459d57ec57..84b01e8792 100644
> > > > --- a/src/intel/vulkan/anv_blorp.c
> > > > +++ b/src/intel/vulkan/anv_blorp.c
> > > > @@ -1451,7 +1451,9 @@ anv_image_ccs_clear(struct anv_cmd_buffer
> > > > *cmd_buffer,
> > > >
> > > > struct blorp_surf surf;
> > > > get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
> > > > -image->aux_usage, );
> > > > +image->aux_usage ==
> > ISL_AUX_USAGE_CCS_E ?
> > > > +ISL_AUX_USAGE_CCS_E :
> > ISL_AUX_USAGE_CCS_D,
> > > > +);
> > > >
> > > > /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> > > >  *
> > > > diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> > > > b/src/intel/vulkan/genX_cmd_buffer.c
> > > > index decf0b28d6..1a9b841c7c 100644
> > > > --- a/src/intel/vulkan/genX_cmd_buffer.c
> > > > +++ b/src/intel/vulkan/genX_cmd_buffer.c
> > > > @@ -524,6 +524,17 @@ genX(copy_fast_clear_dwords)(struct
> > anv_cmd_buffer
> > > > *cmd_buffer,
> > > > }
> > > >  }
> > > >
> > > > +/**
> > > > + * @brief Transitions a color buffer from one layout to another.
> > > > + *
> > > > + * See section 6.1.1. Image Layout Transitions of the Vulkan 1.0.50
> > spec
> > > > for
> > > > + * more information.
> > > > + *
> > > > + * @param level_count VK_REMAINING_MIP_LEVELS isn't supported.
> > > > + * @param layer_count VK_REMAINING_ARRAY_LAYERS isn't supported. For
> > 3D
> > > > images,
> > > > + *this represents the maximum layers to
> > transition at
> > > > each
> > > > + *specified miplevel.
> > > > + */
> > > >  static void
> > > >  transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
> > > >  const struct anv_image *image,
> > > > @@ -532,13 +543,27 @@ transition_color_buffer(struct anv_cmd_buffer
> > > > *cmd_buffer,
> > > >  VkImageLayout initial_layout,
> > > >  VkImageLayout final_layout)
> > > >  {
> > > > -   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> > > > -
> > > > -   if (image->aux_surface.isl.size == 0)
> > > > -  return;
> > > > -
> > > > -   if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> > > > -   initial_layout != VK_IMAGE_LAYOUT_PREINITIALIZED)
> > > > +   /* Validate the inputs. */
> > > > +   assert(cmd_buffer);
> > > > +   assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> > > > +   /* These values aren't supported for simplicity's sake. */
> > > > +   assert(level_count != VK_REMAINING_MIP_LEVELS &&
> > > > +  layer_count != VK_REMAINING_ARRAY_LAYERS);
> > > > +   /* Ensure the subresource range is valid. */
> > > > +   uint64_t last_level_num = base_level + level_count;
> > > > +   const uint32_t max_depth = anv_minify(image->extent.depth,
> > > > base_level);
> > > > +   const uint32_t image_layers = MAX2(image->array_size, max_depth);
> > > > +   assert(base_layer + layer_count  <= image_layers);
> > > > +   assert(last_level_num <= image->levels);
> > > > +   /* The spec disallows these final layouts. */
> > > > +   assert(final_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> > > > +  final_layout != VK_IMAGE_LAYOUT_PREINITIALIZED);
> > > > +
> > > > +   /* No work is necessary if the layout stays the same or if this
> > > > subresource
> > > > +* range lacks auxiliary data.
> > > > +*/
> > > > +   if (initial_layout == final_layout ||
> > > > +   base_layer >= anv_image_aux_layers(image, base_level))
> > > >return;
> > > >
> > > > /* A transition of a 3D subresource works on all slices at a time.
> > */
> > > > @@ -549,22 +574,142 @@ transition_color_buffer(struct anv_cmd_buffer
> > > > *cmd_buffer,
> > > >
> > > > /* We're interested in the subresource range subset that has aux
> > data.
> > > > */
> > > > level_count = MIN2(level_count, anv_image_aux_levels(image));
> > > > +   layer_count = MIN2(layer_count, anv_image_aux_layers(image,
> > > > base_level));
> > > >
> > >
> > > Is this correct?  I think we want MIN2(layer_count,
> > anv_image_aux_layers()
> > > - base_layer), don't we?  This would also mean there's a bug in 

Re: [Mesa-dev] [PATCH v3 08/16] anv: Transition more color buffer layouts

2017-07-17 Thread Jason Ekstrand
On Fri, Jul 14, 2017 at 2:42 AM, Nanley Chery  wrote:

> On Mon, Jul 10, 2017 at 10:14:21AM -0700, Jason Ekstrand wrote:
> > On Wed, Jun 28, 2017 at 2:14 PM, Nanley Chery 
> wrote:
> >
> > > v2: Expound on comment for the pipe controls (Jason Ekstrand).
> > >
> > > Signed-off-by: Nanley Chery 
> > > ---
> > >  src/intel/vulkan/anv_blorp.c   |   4 +-
> > >  src/intel/vulkan/genX_cmd_buffer.c | 183
> ++
> > > +++
> > >  2 files changed, 167 insertions(+), 20 deletions(-)
> > >
> > > diff --git a/src/intel/vulkan/anv_blorp.c
> b/src/intel/vulkan/anv_blorp.c
> > > index 459d57ec57..84b01e8792 100644
> > > --- a/src/intel/vulkan/anv_blorp.c
> > > +++ b/src/intel/vulkan/anv_blorp.c
> > > @@ -1451,7 +1451,9 @@ anv_image_ccs_clear(struct anv_cmd_buffer
> > > *cmd_buffer,
> > >
> > > struct blorp_surf surf;
> > > get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
> > > -image->aux_usage, );
> > > +image->aux_usage ==
> ISL_AUX_USAGE_CCS_E ?
> > > +ISL_AUX_USAGE_CCS_E :
> ISL_AUX_USAGE_CCS_D,
> > > +);
> > >
> > > /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> > >  *
> > > diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> > > b/src/intel/vulkan/genX_cmd_buffer.c
> > > index decf0b28d6..1a9b841c7c 100644
> > > --- a/src/intel/vulkan/genX_cmd_buffer.c
> > > +++ b/src/intel/vulkan/genX_cmd_buffer.c
> > > @@ -524,6 +524,17 @@ genX(copy_fast_clear_dwords)(struct
> anv_cmd_buffer
> > > *cmd_buffer,
> > > }
> > >  }
> > >
> > > +/**
> > > + * @brief Transitions a color buffer from one layout to another.
> > > + *
> > > + * See section 6.1.1. Image Layout Transitions of the Vulkan 1.0.50
> spec
> > > for
> > > + * more information.
> > > + *
> > > + * @param level_count VK_REMAINING_MIP_LEVELS isn't supported.
> > > + * @param layer_count VK_REMAINING_ARRAY_LAYERS isn't supported. For
> 3D
> > > images,
> > > + *this represents the maximum layers to
> transition at
> > > each
> > > + *specified miplevel.
> > > + */
> > >  static void
> > >  transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
> > >  const struct anv_image *image,
> > > @@ -532,13 +543,27 @@ transition_color_buffer(struct anv_cmd_buffer
> > > *cmd_buffer,
> > >  VkImageLayout initial_layout,
> > >  VkImageLayout final_layout)
> > >  {
> > > -   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> > > -
> > > -   if (image->aux_surface.isl.size == 0)
> > > -  return;
> > > -
> > > -   if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> > > -   initial_layout != VK_IMAGE_LAYOUT_PREINITIALIZED)
> > > +   /* Validate the inputs. */
> > > +   assert(cmd_buffer);
> > > +   assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> > > +   /* These values aren't supported for simplicity's sake. */
> > > +   assert(level_count != VK_REMAINING_MIP_LEVELS &&
> > > +  layer_count != VK_REMAINING_ARRAY_LAYERS);
> > > +   /* Ensure the subresource range is valid. */
> > > +   uint64_t last_level_num = base_level + level_count;
> > > +   const uint32_t max_depth = anv_minify(image->extent.depth,
> > > base_level);
> > > +   const uint32_t image_layers = MAX2(image->array_size, max_depth);
> > > +   assert(base_layer + layer_count  <= image_layers);
> > > +   assert(last_level_num <= image->levels);
> > > +   /* The spec disallows these final layouts. */
> > > +   assert(final_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> > > +  final_layout != VK_IMAGE_LAYOUT_PREINITIALIZED);
> > > +
> > > +   /* No work is necessary if the layout stays the same or if this
> > > subresource
> > > +* range lacks auxiliary data.
> > > +*/
> > > +   if (initial_layout == final_layout ||
> > > +   base_layer >= anv_image_aux_layers(image, base_level))
> > >return;
> > >
> > > /* A transition of a 3D subresource works on all slices at a time.
> */
> > > @@ -549,22 +574,142 @@ transition_color_buffer(struct anv_cmd_buffer
> > > *cmd_buffer,
> > >
> > > /* We're interested in the subresource range subset that has aux
> data.
> > > */
> > > level_count = MIN2(level_count, anv_image_aux_levels(image));
> > > +   layer_count = MIN2(layer_count, anv_image_aux_layers(image,
> > > base_level));
> > >
> >
> > Is this correct?  I think we want MIN2(layer_count,
> anv_image_aux_layers()
> > - base_layer), don't we?  This would also mean there's a bug in the
> current
> > level_count.
> >
> >
>
> I see nothing wrong with it. The current equation limits the
> user-specified the layer_count to the actual number of layers which can
> be transitioned. What's the meaning behind subtracting base_layer?
>

Because anv_image_aux_layers is the number of layers 

Re: [Mesa-dev] [PATCH v3 08/16] anv: Transition more color buffer layouts

2017-07-14 Thread Nanley Chery
On Mon, Jul 10, 2017 at 10:14:21AM -0700, Jason Ekstrand wrote:
> On Wed, Jun 28, 2017 at 2:14 PM, Nanley Chery  wrote:
> 
> > v2: Expound on comment for the pipe controls (Jason Ekstrand).
> >
> > Signed-off-by: Nanley Chery 
> > ---
> >  src/intel/vulkan/anv_blorp.c   |   4 +-
> >  src/intel/vulkan/genX_cmd_buffer.c | 183 ++
> > +++
> >  2 files changed, 167 insertions(+), 20 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> > index 459d57ec57..84b01e8792 100644
> > --- a/src/intel/vulkan/anv_blorp.c
> > +++ b/src/intel/vulkan/anv_blorp.c
> > @@ -1451,7 +1451,9 @@ anv_image_ccs_clear(struct anv_cmd_buffer
> > *cmd_buffer,
> >
> > struct blorp_surf surf;
> > get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
> > -image->aux_usage, );
> > +image->aux_usage == ISL_AUX_USAGE_CCS_E ?
> > +ISL_AUX_USAGE_CCS_E : ISL_AUX_USAGE_CCS_D,
> > +);
> >
> > /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> >  *
> > diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> > b/src/intel/vulkan/genX_cmd_buffer.c
> > index decf0b28d6..1a9b841c7c 100644
> > --- a/src/intel/vulkan/genX_cmd_buffer.c
> > +++ b/src/intel/vulkan/genX_cmd_buffer.c
> > @@ -524,6 +524,17 @@ genX(copy_fast_clear_dwords)(struct anv_cmd_buffer
> > *cmd_buffer,
> > }
> >  }
> >
> > +/**
> > + * @brief Transitions a color buffer from one layout to another.
> > + *
> > + * See section 6.1.1. Image Layout Transitions of the Vulkan 1.0.50 spec
> > for
> > + * more information.
> > + *
> > + * @param level_count VK_REMAINING_MIP_LEVELS isn't supported.
> > + * @param layer_count VK_REMAINING_ARRAY_LAYERS isn't supported. For 3D
> > images,
> > + *this represents the maximum layers to transition at
> > each
> > + *specified miplevel.
> > + */
> >  static void
> >  transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
> >  const struct anv_image *image,
> > @@ -532,13 +543,27 @@ transition_color_buffer(struct anv_cmd_buffer
> > *cmd_buffer,
> >  VkImageLayout initial_layout,
> >  VkImageLayout final_layout)
> >  {
> > -   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> > -
> > -   if (image->aux_surface.isl.size == 0)
> > -  return;
> > -
> > -   if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> > -   initial_layout != VK_IMAGE_LAYOUT_PREINITIALIZED)
> > +   /* Validate the inputs. */
> > +   assert(cmd_buffer);
> > +   assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> > +   /* These values aren't supported for simplicity's sake. */
> > +   assert(level_count != VK_REMAINING_MIP_LEVELS &&
> > +  layer_count != VK_REMAINING_ARRAY_LAYERS);
> > +   /* Ensure the subresource range is valid. */
> > +   uint64_t last_level_num = base_level + level_count;
> > +   const uint32_t max_depth = anv_minify(image->extent.depth,
> > base_level);
> > +   const uint32_t image_layers = MAX2(image->array_size, max_depth);
> > +   assert(base_layer + layer_count  <= image_layers);
> > +   assert(last_level_num <= image->levels);
> > +   /* The spec disallows these final layouts. */
> > +   assert(final_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> > +  final_layout != VK_IMAGE_LAYOUT_PREINITIALIZED);
> > +
> > +   /* No work is necessary if the layout stays the same or if this
> > subresource
> > +* range lacks auxiliary data.
> > +*/
> > +   if (initial_layout == final_layout ||
> > +   base_layer >= anv_image_aux_layers(image, base_level))
> >return;
> >
> > /* A transition of a 3D subresource works on all slices at a time. */
> > @@ -549,22 +574,142 @@ transition_color_buffer(struct anv_cmd_buffer
> > *cmd_buffer,
> >
> > /* We're interested in the subresource range subset that has aux data.
> > */
> > level_count = MIN2(level_count, anv_image_aux_levels(image));
> > +   layer_count = MIN2(layer_count, anv_image_aux_layers(image,
> > base_level));
> >
> 
> Is this correct?  I think we want MIN2(layer_count, anv_image_aux_layers()
> - base_layer), don't we?  This would also mean there's a bug in the current
> level_count.
> 
> 

I see nothing wrong with it. The current equation limits the
user-specified the layer_count to the actual number of layers which can
be transitioned. What's the meaning behind subtracting base_layer? 

> > +   last_level_num = base_level + level_count;
> > +
> > +   /* Record whether or not the layout is undefined. Pre-initialized
> > images
> > +* with auxiliary buffers have a non-linear layout and are thus
> > undefined.
> > +*/
> > +   assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
> > +   const bool undef_layout = initial_layout == VK_IMAGE_LAYOUT_UNDEFINED

Re: [Mesa-dev] [PATCH v3 08/16] anv: Transition more color buffer layouts

2017-07-10 Thread Jason Ekstrand
On Wed, Jun 28, 2017 at 2:14 PM, Nanley Chery  wrote:

> v2: Expound on comment for the pipe controls (Jason Ekstrand).
>
> Signed-off-by: Nanley Chery 
> ---
>  src/intel/vulkan/anv_blorp.c   |   4 +-
>  src/intel/vulkan/genX_cmd_buffer.c | 183 ++
> +++
>  2 files changed, 167 insertions(+), 20 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> index 459d57ec57..84b01e8792 100644
> --- a/src/intel/vulkan/anv_blorp.c
> +++ b/src/intel/vulkan/anv_blorp.c
> @@ -1451,7 +1451,9 @@ anv_image_ccs_clear(struct anv_cmd_buffer
> *cmd_buffer,
>
> struct blorp_surf surf;
> get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
> -image->aux_usage, );
> +image->aux_usage == ISL_AUX_USAGE_CCS_E ?
> +ISL_AUX_USAGE_CCS_E : ISL_AUX_USAGE_CCS_D,
> +);
>
> /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
>  *
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> b/src/intel/vulkan/genX_cmd_buffer.c
> index decf0b28d6..1a9b841c7c 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -524,6 +524,17 @@ genX(copy_fast_clear_dwords)(struct anv_cmd_buffer
> *cmd_buffer,
> }
>  }
>
> +/**
> + * @brief Transitions a color buffer from one layout to another.
> + *
> + * See section 6.1.1. Image Layout Transitions of the Vulkan 1.0.50 spec
> for
> + * more information.
> + *
> + * @param level_count VK_REMAINING_MIP_LEVELS isn't supported.
> + * @param layer_count VK_REMAINING_ARRAY_LAYERS isn't supported. For 3D
> images,
> + *this represents the maximum layers to transition at
> each
> + *specified miplevel.
> + */
>  static void
>  transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
>  const struct anv_image *image,
> @@ -532,13 +543,27 @@ transition_color_buffer(struct anv_cmd_buffer
> *cmd_buffer,
>  VkImageLayout initial_layout,
>  VkImageLayout final_layout)
>  {
> -   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> -
> -   if (image->aux_surface.isl.size == 0)
> -  return;
> -
> -   if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> -   initial_layout != VK_IMAGE_LAYOUT_PREINITIALIZED)
> +   /* Validate the inputs. */
> +   assert(cmd_buffer);
> +   assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> +   /* These values aren't supported for simplicity's sake. */
> +   assert(level_count != VK_REMAINING_MIP_LEVELS &&
> +  layer_count != VK_REMAINING_ARRAY_LAYERS);
> +   /* Ensure the subresource range is valid. */
> +   uint64_t last_level_num = base_level + level_count;
> +   const uint32_t max_depth = anv_minify(image->extent.depth,
> base_level);
> +   const uint32_t image_layers = MAX2(image->array_size, max_depth);
> +   assert(base_layer + layer_count  <= image_layers);
> +   assert(last_level_num <= image->levels);
> +   /* The spec disallows these final layouts. */
> +   assert(final_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
> +  final_layout != VK_IMAGE_LAYOUT_PREINITIALIZED);
> +
> +   /* No work is necessary if the layout stays the same or if this
> subresource
> +* range lacks auxiliary data.
> +*/
> +   if (initial_layout == final_layout ||
> +   base_layer >= anv_image_aux_layers(image, base_level))
>return;
>
> /* A transition of a 3D subresource works on all slices at a time. */
> @@ -549,22 +574,142 @@ transition_color_buffer(struct anv_cmd_buffer
> *cmd_buffer,
>
> /* We're interested in the subresource range subset that has aux data.
> */
> level_count = MIN2(level_count, anv_image_aux_levels(image));
> +   layer_count = MIN2(layer_count, anv_image_aux_layers(image,
> base_level));
>

Is this correct?  I think we want MIN2(layer_count, anv_image_aux_layers()
- base_layer), don't we?  This would also mean there's a bug in the current
level_count.


> +   last_level_num = base_level + level_count;
> +
> +   /* Record whether or not the layout is undefined. Pre-initialized
> images
> +* with auxiliary buffers have a non-linear layout and are thus
> undefined.
> +*/
> +   assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
> +   const bool undef_layout = initial_layout == VK_IMAGE_LAYOUT_UNDEFINED
> ||
> + initial_layout == VK_IMAGE_LAYOUT_
> PREINITIALIZED;
>
> -   /* We're transitioning from an undefined layout. We must ensure that
> the
> -* clear values buffer is filled with valid data.
> +   /* Do preparatory work before the resolve operation or return early if
> no
> +* resolve is actually needed.
>  */
> -   for (unsigned l = 0; l < level_count; l++)
> -  init_fast_clear_state_entry(cmd_buffer, image, base_level + l);
> -
> -   if 

[Mesa-dev] [PATCH v3 08/16] anv: Transition more color buffer layouts

2017-06-28 Thread Nanley Chery
v2: Expound on comment for the pipe controls (Jason Ekstrand).

Signed-off-by: Nanley Chery 
---
 src/intel/vulkan/anv_blorp.c   |   4 +-
 src/intel/vulkan/genX_cmd_buffer.c | 183 +
 2 files changed, 167 insertions(+), 20 deletions(-)

diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index 459d57ec57..84b01e8792 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -1451,7 +1451,9 @@ anv_image_ccs_clear(struct anv_cmd_buffer *cmd_buffer,
 
struct blorp_surf surf;
get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT,
-image->aux_usage, );
+image->aux_usage == ISL_AUX_USAGE_CCS_E ?
+ISL_AUX_USAGE_CCS_E : ISL_AUX_USAGE_CCS_D,
+);
 
/* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
 *
diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
b/src/intel/vulkan/genX_cmd_buffer.c
index decf0b28d6..1a9b841c7c 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -524,6 +524,17 @@ genX(copy_fast_clear_dwords)(struct anv_cmd_buffer 
*cmd_buffer,
}
 }
 
+/**
+ * @brief Transitions a color buffer from one layout to another.
+ *
+ * See section 6.1.1. Image Layout Transitions of the Vulkan 1.0.50 spec for
+ * more information.
+ *
+ * @param level_count VK_REMAINING_MIP_LEVELS isn't supported.
+ * @param layer_count VK_REMAINING_ARRAY_LAYERS isn't supported. For 3D images,
+ *this represents the maximum layers to transition at each
+ *specified miplevel.
+ */
 static void
 transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
 const struct anv_image *image,
@@ -532,13 +543,27 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
 VkImageLayout initial_layout,
 VkImageLayout final_layout)
 {
-   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
-
-   if (image->aux_surface.isl.size == 0)
-  return;
-
-   if (initial_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
-   initial_layout != VK_IMAGE_LAYOUT_PREINITIALIZED)
+   /* Validate the inputs. */
+   assert(cmd_buffer);
+   assert(image && image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
+   /* These values aren't supported for simplicity's sake. */
+   assert(level_count != VK_REMAINING_MIP_LEVELS &&
+  layer_count != VK_REMAINING_ARRAY_LAYERS);
+   /* Ensure the subresource range is valid. */
+   uint64_t last_level_num = base_level + level_count;
+   const uint32_t max_depth = anv_minify(image->extent.depth, base_level);
+   const uint32_t image_layers = MAX2(image->array_size, max_depth);
+   assert(base_layer + layer_count  <= image_layers);
+   assert(last_level_num <= image->levels);
+   /* The spec disallows these final layouts. */
+   assert(final_layout != VK_IMAGE_LAYOUT_UNDEFINED &&
+  final_layout != VK_IMAGE_LAYOUT_PREINITIALIZED);
+
+   /* No work is necessary if the layout stays the same or if this subresource
+* range lacks auxiliary data.
+*/
+   if (initial_layout == final_layout ||
+   base_layer >= anv_image_aux_layers(image, base_level))
   return;
 
/* A transition of a 3D subresource works on all slices at a time. */
@@ -549,22 +574,142 @@ transition_color_buffer(struct anv_cmd_buffer 
*cmd_buffer,
 
/* We're interested in the subresource range subset that has aux data. */
level_count = MIN2(level_count, anv_image_aux_levels(image));
+   layer_count = MIN2(layer_count, anv_image_aux_layers(image, base_level));
+   last_level_num = base_level + level_count;
+
+   /* Record whether or not the layout is undefined. Pre-initialized images
+* with auxiliary buffers have a non-linear layout and are thus undefined.
+*/
+   assert(image->tiling == VK_IMAGE_TILING_OPTIMAL);
+   const bool undef_layout = initial_layout == VK_IMAGE_LAYOUT_UNDEFINED ||
+ initial_layout == VK_IMAGE_LAYOUT_PREINITIALIZED;
 
-   /* We're transitioning from an undefined layout. We must ensure that the
-* clear values buffer is filled with valid data.
+   /* Do preparatory work before the resolve operation or return early if no
+* resolve is actually needed.
 */
-   for (unsigned l = 0; l < level_count; l++)
-  init_fast_clear_state_entry(cmd_buffer, image, base_level + l);
-
-   if (image->aux_usage == ISL_AUX_USAGE_CCS_E) {
-  /* We're transitioning from an undefined layout so it doesn't really
-   * matter what data ends up in the color buffer.  We do, however, need to
-   * ensure that the CCS has valid data in it.  One easy way to do that is
-   * to fast-clear the specified range.
+   if (undef_layout) {
+  /* A subresource in the undefined layout may have been aliased and
+   * populated with any arrangement of bits.