OSDN Git Service

vulkan: Implement V7 of ANDROID_native_buffer in nulldrv
authorChris Forbes <chrisforbes@google.com>
Wed, 15 Mar 2017 03:09:15 +0000 (16:09 +1300)
committerChris Forbes <chrisforbes@google.com>
Wed, 15 Mar 2017 20:45:36 +0000 (09:45 +1300)
Walks the struct chain in GPDP2, and claims support for shared
presentable image. This is enough to have libvulkan expose the
extension for us.

Change-Id: Id22593932cd567e79d18aae788935148d6278b3f
Test: setprop ro.hardware.vulkan default, observe extension exposed

vulkan/nulldrv/null_driver.cpp

index e03ee0a..6714779 100644 (file)
@@ -513,6 +513,28 @@ void GetPhysicalDeviceProperties(VkPhysicalDevice,
 void GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physical_device,
                                   VkPhysicalDeviceProperties2KHR* properties) {
     GetPhysicalDeviceProperties(physical_device, &properties->properties);
+
+    while (properties->pNext) {
+        properties = reinterpret_cast<VkPhysicalDeviceProperties2KHR *>(properties->pNext);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wold-style-cast"
+        switch ((VkFlags)properties->sType) {
+        case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID: {
+            VkPhysicalDevicePresentationPropertiesANDROID *presentation_properties =
+                reinterpret_cast<VkPhysicalDevicePresentationPropertiesANDROID *>(properties);
+#pragma clang diagnostic pop
+
+                // Claim that we do all the right things for the loader to
+                // expose KHR_shared_presentable_image on our behalf.
+                presentation_properties->sharedImage = VK_TRUE;
+            } break;
+
+        default:
+            // Silently ignore other extension query structs
+            break;
+        }
+    }
 }
 
 void GetPhysicalDeviceQueueFamilyProperties(