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 <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4596>
This commit is contained in:
Jonathan Marek
2020-05-12 19:38:48 -04:00
committed by Marge Bot
parent f1acf492de
commit da409fb7b8
6 changed files with 38 additions and 20 deletions

View File

@@ -90,12 +90,16 @@ fdl6_pitchalign(struct fdl_layout *layout, int level)
/* NOTE: good way to test this is: (for example) /* NOTE: good way to test this is: (for example)
* piglit/bin/texelFetch fs sampler3D 100x100x8 * piglit/bin/texelFetch fs sampler3D 100x100x8
*/ */
void bool
fdl6_layout(struct fdl_layout *layout, fdl6_layout(struct fdl_layout *layout,
enum pipe_format format, uint32_t nr_samples, enum pipe_format format, uint32_t nr_samples,
uint32_t width0, uint32_t height0, uint32_t depth0, 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); assert(nr_samples > 0);
layout->width0 = width0; layout->width0 = width0;
layout->height0 = height0; layout->height0 = height0;
@@ -129,7 +133,18 @@ fdl6_layout(struct fdl_layout *layout,
layout->base_align = 64; 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_width0 = width0;
uint32_t ubwc_height0 = height0; 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)), util_align_npot(util_format_get_nblocksx(format, u_minify(pitch0, level)),
fdl6_pitchalign(layout, level)); fdl6_pitchalign(layout, level));
slice->offset = layout->size; slice->offset = offset + layout->size;
uint32_t blocks = nblocksx * nblocksy; uint32_t blocks = nblocksx * nblocksy;
slice->pitch = nblocksx * layout->cpp; 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->size0 = align(meta_pitch * meta_height, UBWC_PLANE_SIZE_ALIGNMENT);
ubwc_slice->pitch = meta_pitch; 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; 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->slices[level].offset += layout->ubwc_layer_size * array_size;
layout->size += 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 void

View File

@@ -52,7 +52,8 @@ bool fdl_test_layout(const struct testcase *testcase, int gpu_id)
MAX2(testcase->layout.depth0, 1), MAX2(testcase->layout.depth0, 1),
mip_levels, mip_levels,
MAX2(testcase->array_size, 1), MAX2(testcase->array_size, 1),
testcase->is_3d); testcase->is_3d,
NULL);
} else { } else {
assert(gpu_id >= 500); assert(gpu_id >= 500);
fdl5_layout(&layout, fdl5_layout(&layout,

View File

@@ -190,11 +190,12 @@ fdl5_layout(struct fdl_layout *layout,
uint32_t width0, uint32_t height0, uint32_t depth0, 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);
void bool
fdl6_layout(struct fdl_layout *layout, fdl6_layout(struct fdl_layout *layout,
enum pipe_format format, uint32_t nr_samples, enum pipe_format format, uint32_t nr_samples,
uint32_t width0, uint32_t height0, uint32_t depth0, 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 void
fdl_dump_layout(struct fdl_layout *layout); fdl_dump_layout(struct fdl_layout *layout);

View File

@@ -1580,7 +1580,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd,
staging_image.extent.depth, staging_image.extent.depth,
staging_image.level_count, staging_image.level_count,
staging_image.layer_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, VkResult result = tu_get_scratch_bo(cmd->device,
staging_image.layout.size, staging_image.layout.size,

View File

@@ -157,7 +157,8 @@ tu_image_create(VkDevice _device,
pCreateInfo->extent.depth, pCreateInfo->extent.depth,
pCreateInfo->mipLevels, pCreateInfo->mipLevels,
pCreateInfo->arrayLayers, pCreateInfo->arrayLayers,
pCreateInfo->imageType == VK_IMAGE_TYPE_3D); pCreateInfo->imageType == VK_IMAGE_TYPE_3D,
NULL);
*pImage = tu_image_to_handle(image); *pImage = tu_image_to_handle(image);

View File

@@ -153,7 +153,8 @@ fd6_setup_slices(struct fd_resource *rsc)
fdl6_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc), fdl6_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc),
prsc->width0, prsc->height0, prsc->depth0, prsc->width0, prsc->height0, prsc->depth0,
prsc->last_level + 1, prsc->array_size, prsc->last_level + 1, prsc->array_size,
prsc->target == PIPE_TEXTURE_3D); prsc->target == PIPE_TEXTURE_3D,
NULL);
return rsc->layout.size; return rsc->layout.size;
} }
@@ -175,18 +176,11 @@ fill_ubwc_buffer_sizes(struct fd_resource *rsc)
rsc->layout.ubwc = true; rsc->layout.ubwc = true;
rsc->layout.tile_mode = TILE6_3; 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->width0, prsc->height0, prsc->depth0,
prsc->last_level + 1, prsc->array_size, false); prsc->last_level + 1, prsc->array_size, false, &slice))
if (fd_resource_slice(rsc, 0)->pitch != slice.pitch)
return -1; 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)) if (rsc->layout.size > fd_bo_size(rsc->bo))
return -1; return -1;