anv: Make entrypoint resolution take a gen_device_info
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 7 Oct 2016 22:47:45 +0000 (15:47 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 14 Oct 2016 22:40:39 +0000 (15:40 -0700)
In order for things such as the ANV_CALL and the ifuncs to work, we used to
have a singleton gen_device_info structure that got assigned the first time
you create a device.  Given that the driver will never be used
simultaneously on two different generations of hardware, this was fairly
safe to do.  However, it has caused a few hickups and isn't, in general, a
good plan.  Now that the two primary reasons for this singleton are gone,
we can get rid of it and make things quite a bit safer.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_entrypoints_gen.py
src/intel/vulkan/anv_private.h

index 81078356a3bcd40d6b16ba2e400eb0dab84ed53c..53b9b1b9ac4070e9af6788e73f90f33a5095617a 100644 (file)
@@ -682,7 +682,7 @@ PFN_vkVoidFunction anv_GetInstanceProcAddr(
     VkInstance                                  instance,
     const char*                                 pName)
 {
-   return anv_lookup_entrypoint(pName);
+   return anv_lookup_entrypoint(NULL, pName);
 }
 
 /* With version 1+ of the loader interface the ICD should expose
@@ -702,10 +702,11 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(
 }
 
 PFN_vkVoidFunction anv_GetDeviceProcAddr(
-    VkDevice                                    device,
+    VkDevice                                    _device,
     const char*                                 pName)
 {
-   return anv_lookup_entrypoint(pName);
+   ANV_FROM_HANDLE(anv_device, device, _device);
+   return anv_lookup_entrypoint(&device->info, pName);
 }
 
 static VkResult
@@ -854,8 +855,6 @@ VkResult anv_CreateDevice(
          return vk_error(VK_ERROR_EXTENSION_NOT_PRESENT);
    }
 
-   anv_set_dispatch_devinfo(&physical_device->info);
-
    device = anv_alloc2(&physical_device->instance->alloc, pAllocator,
                        sizeof(*device), 8,
                        VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
index ebabce6d4801a972725f63b76bfb884d070e24b3..9d23dbb358b20be26e3934b7686401192ebdc22a 100644 (file)
@@ -214,22 +214,14 @@ for layer in [ "anv", "gen7", "gen75", "gen8", "gen9" ]:
     print "};\n"
 
 print """
-static struct gen_device_info dispatch_devinfo;
-
-void
-anv_set_dispatch_devinfo(const struct gen_device_info *devinfo)
-{
-   dispatch_devinfo = *devinfo;
-}
-
 static void * __attribute__ ((noinline))
-anv_resolve_entrypoint(uint32_t index)
+anv_resolve_entrypoint(const struct gen_device_info *devinfo, uint32_t index)
 {
-   if (dispatch_devinfo.gen == 0) {
+   if (devinfo == NULL) {
       return anv_layer.entrypoints[index];
    }
 
-   switch (dispatch_devinfo.gen) {
+   switch (devinfo->gen) {
    case 9:
       if (gen9_layer.entrypoints[index])
          return gen9_layer.entrypoints[index];
@@ -239,7 +231,7 @@ anv_resolve_entrypoint(uint32_t index)
          return gen8_layer.entrypoints[index];
       /* fall through */
    case 7:
-      if (dispatch_devinfo.is_haswell && gen75_layer.entrypoints[index])
+      if (devinfo->is_haswell && gen75_layer.entrypoints[index])
          return gen75_layer.entrypoints[index];
 
       if (gen7_layer.entrypoints[index])
@@ -301,7 +293,7 @@ print "};"
 
 print """
 void *
-anv_lookup_entrypoint(const char *name)
+anv_lookup_entrypoint(const struct gen_device_info *devinfo, const char *name)
 {
    static const uint32_t prime_factor = %d;
    static const uint32_t prime_step = %d;
@@ -325,6 +317,6 @@ anv_lookup_entrypoint(const char *name)
    if (strcmp(name, strings + e->name) != 0)
       return NULL;
 
-   return anv_resolve_entrypoint(i);
+   return anv_resolve_entrypoint(devinfo, i);
 }
 """ % (prime_factor, prime_step, hash_mask)
index b04881a68652c5c6bd29194430cc7bef4e45b8c2..18cecdf1007807955132411062e3be2c7abb6366 100644 (file)
@@ -1805,7 +1805,8 @@ struct anv_query_pool {
    struct anv_bo                                bo;
 };
 
-void *anv_lookup_entrypoint(const char *name);
+void *anv_lookup_entrypoint(const struct gen_device_info *devinfo,
+                            const char *name);
 
 void anv_dump_image_to_ppm(struct anv_device *device,
                            struct anv_image *image, unsigned miplevel,