mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 07:48:07 +02:00
anv: implement VK_KHR_format_feature_flags2
v2: fix SAMPLED_IMAGE_DEPTH_COMPARISON_BIT_KHR (Ivan)
v3: Fixup VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT_KHR setting (Ivan)
Add missing drm-modifiers/android bits (Lionel)
v4: Avoid duplicating get_ahw_buffer_format_properties() (Jason)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13198>
This commit is contained in:
parent
01d1ec292a
commit
ce3dd1375f
4 changed files with 83 additions and 9 deletions
|
|
@ -174,10 +174,10 @@ features2_to_features(VkFormatFeatureFlags2KHR features2)
|
|||
}
|
||||
|
||||
static VkResult
|
||||
get_ahw_buffer_format_properties(
|
||||
get_ahw_buffer_format_properties2(
|
||||
VkDevice device_h,
|
||||
const struct AHardwareBuffer *buffer,
|
||||
VkAndroidHardwareBufferFormatPropertiesANDROID *pProperties)
|
||||
VkAndroidHardwareBufferFormatProperties2ANDROID *pProperties)
|
||||
{
|
||||
ANV_FROM_HANDLE(anv_device, device, device_h);
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ get_ahw_buffer_format_properties(
|
|||
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
|
||||
|
||||
/* Fill properties fields based on description. */
|
||||
VkAndroidHardwareBufferFormatPropertiesANDROID *p = pProperties;
|
||||
VkAndroidHardwareBufferFormatProperties2ANDROID *p = pProperties;
|
||||
|
||||
p->format = vk_format_from_android(desc.format, desc.usage);
|
||||
|
||||
|
|
@ -213,10 +213,9 @@ get_ahw_buffer_format_properties(
|
|||
if (desc.usage & AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER)
|
||||
tiling = VK_IMAGE_TILING_LINEAR;
|
||||
|
||||
VkFormatFeatureFlags2KHR features2 =
|
||||
p->formatFeatures =
|
||||
anv_get_image_format_features2(&device->info, p->format, anv_format,
|
||||
tiling, NULL);
|
||||
p->formatFeatures = features2_to_features(features2);
|
||||
|
||||
/* "Images can be created with an external format even if the Android hardware
|
||||
* buffer has a format which has an equivalent Vulkan format to enable
|
||||
|
|
@ -231,7 +230,7 @@ get_ahw_buffer_format_properties(
|
|||
* VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT"
|
||||
*/
|
||||
p->formatFeatures |=
|
||||
VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT;
|
||||
VK_FORMAT_FEATURE_2_MIDPOINT_CHROMA_SAMPLES_BIT_KHR;
|
||||
|
||||
/* "Implementations may not always be able to determine the color model,
|
||||
* numerical range, or chroma offsets of the image contents, so the values
|
||||
|
|
@ -265,10 +264,30 @@ anv_GetAndroidHardwareBufferPropertiesANDROID(
|
|||
VkAndroidHardwareBufferFormatPropertiesANDROID *format_prop =
|
||||
vk_find_struct(pProperties->pNext,
|
||||
ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID);
|
||||
|
||||
/* Fill format properties of an Android hardware buffer. */
|
||||
if (format_prop)
|
||||
get_ahw_buffer_format_properties(device_h, buffer, format_prop);
|
||||
if (format_prop) {
|
||||
VkAndroidHardwareBufferFormatProperties2ANDROID format_prop2 = {
|
||||
.sType = VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_2_ANDROID,
|
||||
};
|
||||
get_ahw_buffer_format_properties2(device_h, buffer, &format_prop2);
|
||||
|
||||
format_prop->format = format_prop2.format;
|
||||
format_prop->externalFormat = format_prop2.externalFormat;
|
||||
format_prop->formatFeatures =
|
||||
features2_to_features(format_prop2.formatFeatures);
|
||||
format_prop->samplerYcbcrConversionComponents =
|
||||
format_prop2.samplerYcbcrConversionComponents;
|
||||
format_prop->suggestedYcbcrModel = format_prop2.suggestedYcbcrModel;
|
||||
format_prop->suggestedYcbcrRange = format_prop2.suggestedYcbcrRange;
|
||||
format_prop->suggestedXChromaOffset = format_prop2.suggestedXChromaOffset;
|
||||
format_prop->suggestedYChromaOffset = format_prop2.suggestedYChromaOffset;
|
||||
}
|
||||
|
||||
VkAndroidHardwareBufferFormatProperties2ANDROID *format_prop2 =
|
||||
vk_find_struct(pProperties->pNext,
|
||||
ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_2_ANDROID);
|
||||
if (format_prop2)
|
||||
get_ahw_buffer_format_properties2(device_h, buffer, format_prop2);
|
||||
|
||||
/* NOTE - We support buffers with only one handle but do not error on
|
||||
* multiple handle case. Reason is that we want to support YUV formats
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ get_device_extensions(const struct anv_physical_device *device,
|
|||
.KHR_external_memory_fd = true,
|
||||
.KHR_external_semaphore = true,
|
||||
.KHR_external_semaphore_fd = true,
|
||||
.KHR_format_feature_flags2 = true,
|
||||
.KHR_fragment_shading_rate = device->info.ver >= 11,
|
||||
.KHR_get_memory_requirements2 = true,
|
||||
.KHR_image_format_list = true,
|
||||
|
|
|
|||
|
|
@ -579,6 +579,9 @@ anv_get_image_format_features2(const struct intel_device_info *devinfo,
|
|||
if ((aspects & VK_IMAGE_ASPECT_DEPTH_BIT) && devinfo->ver >= 9)
|
||||
flags |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT_KHR;
|
||||
|
||||
if (aspects & VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||
flags |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT_KHR;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
|
@ -885,6 +888,39 @@ get_drm_format_modifier_properties_list(const struct anv_physical_device *physic
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_drm_format_modifier_properties_list_2(const struct anv_physical_device *physical_device,
|
||||
VkFormat vk_format,
|
||||
VkDrmFormatModifierPropertiesList2EXT *list)
|
||||
{
|
||||
const struct intel_device_info *devinfo = &physical_device->info;
|
||||
const struct anv_format *anv_format = anv_get_format(vk_format);
|
||||
|
||||
VK_OUTARRAY_MAKE(out, list->pDrmFormatModifierProperties,
|
||||
&list->drmFormatModifierCount);
|
||||
|
||||
isl_drm_modifier_info_for_each(isl_mod_info) {
|
||||
VkFormatFeatureFlags2KHR features2 =
|
||||
anv_get_image_format_features2(devinfo, vk_format, anv_format,
|
||||
VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT,
|
||||
isl_mod_info);
|
||||
if (!features2)
|
||||
continue;
|
||||
|
||||
uint32_t planes = anv_format->n_planes;
|
||||
if (isl_mod_info->aux_usage != ISL_AUX_USAGE_NONE)
|
||||
++planes;
|
||||
|
||||
vk_outarray_append(&out, out_props) {
|
||||
*out_props = (VkDrmFormatModifierProperties2EXT) {
|
||||
.drmFormatModifier = isl_mod_info->modifier,
|
||||
.drmFormatModifierPlaneCount = planes,
|
||||
.drmFormatModifierTilingFeatures = features2,
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void anv_GetPhysicalDeviceFormatProperties2(
|
||||
VkPhysicalDevice physicalDevice,
|
||||
VkFormat vk_format,
|
||||
|
|
@ -916,6 +952,19 @@ void anv_GetPhysicalDeviceFormatProperties2(
|
|||
get_drm_format_modifier_properties_list(physical_device, vk_format,
|
||||
(void *)ext);
|
||||
break;
|
||||
|
||||
case VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXT:
|
||||
get_drm_format_modifier_properties_list_2(physical_device, vk_format,
|
||||
(void *)ext);
|
||||
break;
|
||||
|
||||
case VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3_KHR: {
|
||||
VkFormatProperties3KHR *props = (VkFormatProperties3KHR *)ext;
|
||||
props->linearTilingFeatures = linear2;
|
||||
props->optimalTilingFeatures = optimal2;
|
||||
props->bufferFeatures = buffer2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
anv_debug_ignored_stype(ext->sType);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -124,6 +124,11 @@ anv_shader_compile_to_nir(struct anv_device *device,
|
|||
.fragment_shader_sample_interlock = pdevice->info.ver >= 9,
|
||||
.fragment_shader_pixel_interlock = pdevice->info.ver >= 9,
|
||||
.geometry_streams = true,
|
||||
/* When KHR_format_feature_flags2 is enabled, the read/write without
|
||||
* format is per format, so just report true. It's up to the
|
||||
* application to check.
|
||||
*/
|
||||
.image_read_without_format = device->vk.enabled_extensions.KHR_format_feature_flags2,
|
||||
.image_write_without_format = true,
|
||||
.int8 = pdevice->info.ver >= 8,
|
||||
.int16 = pdevice->info.ver >= 8,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue