aux/vk: add support for optional VK_ANDROID_external_format_resolve

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2316>
This commit is contained in:
Simon Zeni 2024-08-28 11:44:23 -04:00
parent 922e225794
commit 1b8b85d99d
4 changed files with 49 additions and 1 deletions

View file

@ -305,6 +305,7 @@ DEVICE_EXTENSIONS_TO_CHECK = [
"VK_EXT_global_priority",
"VK_EXT_image_drm_format_modifier",
"VK_EXT_robustness2",
"VK_ANDROID_external_format_resolve",
"VK_GOOGLE_display_timing",
]

View file

@ -756,6 +756,7 @@ fill_in_has_device_extensions(struct vk_bundle *vk, struct u_string_list *ext_li
vk->has_EXT_global_priority = false;
vk->has_EXT_image_drm_format_modifier = false;
vk->has_EXT_robustness2 = false;
vk->has_ANDROID_external_format_resolve = false;
vk->has_GOOGLE_display_timing = false;
const char *const *exts = u_string_list_get_data(ext_list);
@ -883,6 +884,13 @@ fill_in_has_device_extensions(struct vk_bundle *vk, struct u_string_list *ext_li
}
#endif // defined(VK_EXT_robustness2)
#if defined(VK_ANDROID_external_format_resolve)
if (strcmp(ext, VK_ANDROID_EXTERNAL_FORMAT_RESOLVE_EXTENSION_NAME) == 0) {
vk->has_ANDROID_external_format_resolve = true;
continue;
}
#endif // defined(VK_ANDROID_external_format_resolve)
#if defined(VK_GOOGLE_display_timing)
if (strcmp(ext, VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME) == 0) {
vk->has_GOOGLE_display_timing = true;
@ -1030,6 +1038,13 @@ filter_device_features(struct vk_bundle *vk,
};
#endif
#ifdef VK_ANDROID_external_format_resolve
VkPhysicalDeviceExternalFormatResolveFeaturesANDROID ext_fmt_resolve_info = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FORMAT_RESOLVE_FEATURES_ANDROID,
.pNext = NULL,
};
#endif
VkPhysicalDeviceFeatures2 physical_device_features = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
.pNext = NULL,
@ -1056,6 +1071,13 @@ filter_device_features(struct vk_bundle *vk,
}
#endif
#ifdef VK_ANDROID_external_format_resolve
if (vk->has_ANDROID_external_format_resolve) {
append_to_pnext_chain((VkBaseInStructure *)&physical_device_features,
(VkBaseInStructure *)&ext_fmt_resolve_info);
}
#endif
vk->vkGetPhysicalDeviceFeatures2( //
physical_device, // physicalDevice
&physical_device_features); // pFeatures
@ -1079,6 +1101,10 @@ filter_device_features(struct vk_bundle *vk,
CHECK(synchronization_2, synchronization_2_info.synchronization2);
#endif
#ifdef VK_ANDROID_external_format_resolve
CHECK(ext_fmt_resolve, ext_fmt_resolve_info.externalFormatResolve);
#endif
CHECK(shader_image_gather_extended, physical_device_features.features.shaderImageGatherExtended);
CHECK(shader_storage_image_write_without_format,
@ -1243,6 +1269,14 @@ vk_create_device(struct vk_bundle *vk,
};
#endif
#ifdef VK_ANDROID_external_format_resolve
VkPhysicalDeviceExternalFormatResolveFeaturesANDROID ext_fmt_resolve_info = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FORMAT_RESOLVE_FEATURES_ANDROID,
.pNext = NULL,
.externalFormatResolve = device_features.ext_fmt_resolve,
};
#endif
VkPhysicalDeviceFeatures enabled_features = {
.shaderImageGatherExtended = device_features.shader_image_gather_extended,
.shaderStorageImageWriteWithoutFormat = device_features.shader_storage_image_write_without_format,
@ -1277,6 +1311,13 @@ vk_create_device(struct vk_bundle *vk,
}
#endif
#ifdef VK_ANDROID_external_format_resolve
if (vk->has_ANDROID_external_format_resolve) {
append_to_pnext_chain((VkBaseInStructure *)&device_create_info,
(VkBaseInStructure *)&ext_fmt_resolve_info);
}
#endif
ret = vk->vkCreateDevice(vk->physical_device, &device_create_info, NULL, &vk->device);
u_string_list_destroy(&device_ext_list);

View file

@ -142,6 +142,7 @@ struct vk_bundle
bool has_EXT_global_priority;
bool has_EXT_image_drm_format_modifier;
bool has_EXT_robustness2;
bool has_ANDROID_external_format_resolve;
bool has_GOOGLE_display_timing;
// end of GENERATED device extension code - do not modify - used by scripts
@ -996,6 +997,7 @@ struct vk_device_features
bool null_descriptor;
bool timeline_semaphore;
bool synchronization_2;
bool ext_fmt_resolve;
};
/*!

View file

@ -556,7 +556,11 @@ static const char *optional_device_extensions[] = {
VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME, //
#elif defined(XRT_GRAPHICS_SYNC_HANDLE_IS_WIN32_HANDLE) // Not optional
#elif defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER)
#if defined(VK_ANDROID_external_format_resolve)
// Requires Vulkan 1.3.268.1
VK_ANDROID_EXTERNAL_FORMAT_RESOLVE_EXTENSION_NAME //
#endif
#else
#error "Need port!"
#endif