Loading vulkan/include/vulkan/vk_android_native_buffer.h +42 −4 Original line number Original line Diff line number Diff line Loading @@ -49,7 +49,13 @@ extern "C" { * in VkBindImageMemorySwapchainInfoKHR will be additionally chained to the * in VkBindImageMemorySwapchainInfoKHR will be additionally chained to the * pNext chain of VkBindImageMemoryInfo and passed down to the driver. * pNext chain of VkBindImageMemoryInfo and passed down to the driver. */ */ #define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 8 /* * NOTE ON VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 9 * * This version of the extension is largely designed to clean up the mix of * GrallocUsage and GrallocUsage2 */ #define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 9 #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer" #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer" #define VK_ANDROID_NATIVE_BUFFER_ENUM(type, id) \ #define VK_ANDROID_NATIVE_BUFFER_ENUM(type, id) \ Loading @@ -61,6 +67,8 @@ extern "C" { VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 1) VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 1) #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID \ #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID \ VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 2) VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 2) #define VK_STRUCTURE_TYPE_GRALLOC_USAGE_INFO_ANDROID \ VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 3) /* clang-format off */ /* clang-format off */ typedef enum VkSwapchainImageUsageFlagBitsANDROID { typedef enum VkSwapchainImageUsageFlagBitsANDROID { Loading Loading @@ -90,6 +98,7 @@ typedef struct { * format: gralloc format requested when the buffer was allocated * format: gralloc format requested when the buffer was allocated * usage: gralloc usage requested when the buffer was allocated * usage: gralloc usage requested when the buffer was allocated * usage2: gralloc usage requested when the buffer was allocated * usage2: gralloc usage requested when the buffer was allocated * usage3: gralloc usage requested when the buffer was allocated */ */ typedef struct { typedef struct { VkStructureType sType; VkStructureType sType; Loading @@ -98,7 +107,8 @@ typedef struct { int stride; int stride; int format; int format; int usage; /* DEPRECATED in SPEC_VERSION 6 */ int usage; /* DEPRECATED in SPEC_VERSION 6 */ VkNativeBufferUsage2ANDROID usage2; /* ADDED in SPEC_VERSION 6 */ VkNativeBufferUsage2ANDROID usage2; /* DEPRECATED in SPEC_VERSION 9 */ uint64_t usage3; /* ADDED in SPEC_VERSION 9 */ } VkNativeBufferANDROID; } VkNativeBufferANDROID; /* /* Loading Loading @@ -127,6 +137,21 @@ typedef struct { VkBool32 sharedImage; VkBool32 sharedImage; } VkPhysicalDevicePresentationPropertiesANDROID; } VkPhysicalDevicePresentationPropertiesANDROID; /* * struct VkGrallocUsageInfoANDROID * * sType: VK_STRUCTURE_TYPE_GRALLOC_USAGE_INFO_ANDROID * pNext: NULL or a pointer to a structure extending this structure * format: value specifying the format the image will be created with * imageUsage: bitmask of VkImageUsageFlagBits describing intended usage */ typedef struct { VkStructureType sType; const void* pNext; VkFormat format; VkImageUsageFlags imageUsage; } VkGrallocUsageInfoANDROID; /* DEPRECATED in SPEC_VERSION 6 */ /* DEPRECATED in SPEC_VERSION 6 */ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)( typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)( VkDevice device, VkDevice device, Loading @@ -134,7 +159,7 @@ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)( VkImageUsageFlags imageUsage, VkImageUsageFlags imageUsage, int* grallocUsage); int* grallocUsage); /* ADDED in SPEC_VERSION 6 */ /* DEPRECATED in SPEC_VERSION 9 */ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)( typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)( VkDevice device, VkDevice device, VkFormat format, VkFormat format, Loading @@ -143,6 +168,12 @@ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)( uint64_t* grallocConsumerUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage); uint64_t* grallocProducerUsage); /* ADDED in SPEC_VERSION 9 */ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage3ANDROID)( VkDevice device, const VkGrallocUsageInfoANDROID* grallocUsageInfo, uint64_t* grallocUsage); typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageANDROID)( typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageANDROID)( VkDevice device, VkDevice device, VkImage image, VkImage image, Loading @@ -167,7 +198,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID( int* grallocUsage int* grallocUsage ); ); /* ADDED in SPEC_VERSION 6 */ /* DEPRECATED in SPEC_VERSION 9 */ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID( VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID( VkDevice device, VkDevice device, VkFormat format, VkFormat format, Loading @@ -177,6 +208,13 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID( uint64_t* grallocProducerUsage uint64_t* grallocProducerUsage ); ); /* ADDED in SPEC_VERSION 9 */ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage3ANDROID( VkDevice device, const VkGrallocUsageInfoANDROID* grallocUsageInfo, uint64_t* grallocUsage ); VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID( VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID( VkDevice device, VkDevice device, VkImage image, VkImage image, Loading vulkan/libvulkan/driver.cpp +147 −7 Original line number Original line Diff line number Diff line Loading @@ -1027,6 +1027,39 @@ void QueryPresentationProperties( } } } } bool GetAndroidNativeBufferSpecVersion9Support( VkPhysicalDevice physicalDevice) { const InstanceData& data = GetData(physicalDevice); // Call to get propertyCount uint32_t propertyCount = 0; ATRACE_BEGIN("driver.EnumerateDeviceExtensionProperties"); VkResult result = data.driver.EnumerateDeviceExtensionProperties( physicalDevice, nullptr, &propertyCount, nullptr); ATRACE_END(); // Call to enumerate properties std::vector<VkExtensionProperties> properties(propertyCount); ATRACE_BEGIN("driver.EnumerateDeviceExtensionProperties"); result = data.driver.EnumerateDeviceExtensionProperties( physicalDevice, nullptr, &propertyCount, properties.data()); ATRACE_END(); for (uint32_t i = 0; i < propertyCount; i++) { auto& prop = properties[i]; if (strcmp(prop.extensionName, VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME) != 0) continue; if (prop.specVersion >= 9) { return true; } } return false; } VkResult EnumerateDeviceExtensionProperties( VkResult EnumerateDeviceExtensionProperties( VkPhysicalDevice physicalDevice, VkPhysicalDevice physicalDevice, const char* pLayerName, const char* pLayerName, Loading Loading @@ -1061,6 +1094,37 @@ VkResult EnumerateDeviceExtensionProperties( VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION}); VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION}); } } // Conditionally add VK_EXT_IMAGE_COMPRESSION_CONTROL* if feature and ANB // support is provided by the driver VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT swapchainCompFeats = {}; swapchainCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT; swapchainCompFeats.pNext = nullptr; VkPhysicalDeviceImageCompressionControlFeaturesEXT imageCompFeats = {}; imageCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT; imageCompFeats.pNext = &swapchainCompFeats; VkPhysicalDeviceFeatures2 feats2 = {}; feats2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; feats2.pNext = &imageCompFeats; GetPhysicalDeviceFeatures2(physicalDevice, &feats2); bool anb9 = GetAndroidNativeBufferSpecVersion9Support(physicalDevice); if (anb9 && imageCompFeats.imageCompressionControl) { loader_extensions.push_back( {VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME, VK_EXT_IMAGE_COMPRESSION_CONTROL_SPEC_VERSION}); } if (anb9 && swapchainCompFeats.imageCompressionControlSwapchain) { loader_extensions.push_back( {VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_EXTENSION_NAME, VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_SPEC_VERSION}); } // enumerate our extensions first // enumerate our extensions first if (!pLayerName && pProperties) { if (!pLayerName && pProperties) { uint32_t count = std::min( uint32_t count = std::min( Loading Loading @@ -1254,15 +1318,18 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice, return VK_ERROR_INCOMPATIBLE_DRIVER; return VK_ERROR_INCOMPATIBLE_DRIVER; } } // sanity check ANDROID_native_buffer implementation, whose set of // Confirming ANDROID_native_buffer implementation, whose set of // entrypoints varies according to the spec version. // entrypoints varies according to the spec version. if ((wrapper.GetHalExtensions()[ProcHook::ANDROID_native_buffer]) && if ((wrapper.GetHalExtensions()[ProcHook::ANDROID_native_buffer]) && !data->driver.GetSwapchainGrallocUsageANDROID && !data->driver.GetSwapchainGrallocUsageANDROID && !data->driver.GetSwapchainGrallocUsage2ANDROID) { !data->driver.GetSwapchainGrallocUsage2ANDROID && ALOGE("Driver's implementation of ANDROID_native_buffer is broken;" !data->driver.GetSwapchainGrallocUsage3ANDROID) { ALOGE( "Driver's implementation of ANDROID_native_buffer is broken;" " must expose at least one of " " must expose at least one of " "vkGetSwapchainGrallocUsageANDROID or " "vkGetSwapchainGrallocUsageANDROID or " "vkGetSwapchainGrallocUsage2ANDROID"); "vkGetSwapchainGrallocUsage2ANDROID or " "vkGetSwapchainGrallocUsage3ANDROID"); data->driver.DestroyDevice(dev, pAllocator); data->driver.DestroyDevice(dev, pAllocator); FreeDeviceData(data, data_allocator); FreeDeviceData(data, data_allocator); Loading Loading @@ -1441,10 +1508,83 @@ void GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, if (driver.GetPhysicalDeviceFeatures2) { if (driver.GetPhysicalDeviceFeatures2) { driver.GetPhysicalDeviceFeatures2(physicalDevice, pFeatures); driver.GetPhysicalDeviceFeatures2(physicalDevice, pFeatures); } else { driver.GetPhysicalDeviceFeatures2KHR(physicalDevice, pFeatures); } // Conditionally add imageCompressionControlSwapchain if // imageCompressionControl is supported Check for imageCompressionControl in // the pChain bool imageCompressionControl = false; bool imageCompressionControlInChain = false; bool imageCompressionControlSwapchainInChain = false; VkPhysicalDeviceFeatures2* pFeats = pFeatures; while (pFeats) { switch (pFeats->sType) { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT: { const VkPhysicalDeviceImageCompressionControlFeaturesEXT* compressionFeat = reinterpret_cast< const VkPhysicalDeviceImageCompressionControlFeaturesEXT*>( pFeats); imageCompressionControl = compressionFeat->imageCompressionControl; imageCompressionControlInChain = true; } break; case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT: { imageCompressionControlSwapchainInChain = true; } break; default: break; } pFeats = reinterpret_cast<VkPhysicalDeviceFeatures2*>(pFeats->pNext); } if (!imageCompressionControlSwapchainInChain) { return; return; } } driver.GetPhysicalDeviceFeatures2KHR(physicalDevice, pFeatures); // If not in pchain, explicitly query for imageCompressionControl if (!imageCompressionControlInChain) { VkPhysicalDeviceImageCompressionControlFeaturesEXT imageCompFeats = {}; imageCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT; imageCompFeats.pNext = nullptr; VkPhysicalDeviceFeatures2 feats2 = {}; feats2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; feats2.pNext = &imageCompFeats; if (driver.GetPhysicalDeviceFeatures2) { driver.GetPhysicalDeviceFeatures2(physicalDevice, &feats2); } else { driver.GetPhysicalDeviceFeatures2KHR(physicalDevice, &feats2); } imageCompressionControl = imageCompFeats.imageCompressionControl; } // Only enumerate imageCompressionControlSwapchin if imageCompressionControl if (imageCompressionControl) { pFeats = pFeatures; while (pFeats) { switch (pFeats->sType) { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT: { VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT* compressionFeat = reinterpret_cast< VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT*>( pFeats); compressionFeat->imageCompressionControlSwapchain = true; } break; default: break; } pFeats = reinterpret_cast<VkPhysicalDeviceFeatures2*>(pFeats->pNext); } } } } void GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, void GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, Loading vulkan/libvulkan/driver.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -107,6 +107,8 @@ void QueryPresentationProperties( VkPhysicalDevice physicalDevice, VkPhysicalDevice physicalDevice, VkPhysicalDevicePresentationPropertiesANDROID* presentation_properties); VkPhysicalDevicePresentationPropertiesANDROID* presentation_properties); bool GetAndroidNativeBufferSpecVersion9Support(VkPhysicalDevice physicalDevice); VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* pName); const char* pName); VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, Loading vulkan/libvulkan/driver_gen.cpp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -495,6 +495,13 @@ const ProcHook g_proc_hooks[] = { nullptr, nullptr, nullptr, nullptr, }, }, { "vkGetSwapchainGrallocUsage3ANDROID", ProcHook::DEVICE, ProcHook::ANDROID_native_buffer, nullptr, nullptr, }, { { "vkGetSwapchainGrallocUsageANDROID", "vkGetSwapchainGrallocUsageANDROID", ProcHook::DEVICE, ProcHook::DEVICE, Loading Loading @@ -664,6 +671,7 @@ bool InitDriverTable(VkDevice dev, INIT_PROC(false, dev, GetDeviceQueue2); INIT_PROC(false, dev, GetDeviceQueue2); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage2ANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage2ANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage3ANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, AcquireImageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, AcquireImageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, QueueSignalReleaseImageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, QueueSignalReleaseImageANDROID); // clang-format on // clang-format on Loading vulkan/libvulkan/driver_gen.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -123,6 +123,7 @@ struct DeviceDriverTable { PFN_vkGetDeviceQueue2 GetDeviceQueue2; PFN_vkGetDeviceQueue2 GetDeviceQueue2; PFN_vkGetSwapchainGrallocUsageANDROID GetSwapchainGrallocUsageANDROID; PFN_vkGetSwapchainGrallocUsageANDROID GetSwapchainGrallocUsageANDROID; PFN_vkGetSwapchainGrallocUsage2ANDROID GetSwapchainGrallocUsage2ANDROID; PFN_vkGetSwapchainGrallocUsage2ANDROID GetSwapchainGrallocUsage2ANDROID; PFN_vkGetSwapchainGrallocUsage3ANDROID GetSwapchainGrallocUsage3ANDROID; PFN_vkAcquireImageANDROID AcquireImageANDROID; PFN_vkAcquireImageANDROID AcquireImageANDROID; PFN_vkQueueSignalReleaseImageANDROID QueueSignalReleaseImageANDROID; PFN_vkQueueSignalReleaseImageANDROID QueueSignalReleaseImageANDROID; // clang-format on // clang-format on Loading Loading
vulkan/include/vulkan/vk_android_native_buffer.h +42 −4 Original line number Original line Diff line number Diff line Loading @@ -49,7 +49,13 @@ extern "C" { * in VkBindImageMemorySwapchainInfoKHR will be additionally chained to the * in VkBindImageMemorySwapchainInfoKHR will be additionally chained to the * pNext chain of VkBindImageMemoryInfo and passed down to the driver. * pNext chain of VkBindImageMemoryInfo and passed down to the driver. */ */ #define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 8 /* * NOTE ON VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 9 * * This version of the extension is largely designed to clean up the mix of * GrallocUsage and GrallocUsage2 */ #define VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION 9 #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer" #define VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME "VK_ANDROID_native_buffer" #define VK_ANDROID_NATIVE_BUFFER_ENUM(type, id) \ #define VK_ANDROID_NATIVE_BUFFER_ENUM(type, id) \ Loading @@ -61,6 +67,8 @@ extern "C" { VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 1) VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 1) #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID \ #define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID \ VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 2) VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 2) #define VK_STRUCTURE_TYPE_GRALLOC_USAGE_INFO_ANDROID \ VK_ANDROID_NATIVE_BUFFER_ENUM(VkStructureType, 3) /* clang-format off */ /* clang-format off */ typedef enum VkSwapchainImageUsageFlagBitsANDROID { typedef enum VkSwapchainImageUsageFlagBitsANDROID { Loading Loading @@ -90,6 +98,7 @@ typedef struct { * format: gralloc format requested when the buffer was allocated * format: gralloc format requested when the buffer was allocated * usage: gralloc usage requested when the buffer was allocated * usage: gralloc usage requested when the buffer was allocated * usage2: gralloc usage requested when the buffer was allocated * usage2: gralloc usage requested when the buffer was allocated * usage3: gralloc usage requested when the buffer was allocated */ */ typedef struct { typedef struct { VkStructureType sType; VkStructureType sType; Loading @@ -98,7 +107,8 @@ typedef struct { int stride; int stride; int format; int format; int usage; /* DEPRECATED in SPEC_VERSION 6 */ int usage; /* DEPRECATED in SPEC_VERSION 6 */ VkNativeBufferUsage2ANDROID usage2; /* ADDED in SPEC_VERSION 6 */ VkNativeBufferUsage2ANDROID usage2; /* DEPRECATED in SPEC_VERSION 9 */ uint64_t usage3; /* ADDED in SPEC_VERSION 9 */ } VkNativeBufferANDROID; } VkNativeBufferANDROID; /* /* Loading Loading @@ -127,6 +137,21 @@ typedef struct { VkBool32 sharedImage; VkBool32 sharedImage; } VkPhysicalDevicePresentationPropertiesANDROID; } VkPhysicalDevicePresentationPropertiesANDROID; /* * struct VkGrallocUsageInfoANDROID * * sType: VK_STRUCTURE_TYPE_GRALLOC_USAGE_INFO_ANDROID * pNext: NULL or a pointer to a structure extending this structure * format: value specifying the format the image will be created with * imageUsage: bitmask of VkImageUsageFlagBits describing intended usage */ typedef struct { VkStructureType sType; const void* pNext; VkFormat format; VkImageUsageFlags imageUsage; } VkGrallocUsageInfoANDROID; /* DEPRECATED in SPEC_VERSION 6 */ /* DEPRECATED in SPEC_VERSION 6 */ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)( typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)( VkDevice device, VkDevice device, Loading @@ -134,7 +159,7 @@ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsageANDROID)( VkImageUsageFlags imageUsage, VkImageUsageFlags imageUsage, int* grallocUsage); int* grallocUsage); /* ADDED in SPEC_VERSION 6 */ /* DEPRECATED in SPEC_VERSION 9 */ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)( typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)( VkDevice device, VkDevice device, VkFormat format, VkFormat format, Loading @@ -143,6 +168,12 @@ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage2ANDROID)( uint64_t* grallocConsumerUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage); uint64_t* grallocProducerUsage); /* ADDED in SPEC_VERSION 9 */ typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainGrallocUsage3ANDROID)( VkDevice device, const VkGrallocUsageInfoANDROID* grallocUsageInfo, uint64_t* grallocUsage); typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageANDROID)( typedef VkResult (VKAPI_PTR *PFN_vkAcquireImageANDROID)( VkDevice device, VkDevice device, VkImage image, VkImage image, Loading @@ -167,7 +198,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID( int* grallocUsage int* grallocUsage ); ); /* ADDED in SPEC_VERSION 6 */ /* DEPRECATED in SPEC_VERSION 9 */ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID( VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID( VkDevice device, VkDevice device, VkFormat format, VkFormat format, Loading @@ -177,6 +208,13 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID( uint64_t* grallocProducerUsage uint64_t* grallocProducerUsage ); ); /* ADDED in SPEC_VERSION 9 */ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage3ANDROID( VkDevice device, const VkGrallocUsageInfoANDROID* grallocUsageInfo, uint64_t* grallocUsage ); VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID( VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID( VkDevice device, VkDevice device, VkImage image, VkImage image, Loading
vulkan/libvulkan/driver.cpp +147 −7 Original line number Original line Diff line number Diff line Loading @@ -1027,6 +1027,39 @@ void QueryPresentationProperties( } } } } bool GetAndroidNativeBufferSpecVersion9Support( VkPhysicalDevice physicalDevice) { const InstanceData& data = GetData(physicalDevice); // Call to get propertyCount uint32_t propertyCount = 0; ATRACE_BEGIN("driver.EnumerateDeviceExtensionProperties"); VkResult result = data.driver.EnumerateDeviceExtensionProperties( physicalDevice, nullptr, &propertyCount, nullptr); ATRACE_END(); // Call to enumerate properties std::vector<VkExtensionProperties> properties(propertyCount); ATRACE_BEGIN("driver.EnumerateDeviceExtensionProperties"); result = data.driver.EnumerateDeviceExtensionProperties( physicalDevice, nullptr, &propertyCount, properties.data()); ATRACE_END(); for (uint32_t i = 0; i < propertyCount; i++) { auto& prop = properties[i]; if (strcmp(prop.extensionName, VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME) != 0) continue; if (prop.specVersion >= 9) { return true; } } return false; } VkResult EnumerateDeviceExtensionProperties( VkResult EnumerateDeviceExtensionProperties( VkPhysicalDevice physicalDevice, VkPhysicalDevice physicalDevice, const char* pLayerName, const char* pLayerName, Loading Loading @@ -1061,6 +1094,37 @@ VkResult EnumerateDeviceExtensionProperties( VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION}); VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION}); } } // Conditionally add VK_EXT_IMAGE_COMPRESSION_CONTROL* if feature and ANB // support is provided by the driver VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT swapchainCompFeats = {}; swapchainCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT; swapchainCompFeats.pNext = nullptr; VkPhysicalDeviceImageCompressionControlFeaturesEXT imageCompFeats = {}; imageCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT; imageCompFeats.pNext = &swapchainCompFeats; VkPhysicalDeviceFeatures2 feats2 = {}; feats2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; feats2.pNext = &imageCompFeats; GetPhysicalDeviceFeatures2(physicalDevice, &feats2); bool anb9 = GetAndroidNativeBufferSpecVersion9Support(physicalDevice); if (anb9 && imageCompFeats.imageCompressionControl) { loader_extensions.push_back( {VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME, VK_EXT_IMAGE_COMPRESSION_CONTROL_SPEC_VERSION}); } if (anb9 && swapchainCompFeats.imageCompressionControlSwapchain) { loader_extensions.push_back( {VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_EXTENSION_NAME, VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_SPEC_VERSION}); } // enumerate our extensions first // enumerate our extensions first if (!pLayerName && pProperties) { if (!pLayerName && pProperties) { uint32_t count = std::min( uint32_t count = std::min( Loading Loading @@ -1254,15 +1318,18 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice, return VK_ERROR_INCOMPATIBLE_DRIVER; return VK_ERROR_INCOMPATIBLE_DRIVER; } } // sanity check ANDROID_native_buffer implementation, whose set of // Confirming ANDROID_native_buffer implementation, whose set of // entrypoints varies according to the spec version. // entrypoints varies according to the spec version. if ((wrapper.GetHalExtensions()[ProcHook::ANDROID_native_buffer]) && if ((wrapper.GetHalExtensions()[ProcHook::ANDROID_native_buffer]) && !data->driver.GetSwapchainGrallocUsageANDROID && !data->driver.GetSwapchainGrallocUsageANDROID && !data->driver.GetSwapchainGrallocUsage2ANDROID) { !data->driver.GetSwapchainGrallocUsage2ANDROID && ALOGE("Driver's implementation of ANDROID_native_buffer is broken;" !data->driver.GetSwapchainGrallocUsage3ANDROID) { ALOGE( "Driver's implementation of ANDROID_native_buffer is broken;" " must expose at least one of " " must expose at least one of " "vkGetSwapchainGrallocUsageANDROID or " "vkGetSwapchainGrallocUsageANDROID or " "vkGetSwapchainGrallocUsage2ANDROID"); "vkGetSwapchainGrallocUsage2ANDROID or " "vkGetSwapchainGrallocUsage3ANDROID"); data->driver.DestroyDevice(dev, pAllocator); data->driver.DestroyDevice(dev, pAllocator); FreeDeviceData(data, data_allocator); FreeDeviceData(data, data_allocator); Loading Loading @@ -1441,10 +1508,83 @@ void GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, if (driver.GetPhysicalDeviceFeatures2) { if (driver.GetPhysicalDeviceFeatures2) { driver.GetPhysicalDeviceFeatures2(physicalDevice, pFeatures); driver.GetPhysicalDeviceFeatures2(physicalDevice, pFeatures); } else { driver.GetPhysicalDeviceFeatures2KHR(physicalDevice, pFeatures); } // Conditionally add imageCompressionControlSwapchain if // imageCompressionControl is supported Check for imageCompressionControl in // the pChain bool imageCompressionControl = false; bool imageCompressionControlInChain = false; bool imageCompressionControlSwapchainInChain = false; VkPhysicalDeviceFeatures2* pFeats = pFeatures; while (pFeats) { switch (pFeats->sType) { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT: { const VkPhysicalDeviceImageCompressionControlFeaturesEXT* compressionFeat = reinterpret_cast< const VkPhysicalDeviceImageCompressionControlFeaturesEXT*>( pFeats); imageCompressionControl = compressionFeat->imageCompressionControl; imageCompressionControlInChain = true; } break; case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT: { imageCompressionControlSwapchainInChain = true; } break; default: break; } pFeats = reinterpret_cast<VkPhysicalDeviceFeatures2*>(pFeats->pNext); } if (!imageCompressionControlSwapchainInChain) { return; return; } } driver.GetPhysicalDeviceFeatures2KHR(physicalDevice, pFeatures); // If not in pchain, explicitly query for imageCompressionControl if (!imageCompressionControlInChain) { VkPhysicalDeviceImageCompressionControlFeaturesEXT imageCompFeats = {}; imageCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT; imageCompFeats.pNext = nullptr; VkPhysicalDeviceFeatures2 feats2 = {}; feats2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; feats2.pNext = &imageCompFeats; if (driver.GetPhysicalDeviceFeatures2) { driver.GetPhysicalDeviceFeatures2(physicalDevice, &feats2); } else { driver.GetPhysicalDeviceFeatures2KHR(physicalDevice, &feats2); } imageCompressionControl = imageCompFeats.imageCompressionControl; } // Only enumerate imageCompressionControlSwapchin if imageCompressionControl if (imageCompressionControl) { pFeats = pFeatures; while (pFeats) { switch (pFeats->sType) { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT: { VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT* compressionFeat = reinterpret_cast< VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT*>( pFeats); compressionFeat->imageCompressionControlSwapchain = true; } break; default: break; } pFeats = reinterpret_cast<VkPhysicalDeviceFeatures2*>(pFeats->pNext); } } } } void GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, void GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, Loading
vulkan/libvulkan/driver.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -107,6 +107,8 @@ void QueryPresentationProperties( VkPhysicalDevice physicalDevice, VkPhysicalDevice physicalDevice, VkPhysicalDevicePresentationPropertiesANDROID* presentation_properties); VkPhysicalDevicePresentationPropertiesANDROID* presentation_properties); bool GetAndroidNativeBufferSpecVersion9Support(VkPhysicalDevice physicalDevice); VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* pName); const char* pName); VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, VKAPI_ATTR PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, Loading
vulkan/libvulkan/driver_gen.cpp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -495,6 +495,13 @@ const ProcHook g_proc_hooks[] = { nullptr, nullptr, nullptr, nullptr, }, }, { "vkGetSwapchainGrallocUsage3ANDROID", ProcHook::DEVICE, ProcHook::ANDROID_native_buffer, nullptr, nullptr, }, { { "vkGetSwapchainGrallocUsageANDROID", "vkGetSwapchainGrallocUsageANDROID", ProcHook::DEVICE, ProcHook::DEVICE, Loading Loading @@ -664,6 +671,7 @@ bool InitDriverTable(VkDevice dev, INIT_PROC(false, dev, GetDeviceQueue2); INIT_PROC(false, dev, GetDeviceQueue2); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage2ANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage2ANDROID); INIT_PROC_EXT(ANDROID_native_buffer, false, dev, GetSwapchainGrallocUsage3ANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, AcquireImageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, AcquireImageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, QueueSignalReleaseImageANDROID); INIT_PROC_EXT(ANDROID_native_buffer, true, dev, QueueSignalReleaseImageANDROID); // clang-format on // clang-format on Loading
vulkan/libvulkan/driver_gen.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -123,6 +123,7 @@ struct DeviceDriverTable { PFN_vkGetDeviceQueue2 GetDeviceQueue2; PFN_vkGetDeviceQueue2 GetDeviceQueue2; PFN_vkGetSwapchainGrallocUsageANDROID GetSwapchainGrallocUsageANDROID; PFN_vkGetSwapchainGrallocUsageANDROID GetSwapchainGrallocUsageANDROID; PFN_vkGetSwapchainGrallocUsage2ANDROID GetSwapchainGrallocUsage2ANDROID; PFN_vkGetSwapchainGrallocUsage2ANDROID GetSwapchainGrallocUsage2ANDROID; PFN_vkGetSwapchainGrallocUsage3ANDROID GetSwapchainGrallocUsage3ANDROID; PFN_vkAcquireImageANDROID AcquireImageANDROID; PFN_vkAcquireImageANDROID AcquireImageANDROID; PFN_vkQueueSignalReleaseImageANDROID QueueSignalReleaseImageANDROID; PFN_vkQueueSignalReleaseImageANDROID QueueSignalReleaseImageANDROID; // clang-format on // clang-format on Loading