From e7bf86e164e88409324fa2c8b41e0775f9d48501 Mon Sep 17 00:00:00 2001 From: Mark Young Date: Mon, 7 Nov 2016 13:27:02 -0700 Subject: loader: gh1120/gh1134 - Object wrapping issues First issue was that we needed to override vkGetDeviceProcAddr. Instead of allowing this to always go directly to the ICD, we needed to intercept a few commands because they require a loader trampoline and terminator call. Most commands still return a pointer directly to ICD command. GH1120 - Unwrap both the physical device handles and the KHR_surface handles in the loader during both the trampoline and terminator calls for DebugMarker commands. This has to be done since the values given to an application are the loader trampoline versions, and the values given to the last layer is the loader terminator versions. GH1134 - We were passing down the wrong device object to the ICD functions when querying the ICD command function address and comparing it in the override functions. Thanks to Baldur (Mr. Renderdoc) for discovering this, testing my fixes, and resolving several bugs. Change-Id: I7618d71ffee6c53d9842758210a9261f6b3a1797 --- loader/table_ops.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'loader/table_ops.h') diff --git a/loader/table_ops.h b/loader/table_ops.h index f8f72259..0e42d0ca 100644 --- a/loader/table_ops.h +++ b/loader/table_ops.h @@ -31,6 +31,7 @@ static VkResult vkDevExtError(VkDevice dev) { struct loader_device *found_dev; + // The device going in is a trampoline device struct loader_icd_term *icd_term = loader_get_icd_and_device(dev, &found_dev, NULL); @@ -541,11 +542,6 @@ loader_lookup_device_dispatch_table(const VkLayerDispatchTable *table, if (!strcmp(name, "CmdExecuteCommands")) return (void *)table->CmdExecuteCommands; - if (!strcmp(name, "CreateSwapchainKHR")) { - // For CreateSwapChainKHR we need to use trampoline and terminator - // functions to properly unwrap the SurfaceKHR object. - return (void *)vkCreateSwapchainKHR; - } if (!strcmp(name, "DestroySwapchainKHR")) return (void *)table->DestroySwapchainKHR; if (!strcmp(name, "GetSwapchainImagesKHR")) @@ -555,6 +551,20 @@ loader_lookup_device_dispatch_table(const VkLayerDispatchTable *table, if (!strcmp(name, "QueuePresentKHR")) return (void *)table->QueuePresentKHR; + // NOTE: Device Funcs needing Trampoline/Terminator. + // Overrides for device functions needing a trampoline and + // a terminator because certain device entry-points still need to go + // through a terminator before hitting the ICD. This could be for + // several reasons, but the main one is currently unwrapping an + // object before passing the appropriate info along to the ICD. + if (!strcmp(name, "CreateSwapchainKHR")) { + return (void *)vkCreateSwapchainKHR; + } else if (!strcmp(name, "DebugMarkerSetObjectTagEXT")) { + return (void *)vkDebugMarkerSetObjectTagEXT; + } else if (!strcmp(name, "DebugMarkerSetObjectNameEXT")) { + return (void *)vkDebugMarkerSetObjectNameEXT; + } + return NULL; } -- cgit v1.2.3