Re: [Mesa-dev] [PATCH 02/29] anv/blorp: Rework image clear/resolve helpers

2018-01-12 Thread Jason Ekstrand
On Wed, Dec 6, 2017 at 9:56 AM, Nanley Chery  wrote:

> On Wed, Dec 06, 2017 at 09:40:25AM -0800, Nanley Chery wrote:
> > On Tue, Dec 05, 2017 at 03:48:45PM -0800, Nanley Chery wrote:
> > > On Mon, Nov 27, 2017 at 07:05:52PM -0800, Jason Ekstrand wrote:
> > > > This replaces image_fast_clear and ccs_resolve with two new helpers
> that
> > > > simply perform an isl_aux_op whatever that may be on CCS or MCS.
> This
> > > > is a bit cleaner as it separates performing the aux operation from
> which
> > > > blorp helper we have to call to do it.
> > > > ---
> > > >  src/intel/vulkan/anv_blorp.c   | 218
> ++---
> > > >  src/intel/vulkan/anv_private.h |  23 ++--
> > > >  src/intel/vulkan/genX_cmd_buffer.c |  28 +++--
> > > >  3 files changed, 165 insertions(+), 104 deletions(-)
> > > >
> > > > diff --git a/src/intel/vulkan/anv_blorp.c
> b/src/intel/vulkan/anv_blorp.c
> > > > index e244468..7c8a673 100644
> > > > --- a/src/intel/vulkan/anv_blorp.c
> > > > +++ b/src/intel/vulkan/anv_blorp.c
> > > > @@ -1439,75 +1439,6 @@ fast_clear_aux_usage(const struct anv_image
> *image,
> > > >  }
> > > >
> > > >  void
> > > > -anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
> > > > - const struct anv_image *image,
> > > > - VkImageAspectFlagBits aspect,
> > > > - const uint32_t base_level, const uint32_t
> level_count,
> > > > - const uint32_t base_layer, uint32_t
> layer_count)
> > > > -{
> > > > -   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth ==
> 1);
> > > > -
> > > > -   if (image->type == VK_IMAGE_TYPE_3D) {
> > > > -  assert(base_layer == 0);
> > > > -  assert(layer_count == anv_minify(image->extent.depth,
> base_level));
> > > > -   }
> > > > -
> > > > -   struct blorp_batch batch;
> > > > -   blorp_batch_init(_buffer->device->blorp, ,
> cmd_buffer, 0);
> > > > -
> > > > -   struct blorp_surf surf;
> > > > -   get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
> > > > -fast_clear_aux_usage(image, aspect),
> > > > -);
> > > > -
> > > > -   /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> > > > -*
> > > > -*"After Render target fast clear, pipe-control with color
> cache
> > > > -*write-flush must be issued before sending any DRAW
> commands on
> > > > -*that render target."
> > > > -*
> > > > -* This comment is a bit cryptic and doesn't really tell you
> what's going
> > > > -* or what's really needed.  It appears that fast clear ops are
> not
> > > > -* properly synchronized with other drawing.  This means that we
> cannot
> > > > -* have a fast clear operation in the pipe at the same time as
> other
> > > > -* regular drawing operations.  We need to use a PIPE_CONTROL to
> ensure
> > > > -* that the contents of the previous draw hit the render target
> before we
> > > > -* resolve and then use a second PIPE_CONTROL after the resolve
> to ensure
> > > > -* that it is completed before any additional drawing occurs.
> > > > -*/
> > > > -   cmd_buffer->state.pending_pipe_bits |=
> > > > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT |
> ANV_PIPE_CS_STALL_BIT;
> > > > -
> > > > -   uint32_t plane = anv_image_aspect_to_plane(image->aspects,
> aspect);
> > > > -   uint32_t width_div = image->format->planes[plane].
> denominator_scales[0];
> > > > -   uint32_t height_div = image->format->planes[plane].
> denominator_scales[1];
> > > > -
> > > > -   for (uint32_t l = 0; l < level_count; l++) {
> > > > -  const uint32_t level = base_level + l;
> > > > -
> > > > -  const VkExtent3D extent = {
> > > > - .width = anv_minify(image->extent.width, level),
> > > > - .height = anv_minify(image->extent.height, level),
> > > > - .depth = anv_minify(image->extent.depth, level),
> > > > -  };
> > > > -
> > > > -  if (image->type == VK_IMAGE_TYPE_3D)
> > > > - layer_count = extent.depth;
> > > > -
> > > > -  assert(level < anv_image_aux_levels(image, aspect));
> > > > -  assert(base_layer + layer_count <=
> anv_image_aux_layers(image, aspect, level));
> > > > -  blorp_fast_clear(, , surf.surf->format,
> > > > -   level, base_layer, layer_count,
> > > > -   0, 0,
> > > > -   extent.width / width_div,
> > > > -   extent.height / height_div);
> > > > -   }
> > > > -
> > > > -   cmd_buffer->state.pending_pipe_bits |=
> > > > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT |
> ANV_PIPE_CS_STALL_BIT;
> > > > -}
> > > > -
> > > > -void
> > > >  anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer)
> > > >  {
> > > > struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
> > > > @@ -1681,36 +1612,153 @@ anv_gen8_hiz_op_resolve(struct
> anv_cmd_buffer *cmd_buffer,

Re: [Mesa-dev] [PATCH 02/29] anv/blorp: Rework image clear/resolve helpers

2018-01-12 Thread Jason Ekstrand
On Tue, Dec 5, 2017 at 4:16 PM, Nanley Chery  wrote:

> On Mon, Nov 27, 2017 at 07:05:52PM -0800, Jason Ekstrand wrote:
> > This replaces image_fast_clear and ccs_resolve with two new helpers that
> > simply perform an isl_aux_op whatever that may be on CCS or MCS.  This
> > is a bit cleaner as it separates performing the aux operation from which
> > blorp helper we have to call to do it.
> > ---
> >  src/intel/vulkan/anv_blorp.c   | 218 ++
> ---
> >  src/intel/vulkan/anv_private.h |  23 ++--
> >  src/intel/vulkan/genX_cmd_buffer.c |  28 +++--
> >  3 files changed, 165 insertions(+), 104 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> > index e244468..7c8a673 100644
> > --- a/src/intel/vulkan/anv_blorp.c
> > +++ b/src/intel/vulkan/anv_blorp.c
> > @@ -1439,75 +1439,6 @@ fast_clear_aux_usage(const struct anv_image
> *image,
> >  }
> >
> >  void
> > -anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
> > - const struct anv_image *image,
> > - VkImageAspectFlagBits aspect,
> > - const uint32_t base_level, const uint32_t
> level_count,
> > - const uint32_t base_layer, uint32_t layer_count)
> > -{
> > -   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
> > -
> > -   if (image->type == VK_IMAGE_TYPE_3D) {
> > -  assert(base_layer == 0);
> > -  assert(layer_count == anv_minify(image->extent.depth,
> base_level));
> > -   }
> > -
> > -   struct blorp_batch batch;
> > -   blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0);
> > -
> > -   struct blorp_surf surf;
> > -   get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
> > -fast_clear_aux_usage(image, aspect),
> > -);
> > -
> > -   /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> > -*
> > -*"After Render target fast clear, pipe-control with color cache
> > -*write-flush must be issued before sending any DRAW commands on
> > -*that render target."
> > -*
> > -* This comment is a bit cryptic and doesn't really tell you what's
> going
> > -* or what's really needed.  It appears that fast clear ops are not
> > -* properly synchronized with other drawing.  This means that we
> cannot
> > -* have a fast clear operation in the pipe at the same time as other
> > -* regular drawing operations.  We need to use a PIPE_CONTROL to
> ensure
> > -* that the contents of the previous draw hit the render target
> before we
> > -* resolve and then use a second PIPE_CONTROL after the resolve to
> ensure
> > -* that it is completed before any additional drawing occurs.
> > -*/
> > -   cmd_buffer->state.pending_pipe_bits |=
> > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> > -
> > -   uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
> > -   uint32_t width_div = image->format->planes[plane].
> denominator_scales[0];
> > -   uint32_t height_div = image->format->planes[plane].
> denominator_scales[1];
> > -
> > -   for (uint32_t l = 0; l < level_count; l++) {
> > -  const uint32_t level = base_level + l;
> > -
> > -  const VkExtent3D extent = {
> > - .width = anv_minify(image->extent.width, level),
> > - .height = anv_minify(image->extent.height, level),
> > - .depth = anv_minify(image->extent.depth, level),
> > -  };
> > -
> > -  if (image->type == VK_IMAGE_TYPE_3D)
> > - layer_count = extent.depth;
> > -
> > -  assert(level < anv_image_aux_levels(image, aspect));
> > -  assert(base_layer + layer_count <= anv_image_aux_layers(image,
> aspect, level));
> > -  blorp_fast_clear(, , surf.surf->format,
> > -   level, base_layer, layer_count,
> > -   0, 0,
> > -   extent.width / width_div,
> > -   extent.height / height_div);
> > -   }
> > -
> > -   cmd_buffer->state.pending_pipe_bits |=
> > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> > -}
> > -
> > -void
> >  anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer)
> >  {
> > struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
> > @@ -1681,36 +1612,153 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer
> *cmd_buffer,
> >  }
> >
> >  void
> > -anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
> > -const struct anv_image * const image,
> > -VkImageAspectFlagBits aspect,
> > -const uint8_t level,
> > -const uint32_t start_layer, const uint32_t layer_count,
> > -const enum blorp_fast_clear_op op)
> > +anv_image_mcs_op(struct anv_cmd_buffer *cmd_buffer,
> > + const struct anv_image *image,
> > + VkImageAspectFlagBits 

Re: [Mesa-dev] [PATCH 02/29] anv/blorp: Rework image clear/resolve helpers

2018-01-12 Thread Jason Ekstrand
On Tue, Dec 5, 2017 at 3:48 PM, Nanley Chery  wrote:

> On Mon, Nov 27, 2017 at 07:05:52PM -0800, Jason Ekstrand wrote:
> > This replaces image_fast_clear and ccs_resolve with two new helpers that
> > simply perform an isl_aux_op whatever that may be on CCS or MCS.  This
> > is a bit cleaner as it separates performing the aux operation from which
> > blorp helper we have to call to do it.
> > ---
> >  src/intel/vulkan/anv_blorp.c   | 218 ++
> ---
> >  src/intel/vulkan/anv_private.h |  23 ++--
> >  src/intel/vulkan/genX_cmd_buffer.c |  28 +++--
> >  3 files changed, 165 insertions(+), 104 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> > index e244468..7c8a673 100644
> > --- a/src/intel/vulkan/anv_blorp.c
> > +++ b/src/intel/vulkan/anv_blorp.c
> > @@ -1439,75 +1439,6 @@ fast_clear_aux_usage(const struct anv_image
> *image,
> >  }
> >
> >  void
> > -anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
> > - const struct anv_image *image,
> > - VkImageAspectFlagBits aspect,
> > - const uint32_t base_level, const uint32_t
> level_count,
> > - const uint32_t base_layer, uint32_t layer_count)
> > -{
> > -   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
> > -
> > -   if (image->type == VK_IMAGE_TYPE_3D) {
> > -  assert(base_layer == 0);
> > -  assert(layer_count == anv_minify(image->extent.depth,
> base_level));
> > -   }
> > -
> > -   struct blorp_batch batch;
> > -   blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0);
> > -
> > -   struct blorp_surf surf;
> > -   get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
> > -fast_clear_aux_usage(image, aspect),
> > -);
> > -
> > -   /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> > -*
> > -*"After Render target fast clear, pipe-control with color cache
> > -*write-flush must be issued before sending any DRAW commands on
> > -*that render target."
> > -*
> > -* This comment is a bit cryptic and doesn't really tell you what's
> going
> > -* or what's really needed.  It appears that fast clear ops are not
> > -* properly synchronized with other drawing.  This means that we
> cannot
> > -* have a fast clear operation in the pipe at the same time as other
> > -* regular drawing operations.  We need to use a PIPE_CONTROL to
> ensure
> > -* that the contents of the previous draw hit the render target
> before we
> > -* resolve and then use a second PIPE_CONTROL after the resolve to
> ensure
> > -* that it is completed before any additional drawing occurs.
> > -*/
> > -   cmd_buffer->state.pending_pipe_bits |=
> > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> > -
> > -   uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
> > -   uint32_t width_div = image->format->planes[plane].
> denominator_scales[0];
> > -   uint32_t height_div = image->format->planes[plane].
> denominator_scales[1];
> > -
> > -   for (uint32_t l = 0; l < level_count; l++) {
> > -  const uint32_t level = base_level + l;
> > -
> > -  const VkExtent3D extent = {
> > - .width = anv_minify(image->extent.width, level),
> > - .height = anv_minify(image->extent.height, level),
> > - .depth = anv_minify(image->extent.depth, level),
> > -  };
> > -
> > -  if (image->type == VK_IMAGE_TYPE_3D)
> > - layer_count = extent.depth;
> > -
> > -  assert(level < anv_image_aux_levels(image, aspect));
> > -  assert(base_layer + layer_count <= anv_image_aux_layers(image,
> aspect, level));
> > -  blorp_fast_clear(, , surf.surf->format,
> > -   level, base_layer, layer_count,
> > -   0, 0,
> > -   extent.width / width_div,
> > -   extent.height / height_div);
> > -   }
> > -
> > -   cmd_buffer->state.pending_pipe_bits |=
> > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> > -}
> > -
> > -void
> >  anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer)
> >  {
> > struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
> > @@ -1681,36 +1612,153 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer
> *cmd_buffer,
> >  }
> >
> >  void
> > -anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
> > -const struct anv_image * const image,
> > -VkImageAspectFlagBits aspect,
> > -const uint8_t level,
> > -const uint32_t start_layer, const uint32_t layer_count,
> > -const enum blorp_fast_clear_op op)
> > +anv_image_mcs_op(struct anv_cmd_buffer *cmd_buffer,
> > + const struct anv_image *image,
> > + VkImageAspectFlagBits 

Re: [Mesa-dev] [PATCH 02/29] anv/blorp: Rework image clear/resolve helpers

2017-12-06 Thread Nanley Chery
On Wed, Dec 06, 2017 at 09:40:25AM -0800, Nanley Chery wrote:
> On Tue, Dec 05, 2017 at 03:48:45PM -0800, Nanley Chery wrote:
> > On Mon, Nov 27, 2017 at 07:05:52PM -0800, Jason Ekstrand wrote:
> > > This replaces image_fast_clear and ccs_resolve with two new helpers that
> > > simply perform an isl_aux_op whatever that may be on CCS or MCS.  This
> > > is a bit cleaner as it separates performing the aux operation from which
> > > blorp helper we have to call to do it.
> > > ---
> > >  src/intel/vulkan/anv_blorp.c   | 218 
> > > ++---
> > >  src/intel/vulkan/anv_private.h |  23 ++--
> > >  src/intel/vulkan/genX_cmd_buffer.c |  28 +++--
> > >  3 files changed, 165 insertions(+), 104 deletions(-)
> > > 
> > > diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> > > index e244468..7c8a673 100644
> > > --- a/src/intel/vulkan/anv_blorp.c
> > > +++ b/src/intel/vulkan/anv_blorp.c
> > > @@ -1439,75 +1439,6 @@ fast_clear_aux_usage(const struct anv_image *image,
> > >  }
> > >  
> > >  void
> > > -anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
> > > - const struct anv_image *image,
> > > - VkImageAspectFlagBits aspect,
> > > - const uint32_t base_level, const uint32_t 
> > > level_count,
> > > - const uint32_t base_layer, uint32_t layer_count)
> > > -{
> > > -   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
> > > -
> > > -   if (image->type == VK_IMAGE_TYPE_3D) {
> > > -  assert(base_layer == 0);
> > > -  assert(layer_count == anv_minify(image->extent.depth, base_level));
> > > -   }
> > > -
> > > -   struct blorp_batch batch;
> > > -   blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0);
> > > -
> > > -   struct blorp_surf surf;
> > > -   get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
> > > -fast_clear_aux_usage(image, aspect),
> > > -);
> > > -
> > > -   /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> > > -*
> > > -*"After Render target fast clear, pipe-control with color cache
> > > -*write-flush must be issued before sending any DRAW commands on
> > > -*that render target."
> > > -*
> > > -* This comment is a bit cryptic and doesn't really tell you what's 
> > > going
> > > -* or what's really needed.  It appears that fast clear ops are not
> > > -* properly synchronized with other drawing.  This means that we 
> > > cannot
> > > -* have a fast clear operation in the pipe at the same time as other
> > > -* regular drawing operations.  We need to use a PIPE_CONTROL to 
> > > ensure
> > > -* that the contents of the previous draw hit the render target 
> > > before we
> > > -* resolve and then use a second PIPE_CONTROL after the resolve to 
> > > ensure
> > > -* that it is completed before any additional drawing occurs.
> > > -*/
> > > -   cmd_buffer->state.pending_pipe_bits |=
> > > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> > > -
> > > -   uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
> > > -   uint32_t width_div = 
> > > image->format->planes[plane].denominator_scales[0];
> > > -   uint32_t height_div = 
> > > image->format->planes[plane].denominator_scales[1];
> > > -
> > > -   for (uint32_t l = 0; l < level_count; l++) {
> > > -  const uint32_t level = base_level + l;
> > > -
> > > -  const VkExtent3D extent = {
> > > - .width = anv_minify(image->extent.width, level),
> > > - .height = anv_minify(image->extent.height, level),
> > > - .depth = anv_minify(image->extent.depth, level),
> > > -  };
> > > -
> > > -  if (image->type == VK_IMAGE_TYPE_3D)
> > > - layer_count = extent.depth;
> > > -
> > > -  assert(level < anv_image_aux_levels(image, aspect));
> > > -  assert(base_layer + layer_count <= anv_image_aux_layers(image, 
> > > aspect, level));
> > > -  blorp_fast_clear(, , surf.surf->format,
> > > -   level, base_layer, layer_count,
> > > -   0, 0,
> > > -   extent.width / width_div,
> > > -   extent.height / height_div);
> > > -   }
> > > -
> > > -   cmd_buffer->state.pending_pipe_bits |=
> > > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> > > -}
> > > -
> > > -void
> > >  anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer)
> > >  {
> > > struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
> > > @@ -1681,36 +1612,153 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer 
> > > *cmd_buffer,
> > >  }
> > >  
> > >  void
> > > -anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
> > > -const struct anv_image * const image,
> > > -VkImageAspectFlagBits aspect,
> > > -const 

Re: [Mesa-dev] [PATCH 02/29] anv/blorp: Rework image clear/resolve helpers

2017-12-06 Thread Nanley Chery
On Tue, Dec 05, 2017 at 03:48:45PM -0800, Nanley Chery wrote:
> On Mon, Nov 27, 2017 at 07:05:52PM -0800, Jason Ekstrand wrote:
> > This replaces image_fast_clear and ccs_resolve with two new helpers that
> > simply perform an isl_aux_op whatever that may be on CCS or MCS.  This
> > is a bit cleaner as it separates performing the aux operation from which
> > blorp helper we have to call to do it.
> > ---
> >  src/intel/vulkan/anv_blorp.c   | 218 
> > ++---
> >  src/intel/vulkan/anv_private.h |  23 ++--
> >  src/intel/vulkan/genX_cmd_buffer.c |  28 +++--
> >  3 files changed, 165 insertions(+), 104 deletions(-)
> > 
> > diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> > index e244468..7c8a673 100644
> > --- a/src/intel/vulkan/anv_blorp.c
> > +++ b/src/intel/vulkan/anv_blorp.c
> > @@ -1439,75 +1439,6 @@ fast_clear_aux_usage(const struct anv_image *image,
> >  }
> >  
> >  void
> > -anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
> > - const struct anv_image *image,
> > - VkImageAspectFlagBits aspect,
> > - const uint32_t base_level, const uint32_t level_count,
> > - const uint32_t base_layer, uint32_t layer_count)
> > -{
> > -   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
> > -
> > -   if (image->type == VK_IMAGE_TYPE_3D) {
> > -  assert(base_layer == 0);
> > -  assert(layer_count == anv_minify(image->extent.depth, base_level));
> > -   }
> > -
> > -   struct blorp_batch batch;
> > -   blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0);
> > -
> > -   struct blorp_surf surf;
> > -   get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
> > -fast_clear_aux_usage(image, aspect),
> > -);
> > -
> > -   /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> > -*
> > -*"After Render target fast clear, pipe-control with color cache
> > -*write-flush must be issued before sending any DRAW commands on
> > -*that render target."
> > -*
> > -* This comment is a bit cryptic and doesn't really tell you what's 
> > going
> > -* or what's really needed.  It appears that fast clear ops are not
> > -* properly synchronized with other drawing.  This means that we cannot
> > -* have a fast clear operation in the pipe at the same time as other
> > -* regular drawing operations.  We need to use a PIPE_CONTROL to ensure
> > -* that the contents of the previous draw hit the render target before 
> > we
> > -* resolve and then use a second PIPE_CONTROL after the resolve to 
> > ensure
> > -* that it is completed before any additional drawing occurs.
> > -*/
> > -   cmd_buffer->state.pending_pipe_bits |=
> > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> > -
> > -   uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
> > -   uint32_t width_div = image->format->planes[plane].denominator_scales[0];
> > -   uint32_t height_div = 
> > image->format->planes[plane].denominator_scales[1];
> > -
> > -   for (uint32_t l = 0; l < level_count; l++) {
> > -  const uint32_t level = base_level + l;
> > -
> > -  const VkExtent3D extent = {
> > - .width = anv_minify(image->extent.width, level),
> > - .height = anv_minify(image->extent.height, level),
> > - .depth = anv_minify(image->extent.depth, level),
> > -  };
> > -
> > -  if (image->type == VK_IMAGE_TYPE_3D)
> > - layer_count = extent.depth;
> > -
> > -  assert(level < anv_image_aux_levels(image, aspect));
> > -  assert(base_layer + layer_count <= anv_image_aux_layers(image, 
> > aspect, level));
> > -  blorp_fast_clear(, , surf.surf->format,
> > -   level, base_layer, layer_count,
> > -   0, 0,
> > -   extent.width / width_div,
> > -   extent.height / height_div);
> > -   }
> > -
> > -   cmd_buffer->state.pending_pipe_bits |=
> > -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> > -}
> > -
> > -void
> >  anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer)
> >  {
> > struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
> > @@ -1681,36 +1612,153 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer 
> > *cmd_buffer,
> >  }
> >  
> >  void
> > -anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
> > -const struct anv_image * const image,
> > -VkImageAspectFlagBits aspect,
> > -const uint8_t level,
> > -const uint32_t start_layer, const uint32_t layer_count,
> > -const enum blorp_fast_clear_op op)
> > +anv_image_mcs_op(struct anv_cmd_buffer *cmd_buffer,
> > + const struct anv_image *image,
> > + VkImageAspectFlagBits 

Re: [Mesa-dev] [PATCH 02/29] anv/blorp: Rework image clear/resolve helpers

2017-12-05 Thread Nanley Chery
On Mon, Nov 27, 2017 at 07:05:52PM -0800, Jason Ekstrand wrote:
> This replaces image_fast_clear and ccs_resolve with two new helpers that
> simply perform an isl_aux_op whatever that may be on CCS or MCS.  This
> is a bit cleaner as it separates performing the aux operation from which
> blorp helper we have to call to do it.
> ---
>  src/intel/vulkan/anv_blorp.c   | 218 
> ++---
>  src/intel/vulkan/anv_private.h |  23 ++--
>  src/intel/vulkan/genX_cmd_buffer.c |  28 +++--
>  3 files changed, 165 insertions(+), 104 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> index e244468..7c8a673 100644
> --- a/src/intel/vulkan/anv_blorp.c
> +++ b/src/intel/vulkan/anv_blorp.c
> @@ -1439,75 +1439,6 @@ fast_clear_aux_usage(const struct anv_image *image,
>  }
>  
>  void
> -anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
> - const struct anv_image *image,
> - VkImageAspectFlagBits aspect,
> - const uint32_t base_level, const uint32_t level_count,
> - const uint32_t base_layer, uint32_t layer_count)
> -{
> -   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
> -
> -   if (image->type == VK_IMAGE_TYPE_3D) {
> -  assert(base_layer == 0);
> -  assert(layer_count == anv_minify(image->extent.depth, base_level));
> -   }
> -
> -   struct blorp_batch batch;
> -   blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0);
> -
> -   struct blorp_surf surf;
> -   get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
> -fast_clear_aux_usage(image, aspect),
> -);
> -
> -   /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> -*
> -*"After Render target fast clear, pipe-control with color cache
> -*write-flush must be issued before sending any DRAW commands on
> -*that render target."
> -*
> -* This comment is a bit cryptic and doesn't really tell you what's going
> -* or what's really needed.  It appears that fast clear ops are not
> -* properly synchronized with other drawing.  This means that we cannot
> -* have a fast clear operation in the pipe at the same time as other
> -* regular drawing operations.  We need to use a PIPE_CONTROL to ensure
> -* that the contents of the previous draw hit the render target before we
> -* resolve and then use a second PIPE_CONTROL after the resolve to ensure
> -* that it is completed before any additional drawing occurs.
> -*/
> -   cmd_buffer->state.pending_pipe_bits |=
> -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> -
> -   uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
> -   uint32_t width_div = image->format->planes[plane].denominator_scales[0];
> -   uint32_t height_div = image->format->planes[plane].denominator_scales[1];
> -
> -   for (uint32_t l = 0; l < level_count; l++) {
> -  const uint32_t level = base_level + l;
> -
> -  const VkExtent3D extent = {
> - .width = anv_minify(image->extent.width, level),
> - .height = anv_minify(image->extent.height, level),
> - .depth = anv_minify(image->extent.depth, level),
> -  };
> -
> -  if (image->type == VK_IMAGE_TYPE_3D)
> - layer_count = extent.depth;
> -
> -  assert(level < anv_image_aux_levels(image, aspect));
> -  assert(base_layer + layer_count <= anv_image_aux_layers(image, aspect, 
> level));
> -  blorp_fast_clear(, , surf.surf->format,
> -   level, base_layer, layer_count,
> -   0, 0,
> -   extent.width / width_div,
> -   extent.height / height_div);
> -   }
> -
> -   cmd_buffer->state.pending_pipe_bits |=
> -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> -}
> -
> -void
>  anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer)
>  {
> struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
> @@ -1681,36 +1612,153 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer 
> *cmd_buffer,
>  }
>  
>  void
> -anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
> -const struct anv_image * const image,
> -VkImageAspectFlagBits aspect,
> -const uint8_t level,
> -const uint32_t start_layer, const uint32_t layer_count,
> -const enum blorp_fast_clear_op op)
> +anv_image_mcs_op(struct anv_cmd_buffer *cmd_buffer,
> + const struct anv_image *image,
> + VkImageAspectFlagBits aspect,
> + uint32_t base_layer, uint32_t layer_count,
> + enum isl_aux_op mcs_op, bool predicate)
>  {
> -   assert(cmd_buffer && image);
> +   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> +   assert(image->samples > 1);
> +   assert(base_layer + layer_count 

Re: [Mesa-dev] [PATCH 02/29] anv/blorp: Rework image clear/resolve helpers

2017-12-05 Thread Nanley Chery
On Mon, Nov 27, 2017 at 07:05:52PM -0800, Jason Ekstrand wrote:
> This replaces image_fast_clear and ccs_resolve with two new helpers that
> simply perform an isl_aux_op whatever that may be on CCS or MCS.  This
> is a bit cleaner as it separates performing the aux operation from which
> blorp helper we have to call to do it.
> ---
>  src/intel/vulkan/anv_blorp.c   | 218 
> ++---
>  src/intel/vulkan/anv_private.h |  23 ++--
>  src/intel/vulkan/genX_cmd_buffer.c |  28 +++--
>  3 files changed, 165 insertions(+), 104 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> index e244468..7c8a673 100644
> --- a/src/intel/vulkan/anv_blorp.c
> +++ b/src/intel/vulkan/anv_blorp.c
> @@ -1439,75 +1439,6 @@ fast_clear_aux_usage(const struct anv_image *image,
>  }
>  
>  void
> -anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer,
> - const struct anv_image *image,
> - VkImageAspectFlagBits aspect,
> - const uint32_t base_level, const uint32_t level_count,
> - const uint32_t base_layer, uint32_t layer_count)
> -{
> -   assert(image->type == VK_IMAGE_TYPE_3D || image->extent.depth == 1);
> -
> -   if (image->type == VK_IMAGE_TYPE_3D) {
> -  assert(base_layer == 0);
> -  assert(layer_count == anv_minify(image->extent.depth, base_level));
> -   }
> -
> -   struct blorp_batch batch;
> -   blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0);
> -
> -   struct blorp_surf surf;
> -   get_blorp_surf_for_anv_image(cmd_buffer->device, image, aspect,
> -fast_clear_aux_usage(image, aspect),
> -);
> -
> -   /* From the Sky Lake PRM Vol. 7, "Render Target Fast Clear":
> -*
> -*"After Render target fast clear, pipe-control with color cache
> -*write-flush must be issued before sending any DRAW commands on
> -*that render target."
> -*
> -* This comment is a bit cryptic and doesn't really tell you what's going
> -* or what's really needed.  It appears that fast clear ops are not
> -* properly synchronized with other drawing.  This means that we cannot
> -* have a fast clear operation in the pipe at the same time as other
> -* regular drawing operations.  We need to use a PIPE_CONTROL to ensure
> -* that the contents of the previous draw hit the render target before we
> -* resolve and then use a second PIPE_CONTROL after the resolve to ensure
> -* that it is completed before any additional drawing occurs.
> -*/
> -   cmd_buffer->state.pending_pipe_bits |=
> -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> -
> -   uint32_t plane = anv_image_aspect_to_plane(image->aspects, aspect);
> -   uint32_t width_div = image->format->planes[plane].denominator_scales[0];
> -   uint32_t height_div = image->format->planes[plane].denominator_scales[1];
> -
> -   for (uint32_t l = 0; l < level_count; l++) {
> -  const uint32_t level = base_level + l;
> -
> -  const VkExtent3D extent = {
> - .width = anv_minify(image->extent.width, level),
> - .height = anv_minify(image->extent.height, level),
> - .depth = anv_minify(image->extent.depth, level),
> -  };
> -
> -  if (image->type == VK_IMAGE_TYPE_3D)
> - layer_count = extent.depth;
> -
> -  assert(level < anv_image_aux_levels(image, aspect));
> -  assert(base_layer + layer_count <= anv_image_aux_layers(image, aspect, 
> level));
> -  blorp_fast_clear(, , surf.surf->format,
> -   level, base_layer, layer_count,
> -   0, 0,
> -   extent.width / width_div,
> -   extent.height / height_div);
> -   }
> -
> -   cmd_buffer->state.pending_pipe_bits |=
> -  ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
> -}
> -
> -void
>  anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer)
>  {
> struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
> @@ -1681,36 +1612,153 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer 
> *cmd_buffer,
>  }
>  
>  void
> -anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer,
> -const struct anv_image * const image,
> -VkImageAspectFlagBits aspect,
> -const uint8_t level,
> -const uint32_t start_layer, const uint32_t layer_count,
> -const enum blorp_fast_clear_op op)
> +anv_image_mcs_op(struct anv_cmd_buffer *cmd_buffer,
> + const struct anv_image *image,
> + VkImageAspectFlagBits aspect,
> + uint32_t base_layer, uint32_t layer_count,
> + enum isl_aux_op mcs_op, bool predicate)
>  {
> -   assert(cmd_buffer && image);
> +   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> +   assert(image->samples > 1);
> +   assert(base_layer + layer_count