The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

aux/vk: Check that native handles are importable

+41
+39
src/xrt/auxiliary/vk/vk_helpers.c
··· 341 341 #error "need port" 342 342 #endif 343 343 344 + VkPhysicalDeviceExternalImageFormatInfo external_image_format_info = { 345 + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO, 346 + .handleType = external_memory_image_create_info.handleTypes, 347 + }; 348 + 349 + VkPhysicalDeviceImageFormatInfo2 format_info = { 350 + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2, 351 + .pNext = &external_image_format_info, 352 + .format = (VkFormat)info->format, 353 + .type = VK_IMAGE_TYPE_2D, 354 + .tiling = VK_IMAGE_TILING_OPTIMAL, 355 + .usage = image_usage, 356 + }; 357 + 358 + VkExternalImageFormatProperties external_format_properties = { 359 + .sType = VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES, 360 + }; 361 + 362 + VkImageFormatProperties2 format_properties = { 363 + .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2, 364 + .pNext = &external_format_properties, 365 + }; 366 + 367 + ret = vk->vkGetPhysicalDeviceImageFormatProperties2(vk->physical_device, &format_info, &format_properties); 368 + if (ret != VK_SUCCESS) { 369 + VK_ERROR(vk, "vkGetPhysicalDeviceImageFormatProperties2: %s", vk_result_string(ret)); 370 + // Nothing to cleanup 371 + return ret; 372 + } 373 + 374 + VkExternalMemoryFeatureFlags features = 375 + external_format_properties.externalMemoryProperties.externalMemoryFeatures; 376 + 377 + if ((features & VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) == 0) { 378 + VK_ERROR(vk, "External memory handle is not importable (has features: %d)", features); 379 + return VK_ERROR_INITIALIZATION_FAILED; 380 + } 381 + 344 382 VkImageCreateInfo vk_info = { 345 383 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, 346 384 .pNext = &external_memory_image_create_info, ··· 778 816 vk->vkGetPhysicalDeviceSurfaceSupportKHR = GET_INS_PROC(vk, vkGetPhysicalDeviceSurfaceSupportKHR); 779 817 vk->vkGetPhysicalDeviceFormatProperties = GET_INS_PROC(vk, vkGetPhysicalDeviceFormatProperties); 780 818 vk->vkEnumerateDeviceExtensionProperties = GET_INS_PROC(vk, vkEnumerateDeviceExtensionProperties); 819 + vk->vkGetPhysicalDeviceImageFormatProperties2 = GET_INS_PROC(vk, vkGetPhysicalDeviceImageFormatProperties2); 781 820 782 821 #ifdef VK_USE_PLATFORM_XCB_KHR 783 822 vk->vkCreateXcbSurfaceKHR = GET_INS_PROC(vk, vkCreateXcbSurfaceKHR);
+2
src/xrt/auxiliary/vk/vk_helpers.h
··· 117 117 118 118 PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties; 119 119 120 + PFN_vkGetPhysicalDeviceImageFormatProperties2 vkGetPhysicalDeviceImageFormatProperties2; 121 + 120 122 121 123 // Device functions. 122 124 PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;