.aspect = VK_IMAGE_ASPECT_DEPTH_BIT, \
}, \
}, \
+ .vk_format = __vk_fmt, \
.n_planes = 1, \
}
.aspect = VK_IMAGE_ASPECT_STENCIL_BIT, \
}, \
}, \
+ .vk_format = __vk_fmt, \
.n_planes = 1, \
}
const struct isl_format_layout *isl_layout =
isl_format_get_layout(plane_format.isl_format);
+ /* On Ivy Bridge we don't even have enough 24 and 48-bit formats that we
+ * can reliably do texture upload with BLORP so just don't claim support
+ * for any of them.
+ */
+ if (devinfo->gen == 7 && !devinfo->is_haswell &&
+ (isl_layout->bpb == 24 || isl_layout->bpb == 48))
+ return unsupported;
+
+ if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
+ /* No non-power-of-two fourcc formats exist */
+ if (!util_is_power_of_two_or_zero(isl_layout->bpb))
+ return unsupported;
+
+ if (vk_format_is_depth_or_stencil(vk_format))
+ return unsupported;
+
+ if (isl_format_is_compressed(plane_format.isl_format))
+ return unsupported;
+ }
+
if (tiling == VK_IMAGE_TILING_OPTIMAL &&
!util_is_power_of_two_or_zero(isl_layout->bpb)) {
/* Tiled formats *must* be power-of-two because we need up upload
return 0;
struct anv_format_plane base_plane_format = plane_format;
- if (vk_tiling == VK_IMAGE_TILING_OPTIMAL) {
+ if (vk_tiling != VK_IMAGE_TILING_LINEAR) {
base_plane_format = anv_get_format_plane(devinfo, vk_format,
VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_TILING_LINEAR);
static void
get_wsi_format_modifier_properties_list(const struct anv_physical_device *physical_device,
VkFormat vk_format,
- struct wsi_format_modifier_properties_list *list)
+ VkDrmFormatModifierPropertiesListEXT *list)
{
const struct anv_format *anv_format = anv_get_format(vk_format);
- VK_OUTARRAY_MAKE(out, list->modifier_properties, &list->modifier_count);
+ VK_OUTARRAY_MAKE(out, list->pDrmFormatModifierProperties,
+ &list->drmFormatModifierCount);
/* This is a simplified list where all the modifiers are available */
assert(vk_format == VK_FORMAT_B8G8R8_SRGB ||
anv_format->planes[0].isl_format))
continue;
+ /* Gen12's CCS layout changes compared to Gen9-11. */
+ if (mod_info->modifier == I915_FORMAT_MOD_Y_TILED_CCS &&
+ physical_device->info.gen >= 12)
+ continue;
+
vk_outarray_append(&out, mod_props) {
- mod_props->modifier = modifiers[i];
+ mod_props->drmFormatModifier = modifiers[i];
if (isl_drm_modifier_has_aux(modifiers[i]))
- mod_props->modifier_plane_count = 2;
+ mod_props->drmFormatModifierPlaneCount = 2;
else
- mod_props->modifier_plane_count = anv_format->n_planes;
+ mod_props->drmFormatModifierPlaneCount = anv_format->n_planes;
}
}
}
vk_foreach_struct(ext, pFormatProperties->pNext) {
/* Use unsigned since some cases are not in the VkStructureType enum. */
switch ((unsigned)ext->sType) {
- case VK_STRUCTURE_TYPE_WSI_FORMAT_MODIFIER_PROPERTIES_LIST_MESA:
+ case VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT:
get_wsi_format_modifier_properties_list(physical_device, format,
(void *)ext);
break;
if (format == NULL)
goto unsupported;
+ assert(format->vk_format == info->format);
format_feature_flags = anv_get_image_format_features(devinfo, info->format,
format, info->tiling);
*/
}
+ if (info->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
+ const VkPhysicalDeviceImageDrmFormatModifierInfoEXT *modifier_info =
+ vk_find_struct_const(info->pNext,
+ PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT);
+
+ /* Modifiers are only supported on simple 2D images */
+ if (info->type != VK_IMAGE_TYPE_2D)
+ goto unsupported;
+ maxArraySize = 1;
+ maxMipLevels = 1;
+ assert(sampleCounts == VK_SAMPLE_COUNT_1_BIT);
+
+ /* Modifiers are not yet supported for YCbCr */
+ const struct anv_format *format = anv_get_format(info->format);
+ if (format->n_planes > 1)
+ goto unsupported;
+
+ const struct isl_drm_modifier_info *isl_mod_info =
+ isl_drm_modifier_get_info(modifier_info->drmFormatModifier);
+ if (isl_mod_info->aux_usage == ISL_AUX_USAGE_CCS_E) {
+ /* If we have a CCS modifier, ensure that the format supports CCS
+ * and, if VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT is set, all of the
+ * formats in the format list are CCS compatible.
+ */
+ const VkImageFormatListCreateInfoKHR *fmt_list =
+ vk_find_struct_const(info->pNext,
+ IMAGE_FORMAT_LIST_CREATE_INFO_KHR);
+ if (!anv_formats_ccs_e_compatible(devinfo, info->flags,
+ info->format, info->tiling,
+ fmt_list))
+ goto unsupported;
+ }
+ }
+
/* From the bspec section entitled "Surface Layout and Tiling",
* pre-gen9 has a 2 GB limitation of the size in bytes,
* gen9 and gen10 have a 256 GB limitation and gen11+
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
};
+static const VkExternalMemoryProperties userptr_props = {
+ .externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT,
+ .exportFromImportedHandleTypes = 0,
+ .compatibleHandleTypes =
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT,
+};
+
static const VkExternalMemoryProperties android_buffer_props = {
.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT,
const VkPhysicalDeviceExternalImageFormatInfo *external_info = NULL;
VkExternalImageFormatProperties *external_props = NULL;
VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = NULL;
- struct VkAndroidHardwareBufferUsageANDROID *android_usage = NULL;
+ VkAndroidHardwareBufferUsageANDROID *android_usage = NULL;
VkResult result;
/* Extract input structs */
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
external_info = (const void *) s;
break;
+ case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT:
+ /* anv_get_image_format_properties will handle this */
+ break;
case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO_EXT:
/* Ignore but don't warn */
break;
if (external_props)
external_props->externalMemoryProperties = prime_fd_props;
break;
+ case VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT:
+ if (external_props)
+ external_props->externalMemoryProperties = userptr_props;
+ break;
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
if (ahw_supported && external_props) {
external_props->externalMemoryProperties = android_image_props;
* vkGetPhysicalDeviceImageFormatProperties2 returns
* VK_ERROR_FORMAT_NOT_SUPPORTED.
*/
- result = vk_errorf(physical_device->instance, physical_device,
- VK_ERROR_FORMAT_NOT_SUPPORTED,
- "unsupported VkExternalMemoryTypeFlagBits 0x%x",
- external_info->handleType);
+ result = vk_errorfi(physical_device->instance, physical_device,
+ VK_ERROR_FORMAT_NOT_SUPPORTED,
+ "unsupported VkExternalMemoryTypeFlagBits 0x%x",
+ external_info->handleType);
goto fail;
}
}
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT:
pExternalBufferProperties->externalMemoryProperties = prime_fd_props;
return;
+ case VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT:
+ pExternalBufferProperties->externalMemoryProperties = userptr_props;
+ return;
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
if (physical_device->supported_extensions.ANDROID_external_memory_android_hardware_buffer) {
pExternalBufferProperties->externalMemoryProperties = android_buffer_props;
}
unsupported:
+ /* From the Vulkan 1.1.113 spec:
+ *
+ * compatibleHandleTypes must include at least handleType.
+ */
pExternalBufferProperties->externalMemoryProperties =
- (VkExternalMemoryProperties) {0};
+ (VkExternalMemoryProperties) {
+ .compatibleHandleTypes = pExternalBufferInfo->handleType,
+ };
}
VkResult anv_CreateSamplerYcbcrConversion(
/* Search for VkExternalFormatANDROID and resolve the format. */
struct anv_format *ext_format = NULL;
- const struct VkExternalFormatANDROID *ext_info =
+ const VkExternalFormatANDROID *ext_info =
vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_FORMAT_ANDROID);
uint64_t format = ext_info ? ext_info->externalFormat : 0;