[Mesa-dev] [PATCH 11/21] anv/entrypoints: Split entrypoint index lookup into its own function

Jason Ekstrand jason at jlekstrand.net
Sat Jan 20 19:11:46 UTC 2018


---
 src/intel/vulkan/anv_entrypoints_gen.py | 19 ++++++++++++++-----
 src/intel/vulkan/anv_private.h          |  2 ++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py
index 6c922b8..9dbf828 100644
--- a/src/intel/vulkan/anv_entrypoints_gen.py
+++ b/src/intel/vulkan/anv_entrypoints_gen.py
@@ -215,8 +215,8 @@ static const uint16_t map[] = {
 % endfor
 };
 
-void *
-anv_lookup_entrypoint(const struct gen_device_info *devinfo, const char *name)
+int
+anv_get_entrypoint_index(const char *name)
 {
    static const uint32_t prime_factor = ${prime_factor};
    static const uint32_t prime_step = ${prime_step};
@@ -232,15 +232,24 @@ anv_lookup_entrypoint(const struct gen_device_info *devinfo, const char *name)
    do {
       i = map[h & ${hash_mask}];
       if (i == none)
-         return NULL;
+         return -1;
       e = &entrypoints[i];
       h += prime_step;
    } while (e->hash != hash);
 
    if (strcmp(name, strings + e->name) != 0)
-      return NULL;
+      return -1;
+
+   return i;
+}
 
-   return anv_resolve_entrypoint(devinfo, i);
+void *
+anv_lookup_entrypoint(const struct gen_device_info *devinfo, const char *name)
+{
+   int idx = anv_get_entrypoint_index(name);
+   if (idx < 0)
+      return NULL;
+   return anv_resolve_entrypoint(devinfo, idx);
 }""", output_encoding='utf-8')
 
 NONE = 0xffff
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 550fec4..7d1cae1 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2836,6 +2836,8 @@ struct anv_query_pool {
    struct anv_bo                                bo;
 };
 
+int anv_get_entrypoint_index(const char *name);
+
 void *anv_lookup_entrypoint(const struct gen_device_info *devinfo,
                             const char *name);
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list