From 62fa4ff5e0252df2564c6b39660941b51b31ed5d Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 13 Jul 2023 16:19:07 -0500 Subject: [PATCH] nvk: Take an nvk_image_plane in nouveau_copy_rect_image Part-of: --- src/nouveau/vulkan/nvk_cmd_copy.c | 44 +++++++++++++++++-------------- src/nouveau/vulkan/nvk_image.h | 8 +++++- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/nouveau/vulkan/nvk_cmd_copy.c b/src/nouveau/vulkan/nvk_cmd_copy.c index 7e8ac7084a5..e895ef10eb3 100644 --- a/src/nouveau/vulkan/nvk_cmd_copy.c +++ b/src/nouveau/vulkan/nvk_cmd_copy.c @@ -68,9 +68,9 @@ vk_to_nil_extent(VkExtent3D extent, uint32_t array_layers) static struct nouveau_copy_buffer nouveau_copy_rect_image( struct nvk_image *img, + struct nvk_image_plane *plane, VkOffset3D offset_px, - const VkImageSubresourceLayers *sub_res, - const uint8_t plane) + const VkImageSubresourceLayers *sub_res) { const VkExtent3D lvl_extent_px = vk_image_mip_level_extent(&img->vk, sub_res->mipLevel); @@ -82,17 +82,17 @@ nouveau_copy_rect_image( vk_to_nil_offset(offset_px, sub_res->baseArrayLayer); struct nouveau_copy_buffer buf = { - .base_addr = nvk_image_base_address(img, plane) + - img->planes[plane].nil.levels[sub_res->mipLevel].offset_B, + .base_addr = nvk_image_plane_base_address(plane) + + plane->nil.levels[sub_res->mipLevel].offset_B, .image_type = img->vk.image_type, - .offset_el = nil_offset4d_px_to_el(offset4d_px, img->planes[plane].nil.format, - img->planes[plane].nil.sample_layout), - .extent_el = nil_extent4d_px_to_el(lvl_extent4d_px, img->planes[plane].nil.format, - img->planes[plane].nil.sample_layout), - .bpp = util_format_get_blocksize(img->planes[plane].nil.format), - .row_stride = img->planes[plane].nil.levels[sub_res->mipLevel].row_stride_B, - .array_stride = img->planes[plane].nil.array_stride_B, - .tiling = img->planes[plane].nil.levels[sub_res->mipLevel].tiling, + .offset_el = nil_offset4d_px_to_el(offset4d_px, plane->nil.format, + plane->nil.sample_layout), + .extent_el = nil_extent4d_px_to_el(lvl_extent4d_px, plane->nil.format, + plane->nil.sample_layout), + .bpp = util_format_get_blocksize(plane->nil.format), + .row_stride = plane->nil.levels[sub_res->mipLevel].row_stride_B, + .array_stride = plane->nil.array_stride_B, + .tiling = plane->nil.levels[sub_res->mipLevel].tiling, }; return buf; @@ -373,8 +373,9 @@ nvk_CmdCopyBufferToImage2(VkCommandBuffer commandBuffer, struct nouveau_copy copy = { .src = nouveau_copy_rect_buffer(src, region->bufferOffset, buffer_layout), - .dst = nouveau_copy_rect_image(dst, region->imageOffset, - ®ion->imageSubresource, plane), + .dst = nouveau_copy_rect_image(dst, &dst->planes[plane], + region->imageOffset, + ®ion->imageSubresource), .extent_el = nil_extent4d_px_to_el(extent4d_px, dst->planes[plane].nil.format, dst->planes[plane].nil.sample_layout), }; @@ -443,8 +444,9 @@ nvk_CmdCopyImageToBuffer2(VkCommandBuffer commandBuffer, uint8_t plane = nvk_image_aspects_to_plane(src, aspects); struct nouveau_copy copy = { - .src = nouveau_copy_rect_image(src, region->imageOffset, - ®ion->imageSubresource, plane), + .src = nouveau_copy_rect_image(src, &src->planes[plane], + region->imageOffset, + ®ion->imageSubresource), .dst = nouveau_copy_rect_buffer(dst, region->bufferOffset, buffer_layout), .extent_el = nil_extent4d_px_to_el(extent4d_px, src->planes[plane].nil.format, @@ -522,10 +524,12 @@ nvk_CmdCopyImage2(VkCommandBuffer commandBuffer, uint8_t dst_plane = nvk_image_aspects_to_plane(dst, dst_aspects); struct nouveau_copy copy = { - .src = nouveau_copy_rect_image(src, region->srcOffset, - ®ion->srcSubresource, src_plane), - .dst = nouveau_copy_rect_image(dst, region->dstOffset, - ®ion->dstSubresource, dst_plane), + .src = nouveau_copy_rect_image(src, &src->planes[src_plane], + region->srcOffset, + ®ion->srcSubresource), + .dst = nouveau_copy_rect_image(dst, &dst->planes[dst_plane], + region->dstOffset, + ®ion->dstSubresource), .extent_el = nil_extent4d_px_to_el(extent4d_px, src->planes[src_plane].nil.format, src->planes[src_plane].nil.sample_layout), }; diff --git a/src/nouveau/vulkan/nvk_image.h b/src/nouveau/vulkan/nvk_image.h index bb67f9db3f1..f243431bfb9 100644 --- a/src/nouveau/vulkan/nvk_image.h +++ b/src/nouveau/vulkan/nvk_image.h @@ -38,10 +38,16 @@ struct nvk_image { VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE) +static inline uint64_t +nvk_image_plane_base_address(const struct nvk_image_plane *plane) +{ + return plane->mem->bo->offset + plane->offset; +} + static inline uint64_t nvk_image_base_address(const struct nvk_image *image, uint8_t plane) { - return image->planes[plane].mem->bo->offset + image->planes[plane].offset; + return nvk_image_plane_base_address(&image->planes[plane]); } static inline uint8_t