<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 18, 2014 at 12:43 AM, Iago Toral Quiroga <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
<br>
We were auto-generating it before.  The problem was that the autogeneration<br>
tool we were using was called "copy, paste, and edit".  Let's use a more<br>
sensible solution.<br>
<br>
Signed-off-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
<br>
v2 by Samuel Iglesias <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
- Remove format_pack.c as it is now autogenerated<br>
- Add usage of INDENT_FLAGS in Makefile.am<br>
- Remove trailing blank line<br>
<br>
Signed-off-by: Samuel Iglesias Gonsalvez <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>><br>
---<br>
 src/mesa/Makefile.am             |    9 +<br>
 src/mesa/Makefile.sources        |    2 +-<br>
 src/mesa/main/format_convert.py  |   71 +<br>
 src/mesa/main/format_pack.c      | 2982 --------------------------------------<br>
 src/mesa/main/format_pack.c.mako |  898 ++++++++++++<br>
 src/mesa/main/run_mako.py        |    7 +<br>
 6 files changed, 986 insertions(+), 2983 deletions(-)<br>
 create mode 100644 src/mesa/main/format_convert.py<br>
 delete mode 100644 src/mesa/main/format_pack.c<br>
 create mode 100644 src/mesa/main/format_pack.c.mako<br>
 create mode 100644 src/mesa/main/run_mako.py<br>
<br>
diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am<br>
index e71bccb..76cac4a 100644<br>
--- a/src/mesa/Makefile.am<br>
+++ b/src/mesa/Makefile.am<br>
@@ -66,6 +66,7 @@ BUILT_SOURCES = \<br>
        main/get_hash.h \<br>
         main/format_info.c \<br>
        $(BUILDDIR)main/git_sha1.h \<br>
+       $(BUILDDIR)main/format_pack.c \<br>
        $(BUILDDIR)program/program_parse.tab.c \<br>
        $(BUILDDIR)program/lex.yy.c<br>
 CLEANFILES = \<br>
@@ -89,6 +90,14 @@ main/format_info.c: main/formats.csv                                    \<br>
                    $< > $@.tmp;                                         \<br>
        mv $@.tmp $@;<br>
<br>
+$(BUILDDIR)main/format_pack.c: main/format_pack.c.mako main/formats.csv \<br>
+                               main/run_mako.py main/format_parser.py<br>
+       $(AM_V_GEN)set -e;                                              \<br>
+       $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/run_mako.py           \<br>
+                   $< $(srcdir)/main/formats.csv > $@.tmp;              \<br>
+       cat $@.tmp | $(INDENT) $(INDENT_FLAGS) > $@;                    \<br>
+        rm $@.tmp;<br>
+<br>
 main/formats.c: main/format_info.c<br>
<br>
 noinst_LTLIBRARIES = $(ARCH_LIBS)<br>
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources<br>
index 4755018..99fc497 100644<br>
--- a/src/mesa/Makefile.sources<br>
+++ b/src/mesa/Makefile.sources<br>
@@ -50,7 +50,7 @@ MAIN_FILES = \<br>
        $(SRCDIR)main/fog.c \<br>
        $(SRCDIR)main/formatquery.c \<br>
        $(SRCDIR)main/formats.c \<br>
-       $(SRCDIR)main/format_pack.c \<br>
+       $(BUILDDIR)main/format_pack.c \<br>
        $(SRCDIR)main/format_unpack.c \<br>
        $(SRCDIR)main/format_utils.c \<br>
        $(SRCDIR)main/framebuffer.c \<br>
diff --git a/src/mesa/main/format_convert.py b/src/mesa/main/format_convert.py<br>
new file mode 100644<br>
index 0000000..0423427<br>
--- /dev/null<br>
+++ b/src/mesa/main/format_convert.py<br>
@@ -0,0 +1,71 @@<br>
+#!/usr/bin/env python<br>
+#<br>
+# Copyright 2014 Intel Corporation<br>
+# All Rights Reserved.<br>
+#<br>
+# Permission is hereby granted, free of charge, to any person obtaining a<br>
+# copy of this software and associated documentation files (the<br>
+# "Software"), to deal in the Software without restriction, including<br>
+# without limitation the rights to use, copy, modify, merge, publish,<br>
+# distribute, sub license, and/or sell copies of the Software, and to<br>
+# permit persons to whom the Software is furnished to do so, subject to<br>
+# the following conditions:<br>
+#<br>
+# The above copyright notice and this permission notice (including the<br>
+# next paragraph) shall be included in all copies or substantial portions<br>
+# of the Software.<br>
+#<br>
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS<br>
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.<br>
+# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR<br>
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,<br>
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE<br>
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+<br>
+import format_parser as parser<br>
+<br>
+def __get_datatype(_type, size):<br>
+   if _type == parser.FLOAT:<br>
+      if size == 32:<br>
+         return 'float'<br>
+      elif size == 16:<br>
+         return 'uint16_t'<br>
+      else:<br>
+         assert False<br>
+   elif _type == parser.UNSIGNED:<br>
+      if size <= 8:<br>
+         return 'uint8_t'<br>
+      elif size <= 16:<br>
+         return 'uint16_t'<br>
+      elif size <= 32:<br>
+         return 'uint32_t'<br>
+      else:<br>
+         assert False<br>
+   elif _type == parser.SIGNED:<br>
+      if size <= 8:<br>
+         return 'int8_t'<br>
+      elif size <= 16:<br>
+         return 'int16_t'<br>
+      elif size <= 32:<br>
+         return 'int32_t'<br>
+      else:<br>
+         assert False<br>
+   else:<br>
+      assert False<br>
+<br>
+def channel_datatype(c):<br>
+   return __get_datatype(c.type, c.size)<br>
+<br>
+def format_datatype(f):<br>
+   if f.layout == parser.PACKED:<br>
+      if f.block_size() == 8:<br>
+         return 'uint8_t'<br>
+      if f.block_size() == 16:<br>
+         return 'uint16_t'<br>
+      if f.block_size() == 32:<br>
+         return 'uint32_t'<br>
+      else:<br>
+         assert False<br>
+   else:<br>
+      return __get_datatype(f.channel_type(), f.channel_size())<br></blockquote><div><br></div><div>On second thought, this could probably be easily rolled into the format parse.  I initially; had it separate because this file initially contained almost the entire generator and was highly GL-specific.  Now that it's just a couple of helpers to get an stdint datatype, I don't see any reason for it to be its own file.  We should just have c_datatype methods on Format and Channel in format_parser.py and get rid of the extra file.<br></div><div>--Jason<br></div><div><br></div><div>(snip...)<br></div></div><br></div></div>