Add Vulkan extensions for AHardwareBuffer support

Just adds the appropriate extensions for AHardwareBuffer support on
Android doesn't yet attempt to expose any.

Bug: dawn:286
Change-Id: I1345d98044bbcaf91cb31235bffbdc28a163c6e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Brandon Jones 2022-09-06 22:40:13 +00:00 committed by Dawn LUCI CQ
parent 11e2571aed
commit 8f3d7711d9
4 changed files with 34 additions and 15 deletions

View File

@ -36,7 +36,8 @@ declare_args() {
# Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir # Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir
# to be set to take effect. # to be set to take effect.
dawn_use_swiftshader = true # TODO(dawn:1536): Enable SwiftShader for Android.
dawn_use_swiftshader = !is_android
} }
declare_args() { declare_args() {

View File

@ -30,8 +30,7 @@ if (enable_vulkan_validation_layers) {
use_angle = dawn_use_angle && defined(dawn_angle_dir) use_angle = dawn_use_angle && defined(dawn_angle_dir)
# Swiftshader is an optional dependency, only use it if the path has been set. # Swiftshader is an optional dependency, only use it if the path has been set.
use_swiftshader = use_swiftshader = dawn_use_swiftshader && dawn_swiftshader_dir != ""
dawn_use_swiftshader && dawn_swiftshader_dir != "" && !is_android
if (use_swiftshader) { if (use_swiftshader) {
assert(dawn_enable_vulkan, assert(dawn_enable_vulkan,
"dawn_use_swiftshader requires dawn_enable_vulkan=true") "dawn_use_swiftshader requires dawn_enable_vulkan=true")

View File

@ -139,6 +139,7 @@ static constexpr std::array<DeviceExtInfo, kDeviceExtCount> sDeviceExtInfos{{
{DeviceExt::GetPhysicalDeviceProperties2, "VK_KHR_get_physical_device_properties2", {DeviceExt::GetPhysicalDeviceProperties2, "VK_KHR_get_physical_device_properties2",
VulkanVersion_1_1}, VulkanVersion_1_1},
{DeviceExt::GetMemoryRequirements2, "VK_KHR_get_memory_requirements2", VulkanVersion_1_1}, {DeviceExt::GetMemoryRequirements2, "VK_KHR_get_memory_requirements2", VulkanVersion_1_1},
{DeviceExt::DedicatedAllocation, "VK_KHR_dedicated_allocation", VulkanVersion_1_1},
{DeviceExt::ExternalMemoryCapabilities, "VK_KHR_external_memory_capabilities", {DeviceExt::ExternalMemoryCapabilities, "VK_KHR_external_memory_capabilities",
VulkanVersion_1_1}, VulkanVersion_1_1},
{DeviceExt::ExternalSemaphoreCapabilities, "VK_KHR_external_semaphore_capabilities", {DeviceExt::ExternalSemaphoreCapabilities, "VK_KHR_external_semaphore_capabilities",
@ -156,16 +157,19 @@ static constexpr std::array<DeviceExtInfo, kDeviceExtCount> sDeviceExtInfos{{
{DeviceExt::ZeroInitializeWorkgroupMemory, "VK_KHR_zero_initialize_workgroup_memory", {DeviceExt::ZeroInitializeWorkgroupMemory, "VK_KHR_zero_initialize_workgroup_memory",
VulkanVersion_1_3}, VulkanVersion_1_3},
{DeviceExt::DepthClipEnable, "VK_EXT_depth_clip_enable", NeverPromoted},
{DeviceExt::ImageDrmFormatModifier, "VK_EXT_image_drm_format_modifier", NeverPromoted},
{DeviceExt::Swapchain, "VK_KHR_swapchain", NeverPromoted},
{DeviceExt::SubgroupSizeControl, "VK_EXT_subgroup_size_control", NeverPromoted},
{DeviceExt::QueueFamilyForeign, "VK_EXT_queue_family_foreign", NeverPromoted},
{DeviceExt::ExternalMemoryAndroidHardwareBuffer,
"VK_ANDROID_external_memory_android_hardware_buffer", NeverPromoted},
{DeviceExt::ExternalMemoryFD, "VK_KHR_external_memory_fd", NeverPromoted}, {DeviceExt::ExternalMemoryFD, "VK_KHR_external_memory_fd", NeverPromoted},
{DeviceExt::ExternalMemoryDmaBuf, "VK_EXT_external_memory_dma_buf", NeverPromoted}, {DeviceExt::ExternalMemoryDmaBuf, "VK_EXT_external_memory_dma_buf", NeverPromoted},
{DeviceExt::ExternalMemoryZirconHandle, "VK_FUCHSIA_external_memory", NeverPromoted}, {DeviceExt::ExternalMemoryZirconHandle, "VK_FUCHSIA_external_memory", NeverPromoted},
{DeviceExt::ExternalSemaphoreFD, "VK_KHR_external_semaphore_fd", NeverPromoted}, {DeviceExt::ExternalSemaphoreFD, "VK_KHR_external_semaphore_fd", NeverPromoted},
{DeviceExt::ExternalSemaphoreZirconHandle, "VK_FUCHSIA_external_semaphore", NeverPromoted}, {DeviceExt::ExternalSemaphoreZirconHandle, "VK_FUCHSIA_external_semaphore", NeverPromoted},
{DeviceExt::DepthClipEnable, "VK_EXT_depth_clip_enable", NeverPromoted},
{DeviceExt::ImageDrmFormatModifier, "VK_EXT_image_drm_format_modifier", NeverPromoted},
{DeviceExt::Swapchain, "VK_KHR_swapchain", NeverPromoted},
{DeviceExt::SubgroupSizeControl, "VK_EXT_subgroup_size_control", NeverPromoted},
// //
}}; }};
@ -211,6 +215,10 @@ DeviceExtSet EnsureDependencies(const DeviceExtSet& advertisedExts,
hasDependencies = true; hasDependencies = true;
break; break;
case DeviceExt::DedicatedAllocation:
hasDependencies = HasDep(DeviceExt::GetMemoryRequirements2);
break;
// Physical device extensions technically don't require the instance to support // Physical device extensions technically don't require the instance to support
// them but VulkanFunctions only loads the function pointers if the instance // them but VulkanFunctions only loads the function pointers if the instance
// advertises the extension. So if we didn't have this check, we'd risk a calling // advertises the extension. So if we didn't have this check, we'd risk a calling
@ -258,8 +266,16 @@ DeviceExtSet EnsureDependencies(const DeviceExtSet& advertisedExts,
hasDependencies = HasDep(DeviceExt::ExternalSemaphoreCapabilities); hasDependencies = HasDep(DeviceExt::ExternalSemaphoreCapabilities);
break; break;
case DeviceExt::ExternalMemoryAndroidHardwareBuffer:
hasDependencies = HasDep(DeviceExt::ExternalMemory) &&
HasDep(DeviceExt::SamplerYCbCrConversion) &&
HasDep(DeviceExt::DedicatedAllocation) &&
HasDep(DeviceExt::QueueFamilyForeign);
break;
case DeviceExt::ExternalMemoryFD: case DeviceExt::ExternalMemoryFD:
case DeviceExt::ExternalMemoryZirconHandle: case DeviceExt::ExternalMemoryZirconHandle:
case DeviceExt::QueueFamilyForeign:
hasDependencies = HasDep(DeviceExt::ExternalMemory); hasDependencies = HasDep(DeviceExt::ExternalMemory);
break; break;

View File

@ -79,6 +79,7 @@ enum class DeviceExt {
StorageBufferStorageClass, StorageBufferStorageClass,
GetPhysicalDeviceProperties2, GetPhysicalDeviceProperties2,
GetMemoryRequirements2, GetMemoryRequirements2,
DedicatedAllocation,
ExternalMemoryCapabilities, ExternalMemoryCapabilities,
ExternalSemaphoreCapabilities, ExternalSemaphoreCapabilities,
ExternalMemory, ExternalMemory,
@ -95,18 +96,20 @@ enum class DeviceExt {
ShaderIntegerDotProduct, ShaderIntegerDotProduct,
ZeroInitializeWorkgroupMemory, ZeroInitializeWorkgroupMemory,
// External* extensions
ExternalMemoryFD,
ExternalMemoryDmaBuf,
ExternalMemoryZirconHandle,
ExternalSemaphoreFD,
ExternalSemaphoreZirconHandle,
// Others // Others
DepthClipEnable, DepthClipEnable,
ImageDrmFormatModifier, ImageDrmFormatModifier,
Swapchain, Swapchain,
SubgroupSizeControl, SubgroupSizeControl,
QueueFamilyForeign,
// External* extensions
ExternalMemoryAndroidHardwareBuffer,
ExternalMemoryFD,
ExternalMemoryDmaBuf,
ExternalMemoryZirconHandle,
ExternalSemaphoreFD,
ExternalSemaphoreZirconHandle,
EnumCount, EnumCount,
}; };