Re: [Mesa-dev] [PATCH 4/6] anv/blorp: Refactor MSAA resolves into an exportable helper function
On Fri, 2019-01-11 at 12:20 -0600, Jason Ekstrand wrote: > On Fri, Jan 11, 2019 at 2:19 AM Iago Toral wrote: > > On Mon, 2019-01-07 at 09:39 -0600, Jason Ekstrand wrote: > > > > > This function is modeled after the aux_op functions except that > > it > > > > > has a > > > > > lot more parameters because it deals with two images as well as > > > > > source > > > > > and destination regions. > > > > > --- > > > > > src/intel/vulkan/anv_blorp.c | 225 ++- > > > > > > > -- > > > > > src/intel/vulkan/anv_private.h | 14 ++ > > > > > 2 files changed, 107 insertions(+), 132 deletions(-) > > > > > > > > > > diff --git a/src/intel/vulkan/anv_blorp.c > > > > > b/src/intel/vulkan/anv_blorp.c > > > > > index eee7a8c3b3c..2f8d502e289 100644 > > > > > --- a/src/intel/vulkan/anv_blorp.c > > > > > +++ b/src/intel/vulkan/anv_blorp.c > > > > > @@ -1169,63 +1169,52 @@ enum subpass_stage { > > > > > SUBPASS_STAGE_RESOLVE, > > > > > }; > > > > > > > > > > -static void > > > > > -resolve_surface(struct blorp_batch *batch, > > > > > -struct blorp_surf *src_surf, > > > > > -uint32_t src_level, uint32_t src_layer, > > > > > -struct blorp_surf *dst_surf, > > > > > -uint32_t dst_level, uint32_t dst_layer, > > > > > -uint32_t src_x, uint32_t src_y, uint32_t dst_x, > > > > > uint32_t dst_y, > > > > > -uint32_t width, uint32_t height, > > > > > -enum blorp_filter filter) > > > > > -{ > > > > > - blorp_blit(batch, > > > > > - src_surf, src_level, src_layer, > > > > > - ISL_FORMAT_UNSUPPORTED, ISL_SWIZZLE_IDENTITY, > > > > > - dst_surf, dst_level, dst_layer, > > > > > - ISL_FORMAT_UNSUPPORTED, ISL_SWIZZLE_IDENTITY, > > > > > - src_x, src_y, src_x + width, src_y + height, > > > > > - dst_x, dst_y, dst_x + width, dst_y + height, > > > > > - filter, false, false); > > > > > -} > > > > > - > > > > > -static void > > > > > -resolve_image(struct anv_device *device, > > > > > - struct blorp_batch *batch, > > > > > - const struct anv_image *src_image, > > > > > - VkImageLayout src_image_layout, > > > > > - uint32_t src_level, uint32_t src_layer, > > > > > - const struct anv_image *dst_image, > > > > > - VkImageLayout dst_image_layout, > > > > > - uint32_t dst_level, uint32_t dst_layer, > > > > > - VkImageAspectFlags aspect_mask, > > > > > - uint32_t src_x, uint32_t src_y, uint32_t dst_x, > > > > > uint32_t dst_y, > > > > > - uint32_t width, uint32_t height) > > > > > +void > > > > > +anv_image_msaa_resolve(struct anv_cmd_buffer *cmd_buffer, > > > > > + const struct anv_image *src_image, > > > > > + enum isl_aux_usage src_aux_usage, > > > > > + uint32_t src_level, uint32_t > > src_base_layer, > > > > > + const struct anv_image *dst_image, > > > > > + enum isl_aux_usage dst_aux_usage, > > > > > + uint32_t dst_level, uint32_t > > dst_base_layer, > > > > > + VkImageAspectFlagBits aspect, > > > > > + uint32_t src_x, uint32_t src_y, > > > > > + uint32_t dst_x, uint32_t dst_y, > > > > > + uint32_t width, uint32_t height, > > > > > + uint32_t layer_count, > > > > > + enum blorp_filter filter) > > > > > { > > > > > - struct anv_cmd_buffer *cmd_buffer = batch->driver_batch; > > > > > + struct blorp_batch batch; > > > > > + blorp_batch_init(_buffer->device->blorp, , > > cmd_buffer, > > > > > 0); > > > > > > > > > > assert(src_image->type == VK_IMAGE_TYPE_2D); > > > > > assert(src_image->samples > 1); > > > > > assert(dst_image->type == VK_IMAGE_TYPE_2D); > > > > > assert(dst_image->samples == 1); > > > > > assert(src_image->n_planes == dst_image->n_planes); > > > > > + assert(!src_image->format->can_ycbcr); > > > > > + assert(!dst_image->format->can_ycbcr); > > > > > > > > > > - uint32_t aspect_bit; > > > > > - > > > > > - anv_foreach_image_aspect_bit(aspect_bit, src_image, > > aspect_mask) > > > > > { > > > > > - struct blorp_surf src_surf, dst_surf; > > > > > - get_blorp_surf_for_anv_image(device, src_image, 1UL << > > > > > aspect_bit, > > > > > - src_image_layout, > > > > > ISL_AUX_USAGE_NONE, > > > > > - _surf); > > > > > - get_blorp_surf_for_anv_image(device, dst_image, 1UL << > > > > > aspect_bit, > > > > > - dst_image_layout, > > > > > ISL_AUX_USAGE_NONE, > > > > > -
Re: [Mesa-dev] [PATCH 4/6] anv/blorp: Refactor MSAA resolves into an exportable helper function
On Fri, Jan 11, 2019 at 2:19 AM Iago Toral wrote: > On Mon, 2019-01-07 at 09:39 -0600, Jason Ekstrand wrote: > > This function is modeled after the aux_op functions except that it > > has a > > lot more parameters because it deals with two images as well as > > source > > and destination regions. > > --- > > src/intel/vulkan/anv_blorp.c | 225 ++- > > -- > > src/intel/vulkan/anv_private.h | 14 ++ > > 2 files changed, 107 insertions(+), 132 deletions(-) > > > > diff --git a/src/intel/vulkan/anv_blorp.c > > b/src/intel/vulkan/anv_blorp.c > > index eee7a8c3b3c..2f8d502e289 100644 > > --- a/src/intel/vulkan/anv_blorp.c > > +++ b/src/intel/vulkan/anv_blorp.c > > @@ -1169,63 +1169,52 @@ enum subpass_stage { > > SUBPASS_STAGE_RESOLVE, > > }; > > > > -static void > > -resolve_surface(struct blorp_batch *batch, > > -struct blorp_surf *src_surf, > > -uint32_t src_level, uint32_t src_layer, > > -struct blorp_surf *dst_surf, > > -uint32_t dst_level, uint32_t dst_layer, > > -uint32_t src_x, uint32_t src_y, uint32_t dst_x, > > uint32_t dst_y, > > -uint32_t width, uint32_t height, > > -enum blorp_filter filter) > > -{ > > - blorp_blit(batch, > > - src_surf, src_level, src_layer, > > - ISL_FORMAT_UNSUPPORTED, ISL_SWIZZLE_IDENTITY, > > - dst_surf, dst_level, dst_layer, > > - ISL_FORMAT_UNSUPPORTED, ISL_SWIZZLE_IDENTITY, > > - src_x, src_y, src_x + width, src_y + height, > > - dst_x, dst_y, dst_x + width, dst_y + height, > > - filter, false, false); > > -} > > - > > -static void > > -resolve_image(struct anv_device *device, > > - struct blorp_batch *batch, > > - const struct anv_image *src_image, > > - VkImageLayout src_image_layout, > > - uint32_t src_level, uint32_t src_layer, > > - const struct anv_image *dst_image, > > - VkImageLayout dst_image_layout, > > - uint32_t dst_level, uint32_t dst_layer, > > - VkImageAspectFlags aspect_mask, > > - uint32_t src_x, uint32_t src_y, uint32_t dst_x, > > uint32_t dst_y, > > - uint32_t width, uint32_t height) > > +void > > +anv_image_msaa_resolve(struct anv_cmd_buffer *cmd_buffer, > > + const struct anv_image *src_image, > > + enum isl_aux_usage src_aux_usage, > > + uint32_t src_level, uint32_t src_base_layer, > > + const struct anv_image *dst_image, > > + enum isl_aux_usage dst_aux_usage, > > + uint32_t dst_level, uint32_t dst_base_layer, > > + VkImageAspectFlagBits aspect, > > + uint32_t src_x, uint32_t src_y, > > + uint32_t dst_x, uint32_t dst_y, > > + uint32_t width, uint32_t height, > > + uint32_t layer_count, > > + enum blorp_filter filter) > > { > > - struct anv_cmd_buffer *cmd_buffer = batch->driver_batch; > > + struct blorp_batch batch; > > + blorp_batch_init(_buffer->device->blorp, , cmd_buffer, > > 0); > > > > assert(src_image->type == VK_IMAGE_TYPE_2D); > > assert(src_image->samples > 1); > > assert(dst_image->type == VK_IMAGE_TYPE_2D); > > assert(dst_image->samples == 1); > > assert(src_image->n_planes == dst_image->n_planes); > > + assert(!src_image->format->can_ycbcr); > > + assert(!dst_image->format->can_ycbcr); > > > > - uint32_t aspect_bit; > > - > > - anv_foreach_image_aspect_bit(aspect_bit, src_image, aspect_mask) > > { > > - struct blorp_surf src_surf, dst_surf; > > - get_blorp_surf_for_anv_image(device, src_image, 1UL << > > aspect_bit, > > - src_image_layout, > > ISL_AUX_USAGE_NONE, > > - _surf); > > - get_blorp_surf_for_anv_image(device, dst_image, 1UL << > > aspect_bit, > > - dst_image_layout, > > ISL_AUX_USAGE_NONE, > > - _surf); > > - anv_cmd_buffer_mark_image_written(cmd_buffer, dst_image, > > -1UL << aspect_bit, > > -dst_surf.aux_usage, > > -dst_level, dst_layer, 1); > > - > > - enum blorp_filter filter; > > + struct blorp_surf src_surf, dst_surf; > > + get_blorp_surf_for_anv_image(cmd_buffer->device, src_image, > > aspect, > > +ANV_IMAGE_LAYOUT_EXPLICIT_AUX, > > +src_aux_usage, _surf); > > + if (src_aux_usage == ISL_AUX_USAGE_MCS) { > > + src_surf.clear_color_addr = anv_to_blorp_address( > > +
Re: [Mesa-dev] [PATCH 4/6] anv/blorp: Refactor MSAA resolves into an exportable helper function
On Mon, 2019-01-07 at 09:39 -0600, Jason Ekstrand wrote: > This function is modeled after the aux_op functions except that it > has a > lot more parameters because it deals with two images as well as > source > and destination regions. > --- > src/intel/vulkan/anv_blorp.c | 225 ++- > -- > src/intel/vulkan/anv_private.h | 14 ++ > 2 files changed, 107 insertions(+), 132 deletions(-) > > diff --git a/src/intel/vulkan/anv_blorp.c > b/src/intel/vulkan/anv_blorp.c > index eee7a8c3b3c..2f8d502e289 100644 > --- a/src/intel/vulkan/anv_blorp.c > +++ b/src/intel/vulkan/anv_blorp.c > @@ -1169,63 +1169,52 @@ enum subpass_stage { > SUBPASS_STAGE_RESOLVE, > }; > > -static void > -resolve_surface(struct blorp_batch *batch, > -struct blorp_surf *src_surf, > -uint32_t src_level, uint32_t src_layer, > -struct blorp_surf *dst_surf, > -uint32_t dst_level, uint32_t dst_layer, > -uint32_t src_x, uint32_t src_y, uint32_t dst_x, > uint32_t dst_y, > -uint32_t width, uint32_t height, > -enum blorp_filter filter) > -{ > - blorp_blit(batch, > - src_surf, src_level, src_layer, > - ISL_FORMAT_UNSUPPORTED, ISL_SWIZZLE_IDENTITY, > - dst_surf, dst_level, dst_layer, > - ISL_FORMAT_UNSUPPORTED, ISL_SWIZZLE_IDENTITY, > - src_x, src_y, src_x + width, src_y + height, > - dst_x, dst_y, dst_x + width, dst_y + height, > - filter, false, false); > -} > - > -static void > -resolve_image(struct anv_device *device, > - struct blorp_batch *batch, > - const struct anv_image *src_image, > - VkImageLayout src_image_layout, > - uint32_t src_level, uint32_t src_layer, > - const struct anv_image *dst_image, > - VkImageLayout dst_image_layout, > - uint32_t dst_level, uint32_t dst_layer, > - VkImageAspectFlags aspect_mask, > - uint32_t src_x, uint32_t src_y, uint32_t dst_x, > uint32_t dst_y, > - uint32_t width, uint32_t height) > +void > +anv_image_msaa_resolve(struct anv_cmd_buffer *cmd_buffer, > + const struct anv_image *src_image, > + enum isl_aux_usage src_aux_usage, > + uint32_t src_level, uint32_t src_base_layer, > + const struct anv_image *dst_image, > + enum isl_aux_usage dst_aux_usage, > + uint32_t dst_level, uint32_t dst_base_layer, > + VkImageAspectFlagBits aspect, > + uint32_t src_x, uint32_t src_y, > + uint32_t dst_x, uint32_t dst_y, > + uint32_t width, uint32_t height, > + uint32_t layer_count, > + enum blorp_filter filter) > { > - struct anv_cmd_buffer *cmd_buffer = batch->driver_batch; > + struct blorp_batch batch; > + blorp_batch_init(_buffer->device->blorp, , cmd_buffer, > 0); > > assert(src_image->type == VK_IMAGE_TYPE_2D); > assert(src_image->samples > 1); > assert(dst_image->type == VK_IMAGE_TYPE_2D); > assert(dst_image->samples == 1); > assert(src_image->n_planes == dst_image->n_planes); > + assert(!src_image->format->can_ycbcr); > + assert(!dst_image->format->can_ycbcr); > > - uint32_t aspect_bit; > - > - anv_foreach_image_aspect_bit(aspect_bit, src_image, aspect_mask) > { > - struct blorp_surf src_surf, dst_surf; > - get_blorp_surf_for_anv_image(device, src_image, 1UL << > aspect_bit, > - src_image_layout, > ISL_AUX_USAGE_NONE, > - _surf); > - get_blorp_surf_for_anv_image(device, dst_image, 1UL << > aspect_bit, > - dst_image_layout, > ISL_AUX_USAGE_NONE, > - _surf); > - anv_cmd_buffer_mark_image_written(cmd_buffer, dst_image, > -1UL << aspect_bit, > -dst_surf.aux_usage, > -dst_level, dst_layer, 1); > - > - enum blorp_filter filter; > + struct blorp_surf src_surf, dst_surf; > + get_blorp_surf_for_anv_image(cmd_buffer->device, src_image, > aspect, > +ANV_IMAGE_LAYOUT_EXPLICIT_AUX, > +src_aux_usage, _surf); > + if (src_aux_usage == ISL_AUX_USAGE_MCS) { > + src_surf.clear_color_addr = anv_to_blorp_address( > + anv_image_get_clear_color_addr(cmd_buffer->device, > src_image, > +VK_IMAGE_ASPECT_COLOR_BIT)); > + } > + get_blorp_surf_for_anv_image(cmd_buffer->device, dst_image, > aspect, > +ANV_IMAGE_LAYOUT_EXPLICIT_AUX, > +
[Mesa-dev] [PATCH 4/6] anv/blorp: Refactor MSAA resolves into an exportable helper function
This function is modeled after the aux_op functions except that it has a lot more parameters because it deals with two images as well as source and destination regions. --- src/intel/vulkan/anv_blorp.c | 225 ++--- src/intel/vulkan/anv_private.h | 14 ++ 2 files changed, 107 insertions(+), 132 deletions(-) diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c index eee7a8c3b3c..2f8d502e289 100644 --- a/src/intel/vulkan/anv_blorp.c +++ b/src/intel/vulkan/anv_blorp.c @@ -1169,63 +1169,52 @@ enum subpass_stage { SUBPASS_STAGE_RESOLVE, }; -static void -resolve_surface(struct blorp_batch *batch, -struct blorp_surf *src_surf, -uint32_t src_level, uint32_t src_layer, -struct blorp_surf *dst_surf, -uint32_t dst_level, uint32_t dst_layer, -uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, -uint32_t width, uint32_t height, -enum blorp_filter filter) -{ - blorp_blit(batch, - src_surf, src_level, src_layer, - ISL_FORMAT_UNSUPPORTED, ISL_SWIZZLE_IDENTITY, - dst_surf, dst_level, dst_layer, - ISL_FORMAT_UNSUPPORTED, ISL_SWIZZLE_IDENTITY, - src_x, src_y, src_x + width, src_y + height, - dst_x, dst_y, dst_x + width, dst_y + height, - filter, false, false); -} - -static void -resolve_image(struct anv_device *device, - struct blorp_batch *batch, - const struct anv_image *src_image, - VkImageLayout src_image_layout, - uint32_t src_level, uint32_t src_layer, - const struct anv_image *dst_image, - VkImageLayout dst_image_layout, - uint32_t dst_level, uint32_t dst_layer, - VkImageAspectFlags aspect_mask, - uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, - uint32_t width, uint32_t height) +void +anv_image_msaa_resolve(struct anv_cmd_buffer *cmd_buffer, + const struct anv_image *src_image, + enum isl_aux_usage src_aux_usage, + uint32_t src_level, uint32_t src_base_layer, + const struct anv_image *dst_image, + enum isl_aux_usage dst_aux_usage, + uint32_t dst_level, uint32_t dst_base_layer, + VkImageAspectFlagBits aspect, + uint32_t src_x, uint32_t src_y, + uint32_t dst_x, uint32_t dst_y, + uint32_t width, uint32_t height, + uint32_t layer_count, + enum blorp_filter filter) { - struct anv_cmd_buffer *cmd_buffer = batch->driver_batch; + struct blorp_batch batch; + blorp_batch_init(_buffer->device->blorp, , cmd_buffer, 0); assert(src_image->type == VK_IMAGE_TYPE_2D); assert(src_image->samples > 1); assert(dst_image->type == VK_IMAGE_TYPE_2D); assert(dst_image->samples == 1); assert(src_image->n_planes == dst_image->n_planes); + assert(!src_image->format->can_ycbcr); + assert(!dst_image->format->can_ycbcr); - uint32_t aspect_bit; - - anv_foreach_image_aspect_bit(aspect_bit, src_image, aspect_mask) { - struct blorp_surf src_surf, dst_surf; - get_blorp_surf_for_anv_image(device, src_image, 1UL << aspect_bit, - src_image_layout, ISL_AUX_USAGE_NONE, - _surf); - get_blorp_surf_for_anv_image(device, dst_image, 1UL << aspect_bit, - dst_image_layout, ISL_AUX_USAGE_NONE, - _surf); - anv_cmd_buffer_mark_image_written(cmd_buffer, dst_image, -1UL << aspect_bit, -dst_surf.aux_usage, -dst_level, dst_layer, 1); - - enum blorp_filter filter; + struct blorp_surf src_surf, dst_surf; + get_blorp_surf_for_anv_image(cmd_buffer->device, src_image, aspect, +ANV_IMAGE_LAYOUT_EXPLICIT_AUX, +src_aux_usage, _surf); + if (src_aux_usage == ISL_AUX_USAGE_MCS) { + src_surf.clear_color_addr = anv_to_blorp_address( + anv_image_get_clear_color_addr(cmd_buffer->device, src_image, +VK_IMAGE_ASPECT_COLOR_BIT)); + } + get_blorp_surf_for_anv_image(cmd_buffer->device, dst_image, aspect, +ANV_IMAGE_LAYOUT_EXPLICIT_AUX, +dst_aux_usage, _surf); + anv_cmd_buffer_mark_image_written(cmd_buffer, dst_image, + aspect, dst_aux_usage, + dst_level, dst_base_layer, layer_count); + + if (filter == BLORP_FILTER_NONE) { + /* If no