summaryrefslogtreecommitdiff
path: root/layers/unique_objects.cpp
diff options
context:
space:
mode:
authorMark Young <marky@lunarg.com>2017-01-19 21:10:49 -0700
committerLenny Komow <lenny@lunarg.com>2017-01-24 14:07:22 -0700
commitb5f087aec8b42faee128c5c3dd1cb11b662d85aa (patch)
tree77d57ceca8898265742478a10b051c5505c1bd5e /layers/unique_objects.cpp
parent75a442807593315f53092f56527702a7174ee1c2 (diff)
loader: Update the loader to 1.0.39
Add new extensions for 1.0.39. Also, updated layers to include minimal set of functionality for 1.0.39 extensions. Extensions include: - VK_KHR_get_physical_device_properties2 - VK_KHR_shader_draw_parameters - VK_EXT_direct_mode_display - VK_EXT_display_surface_counter - VK_EXT_display_control Also, redo the LoaderAndLayerIf document. Change-Id: I10412086da7a798afe832a3892e18f606259b5af
Diffstat (limited to 'layers/unique_objects.cpp')
-rw-r--r--layers/unique_objects.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/layers/unique_objects.cpp b/layers/unique_objects.cpp
index df03daa1..dabdc041 100644
--- a/layers/unique_objects.cpp
+++ b/layers/unique_objects.cpp
@@ -51,6 +51,8 @@
namespace unique_objects {
+static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
+
static void initUniqueObjects(layer_data *instance_data, const VkAllocationCallbacks *pAllocator) {
layer_debug_actions(instance_data->report_data, instance_data->logging_callback, pAllocator, "google_unique_objects");
}
@@ -262,11 +264,17 @@ static const VkLayerProperties globalLayerProps = {"VK_LAYER_GOOGLE_unique_objec
1, // implementationVersion
"Google Validation Layer"};
+/// Declare prototype for these functions
+VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName);
+
static inline PFN_vkVoidFunction layer_intercept_proc(const char *name) {
for (unsigned int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) {
if (!strcmp(name, procmap[i].name))
return procmap[i].pFunc;
}
+ if (0 == strcmp(name, "vk_layerGetPhysicalDeviceProcAddr")) {
+ return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr;
+ }
return NULL;
}
@@ -337,6 +345,17 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance
return disp_table->GetInstanceProcAddr(instance, funcName);
}
+VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) {
+ assert(instance);
+
+ layer_data *instance_data = get_my_data_ptr(get_dispatch_key(instance), layer_data_map);
+ VkLayerInstanceDispatchTable *disp_table = instance_data->instance_dispatch_table;
+ if (disp_table->GetPhysicalDeviceProcAddr == NULL) {
+ return NULL;
+ }
+ return disp_table->GetPhysicalDeviceProcAddr(instance, funcName);
+}
+
VKAPI_ATTR VkResult VKAPI_CALL AllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory) {
const VkMemoryAllocateInfo *input_allocate_info = pAllocateInfo;
@@ -749,3 +768,27 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionPropert
assert(physicalDevice == VK_NULL_HANDLE);
return unique_objects::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties);
}
+
+VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) {
+ return unique_objects::GetPhysicalDeviceProcAddr(instance, funcName);
+}
+
+VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) {
+ assert(pVersionStruct != NULL);
+ assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT);
+
+ // Fill in the function pointers if our version is at least capable of having the structure contain them.
+ if (pVersionStruct->loaderLayerInterfaceVersion >= 2) {
+ pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
+ pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr;
+ pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr;
+ }
+
+ if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
+ unique_objects::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion;
+ } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) {
+ pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION;
+ }
+
+ return VK_SUCCESS;
+}