[Mesa-dev] [PATCH 06/18] mapi/new: use the static_data offsets in the new generator

Erik Faye-Lund erik.faye-lund at collabora.com
Thu Dec 6 16:55:41 UTC 2018


On Wed, 2018-11-21 at 12:04 +0000, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Otherwise the incorrect ones will be used, effecitvely breaking the
> ABI.
> 
> Note: some entries in static_data.py list a suffixed API, while (for
> ES*
> at least) we expect the one w/o suffix.
> 
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/mapi/new/genCommon.py | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/src/mapi/new/genCommon.py b/src/mapi/new/genCommon.py
> index ee3c468479d..4152ccab3f4 100644
> --- a/src/mapi/new/genCommon.py
> +++ b/src/mapi/new/genCommon.py
> @@ -30,6 +30,11 @@ import collections
>  import re
>  import xml.etree.cElementTree as etree
>  
> +import os
> +GLAPI = os.path.join(os.path.dirname(sys.argv[0]), "..",
> "glapi/gen")
> +sys.path.append(GLAPI)
> +import static_data
> +
>  MAPI_TABLE_NUM_DYNAMIC = 4096
>  
>  _LIBRARY_FEATURE_NAMES = {
> @@ -71,8 +76,31 @@ def getFunctionsFromRoots(roots):
>      # Assign a slot number to each function. This isn't strictly
> necessary,
>      # since you can just look at the index in the list, but it makes
> it easier
>      # to include the slot when formatting output.
> +
> +    next_slot = 0
>      for i in range(len(functions)):
> -        functions[i] = functions[i]._replace(slot=i)
> +        name = functions[i].name[2:]
> +        slot_set = False
> +
> +        if name in static_data.offsets:
> +            functions[i] =
> functions[i]._replace(slot=static_data.offsets[name])
> +            slot_set = True
> +
> +        if slot_set == False and name[-3:] != "ARB":
> +            lname = name + "ARB"
> +            if lname in static_data.offsets:
> +                functions[i] =
> functions[i]._replace(slot=static_data.offsets[lname])
> +                slot_set = True
> +
> +        if slot_set == False and name[-3:] != "EXT":
> +            lname = name + "EXT"
> +            if lname in static_data.offsets:
> +                functions[i] =
> functions[i]._replace(slot=static_data.offsets[lname])
> +                slot_set = True
> +
> +        if slot_set == False:
> +            functions[i] = functions[i]._replace(slot=next_slot)
> +            next_slot += 1
>  

Hmm, this swhole "slot_set"-dance looks like a clunky way of doing
"else if"... How about this on top?

---8<---
diff --git a/src/mapi/new/genCommon.py b/src/mapi/new/genCommon.py
index 4152ccab3f4..9b2e8a95f3d 100644
--- a/src/mapi/new/genCommon.py
+++ b/src/mapi/new/genCommon.py
@@ -80,25 +80,14 @@ def getFunctionsFromRoots(roots):
     next_slot = 0
     for i in range(len(functions)):
         name = functions[i].name[2:]
-        slot_set = False
 
         if name in static_data.offsets:
             functions[i] =
functions[i]._replace(slot=static_data.offsets[name])
-            slot_set = True
-
-        if slot_set == False and name[-3:] != "ARB":
-            lname = name + "ARB"
-            if lname in static_data.offsets:
-                functions[i] =
functions[i]._replace(slot=static_data.offsets[lname])
-                slot_set = True
-
-        if slot_set == False and name[-3:] != "EXT":
-            lname = name + "EXT"
-            if lname in static_data.offsets:
-                functions[i] =
functions[i]._replace(slot=static_data.offsets[lname])
-                slot_set = True
-
-        if slot_set == False:
+        else if name[-3:] != "ARB" and name + "ARB" in
static_data.offsets:
+            functions[i] =
functions[i]._replace(slot=static_data.offsets[lname])
+        else if name[-3:] != "EXT" and name + "EXT" in
static_data.offsets:
+            functions[i] =
functions[i]._replace(slot=static_data.offsets[lname])
+        else
             functions[i] = functions[i]._replace(slot=next_slot)
             next_slot += 1
---8<---

>      # Sort the function list by slot.... to simplify the diff
>      functions = sorted(functions, key=lambda f: f.slot)



More information about the mesa-dev mailing list