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>
/* 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;
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;
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;
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;
}
}
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
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,
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);
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,
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);
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;
}
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;