OSDN Git Service

vulkan: use driver::GetData everywhere
authorChia-I Wu <olv@google.com>
Fri, 25 Mar 2016 23:17:34 +0000 (07:17 +0800)
committerChia-I Wu <olv@google.com>
Sun, 10 Apr 2016 23:37:20 +0000 (07:37 +0800)
Move away from the one-liners defined in loader.cpp.

Change-Id: I73c39cbe21aa3b2079f67590bb40f0cd55563f84

vulkan/libvulkan/code-generator.tmpl
vulkan/libvulkan/debug_report.cpp
vulkan/libvulkan/driver.cpp
vulkan/libvulkan/driver.h
vulkan/libvulkan/driver_gen.cpp
vulkan/libvulkan/swapchain.cpp

index 5b6c6d2..afe0d84 100644 (file)
@@ -219,7 +219,6 @@ bool InitDriverTable(VkDevice dev, PFN_vkGetDeviceProcAddr get_proc);
 #include <log/log.h>
 ¶
 #include "driver.h"
-#include "loader.h"
 ¶
 namespace vulkan {«
 namespace driver {«
index 5055640..c4a1174 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "loader.h"
+#include "driver.h"
 
 namespace vulkan {
 namespace driver {
@@ -26,24 +26,22 @@ VkResult DebugReportCallbackList::CreateCallback(
     VkDebugReportCallbackEXT* callback) {
     VkDebugReportCallbackEXT driver_callback = VK_NULL_HANDLE;
 
-    if (GetDriverDispatch(instance).CreateDebugReportCallbackEXT) {
-        VkResult result =
-            GetDriverDispatch(instance).CreateDebugReportCallbackEXT(
-                GetDriverInstance(instance), create_info, allocator,
-                &driver_callback);
+    if (GetData(instance).driver.CreateDebugReportCallbackEXT) {
+        VkResult result = GetData(instance).driver.CreateDebugReportCallbackEXT(
+            instance, create_info, allocator, &driver_callback);
         if (result != VK_SUCCESS)
             return result;
     }
 
     const VkAllocationCallbacks* alloc =
-        allocator ? allocator : GetAllocator(instance);
+        allocator ? allocator : &GetData(instance).allocator;
     void* mem =
         alloc->pfnAllocation(alloc->pUserData, sizeof(Node), alignof(Node),
                              VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
     if (!mem) {
-        if (GetDriverDispatch(instance).DestroyDebugReportCallbackEXT) {
-            GetDriverDispatch(instance).DestroyDebugReportCallbackEXT(
-                GetDriverInstance(instance), driver_callback, allocator);
+        if (GetData(instance).driver.DestroyDebugReportCallbackEXT) {
+            GetData(instance).driver.DestroyDebugReportCallbackEXT(
+                instance, driver_callback, allocator);
         }
         return VK_ERROR_OUT_OF_HOST_MEMORY;
     }
@@ -69,13 +67,13 @@ void DebugReportCallbackList::DestroyCallback(
     prev->next = node->next;
     lock.unlock();
 
-    if (GetDriverDispatch(instance).DestroyDebugReportCallbackEXT) {
-        GetDriverDispatch(instance).DestroyDebugReportCallbackEXT(
-            GetDriverInstance(instance), node->driver_callback, allocator);
+    if (GetData(instance).driver.DestroyDebugReportCallbackEXT) {
+        GetData(instance).driver.DestroyDebugReportCallbackEXT(
+            instance, node->driver_callback, allocator);
     }
 
     const VkAllocationCallbacks* alloc =
-        allocator ? allocator : GetAllocator(instance);
+        allocator ? allocator : &GetData(instance).allocator;
     alloc->pfnFree(alloc->pUserData, node);
 }
 
@@ -101,7 +99,7 @@ VkResult CreateDebugReportCallbackEXT(
     const VkDebugReportCallbackCreateInfoEXT* create_info,
     const VkAllocationCallbacks* allocator,
     VkDebugReportCallbackEXT* callback) {
-    return GetDebugReportCallbacks(instance).CreateCallback(
+    return GetData(instance).debug_report_callbacks.CreateCallback(
         instance, create_info, allocator, callback);
 }
 
@@ -109,8 +107,8 @@ void DestroyDebugReportCallbackEXT(VkInstance instance,
                                    VkDebugReportCallbackEXT callback,
                                    const VkAllocationCallbacks* allocator) {
     if (callback)
-        GetDebugReportCallbacks(instance).DestroyCallback(instance, callback,
-                                                          allocator);
+        GetData(instance).debug_report_callbacks.DestroyCallback(
+            instance, callback, allocator);
 }
 
 void DebugReportMessageEXT(VkInstance instance,
@@ -121,14 +119,14 @@ void DebugReportMessageEXT(VkInstance instance,
                            int32_t message_code,
                            const char* layer_prefix,
                            const char* message) {
-    if (GetDriverDispatch(instance).DebugReportMessageEXT) {
-        GetDriverDispatch(instance).DebugReportMessageEXT(
-            GetDriverInstance(instance), flags, object_type, object, location,
-            message_code, layer_prefix, message);
+    if (GetData(instance).driver.DebugReportMessageEXT) {
+        GetData(instance).driver.DebugReportMessageEXT(
+            instance, flags, object_type, object, location, message_code,
+            layer_prefix, message);
     }
-    GetDebugReportCallbacks(instance).Message(flags, object_type, object,
-                                              location, message_code,
-                                              layer_prefix, message);
+    GetData(instance).debug_report_callbacks.Message(flags, object_type, object,
+                                                     location, message_code,
+                                                     layer_prefix, message);
 }
 
 }  // namespace driver
index f2f1d08..007c54d 100644 (file)
@@ -23,7 +23,6 @@
 #include <sys/prctl.h>
 
 #include "driver.h"
-#include "loader.h"
 
 // #define ENABLE_ALLOC_CALLSTACKS 1
 #if ENABLE_ALLOC_CALLSTACKS
index 4cc3ee7..22db93f 100644 (file)
@@ -28,6 +28,7 @@
 #include "api_gen.h"
 #include "driver_gen.h"
 #include "debug_report.h"
+#include "swapchain.h"
 
 namespace vulkan {
 
index 78a952a..8b816ba 100644 (file)
@@ -21,7 +21,6 @@
 #include <log/log.h>
 
 #include "driver.h"
-#include "loader.h"
 
 namespace vulkan {
 namespace driver {
index 4aa1ed6..bda6676 100644 (file)
@@ -21,7 +21,7 @@
 #include <log/log.h>
 #include <sync/sync.h>
 
-#include "loader.h"
+#include "driver.h"
 
 // TODO(jessehall): Currently we don't have a good error code for when a native
 // window operation fails. Just returning INITIALIZATION_FAILED for now. Later
@@ -98,9 +98,9 @@ template <typename T, typename Host>
 std::shared_ptr<T> InitSharedPtr(Host host, T* obj) {
     try {
         obj->common.incRef(&obj->common);
-        return std::shared_ptr<T>(
-            obj, NativeBaseDeleter<T>(),
-            VulkanAllocator<T>(*GetAllocator(host), AllocScope<Host>::kScope));
+        return std::shared_ptr<T>(obj, NativeBaseDeleter<T>(),
+                                  VulkanAllocator<T>(GetData(host).allocator,
+                                                     AllocScope<Host>::kScope));
     } catch (std::bad_alloc&) {
         obj->common.decRef(&obj->common);
         return nullptr;
@@ -231,7 +231,7 @@ VkResult CreateAndroidSurfaceKHR(
     const VkAllocationCallbacks* allocator,
     VkSurfaceKHR* out_surface) {
     if (!allocator)
-        allocator = GetAllocator(instance);
+        allocator = &GetData(instance).allocator;
     void* mem = allocator->pfnAllocation(allocator->pUserData, sizeof(Surface),
                                          alignof(Surface),
                                          VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@@ -274,7 +274,7 @@ void DestroySurfaceKHR(VkInstance instance,
     native_window_api_disconnect(surface->window.get(), NATIVE_WINDOW_API_EGL);
     surface->~Surface();
     if (!allocator)
-        allocator = GetAllocator(instance);
+        allocator = &GetData(instance).allocator;
     allocator->pfnFree(allocator->pUserData, surface);
 }
 
@@ -411,7 +411,7 @@ VkResult CreateSwapchainKHR(VkDevice device,
     VkResult result = VK_SUCCESS;
 
     if (!allocator)
-        allocator = GetAllocator(device);
+        allocator = &GetData(device).allocator;
 
     ALOGV_IF(create_info->imageArrayLayers != 1,
              "Swapchain imageArrayLayers (%u) != 1 not supported",
@@ -432,7 +432,7 @@ VkResult CreateSwapchainKHR(VkDevice device,
     // -- Configure the native window --
 
     Surface& surface = *SurfaceFromHandle(create_info->surface);
-    const auto& dispatch = GetDriverDispatch(device);
+    const auto& dispatch = GetData(device).driver;
 
     int native_format = HAL_PIXEL_FORMAT_RGBA_8888;
     switch (create_info->imageFormat) {
@@ -680,7 +680,7 @@ VKAPI_ATTR
 void DestroySwapchainKHR(VkDevice device,
                          VkSwapchainKHR swapchain_handle,
                          const VkAllocationCallbacks* allocator) {
-    const auto& dispatch = GetDriverDispatch(device);
+    const auto& dispatch = GetData(device).driver;
     Swapchain* swapchain = SwapchainFromHandle(swapchain_handle);
     const std::shared_ptr<ANativeWindow>& window = swapchain->surface.window;
 
@@ -698,7 +698,7 @@ void DestroySwapchainKHR(VkDevice device,
     }
 
     if (!allocator)
-        allocator = GetAllocator(device);
+        allocator = &GetData(device).allocator;
     swapchain->~Swapchain();
     allocator->pfnFree(allocator->pUserData, swapchain);
 }
@@ -773,7 +773,7 @@ VkResult AcquireNextImageKHR(VkDevice device,
         }
     }
 
-    result = GetDriverDispatch(device).AcquireImageANDROID(
+    result = GetData(device).driver.AcquireImageANDROID(
         device, swapchain.images[idx].image, fence_clone, semaphore, vk_fence);
     if (result != VK_SUCCESS) {
         // NOTE: we're relying on AcquireImageANDROID to close fence_clone,
@@ -800,7 +800,7 @@ VkResult QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) {
              present_info->sType);
     ALOGV_IF(present_info->pNext, "VkPresentInfo::pNext != NULL");
 
-    const auto& dispatch = GetDriverDispatch(queue);
+    const auto& dispatch = GetData(queue).driver;
     VkResult final_result = VK_SUCCESS;
     for (uint32_t sc = 0; sc < present_info->swapchainCount; sc++) {
         Swapchain& swapchain =