anv: Add support for the ICD loader
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 24 Sep 2015 20:51:40 +0000 (13:51 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 24 Sep 2015 21:45:58 +0000 (14:45 -0700)
src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_device.c
src/vulkan/anv_private.h

index cca5cfae3ef97f2a0ee26dbe2774f1c9c95af3e3..38d032b36612388a777ded28061cf81bfcb076d2 100644 (file)
@@ -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);
index 75a889f134d372a4595179ac7a06e7f99000db32..d79ff8a779c5319f7208cc44dc169cfce4ff1061 100644 (file)
@@ -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? */
index 07a1d97c65b1f7bbd27d761a389f4f8508690046..4917f9ad768ce2719c2894247ce5e54a76934b2d 100644 (file)
 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;