<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Sep 9, 2016 at 2:35 PM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Aug 31, 2016 at 02:22:48PM -0700, Jason Ekstrand wrote:<br>
> ---<br>
> src/intel/vulkan/anv_blorp.c | 67 +++++++++++++++++<br>
> src/intel/vulkan/anv_meta_<wbr>copy.c | 158 ------------------------------<wbr>---------<br>
> 2 files changed, 67 insertions(+), 158 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c<br>
> index 5fa6699..89ff3b3 100644<br>
> --- a/src/intel/vulkan/anv_blorp.c<br>
> +++ b/src/intel/vulkan/anv_blorp.c<br>
> @@ -168,6 +168,73 @@ get_blorp_surf_for_anv_image(<wbr>const struct anv_image *image,<br>
> };<br>
> }<br>
><br>
> +void anv_CmdCopyImage(<br>
> + VkCommandBuffer commandBuffer,<br>
> + VkImage srcImage,<br>
> + VkImageLayout srcImageLayout,<br>
> + VkImage dstImage,<br>
> + VkImageLayout dstImageLayout,<br>
> + uint32_t regionCount,<br>
> + const VkImageCopy* pRegions)<br>
> +{<br>
> + ANV_FROM_HANDLE(anv_cmd_<wbr>buffer, cmd_buffer, commandBuffer);<br>
> + ANV_FROM_HANDLE(anv_image, src_image, srcImage);<br>
> + ANV_FROM_HANDLE(anv_image, dst_image, dstImage);<br>
> +<br>
> + struct blorp_batch batch;<br>
> + blorp_batch_init(&cmd_buffer-><wbr>device->blorp, &batch, cmd_buffer);<br>
> +<br>
> + for (unsigned r = 0; r < regionCount; r++) {<br>
> + VkOffset3D srcOffset =<br>
> + anv_sanitize_image_offset(src_<wbr>image->type, pRegions[r].srcOffset);<br>
> + VkOffset3D dstOffset =<br>
> + anv_sanitize_image_offset(src_<wbr>image->type, pRegions[r].dstOffset);<br>
> + VkExtent3D extent =<br>
> + anv_sanitize_image_extent(src_<wbr>image->type, pRegions[r].extent);<br>
> +<br>
> + unsigned dst_base_layer, layer_count;<br>
> + if (dst_image->type == VK_IMAGE_TYPE_3D) {<br>
> + dst_base_layer = dstOffset.z;<br>
> + layer_count = extent.depth;<br>
<br>
</div></div>In the patch titled, "anv/blorp: Use the correct coordinates in CmdCopyImage,"<br>
you replace extent.depth with pRegions[r].extent.depth. I think it also makes<br>
sense to change the assignment of src_base_layer and dest_base_layer with the<br>
offsets straight from user when we know the image type is VK_IMAGE_TYPE_3D.<br>
When the type is 3D, the sanitize functions do nothing.<br></blockquote><div><br></div><div>Sounds reasonable.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
With or without that change, and assuming the fixup patch is amended,<br>
this patch is,<br>
<br>
Reviewed-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
</blockquote><div> <br></div><div>Thanks!<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> + } else {<br>
> + dst_base_layer = pRegions[r].dstSubresource.<wbr>baseArrayLayer;<br>
> + layer_count = pRegions[r].dstSubresource.<wbr>layerCount;<br>
> + }<br>
> +<br>
> + unsigned src_base_layer;<br>
> + if (src_image->type == VK_IMAGE_TYPE_3D) {<br>
> + src_base_layer = srcOffset.z;<br>
> + } else {<br>
> + src_base_layer = pRegions[r].srcSubresource.<wbr>baseArrayLayer;<br>
> + assert(pRegions[r].<wbr>srcSubresource.layerCount == layer_count);<br>
> + }<br>
> +<br>
> + assert(pRegions[r].<wbr>srcSubresource.aspectMask ==<br>
> + pRegions[r].dstSubresource.<wbr>aspectMask);<br>
> +<br>
> + uint32_t a;<br>
> + for_each_bit(a, pRegions[r].dstSubresource.<wbr>aspectMask) {<br>
> + VkImageAspectFlagBits aspect = (1 << a);<br>
> +<br>
> + struct blorp_surf src_surf, dst_surf;<br>
> + get_blorp_surf_for_anv_image(<wbr>src_image, aspect, &src_surf);<br>
> + get_blorp_surf_for_anv_image(<wbr>dst_image, aspect, &dst_surf);<br>
> +<br>
> + for (unsigned i = 0; i < layer_count; i++) {<br>
> + blorp_copy(&batch, &src_surf, pRegions[r].srcSubresource.<wbr>mipLevel,<br>
> + src_base_layer + i,<br>
> + &dst_surf, pRegions[r].dstSubresource.<wbr>mipLevel,<br>
> + dst_base_layer + i,<br>
> + srcOffset.x, srcOffset.y,<br>
> + dstOffset.x, dstOffset.y,<br>
> + extent.width, extent.height);<br>
> + }<br>
> + }<br>
> + }<br>
> +<br>
> + blorp_batch_finish(&batch);<br>
> +}<br>
> +<br>
> static void<br>
> copy_buffer_to_image(struct anv_cmd_buffer *cmd_buffer,<br>
> struct anv_buffer *anv_buffer,<br>
> diff --git a/src/intel/vulkan/anv_meta_<wbr>copy.c b/src/intel/vulkan/anv_meta_<wbr>copy.c<br>
> index 5df04e6..b33273e 100644<br>
> --- a/src/intel/vulkan/anv_meta_<wbr>copy.c<br>
> +++ b/src/intel/vulkan/anv_meta_<wbr>copy.c<br>
> @@ -23,63 +23,6 @@<br>
><br>
> #include "anv_meta.h"<br>
><br>
> -static VkExtent3D<br>
> -meta_image_block_size(const struct anv_image *image)<br>
> -{<br>
> - if (image->aspects == VK_IMAGE_ASPECT_COLOR_BIT) {<br>
> - const struct isl_format_layout *isl_layout =<br>
> - isl_format_get_layout(image-><wbr>color_surface.isl.format);<br>
> - return (VkExtent3D) { isl_layout->bw, isl_layout->bh, isl_layout->bd };<br>
> - } else {<br>
> - return (VkExtent3D) { 1, 1, 1 };<br>
> - }<br>
> -}<br>
> -<br>
> -/* Returns the user-provided VkBufferImageCopy::imageExtent in units of<br>
> - * elements rather than texels. One element equals one texel or one block<br>
> - * if Image is uncompressed or compressed, respectively.<br>
> - */<br>
> -static struct VkExtent3D<br>
> -meta_region_extent_el(const struct anv_image *image,<br>
> - const struct VkExtent3D *extent)<br>
> -{<br>
> - const VkExtent3D block = meta_image_block_size(image);<br>
> - return anv_sanitize_image_extent(<wbr>image->type, (VkExtent3D) {<br>
> - .width = DIV_ROUND_UP(extent->width , block.width),<br>
> - .height = DIV_ROUND_UP(extent->height, block.height),<br>
> - .depth = DIV_ROUND_UP(extent->depth , block.depth),<br>
> - });<br>
> -}<br>
> -<br>
> -/* Returns the user-provided VkBufferImageCopy::imageOffset in units of<br>
> - * elements rather than texels. One element equals one texel or one block<br>
> - * if Image is uncompressed or compressed, respectively.<br>
> - */<br>
> -static struct VkOffset3D<br>
> -meta_region_offset_el(const struct anv_image *image,<br>
> - const struct VkOffset3D *offset)<br>
> -{<br>
> - const VkExtent3D block = meta_image_block_size(image);<br>
> - return anv_sanitize_image_offset(<wbr>image->type, (VkOffset3D) {<br>
> - .x = offset->x / block.width,<br>
> - .y = offset->y / block.height,<br>
> - .z = offset->z / block.depth,<br>
> - });<br>
> -}<br>
> -<br>
> -static struct anv_meta_blit2d_surf<br>
> -blit_surf_for_image(const struct anv_image* image,<br>
> - const struct anv_surface *surf)<br>
> -{<br>
> - return (struct anv_meta_blit2d_surf) {<br>
> - .bo = image->bo,<br>
> - .tiling = surf->isl.tiling,<br>
> - .base_offset = image->offset + surf->offset,<br>
> - .bs = isl_format_get_layout(surf-><wbr>isl.format)->bpb / 8,<br>
> - .pitch = isl_surf_get_row_pitch(&surf-><wbr>isl),<br>
> - };<br>
> -}<br>
> -<br>
> static void<br>
> do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,<br>
> struct anv_bo *src, uint64_t src_offset,<br>
> @@ -107,107 +50,6 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,<br>
> anv_meta_blit2d(cmd_buffer, &b_src, &b_dst, 1, &rect);<br>
> }<br>
><br>
> -void anv_CmdCopyImage(<br>
> - VkCommandBuffer commandBuffer,<br>
> - VkImage srcImage,<br>
> - VkImageLayout srcImageLayout,<br>
> - VkImage destImage,<br>
> - VkImageLayout destImageLayout,<br>
> - uint32_t regionCount,<br>
> - const VkImageCopy* pRegions)<br>
> -{<br>
> - ANV_FROM_HANDLE(anv_cmd_<wbr>buffer, cmd_buffer, commandBuffer);<br>
> - ANV_FROM_HANDLE(anv_image, src_image, srcImage);<br>
> - ANV_FROM_HANDLE(anv_image, dest_image, destImage);<br>
> - struct anv_meta_saved_state saved_state;<br>
> -<br>
> - /* From the Vulkan 1.0 spec:<br>
> - *<br>
> - * vkCmdCopyImage can be used to copy image data between multisample<br>
> - * images, but both images must have the same number of samples.<br>
> - */<br>
> - assert(src_image->samples == dest_image->samples);<br>
> -<br>
> - anv_meta_begin_blit2d(cmd_<wbr>buffer, &saved_state);<br>
> -<br>
> - for (unsigned r = 0; r < regionCount; r++) {<br>
> - assert(pRegions[r].<wbr>srcSubresource.aspectMask ==<br>
> - pRegions[r].dstSubresource.<wbr>aspectMask);<br>
> -<br>
> - VkImageAspectFlags aspect = pRegions[r].srcSubresource.<wbr>aspectMask;<br>
> -<br>
> - /* Create blit surfaces */<br>
> - const struct anv_surface *src_surf =<br>
> - anv_image_get_surface_for_<wbr>aspect_mask(src_image, aspect);<br>
> - const struct anv_surface *dst_surf =<br>
> - anv_image_get_surface_for_<wbr>aspect_mask(dest_image, aspect);<br>
> - struct anv_meta_blit2d_surf b_src =<br>
> - blit_surf_for_image(src_image, src_surf);<br>
> - struct anv_meta_blit2d_surf b_dst =<br>
> - blit_surf_for_image(dest_<wbr>image, dst_surf);<br>
> -<br>
> - /**<br>
> - * From the Vulkan 1.0.6 spec: 18.4 Copying Data Between Buffers and Images<br>
> - * imageExtent is the size in texels of the image to copy in width, height<br>
> - * and depth. 1D images use only x and width. 2D images use x, y, width<br>
> - * and height. 3D images use x, y, z, width, height and depth.<br>
> - *<br>
> - * Also, convert the offsets and extent from units of texels to units of<br>
> - * blocks - which is the highest resolution accessible in this command.<br>
> - */<br>
> - const VkOffset3D dst_offset_el =<br>
> - meta_region_offset_el(dest_<wbr>image, &pRegions[r].dstOffset);<br>
> - const VkOffset3D src_offset_el =<br>
> - meta_region_offset_el(src_<wbr>image, &pRegions[r].srcOffset);<br>
> - const VkExtent3D img_extent_el =<br>
> - meta_region_extent_el(src_<wbr>image, &pRegions[r].extent);<br>
> -<br>
> - /* Start creating blit rect */<br>
> - struct anv_meta_blit2d_rect rect = {<br>
> - .width = img_extent_el.width,<br>
> - .height = img_extent_el.height,<br>
> - };<br>
> -<br>
> - /* Loop through each 3D or array slice */<br>
> - unsigned num_slices_3d = img_extent_el.depth;<br>
> - unsigned num_slices_array = pRegions[r].dstSubresource.<wbr>layerCount;<br>
> - unsigned slice_3d = 0;<br>
> - unsigned slice_array = 0;<br>
> - while (slice_3d < num_slices_3d && slice_array < num_slices_array) {<br>
> -<br>
> - /* Finish creating blit rect */<br>
> - isl_surf_get_image_offset_el(&<wbr>dst_surf->isl,<br>
> - pRegions[r].dstSubresource.<wbr>mipLevel,<br>
> - pRegions[r].dstSubresource.<wbr>baseArrayLayer<br>
> - + slice_array,<br>
> - dst_offset_el.z + slice_3d,<br>
> - &rect.dst_x,<br>
> - &rect.dst_y);<br>
> - isl_surf_get_image_offset_el(&<wbr>src_surf->isl,<br>
> - pRegions[r].srcSubresource.<wbr>mipLevel,<br>
> - pRegions[r].srcSubresource.<wbr>baseArrayLayer<br>
> - + slice_array,<br>
> - src_offset_el.z + slice_3d,<br>
> - &rect.src_x,<br>
> - &rect.src_y);<br>
> - rect.dst_x += dst_offset_el.x;<br>
> - rect.dst_y += dst_offset_el.y;<br>
> - rect.src_x += src_offset_el.x;<br>
> - rect.src_y += src_offset_el.y;<br>
> -<br>
> - /* Perform Blit */<br>
> - anv_meta_blit2d(cmd_buffer, &b_src, &b_dst, 1, &rect);<br>
> -<br>
> - if (dest_image->type == VK_IMAGE_TYPE_3D)<br>
> - slice_3d++;<br>
> - else<br>
> - slice_array++;<br>
> - }<br>
> - }<br>
> -<br>
> - anv_meta_end_blit2d(cmd_<wbr>buffer, &saved_state);<br>
> -}<br>
> -<br>
> void anv_CmdCopyBuffer(<br>
> VkCommandBuffer commandBuffer,<br>
> VkBuffer srcBuffer,<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>