Request dma-buf Vulkan extensions

This CL adds a few Vulkan extensions to be used for importing
dma-bufs as VkImages.

In particular, we need:
  - VK_EXT_external_memory_dma_buf
  - VK_EXT_image_drm_format_modifier

BUG=chromium:996470

Change-Id: I7a3dfd0184177c756b07613fbfe140506f54584c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13783
Commit-Queue: Brian Ho <hob@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Brian Ho 2019-11-20 18:06:33 +00:00 committed by Commit Bot service account
parent 39695fd41d
commit d3123137b1
5 changed files with 29 additions and 9 deletions

View File

@ -355,6 +355,14 @@ namespace dawn_native { namespace vulkan {
extensionsToRequest.push_back(kExtensionNameKhrExternalMemoryFD);
usedKnobs.externalMemoryFD = true;
}
if (mDeviceInfo.externalMemoryDmaBuf) {
extensionsToRequest.push_back(kExtensionNameExtExternalMemoryDmaBuf);
usedKnobs.externalMemoryDmaBuf = true;
}
if (mDeviceInfo.imageDrmFormatModifier) {
extensionsToRequest.push_back(kExtensionNameExtImageDrmFormatModifier);
usedKnobs.imageDrmFormatModifier = true;
}
if (mDeviceInfo.externalMemoryZirconHandle) {
extensionsToRequest.push_back(kExtensionNameFuchsiaExternalMemory);
usedKnobs.externalMemoryZirconHandle = true;

View File

@ -119,7 +119,7 @@ namespace dawn_native { namespace vulkan {
}
MaybeError VulkanFunctions::LoadDeviceProcs(VkDevice device,
const VulkanDeviceKnobs& usedKnobs) {
const VulkanDeviceInfo& deviceInfo) {
GET_DEVICE_PROC(AllocateCommandBuffers);
GET_DEVICE_PROC(AllocateDescriptorSets);
GET_DEVICE_PROC(AllocateMemory);
@ -240,35 +240,35 @@ namespace dawn_native { namespace vulkan {
GET_DEVICE_PROC(UpdateDescriptorSets);
GET_DEVICE_PROC(WaitForFences);
if (usedKnobs.debugMarker) {
if (deviceInfo.debugMarker) {
GET_DEVICE_PROC(CmdDebugMarkerBeginEXT);
GET_DEVICE_PROC(CmdDebugMarkerEndEXT);
GET_DEVICE_PROC(CmdDebugMarkerInsertEXT);
}
if (usedKnobs.externalMemoryFD) {
if (deviceInfo.externalMemoryFD) {
GET_DEVICE_PROC(GetMemoryFdKHR);
GET_DEVICE_PROC(GetMemoryFdPropertiesKHR);
}
if (usedKnobs.externalSemaphoreFD) {
if (deviceInfo.externalSemaphoreFD) {
GET_DEVICE_PROC(ImportSemaphoreFdKHR);
GET_DEVICE_PROC(GetSemaphoreFdKHR);
}
#if VK_USE_PLATFORM_FUCHSIA
if (usedKnobs.externalMemoryZirconHandle) {
if (deviceInfo.externalMemoryZirconHandle) {
GET_DEVICE_PROC(GetMemoryZirconHandleFUCHSIA);
GET_DEVICE_PROC(GetMemoryZirconHandlePropertiesFUCHSIA);
}
if (usedKnobs.externalSemaphoreZirconHandle) {
if (deviceInfo.externalSemaphoreZirconHandle) {
GET_DEVICE_PROC(ImportSemaphoreZirconHandleFUCHSIA);
GET_DEVICE_PROC(GetSemaphoreZirconHandleFUCHSIA);
}
#endif
if (usedKnobs.swapchain) {
if (deviceInfo.swapchain) {
GET_DEVICE_PROC(CreateSwapchainKHR);
GET_DEVICE_PROC(DestroySwapchainKHR);
GET_DEVICE_PROC(GetSwapchainImagesKHR);

View File

@ -24,14 +24,14 @@ class DynamicLib;
namespace dawn_native { namespace vulkan {
struct VulkanGlobalInfo;
struct VulkanDeviceKnobs;
struct VulkanDeviceInfo;
// Stores the Vulkan entry points. Also loads them from the dynamic library
// and the vkGet*ProcAddress entry points.
struct VulkanFunctions {
MaybeError LoadGlobalProcs(const DynamicLib& vulkanLib);
MaybeError LoadInstanceProcs(VkInstance instance, const VulkanGlobalInfo& globalInfo);
MaybeError LoadDeviceProcs(VkDevice device, const VulkanDeviceKnobs& usedKnobs);
MaybeError LoadDeviceProcs(VkDevice device, const VulkanDeviceInfo& deviceInfo);
// ---------- Global procs

View File

@ -59,6 +59,8 @@ namespace dawn_native { namespace vulkan {
const char kExtensionNameKhrExternalMemoryCapabilities[] =
"VK_KHR_external_memory_capabilities";
const char kExtensionNameKhrExternalMemoryFD[] = "VK_KHR_external_memory_fd";
const char kExtensionNameExtExternalMemoryDmaBuf[] = "VK_EXT_external_memory_dma_buf";
const char kExtensionNameExtImageDrmFormatModifier[] = "VK_EXT_image_drm_format_modifier";
const char kExtensionNameFuchsiaExternalMemory[] = "VK_FUCHSIA_external_memory";
const char kExtensionNameKhrExternalSemaphore[] = "VK_KHR_external_semaphore";
const char kExtensionNameKhrExternalSemaphoreCapabilities[] =
@ -287,6 +289,12 @@ namespace dawn_native { namespace vulkan {
if (IsExtensionName(extension, kExtensionNameKhrExternalMemoryFD)) {
info.externalMemoryFD = true;
}
if (IsExtensionName(extension, kExtensionNameExtExternalMemoryDmaBuf)) {
info.externalMemoryDmaBuf = true;
}
if (IsExtensionName(extension, kExtensionNameExtImageDrmFormatModifier)) {
info.imageDrmFormatModifier = true;
}
if (IsExtensionName(extension, kExtensionNameFuchsiaExternalMemory)) {
info.externalMemoryZirconHandle = true;
}

View File

@ -36,6 +36,8 @@ namespace dawn_native { namespace vulkan {
extern const char kExtensionNameKhrExternalMemory[];
extern const char kExtensionNameKhrExternalMemoryCapabilities[];
extern const char kExtensionNameKhrExternalMemoryFD[];
extern const char kExtensionNameExtExternalMemoryDmaBuf[];
extern const char kExtensionNameExtImageDrmFormatModifier[];
extern const char kExtensionNameFuchsiaExternalMemory[];
extern const char kExtensionNameKhrExternalSemaphore[];
extern const char kExtensionNameKhrExternalSemaphoreCapabilities[];
@ -88,6 +90,8 @@ namespace dawn_native { namespace vulkan {
bool debugMarker = false;
bool externalMemory = false;
bool externalMemoryFD = false;
bool externalMemoryDmaBuf = false;
bool imageDrmFormatModifier = false;
bool externalMemoryZirconHandle = false;
bool externalSemaphore = false;
bool externalSemaphoreFD = false;