summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-09-24 13:51:40 -0700
committerJason Ekstrand <[email protected]>2015-09-24 14:45:58 -0700
commit39cd3783a42926c0c4570d6e5576e2e88baece4f (patch)
tree4bb2f2be876a101c0f241857c8697cc639877ab8
parenta95f51c1d79848941dae2965dc0d2db4d1fd3d18 (diff)
anv: Add support for the ICD loader
-rw-r--r--src/vulkan/anv_cmd_buffer.c1
-rw-r--r--src/vulkan/anv_device.c4
-rw-r--r--src/vulkan/anv_private.h17
3 files changed, 22 insertions, 0 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c
index cca5cfae3ef..38d032b3661 100644
--- a/src/vulkan/anv_cmd_buffer.c
+++ b/src/vulkan/anv_cmd_buffer.c
@@ -109,6 +109,7 @@ VkResult anv_CreateCommandBuffer(
if (cmd_buffer == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ cmd_buffer->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
cmd_buffer->device = device;
result = anv_cmd_buffer_init_batch_bo_chain(cmd_buffer);
diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c
index 75a889f134d..d79ff8a779c 100644
--- a/src/vulkan/anv_device.c
+++ b/src/vulkan/anv_device.c
@@ -45,6 +45,7 @@ anv_physical_device_init(struct anv_physical_device *device,
if (fd < 0)
return vk_errorf(VK_ERROR_UNAVAILABLE, "failed to open %s: %m", path);
+ device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
device->instance = instance;
device->path = path;
@@ -159,6 +160,7 @@ VkResult anv_CreateInstance(
if (!instance)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ instance->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
instance->pAllocUserData = alloc_callbacks->pUserData;
instance->pfnAlloc = alloc_callbacks->pfnAlloc;
instance->pfnFree = alloc_callbacks->pfnFree;
@@ -523,6 +525,7 @@ PFN_vkVoidFunction anv_GetDeviceProcAddr(
static VkResult
anv_queue_init(struct anv_device *device, struct anv_queue *queue)
{
+ queue->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
queue->device = device;
queue->pool = &device->surface_state_pool;
@@ -596,6 +599,7 @@ VkResult anv_CreateDevice(
if (!device)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+ device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
device->instance = physical_device->instance;
/* XXX(chadv): Can we dup() physicalDevice->fd here? */
diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h
index 07a1d97c65b..4917f9ad768 100644
--- a/src/vulkan/anv_private.h
+++ b/src/vulkan/anv_private.h
@@ -57,6 +57,13 @@
extern "C" {
#endif
+#define ICD_LOADER_MAGIC 0x01CDC0DE
+
+typedef union _VK_LOADER_DATA {
+ uintptr_t loaderMagic;
+ void *loaderData;
+} VK_LOADER_DATA;
+
#define anv_noreturn __attribute__((__noreturn__))
#define anv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
@@ -381,6 +388,8 @@ extern struct anv_dispatch_table dtable;
struct anv_physical_device {
+ VK_LOADER_DATA _loader_data;
+
struct anv_instance * instance;
uint32_t chipset_id;
const char * path;
@@ -390,6 +399,8 @@ struct anv_physical_device {
};
struct anv_instance {
+ VK_LOADER_DATA _loader_data;
+
void * pAllocUserData;
PFN_vkAllocFunction pfnAlloc;
PFN_vkFreeFunction pfnFree;
@@ -427,6 +438,8 @@ struct anv_meta_state {
};
struct anv_queue {
+ VK_LOADER_DATA _loader_data;
+
struct anv_device * device;
struct anv_state_pool * pool;
@@ -447,6 +460,8 @@ struct anv_queue {
};
struct anv_device {
+ VK_LOADER_DATA _loader_data;
+
struct anv_instance * instance;
uint32_t chipset_id;
struct brw_device_info info;
@@ -832,6 +847,8 @@ enum anv_cmd_buffer_exec_mode {
};
struct anv_cmd_buffer {
+ VK_LOADER_DATA _loader_data;
+
struct anv_device * device;
struct list_head pool_link;