aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Ashburn <jon@lunarg.com>2016-03-31 10:52:22 -0600
committerJon Ashburn <jon@lunarg.com>2016-04-01 10:48:22 -0600
commitfff87f6cca6918c85f14c97d5f912f4b28013ce2 (patch)
tree8da6b70073cb5ac72e9cd6e35169b24ab3f5532b
parent59af5e5546006754a92b32ce31b112f9ae47f14e (diff)
downloadusermoji-fff87f6cca6918c85f14c97d5f912f4b28013ce2.tar.xz
loader: Add device callback to set dispatchable object
Change-Id: I5ca8f532e777e2cb0facf8fe5bab4c82409f8d37
-rw-r--r--include/vulkan/vk_layer.h5
-rw-r--r--loader/loader.c23
2 files changed, 26 insertions, 2 deletions
diff --git a/include/vulkan/vk_layer.h b/include/vulkan/vk_layer.h
index e99e8134..f3edd98f 100644
--- a/include/vulkan/vk_layer.h
+++ b/include/vulkan/vk_layer.h
@@ -268,7 +268,7 @@ typedef enum VkLayerDbgAction_ {
*/
typedef enum VkLayerFunction_ {
VK_LAYER_LINK_INFO = 0,
- VK_LOADER_DISPATCH_CALLBACK = 1
+ VK_LOADER_DATA_CALLBACK = 1
} VkLayerFunction;
typedef struct VkLayerInstanceLink_ {
@@ -290,6 +290,8 @@ typedef struct VkLayerDeviceInfo_ {
typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance,
void *object);
+typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device,
+ void *object);
typedef struct {
VkStructureType sType; // VK_STRUCTURE_TYPE_LAYER_INSTANCE_CREATE_INFO
@@ -313,6 +315,7 @@ typedef struct {
VkLayerFunction function;
union {
VkLayerDeviceLink *pLayerInfo;
+ PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData;
} u;
} VkLayerDeviceCreateInfo;
diff --git a/loader/loader.c b/loader/loader.c
index d44ca744..7786f147 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -271,6 +271,17 @@ VKAPI_ATTR VkResult VKAPI_CALL vkSetInstanceDispatch(VkInstance instance, void *
return VK_SUCCESS;
}
+VKAPI_ATTR VkResult VKAPI_CALL vkSetDeviceDispatch(VkDevice device, void *object) {
+ struct loader_device *dev;
+ struct loader_icd *icd = loader_get_icd_and_device(device, &dev);
+
+ if (!icd) {
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
+ loader_set_dispatch(object, &dev->loader_dispatch);
+ return VK_SUCCESS;
+}
+
#if defined(WIN32)
static char *loader_get_next_path(char *path);
/**
@@ -3281,7 +3292,7 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo,
create_info_disp.sType =
VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO;
- create_info_disp.function = VK_LOADER_DISPATCH_CALLBACK;
+ create_info_disp.function = VK_LOADER_DATA_CALLBACK;
create_info_disp.u.pfnSetInstanceLoaderData = vkSetInstanceDispatch;
@@ -3458,6 +3469,16 @@ VkResult loader_create_device_chain(const struct loader_physical_device_tramp *p
PFN_vkCreateDevice fpCreateDevice =
(PFN_vkCreateDevice)nextGIPA(inst->instance, "vkCreateDevice");
if (fpCreateDevice) {
+ VkLayerDeviceCreateInfo create_info_disp;
+
+ create_info_disp.sType =
+ VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO;
+ create_info_disp.function = VK_LOADER_DATA_CALLBACK;
+
+ create_info_disp.u.pfnSetDeviceLoaderData = vkSetDeviceDispatch;
+
+ create_info_disp.pNext = loader_create_info.pNext;
+ loader_create_info.pNext = &create_info_disp;
res = fpCreateDevice(pd->phys_dev, &loader_create_info, pAllocator,
&created_device);
dev->device = created_device;