diff --git a/docs/features.txt b/docs/features.txt index 1249b8ae53e..e2f9e61eb62 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -486,7 +486,7 @@ Vulkan 1.3 -- all DONE: anv, lvp, nvk, radv, tu, vn, v3dv VK_KHR_copy_commands2 DONE (anv, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_KHR_dynamic_rendering DONE (anv, dzn, hasvk, lvp, nvk, panvk, radv, tu, v3dv, vn) - VK_KHR_format_feature_flags2 DONE (anv, hasvk, lvp, nvk, pvr, radv, tu, v3dv, vn) + VK_KHR_format_feature_flags2 DONE (anv, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_KHR_maintenance4 DONE (anv, hasvk, lvp, nvk, radv, tu, v3dv, vn) VK_KHR_shader_integer_dot_product DONE (anv, dzn, hasvk, lvp, nvk, radv, tu, v3dv, vn) VK_KHR_shader_non_semantic_info DONE (anv, hasvk, nvk, panvk, radv, tu, v3dv, vn) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index ca6b4266e69..bd0c2dd2fa8 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -41,3 +41,4 @@ Mali G720 and G725 on Panfrost and panvk dualSrcBlend on panvk VK_KHR_dynamic_rendering_local_read on panvk VK_EXT_subgroup_size_control on panvk/v10+ +VK_KHR_format_feature_flags2 on panvk diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index ebbbb043d5a..25961ba9b1e 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -231,6 +231,7 @@ get_device_extensions(const struct panvk_physical_device *device, .KHR_external_memory_fd = true, .KHR_external_semaphore = true, .KHR_external_semaphore_fd = true, + .KHR_format_feature_flags2 = true, .KHR_get_memory_requirements2 = true, .KHR_global_priority = true, .KHR_image_format_list = true, @@ -1353,11 +1354,11 @@ format_is_supported(struct panvk_physical_device *physical_device, return true; } -static VkFormatFeatureFlags +static VkFormatFeatureFlags2 get_image_plane_format_features(struct panvk_physical_device *physical_device, VkFormat format) { - VkFormatFeatureFlags features = 0; + VkFormatFeatureFlags2 features = 0; enum pipe_format pfmt = vk_format_to_pipe_format(format); const struct panfrost_format fmt = physical_device->formats.all[pfmt]; unsigned arch = pan_arch(physical_device->kmod.props.gpu_prod_id); @@ -1366,22 +1367,22 @@ get_image_plane_format_features(struct panvk_physical_device *physical_device, return 0; if (fmt.bind & PAN_BIND_SAMPLER_VIEW) { - features |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | - VK_FORMAT_FEATURE_TRANSFER_DST_BIT | - VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT; + features |= VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT | + VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT | + VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT; if (arch >= 10) - features |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT; + features |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT; /* Integer formats only support nearest filtering */ if (!util_format_is_scaled(pfmt) && !util_format_is_pure_integer(pfmt)) - features |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; + features |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT; - features |= VK_FORMAT_FEATURE_BLIT_SRC_BIT; + features |= VK_FORMAT_FEATURE_2_BLIT_SRC_BIT; } if (fmt.bind & PAN_BIND_RENDER_TARGET) { - features |= VK_FORMAT_FEATURE_BLIT_DST_BIT; + features |= VK_FORMAT_FEATURE_2_BLIT_DST_BIT; /* SNORM rendering isn't working yet (nir_lower_blend bugs), disable for * now. @@ -1389,24 +1390,27 @@ get_image_plane_format_features(struct panvk_physical_device *physical_device, * XXX: Enable once fixed. */ if (!util_format_is_snorm(pfmt)) { - features |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; - features |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT; + features |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT; + features |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT; } } if (fmt.bind & PAN_BIND_STORAGE_IMAGE) - features |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; + features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT; if (pfmt == PIPE_FORMAT_R32_UINT || pfmt == PIPE_FORMAT_R32_SINT) - features |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT; + features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT; if (fmt.bind & PAN_BIND_DEPTH_STENCIL) - features |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT; + features |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT; + + if (vk_format_has_depth(format)) + features |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT; return features; } -static VkFormatFeatureFlags +static VkFormatFeatureFlags2 get_image_format_features(struct panvk_physical_device *physical_device, VkFormat format) { @@ -1427,7 +1431,7 @@ get_image_format_features(struct panvk_physical_device *physical_device, /* For multi-plane, we get the feature flags of each plane separately, * then take their intersection as the overall format feature flags */ - VkFormatFeatureFlags features = ~0u; + VkFormatFeatureFlags2 features = ~0ull; bool cosited_chroma = false; for (uint8_t plane = 0; plane < ycbcr_info->n_planes; plane++) { const struct vk_format_ycbcr_plane *plane_info = @@ -1442,24 +1446,24 @@ get_image_format_features(struct panvk_physical_device *physical_device, return 0; /* Uh... We really should be able to sample from YCbCr */ - assert(features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT); - assert(features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT); + assert(features & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT); + assert(features & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT); /* Siting is handled in the YCbCr lowering pass. */ - features |= VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT; + features |= VK_FORMAT_FEATURE_2_MIDPOINT_CHROMA_SAMPLES_BIT; if (cosited_chroma) - features |= VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT; + features |= VK_FORMAT_FEATURE_2_COSITED_CHROMA_SAMPLES_BIT; /* These aren't allowed for YCbCr formats */ - features &= ~(VK_FORMAT_FEATURE_BLIT_SRC_BIT | - VK_FORMAT_FEATURE_BLIT_DST_BIT | - VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | - VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT | - VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT); + features &= ~(VK_FORMAT_FEATURE_2_BLIT_SRC_BIT | + VK_FORMAT_FEATURE_2_BLIT_DST_BIT | + VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT | + VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT | + VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT); /* This is supported on all YCbCr formats */ features |= - VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT; + VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT; if (ycbcr_info->n_planes > 1) { /* DISJOINT_BIT implies that each plane has its own separate binding, @@ -1467,14 +1471,14 @@ get_image_format_features(struct panvk_physical_device *physical_device, * each have their own, separate filters, so these two bits make sense * for multi-planar formats only. */ - features |= VK_FORMAT_FEATURE_DISJOINT_BIT | - VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT; + features |= VK_FORMAT_FEATURE_2_DISJOINT_BIT | + VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT; } return features; } -static VkFormatFeatureFlags +static VkFormatFeatureFlags2 get_image_format_sample_counts(struct panvk_physical_device *physical_device, VkFormat format) { @@ -1488,11 +1492,11 @@ get_image_format_sample_counts(struct panvk_physical_device *physical_device, return get_sample_counts(arch, max_tib_size, max_cbuf_atts, format_size); } -static VkFormatFeatureFlags +static VkFormatFeatureFlags2 get_buffer_format_features(struct panvk_physical_device *physical_device, VkFormat format) { - VkFormatFeatureFlags features = 0; + VkFormatFeatureFlags2 features = 0; enum pipe_format pfmt = vk_format_to_pipe_format(format); const struct panfrost_format fmt = physical_device->formats.all[pfmt]; @@ -1503,17 +1507,17 @@ get_buffer_format_features(struct panvk_physical_device *physical_device, * https://github.com/KhronosGroup/Vulkan-Docs/issues/2214). */ if ((fmt.bind & PAN_BIND_VERTEX_BUFFER) && !util_format_is_srgb(pfmt)) - features |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT; + features |= VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT; if ((fmt.bind & PAN_BIND_SAMPLER_VIEW) && !util_format_is_depth_or_stencil(pfmt)) - features |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT; + features |= VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT; if (fmt.bind & PAN_BIND_STORAGE_IMAGE) - features |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT; + features |= VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT; if (pfmt == PIPE_FORMAT_R32_UINT || pfmt == PIPE_FORMAT_R32_SINT) - features |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT; + features |= VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_ATOMIC_BIT; return features; } @@ -1525,9 +1529,9 @@ panvk_GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, { VK_FROM_HANDLE(panvk_physical_device, physical_device, physicalDevice); - VkFormatFeatureFlags tex = + VkFormatFeatureFlags2 tex = get_image_format_features(physical_device, format); - VkFormatFeatureFlags buffer = + VkFormatFeatureFlags2 buffer = get_buffer_format_features(physical_device, format); pFormatProperties->formatProperties = (VkFormatProperties){ @@ -1536,6 +1540,14 @@ panvk_GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, .bufferFeatures = buffer, }; + VkFormatProperties3 *formatProperties3 = + vk_find_struct(pFormatProperties->pNext, FORMAT_PROPERTIES_3); + if (formatProperties3) { + formatProperties3->linearTilingFeatures = tex; + formatProperties3->optimalTilingFeatures = tex; + formatProperties3->bufferFeatures = buffer; + } + VkDrmFormatModifierPropertiesListEXT *list = vk_find_struct( pFormatProperties->pNext, DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT); if (list) { @@ -1560,9 +1572,9 @@ static VkResult get_image_format_properties(struct panvk_physical_device *physical_device, const VkPhysicalDeviceImageFormatInfo2 *info, VkImageFormatProperties *pImageFormatProperties, - VkFormatFeatureFlags *p_feature_flags) + VkFormatFeatureFlags2 *p_feature_flags) { - VkFormatFeatureFlags format_feature_flags; + VkFormatFeatureFlags2 format_feature_flags; VkExtent3D maxExtent; uint32_t maxMipLevels; uint32_t maxArraySize; @@ -1656,8 +1668,8 @@ get_image_format_properties(struct panvk_physical_device *physical_device, if (info->tiling == VK_IMAGE_TILING_OPTIMAL && info->type == VK_IMAGE_TYPE_2D && ycbcr_info == NULL && (format_feature_flags & - (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | - VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) && + (VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT | + VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT)) && !(info->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) && !(all_usage & VK_IMAGE_USAGE_STORAGE_BIT)) { sampleCounts |= @@ -1677,13 +1689,13 @@ get_image_format_properties(struct panvk_physical_device *physical_device, */ if (!(info->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT)) { if (all_usage & VK_IMAGE_USAGE_SAMPLED_BIT) { - if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) { + if (!(format_feature_flags & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT)) { goto unsupported; } } if (all_usage & VK_IMAGE_USAGE_STORAGE_BIT) { - if (!(format_feature_flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)) { + if (!(format_feature_flags & VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT)) { goto unsupported; } } @@ -1691,7 +1703,7 @@ get_image_format_properties(struct panvk_physical_device *physical_device, if (all_usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT || ((all_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) && !vk_format_is_depth_or_stencil(info->format))) { - if (!(format_feature_flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) { + if (!(format_feature_flags & VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT)) { goto unsupported; } } @@ -1700,7 +1712,7 @@ get_image_format_properties(struct panvk_physical_device *physical_device, ((all_usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) && vk_format_is_depth_or_stencil(info->format))) { if (!(format_feature_flags & - VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) { + VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT)) { goto unsupported; } } @@ -1805,7 +1817,7 @@ panvk_GetPhysicalDeviceImageFormatProperties2( const VkPhysicalDeviceImageViewImageFormatInfoEXT *image_view_info = NULL; VkExternalImageFormatProperties *external_props = NULL; VkFilterCubicImageViewImageFormatPropertiesEXT *cubic_props = NULL; - VkFormatFeatureFlags format_feature_flags; + VkFormatFeatureFlags2 format_feature_flags; VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = NULL; VkResult result; @@ -1879,7 +1891,7 @@ panvk_GetPhysicalDeviceImageFormatProperties2( if ((image_view_info->imageViewType == VK_IMAGE_VIEW_TYPE_2D || image_view_info->imageViewType == VK_IMAGE_VIEW_TYPE_2D_ARRAY) && (format_feature_flags & - VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT)) { + VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT)) { cubic_props->filterCubic = true; cubic_props->filterCubicMinmax = true; } else { @@ -1899,7 +1911,7 @@ panvk_GetPhysicalDeviceImageFormatProperties2( * * "If format is a multi-planar format, and if imageCreateFormatFeatures * (as defined in Image Creation Limits) does not contain - * VK_FORMAT_FEATURE_DISJOINT_BIT, then flags must not contain + * VK_FORMAT_FEATURE_2_DISJOINT_BIT, then flags must not contain * VK_IMAGE_CREATE_DISJOINT_BIT" * * This is satisfied trivially because we support DISJOINT on all