From: Jonathan Marek Date: Tue, 12 May 2020 23:38:48 +0000 (-0400) Subject: freedreno/layout: add explicit offset/pitch argument to fdl6_layout X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=da409fb7b8c997de28db4016c788abff14bd8c57;p=mesa.git freedreno/layout: add explicit offset/pitch argument to fdl6_layout fdl6_layout will return false when the explicit pitch is not valid. Signed-off-by: Jonathan Marek Part-of: --- diff --git a/src/freedreno/fdl/fd6_layout.c b/src/freedreno/fdl/fd6_layout.c index ea71da8918f..20aec1fdb9a 100644 --- a/src/freedreno/fdl/fd6_layout.c +++ b/src/freedreno/fdl/fd6_layout.c @@ -90,12 +90,16 @@ fdl6_pitchalign(struct fdl_layout *layout, int level) /* NOTE: good way to test this is: (for example) * piglit/bin/texelFetch fs sampler3D 100x100x8 */ -void +bool fdl6_layout(struct fdl_layout *layout, enum pipe_format format, uint32_t nr_samples, uint32_t width0, uint32_t height0, uint32_t depth0, - uint32_t mip_levels, uint32_t array_size, bool is_3d) + uint32_t mip_levels, uint32_t array_size, bool is_3d, + struct fdl_slice *plane_layout) { + uint32_t offset; + uint32_t pitch0; + assert(nr_samples > 0); layout->width0 = width0; layout->height0 = height0; @@ -129,7 +133,18 @@ fdl6_layout(struct fdl_layout *layout, layout->base_align = 64; } - uint32_t pitch0 = util_align_npot(width0, fdl6_pitchalign(layout, 0)); + if (plane_layout) { + offset = plane_layout->offset; + pitch0 = plane_layout->pitch; + if (align(pitch0, fdl6_pitchalign(layout, 0) * layout->cpp) != pitch0) + return false; + pitch0 /= layout->cpp; /* explicit pitch is in bytes */ + if (pitch0 < width0 && height0 > 1) + return false; + } else { + offset = 0; + pitch0 = util_align_npot(width0, fdl6_pitchalign(layout, 0)); + } uint32_t ubwc_width0 = width0; uint32_t ubwc_height0 = height0; @@ -182,7 +197,7 @@ fdl6_layout(struct fdl_layout *layout, util_align_npot(util_format_get_nblocksx(format, u_minify(pitch0, level)), fdl6_pitchalign(layout, level)); - slice->offset = layout->size; + slice->offset = offset + layout->size; uint32_t blocks = nblocksx * nblocksy; slice->pitch = nblocksx * layout->cpp; @@ -216,7 +231,7 @@ fdl6_layout(struct fdl_layout *layout, ubwc_slice->size0 = align(meta_pitch * meta_height, UBWC_PLANE_SIZE_ALIGNMENT); ubwc_slice->pitch = meta_pitch; - ubwc_slice->offset = layout->ubwc_layer_size; + ubwc_slice->offset = offset + layout->ubwc_layer_size; layout->ubwc_layer_size += ubwc_slice->size0; } } @@ -236,6 +251,11 @@ fdl6_layout(struct fdl_layout *layout, layout->slices[level].offset += layout->ubwc_layer_size * array_size; layout->size += layout->ubwc_layer_size * array_size; } + + /* include explicit offset in size */ + layout->size += offset; + + return true; } void diff --git a/src/freedreno/fdl/fd_layout_test.c b/src/freedreno/fdl/fd_layout_test.c index f0bdecf9258..03174e58688 100644 --- a/src/freedreno/fdl/fd_layout_test.c +++ b/src/freedreno/fdl/fd_layout_test.c @@ -52,7 +52,8 @@ bool fdl_test_layout(const struct testcase *testcase, int gpu_id) MAX2(testcase->layout.depth0, 1), mip_levels, MAX2(testcase->array_size, 1), - testcase->is_3d); + testcase->is_3d, + NULL); } else { assert(gpu_id >= 500); fdl5_layout(&layout, diff --git a/src/freedreno/fdl/freedreno_layout.h b/src/freedreno/fdl/freedreno_layout.h index 6753890bf4a..ec4090066ca 100644 --- a/src/freedreno/fdl/freedreno_layout.h +++ b/src/freedreno/fdl/freedreno_layout.h @@ -190,11 +190,12 @@ fdl5_layout(struct fdl_layout *layout, uint32_t width0, uint32_t height0, uint32_t depth0, uint32_t mip_levels, uint32_t array_size, bool is_3d); -void +bool fdl6_layout(struct fdl_layout *layout, enum pipe_format format, uint32_t nr_samples, uint32_t width0, uint32_t height0, uint32_t depth0, - uint32_t mip_levels, uint32_t array_size, bool is_3d); + uint32_t mip_levels, uint32_t array_size, bool is_3d, + struct fdl_slice *plane_layout); void fdl_dump_layout(struct fdl_layout *layout); diff --git a/src/freedreno/vulkan/tu_clear_blit.c b/src/freedreno/vulkan/tu_clear_blit.c index 48e49b224d2..c200c8d9775 100644 --- a/src/freedreno/vulkan/tu_clear_blit.c +++ b/src/freedreno/vulkan/tu_clear_blit.c @@ -1580,7 +1580,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, staging_image.extent.depth, staging_image.level_count, staging_image.layer_count, - staging_image.type == VK_IMAGE_TYPE_3D); + staging_image.type == VK_IMAGE_TYPE_3D, + NULL); VkResult result = tu_get_scratch_bo(cmd->device, staging_image.layout.size, diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c index de8b6dc3f0d..3e16f812904 100644 --- a/src/freedreno/vulkan/tu_image.c +++ b/src/freedreno/vulkan/tu_image.c @@ -157,7 +157,8 @@ tu_image_create(VkDevice _device, pCreateInfo->extent.depth, pCreateInfo->mipLevels, pCreateInfo->arrayLayers, - pCreateInfo->imageType == VK_IMAGE_TYPE_3D); + pCreateInfo->imageType == VK_IMAGE_TYPE_3D, + NULL); *pImage = tu_image_to_handle(image); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c index 73434e0e41c..c3e34939579 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c @@ -153,7 +153,8 @@ fd6_setup_slices(struct fd_resource *rsc) fdl6_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc), prsc->width0, prsc->height0, prsc->depth0, prsc->last_level + 1, prsc->array_size, - prsc->target == PIPE_TEXTURE_3D); + prsc->target == PIPE_TEXTURE_3D, + NULL); return rsc->layout.size; } @@ -175,18 +176,11 @@ fill_ubwc_buffer_sizes(struct fd_resource *rsc) rsc->layout.ubwc = true; rsc->layout.tile_mode = TILE6_3; - fdl6_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc), + if (!fdl6_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc), prsc->width0, prsc->height0, prsc->depth0, - prsc->last_level + 1, prsc->array_size, false); - - if (fd_resource_slice(rsc, 0)->pitch != slice.pitch) + prsc->last_level + 1, prsc->array_size, false, &slice)) return -1; - /* The imported buffer may specify an offset, add that in here. */ - rsc->layout.slices[0].offset += slice.offset; - rsc->layout.ubwc_slices[0].offset += slice.offset; - rsc->layout.size += slice.offset; - if (rsc->layout.size > fd_bo_size(rsc->bo)) return -1;