[Mesa-dev] [PATCH 08/13] anv: Adjust params of color buffer transitioning functions
Jason Ekstrand
jason at jlekstrand.net
Mon Jun 19 23:33:29 UTC 2017
On Tue, Jun 13, 2017 at 11:41 AM, Nanley Chery <nanleychery at gmail.com>
wrote:
> Splitting out these fields will make the color buffer transitioning
> function simpler when it gains more features.
>
> Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
> ---
> src/intel/vulkan/anv_blorp.c | 33 ++++++++++++--------------------
> src/intel/vulkan/anv_private.h | 4 ++--
> src/intel/vulkan/genX_cmd_buffer.c | 39 +++++++++++++++++++++++++-----
> --------
> 3 files changed, 40 insertions(+), 36 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
> index ff3d7b126f..2d970ac3a7 100644
> --- a/src/intel/vulkan/anv_blorp.c
> +++ b/src/intel/vulkan/anv_blorp.c
> @@ -1433,12 +1433,17 @@ void anv_CmdResolveImage(
> void
> anv_image_ccs_clear(struct anv_cmd_buffer *cmd_buffer,
> const struct anv_image *image,
> - const struct isl_view *view,
> - const VkImageSubresourceRange *subresourceRange)
> + const uint32_t base_level, const uint32_t level_count,
> + const uint32_t base_layer, uint32_t layer_count)
> {
> assert(anv_image_has_color_aux(image) && image->samples == 1);
> 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(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0);
>
> @@ -1464,11 +1469,8 @@ anv_image_ccs_clear(struct anv_cmd_buffer
> *cmd_buffer,
> cmd_buffer->state.pending_pipe_bits |=
> ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT | ANV_PIPE_CS_STALL_BIT;
>
> - const uint32_t level_count =
> - view ? view->levels : anv_get_levelCount(image, subresourceRange);
> for (uint32_t l = 0; l < level_count; l++) {
> - const uint32_t level =
> - (view ? view->base_level : subresourceRange->baseMipLevel) + l;
> + const uint32_t level = base_level + l;
>
> const VkExtent3D extent = {
> .width = anv_minify(image->extent.width, level),
> @@ -1476,24 +1478,13 @@ anv_image_ccs_clear(struct anv_cmd_buffer
> *cmd_buffer,
> .depth = anv_minify(image->extent.depth, level),
> };
>
> - /* Blorp likes to treat 2D_ARRAY and 3D the same. */
> - uint32_t blorp_base_layer, blorp_layer_count;
> - if (image->type == VK_IMAGE_TYPE_3D) {
> - blorp_base_layer = 0;
> - blorp_layer_count = extent.depth;
> - } else if (view) {
> - blorp_base_layer = view->base_array_layer;
> - blorp_layer_count = view->array_len;
> - } else {
> - blorp_base_layer = subresourceRange->baseArrayLayer;
> - blorp_layer_count = anv_get_layerCount(image, subresourceRange);
> - }
> + if (image->type == VK_IMAGE_TYPE_3D)
> + layer_count = extent.depth;
>
Don't you need to minify here? Also, given the assert above, is it needed
at all?
>
> assert(level < anv_color_aux_levels(image));
> - assert(blorp_base_layer + blorp_layer_count <=
> - anv_color_aux_layers(image, level));
> + assert(base_layer + layer_count <= anv_color_aux_layers(image,
> level));
> blorp_fast_clear(&batch, &surf, surf.surf->format,
> - level, blorp_base_layer, blorp_layer_count,
> + level, base_layer, layer_count,
> 0, 0, extent.width, extent.height);
> }
>
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_
> private.h
> index 32aec7782b..5401c09f02 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -2130,8 +2130,8 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer
> *cmd_buffer,
> void
> anv_image_ccs_clear(struct anv_cmd_buffer *cmd_buffer,
> const struct anv_image *image,
> - const struct isl_view *view,
> - const VkImageSubresourceRange *subresourceRange);
> + const uint32_t base_level, const uint32_t level_count,
> + const uint32_t base_layer, uint32_t layer_count);
>
> enum isl_aux_usage
> anv_layout_to_aux_usage(const struct gen_device_info * const devinfo,
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> b/src/intel/vulkan/genX_cmd_buffer.c
> index 1027b64cb7..c8c7f8fbd6 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -384,10 +384,10 @@ transition_depth_buffer(struct anv_cmd_buffer
> *cmd_buffer,
> static void
> transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
> const struct anv_image *image,
> + const uint32_t base_level, uint32_t level_count,
> + uint32_t base_layer, uint32_t layer_count,
> VkImageLayout initial_layout,
> - VkImageLayout final_layout,
> - const struct isl_view *view,
> - const VkImageSubresourceRange *subresourceRange)
> + VkImageLayout final_layout)
> {
> if (image->aux_usage != ISL_AUX_USAGE_CCS_E)
> return;
> @@ -396,13 +396,20 @@ transition_color_buffer(struct anv_cmd_buffer
> *cmd_buffer,
> initial_layout != VK_IMAGE_LAYOUT_PREINITIALIZED)
> return;
>
> + /* A transition of a 3D subresource works on all slices at a time. */
> + if (image->type == VK_IMAGE_TYPE_3D) {
> + base_layer = 0;
> + layer_count = anv_minify(image->extent.depth, base_level);
> + }
> +
> #if GEN_GEN >= 9
> /* 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.
> */
> - anv_image_ccs_clear(cmd_buffer, image, view, subresourceRange);
> + anv_image_ccs_clear(cmd_buffer, image, base_level, level_count,
> + base_layer, layer_count);
> #endif
> }
>
> @@ -987,18 +994,21 @@ void genX(CmdPipelineBarrier)(
> src_flags |= pImageMemoryBarriers[i].srcAccessMask;
> dst_flags |= pImageMemoryBarriers[i].dstAccessMask;
> ANV_FROM_HANDLE(anv_image, image, pImageMemoryBarriers[i].image);
> - if (pImageMemoryBarriers[i].subresourceRange.aspectMask &
> - VK_IMAGE_ASPECT_DEPTH_BIT) {
> + const VkImageSubresourceRange *range =
> + &pImageMemoryBarriers[i].subresourceRange;
> +
> + if (range->aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) {
> transition_depth_buffer(cmd_buffer, image,
> pImageMemoryBarriers[i].oldLayout,
> pImageMemoryBarriers[i].newLayout);
> - } else if (pImageMemoryBarriers[i].subresourceRange.aspectMask ==
> - VK_IMAGE_ASPECT_COLOR_BIT) {
> + } else if (range->aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) {
> transition_color_buffer(cmd_buffer, image,
> + range->baseMipLevel,
> + anv_get_levelCount(image, range),
> + range->baseArrayLayer,
> + anv_get_layerCount(image, range),
> pImageMemoryBarriers[i].oldLayout,
> - pImageMemoryBarriers[i].newLayout,
> - NULL,
> - &pImageMemoryBarriers[i].
> subresourceRange);
> + pImageMemoryBarriers[i].newLayout);
> }
> }
>
> @@ -2485,10 +2495,13 @@ cmd_buffer_subpass_transition_layouts(struct
> anv_cmd_buffer * const cmd_buffer,
> image->aspects, target_layout);
> } else if (image->aspects == VK_IMAGE_ASPECT_COLOR_BIT) {
> transition_color_buffer(cmd_buffer, image,
> - att_state->current_layout, target_layout,
> - &iview->isl, NULL);
> + iview->isl.base_level, 1,
> + iview->isl.base_array_layer,
> + iview->isl.array_len,
> + att_state->current_layout,
> target_layout);
> }
>
> +
> att_state->current_layout = target_layout;
> }
> }
> --
> 2.13.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170619/3d3d7ea3/attachment.html>
More information about the mesa-dev
mailing list