gfxstream: Clean up VK_KHR_external_memory_fd support for Linux
Reviewed-by: Aaron Ruby <aruby@blackberry.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
@@ -44,6 +44,8 @@ RESOURCE_TRACKER_ENTRIES = [
|
|||||||
# } end Warning: These need to be defined in vk.xml (currently no-op)
|
# } end Warning: These need to be defined in vk.xml (currently no-op)
|
||||||
"vkGetAndroidHardwareBufferPropertiesANDROID",
|
"vkGetAndroidHardwareBufferPropertiesANDROID",
|
||||||
"vkGetMemoryAndroidHardwareBufferANDROID",
|
"vkGetMemoryAndroidHardwareBufferANDROID",
|
||||||
|
"vkGetMemoryFdKHR",
|
||||||
|
"vkGetMemoryFdPropertiesKHR",
|
||||||
"vkCreateSamplerYcbcrConversion",
|
"vkCreateSamplerYcbcrConversion",
|
||||||
"vkDestroySamplerYcbcrConversion",
|
"vkDestroySamplerYcbcrConversion",
|
||||||
"vkCreateSamplerYcbcrConversionKHR",
|
"vkCreateSamplerYcbcrConversionKHR",
|
||||||
|
@@ -122,11 +122,12 @@ SUPPORTED_FEATURES = [
|
|||||||
"VK_MVK_moltenvk",
|
"VK_MVK_moltenvk",
|
||||||
"VK_KHR_external_semaphore_win32",
|
"VK_KHR_external_semaphore_win32",
|
||||||
"VK_KHR_external_memory_win32",
|
"VK_KHR_external_memory_win32",
|
||||||
"VK_KHR_external_memory_fd",
|
|
||||||
# Android
|
# Android
|
||||||
"VK_ANDROID_native_buffer",
|
"VK_ANDROID_native_buffer",
|
||||||
"VK_ANDROID_external_memory_android_hardware_buffer",
|
"VK_ANDROID_external_memory_android_hardware_buffer",
|
||||||
"VK_KHR_android_surface",
|
"VK_KHR_android_surface",
|
||||||
|
# Linux
|
||||||
|
"VK_KHR_external_memory_fd",
|
||||||
# Custom
|
# Custom
|
||||||
"VK_GOOGLE_gfxstream",
|
"VK_GOOGLE_gfxstream",
|
||||||
# Used in tests without proper support checks
|
# Used in tests without proper support checks
|
||||||
@@ -159,7 +160,8 @@ SUPPORTED_MODULES = {
|
|||||||
"VK_MVK_moltenvk": ["goldfish_vk_dispatch"],
|
"VK_MVK_moltenvk": ["goldfish_vk_dispatch"],
|
||||||
"VK_KHR_external_semaphore_win32" : ["goldfish_vk_dispatch"],
|
"VK_KHR_external_semaphore_win32" : ["goldfish_vk_dispatch"],
|
||||||
"VK_KHR_external_memory_win32" : ["goldfish_vk_dispatch"],
|
"VK_KHR_external_memory_win32" : ["goldfish_vk_dispatch"],
|
||||||
"VK_KHR_external_memory_fd": ["goldfish_vk_dispatch"],
|
# Host dispatch for Linux hosts + and entrypoint for guests
|
||||||
|
"VK_KHR_external_memory_fd": ["goldfish_vk_dispatch", "func_table"],
|
||||||
"VK_QNX_external_memory_screen_buffer": ["goldfish_vk_dispatch"],
|
"VK_QNX_external_memory_screen_buffer": ["goldfish_vk_dispatch"],
|
||||||
"VK_ANDROID_external_memory_android_hardware_buffer": ["func_table"],
|
"VK_ANDROID_external_memory_android_hardware_buffer": ["func_table"],
|
||||||
"VK_KHR_android_surface": ["func_table"],
|
"VK_KHR_android_surface": ["func_table"],
|
||||||
|
@@ -760,29 +760,6 @@ void gfxstream_vk_CmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult gfxstream_vk_GetMemoryFdKHR(VkDevice device, const VkMemoryGetFdInfoKHR* pGetFdInfo,
|
|
||||||
int* pFd) {
|
|
||||||
AEMU_SCOPED_TRACE("vkGetMemoryFdKHR");
|
|
||||||
VK_FROM_HANDLE(gfxstream_vk_device, gfxstream_device, device);
|
|
||||||
VkResult vkGetMemoryFdKHR_VkResult_return = (VkResult)0;
|
|
||||||
|
|
||||||
{
|
|
||||||
auto vkEnc = gfxstream::vk::ResourceTracker::getThreadLocalEncoder();
|
|
||||||
std::vector<VkMemoryGetFdInfoKHR> internal_pGetFdInfo(1);
|
|
||||||
for (uint32_t i = 0; i < 1; ++i) {
|
|
||||||
internal_pGetFdInfo[i] = pGetFdInfo[i];
|
|
||||||
/* VkMemoryGetFdInfoKHR::memory */
|
|
||||||
VK_FROM_HANDLE(gfxstream_vk_device_memory, gfxstream_memory,
|
|
||||||
internal_pGetFdInfo[i].memory);
|
|
||||||
internal_pGetFdInfo[i].memory = gfxstream_memory->internal_object;
|
|
||||||
}
|
|
||||||
auto resources = gfxstream::vk::ResourceTracker::get();
|
|
||||||
vkGetMemoryFdKHR_VkResult_return = resources->on_vkGetMemoryFdKHR(
|
|
||||||
vkEnc, VK_SUCCESS, gfxstream_device->internal_object, internal_pGetFdInfo.data(), pFd);
|
|
||||||
}
|
|
||||||
return vkGetMemoryFdKHR_VkResult_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkResult gfxstream_vk_EnumerateInstanceLayerProperties(uint32_t* pPropertyCount,
|
VkResult gfxstream_vk_EnumerateInstanceLayerProperties(uint32_t* pPropertyCount,
|
||||||
VkLayerProperties* pProperties) {
|
VkLayerProperties* pProperties) {
|
||||||
AEMU_SCOPED_TRACE("vkEnumerateInstanceLayerProperties");
|
AEMU_SCOPED_TRACE("vkEnumerateInstanceLayerProperties");
|
||||||
|
@@ -5596,6 +5596,42 @@ VkResult ResourceTracker::on_vkImportSemaphoreFdKHR(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult ResourceTracker::on_vkGetMemoryFdPropertiesKHR(
|
||||||
|
void* context, VkResult, VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, int fd,
|
||||||
|
VkMemoryFdPropertiesKHR* pMemoryFdProperties) {
|
||||||
|
#if defined(__linux__) && !defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||||
|
if (!(handleType & VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT)) {
|
||||||
|
ALOGE("%s: VK_KHR_external_memory_fd behavior not defined for handleType: 0x%x\n", __func__,
|
||||||
|
handleType);
|
||||||
|
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
|
||||||
|
}
|
||||||
|
// Sanity-check device
|
||||||
|
AutoLock<RecursiveLock> lock(mLock);
|
||||||
|
auto deviceIt = info_VkDevice.find(device);
|
||||||
|
if (deviceIt == info_VkDevice.end()) {
|
||||||
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
|
}
|
||||||
|
// TODO: Verify FD valid ?
|
||||||
|
(void)fd;
|
||||||
|
|
||||||
|
if (mCaps.vulkanCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
|
||||||
|
mCaps.vulkanCapset.colorBufferMemoryIndex = getColorBufferMemoryIndex(context, device);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMemoryTypeBits(&pMemoryFdProperties->memoryTypeBits,
|
||||||
|
mCaps.vulkanCapset.colorBufferMemoryIndex);
|
||||||
|
|
||||||
|
return VK_SUCCESS;
|
||||||
|
#else
|
||||||
|
(void)context;
|
||||||
|
(void)device;
|
||||||
|
(void)handleType;
|
||||||
|
(void)fd;
|
||||||
|
(void)pMemoryFdProperties;
|
||||||
|
return VK_ERROR_INCOMPATIBLE_DRIVER;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
VkResult ResourceTracker::on_vkGetMemoryFdKHR(void* context, VkResult, VkDevice device,
|
VkResult ResourceTracker::on_vkGetMemoryFdKHR(void* context, VkResult, VkDevice device,
|
||||||
const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd) {
|
const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd) {
|
||||||
#if defined(__linux__) && !defined(VK_USE_PLATFORM_ANDROID_KHR)
|
#if defined(__linux__) && !defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||||
|
@@ -272,6 +272,9 @@ class ResourceTracker {
|
|||||||
|
|
||||||
VkResult on_vkGetMemoryFdKHR(void* context, VkResult input_result, VkDevice device,
|
VkResult on_vkGetMemoryFdKHR(void* context, VkResult input_result, VkDevice device,
|
||||||
const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd);
|
const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd);
|
||||||
|
VkResult on_vkGetMemoryFdPropertiesKHR(void* context, VkResult input_result, VkDevice device,
|
||||||
|
VkExternalMemoryHandleTypeFlagBits handleType, int fd,
|
||||||
|
VkMemoryFdPropertiesKHR* pMemoryFdProperties);
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||||
VkResult on_vkGetMemoryZirconHandleFUCHSIA(void* context, VkResult input_result,
|
VkResult on_vkGetMemoryZirconHandleFUCHSIA(void* context, VkResult input_result,
|
||||||
|
Reference in New Issue
Block a user