aboutsummaryrefslogtreecommitdiff
path: root/loader/loader.c
diff options
context:
space:
mode:
authorJon Ashburn <jon@lunarg.com>2015-11-06 11:02:40 -0700
committerJon Ashburn <jon@lunarg.com>2015-11-06 13:06:37 -0700
commit08d7150c2f509a793ef1faff112d96cac5bf017a (patch)
tree3573a3506f3ec697029b6e1c8e47b517288296eb /loader/loader.c
parent2ba1a459da681ddfdcc28a8e6f7ca9c162e5cb67 (diff)
downloadusermoji-08d7150c2f509a793ef1faff112d96cac5bf017a.tar.xz
loader: Convert GetInstanceProcAddr and GetDeviceProcAddr over to new semantics
As per Vulkan bug 13288. Still need to handle device extensions correctly.
Diffstat (limited to 'loader/loader.c')
-rw-r--r--loader/loader.c73
1 files changed, 27 insertions, 46 deletions
diff --git a/loader/loader.c b/loader/loader.c
index 5cef3006..d8926478 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -44,6 +44,7 @@
#include "gpa_helper.h"
#include "table_ops.h"
#include "debug_report.h"
+#include "wsi_swapchain.h"
#include "vk_icd.h"
#include "cJSON.h"
@@ -3075,52 +3076,35 @@ VkResult VKAPI loader_CreateDevice(
* @param instance
* @param pName
* @return
- * If instance == NULL returns a global level entrypoint for all core entry points
- * If instance is valid returns a instance relative entry point for instance level
- * entry points both core and extensions.
- * Instance relative means call down the instance chain. Global means trampoline entry points.
+ * If instance == NULL returns a global level functions only
+ * If instance is valid returns a trampoline entry point for all dispatchable Vulkan
+ * functions both core and extensions.
*/
LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(VkInstance instance, const char * pName)
{
void *addr;
+ addr = globalGetProcAddr(pName);
if (instance == VK_NULL_HANDLE) {
- /* get entrypoint addresses that are global (in the loader),
- doesn't include any instance extensions since they may not be enabled yet*/
-
- addr = globalGetProcAddr(pName);
-
- return addr;
- }
-
+ // get entrypoint addresses that are global (no dispatchable object)
- /* return any instance entrypoints that must resolve to loader code */
- addr = loader_non_passthrough_gipa(pName);
- if (addr) {
return addr;
+ } else {
+ // if a global entrypoint return NULL
+ if (addr)
+ return NULL;
}
- /* debug_report is a special case; need to return loader trampoline entrypoints
- * unless the extension is not enabled; also need to handle debug_report
- * utility functions */
struct loader_instance *ptr_instance = loader_get_instance(instance);
- if (debug_report_instance_gpa(ptr_instance, pName, &addr)) {
- return addr;
- }
-
- /* return the instance dispatch table entrypoint for core and extensions */
- const VkLayerInstanceDispatchTable *disp_table = * (VkLayerInstanceDispatchTable **) instance;
- if (disp_table == NULL)
+ if (ptr_instance == NULL)
return NULL;
+ // Return trampoline code for non-global entrypoints including any extensions.
+ // Device extensions are returned if a layer or ICD supports the extension.
+ // Instance extensions are returned if the extension is enabled and the loader
+ // or someone else supports the extension
+ return trampolineGetProcAddr(ptr_instance, pName);
- addr = loader_lookup_instance_dispatch_table(disp_table, pName);
- if (addr)
- return addr;
-
- // NOTE: any instance extensions must be known to loader and resolved
- // in the above call to loader_lookup_instance_dispatch_table())
- return NULL;
}
/**
@@ -3128,22 +3112,14 @@ LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetInstanceProcAddr(VkInstance instance
* @param device
* @param pName
* @return
- * If device == NULL, returns a global level entrypoint for all core entry points
* If device is valid, returns a device relative entry point for device level
* entry points both core and extensions.
- * Device relative means call down the device chain. Global means trampoline entry points.
+ * Device relative means call down the device chain.
*/
LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice device, const char * pName)
{
void *addr;
- if (device == VK_NULL_HANDLE) {
- /* get entrypoint addresses that are global (in the loader)*/
- addr = globalGetProcAddr(pName);
- return addr;
- }
-
-
/* for entrypoints that loader must handle (ie non-dispatchable or create object)
make sure the loader entrypoint is returned */
addr = loader_non_passthrough_gdpa(pName);
@@ -3151,6 +3127,12 @@ LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice device, cons
return addr;
}
+ /* Although CreateDevice is on device chain it's dispatchable object isn't
+ * a VkDevice or child of VkDevice so return NULL.
+ */
+ if (!strcmp(pName, "CreateDevice"))
+ return NULL;
+
/* return the dispatch table entrypoint for the fastest case */
const VkLayerDispatchTable *disp_table = * (VkLayerDispatchTable **) device;
if (disp_table == NULL)
@@ -3159,11 +3141,10 @@ LOADER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice device, cons
addr = loader_lookup_device_dispatch_table(disp_table, pName);
if (addr)
return addr;
- else {
- if (disp_table->GetDeviceProcAddr == NULL)
- return NULL;
- return disp_table->GetDeviceProcAddr(device, pName);
- }
+
+ if (disp_table->GetDeviceProcAddr == NULL)
+ return NULL;
+ return disp_table->GetDeviceProcAddr(device, pName);
}
LOADER_EXPORT VkResult VKAPI vkEnumerateInstanceExtensionProperties(