Mesa (master): spirv: Add imageoperands_to_string helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 24 19:31:49 UTC 2019


Module: Mesa
Branch: master
Commit: d27b853c08e5e254b89c1fda003cc331792f3744
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d27b853c08e5e254b89c1fda003cc331792f3744

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Tue Oct 22 22:25:29 2019 -0700

spirv: Add imageoperands_to_string helper

Change the information to also include the category, so that the
particulars of BitEnum enumeration can be handled in the template.

Acked-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

---

 src/compiler/spirv/spirv_info.h    |  1 +
 src/compiler/spirv/spirv_info_c.py | 25 ++++++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/compiler/spirv/spirv_info.h b/src/compiler/spirv/spirv_info.h
index 199b98c9cc3..8b8b68723fb 100644
--- a/src/compiler/spirv/spirv_info.h
+++ b/src/compiler/spirv/spirv_info.h
@@ -34,6 +34,7 @@ const char *spirv_dim_to_string(SpvDim dim);
 const char *spirv_executionmode_to_string(SpvExecutionMode mode);
 const char *spirv_executionmodel_to_string(SpvExecutionModel model);
 const char *spirv_imageformat_to_string(SpvImageFormat format);
+const char *spirv_imageoperands_to_string(SpvImageOperandsMask op);
 const char *spirv_memorymodel_to_string(SpvMemoryModel cap);
 const char *spirv_op_to_string(SpvOp op);
 const char *spirv_storageclass_to_string(SpvStorageClass sc);
diff --git a/src/compiler/spirv/spirv_info_c.py b/src/compiler/spirv/spirv_info_c.py
index 1e5017cb249..29baec1fc30 100644
--- a/src/compiler/spirv/spirv_info_c.py
+++ b/src/compiler/spirv/spirv_info_c.py
@@ -43,7 +43,7 @@ def collect_data(spirv, kind):
             seen.add(x["value"])
             values.append(x["enumerant"])
 
-    return (kind, values)
+    return (kind, values, operands["category"])
 
 def collect_opcodes(spirv):
     seen = set()
@@ -59,7 +59,7 @@ def collect_opcodes(spirv):
         values.append(name[2:])
         seen.add(opcode)
 
-    return ("Op", values)
+    return ("Op", values, None)
 
 def parse_args():
     p = argparse.ArgumentParser()
@@ -72,8 +72,25 @@ TEMPLATE  = Template("""\
 
 """ + COPYRIGHT + """\
 #include "spirv_info.h"
-% for kind,values in info:
+% for kind,values,category in info:
 
+% if category == "BitEnum":
+const char *
+spirv_${kind.lower()}_to_string(Spv${kind}Mask v)
+{
+   switch (v) {
+    % for name in values:
+    %if name != "None":
+   case Spv${kind}${name}Mask: return "Spv${kind}${name}";
+    % else:
+   case Spv${kind}MaskNone: return "Spv${kind}${name}";
+    % endif
+    % endfor
+   }
+
+   return "unknown";
+}
+% else:
 const char *
 spirv_${kind.lower()}_to_string(Spv${kind} v)
 {
@@ -86,6 +103,7 @@ spirv_${kind.lower()}_to_string(Spv${kind} v)
 
    return "unknown";
 }
+% endif
 % endfor
 """)
 
@@ -105,6 +123,7 @@ if __name__ == "__main__":
         collect_data(spirv_info, "ImageFormat"),
         collect_data(spirv_info, "MemoryModel"),
         collect_data(spirv_info, "StorageClass"),
+        collect_data(spirv_info, "ImageOperands"),
         collect_opcodes(spirv_info),
     ]
 




More information about the mesa-commit mailing list