} else {
close(import_info->fd);
}
+
+ if (mem->image && mem->image->plane_count == 1 &&
+ !vk_format_is_depth_or_stencil(mem->image->vk_format)) {
+ struct radeon_bo_metadata metadata;
+ device->ws->buffer_get_metadata(mem->bo, &metadata);
+
+ struct radv_image_create_info create_info = {
+ .no_metadata_planes = true,
+ .bo_metadata = &metadata
+ };
+
+ /* This gives a basic ability to import radeonsi images
+ * that don't have DCC. This is not guaranteed by any
+ * spec and can be removed after we support modifiers. */
+ result = radv_image_create_layout(device, create_info, mem->image);
+ if (result != VK_SUCCESS) {
+ device->ws->buffer_destroy(mem->bo);
+ goto fail;
+ }
+ }
} else if (host_ptr_info) {
assert(host_ptr_info->handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT);
mem->bo = device->ws->buffer_from_ptr(device->ws, host_ptr_info->pHostPointer,
}
}
+
+static void
+radv_image_reset_layout(struct radv_image *image)
+{
+ image->size = 0;
+ image->alignment = 1;
+
+ image->tc_compatible_cmask = image->tc_compatible_htile = 0;
+ image->fce_pred_offset = image->dcc_pred_offset = 0;
+ image->clear_value_offset = image->tc_compat_zrange_offset = 0;
+
+ for (unsigned i = 0; i < image->plane_count; ++i) {
+ VkFormat format = vk_format_get_plane_format(image->vk_format, i);
+
+ uint32_t flags = image->planes[i].surface.flags;
+ memset(image->planes + i, 0, sizeof(image->planes[i]));
+
+ image->planes[i].surface.flags = flags;
+ image->planes[i].surface.blk_w = vk_format_get_blockwidth(format);
+ image->planes[i].surface.blk_h = vk_format_get_blockheight(format);
+ image->planes[i].surface.bpe = vk_format_get_blocksize(vk_format_depth_only(format));
+
+ /* align byte per element on dword */
+ if (image->planes[i].surface.bpe == 3) {
+ image->planes[i].surface.bpe = 4;
+ }
+ }
+}
+
VkResult
radv_image_create_layout(struct radv_device *device,
struct radv_image_create_info create_info,
struct radv_image *image)
{
- /* Check that we did not initialize things earlier */
- assert(!image->planes[0].surface.surf_size);
-
/* Clear the pCreateInfo pointer so we catch issues in the delayed case when we test in the
* common internal case. */
create_info.vk_info = NULL;
if (result != VK_SUCCESS)
return result;
- image->size = 0;
- image->alignment = 1;
+ radv_image_reset_layout(image);
+
for (unsigned plane = 0; plane < image->plane_count; ++plane) {
struct ac_surf_info info = image_info;