vulkan: use driver::GetData everywhere
Move away from the one-liners defined in loader.cpp.
Change-Id: I73c39cbe21aa3b2079f67590bb40f0cd55563f84
diff --git a/vulkan/libvulkan/code-generator.tmpl b/vulkan/libvulkan/code-generator.tmpl
index 5b6c6d2..afe0d84 100644
--- a/vulkan/libvulkan/code-generator.tmpl
+++ b/vulkan/libvulkan/code-generator.tmpl
@@ -219,7 +219,6 @@
#include <log/log.h>
¶
#include "driver.h"
-#include "loader.h"
¶
namespace vulkan {«
namespace driver {«
diff --git a/vulkan/libvulkan/debug_report.cpp b/vulkan/libvulkan/debug_report.cpp
index 5055640..c4a1174 100644
--- a/vulkan/libvulkan/debug_report.cpp
+++ b/vulkan/libvulkan/debug_report.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "loader.h"
+#include "driver.h"
namespace vulkan {
namespace driver {
@@ -26,24 +26,22 @@
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 @@
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 @@
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 @@
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 @@
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
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index f2f1d08..007c54d 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -23,7 +23,6 @@
#include <sys/prctl.h>
#include "driver.h"
-#include "loader.h"
// #define ENABLE_ALLOC_CALLSTACKS 1
#if ENABLE_ALLOC_CALLSTACKS
diff --git a/vulkan/libvulkan/driver.h b/vulkan/libvulkan/driver.h
index 4cc3ee7..22db93f 100644
--- a/vulkan/libvulkan/driver.h
+++ b/vulkan/libvulkan/driver.h
@@ -28,6 +28,7 @@
#include "api_gen.h"
#include "driver_gen.h"
#include "debug_report.h"
+#include "swapchain.h"
namespace vulkan {
diff --git a/vulkan/libvulkan/driver_gen.cpp b/vulkan/libvulkan/driver_gen.cpp
index 78a952a..8b816ba 100644
--- a/vulkan/libvulkan/driver_gen.cpp
+++ b/vulkan/libvulkan/driver_gen.cpp
@@ -21,7 +21,6 @@
#include <log/log.h>
#include "driver.h"
-#include "loader.h"
namespace vulkan {
namespace driver {
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 4aa1ed6..bda6676 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -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 @@
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 @@
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 @@
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 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 @@
// -- 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 @@
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 @@
}
if (!allocator)
- allocator = GetAllocator(device);
+ allocator = &GetData(device).allocator;
swapchain->~Swapchain();
allocator->pfnFree(allocator->pUserData, swapchain);
}
@@ -773,7 +773,7 @@
}
}
- 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 @@
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 =