Re: [Mesa-dev] [PATCH 11/20] mesa: Autogenerate most of format_pack.c
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 18/11/14 19:54, Jason Ekstrand wrote: On Tue, Nov 18, 2014 at 12:43 AM, Iago Toral Quiroga ito...@igalia.com wrote: From: Jason Ekstrand jason.ekstr...@intel.com We were auto-generating it before. The problem was that the autogeneration tool we were using was called copy, paste, and edit. Let's use a more sensible solution. Signed-off-by: Jason Ekstrand jason.ekstr...@intel.com v2 by Samuel Iglesias sigles...@igalia.com - Remove format_pack.c as it is now autogenerated - Add usage of INDENT_FLAGS in Makefile.am - Remove trailing blank line Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com --- src/mesa/Makefile.am |9 + src/mesa/Makefile.sources|2 +- src/mesa/main/format_convert.py | 71 + src/mesa/main/format_pack.c | 2982 -- src/mesa/main/format_pack.c.mako | 898 src/mesa/main/run_mako.py|7 + 6 files changed, 986 insertions(+), 2983 deletions(-) create mode 100644 src/mesa/main/format_convert.py delete mode 100644 src/mesa/main/format_pack.c create mode 100644 src/mesa/main/format_pack.c.mako create mode 100644 src/mesa/main/run_mako.py diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index e71bccb..76cac4a 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -66,6 +66,7 @@ BUILT_SOURCES = \ main/get_hash.h \ main/format_info.c \ $(BUILDDIR)main/git_sha1.h \ + $(BUILDDIR)main/format_pack.c \ $(BUILDDIR)program/program_parse.tab.c \ $(BUILDDIR)program/lex.yy.c CLEANFILES = \ @@ -89,6 +90,14 @@ main/format_info.c: main/formats.csv \ $ $@.tmp; \ mv $@.tmp $@; +$(BUILDDIR)main/format_pack.c: main/format_pack.c.mako main/formats.csv \ + main/run_mako.py main/format_parser.py + $(AM_V_GEN)set -e; \ + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/run_mako.py \ + $ $(srcdir)/main/formats.csv $@.tmp; \ + cat $@.tmp | $(INDENT) $(INDENT_FLAGS) $@;\ +rm $@.tmp; + main/formats.c: main/format_info.c noinst_LTLIBRARIES = $(ARCH_LIBS) diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 4755018..99fc497 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -50,7 +50,7 @@ MAIN_FILES = \ $(SRCDIR)main/fog.c \ $(SRCDIR)main/formatquery.c \ $(SRCDIR)main/formats.c \ - $(SRCDIR)main/format_pack.c \ + $(BUILDDIR)main/format_pack.c \ $(SRCDIR)main/format_unpack.c \ $(SRCDIR)main/format_utils.c \ $(SRCDIR)main/framebuffer.c \ diff --git a/src/mesa/main/format_convert.py b/src/mesa/main/format_convert.py new file mode 100644 index 000..0423427 --- /dev/null +++ b/src/mesa/main/format_convert.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# Copyright 2014 Intel Corporation +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# Software), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import format_parser as parser + +def __get_datatype(_type, size): + if _type == parser.FLOAT: + if size == 32: + return 'float' + elif size == 16: + return 'uint16_t' + else: + assert False + elif _type == parser.UNSIGNED: + if size = 8: + return 'uint8_t' + elif size = 16: + return 'uint16_t' + elif size = 32: + return 'uint32_t' + else: + assert False + elif _type == parser.SIGNED: + if size = 8: + return 'int8_t' + elif size = 16: + return 'int16_t' + elif size = 32: + return 'int32_t' + else: +
Re: [Mesa-dev] [PATCH 11/20] mesa: Autogenerate most of format_pack.c
On Tue, Nov 18, 2014 at 12:43 AM, Iago Toral Quiroga ito...@igalia.com wrote: From: Jason Ekstrand jason.ekstr...@intel.com We were auto-generating it before. The problem was that the autogeneration tool we were using was called copy, paste, and edit. Let's use a more sensible solution. Signed-off-by: Jason Ekstrand jason.ekstr...@intel.com v2 by Samuel Iglesias sigles...@igalia.com - Remove format_pack.c as it is now autogenerated - Add usage of INDENT_FLAGS in Makefile.am - Remove trailing blank line Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com --- src/mesa/Makefile.am |9 + src/mesa/Makefile.sources|2 +- src/mesa/main/format_convert.py | 71 + src/mesa/main/format_pack.c | 2982 -- src/mesa/main/format_pack.c.mako | 898 src/mesa/main/run_mako.py|7 + 6 files changed, 986 insertions(+), 2983 deletions(-) create mode 100644 src/mesa/main/format_convert.py delete mode 100644 src/mesa/main/format_pack.c create mode 100644 src/mesa/main/format_pack.c.mako create mode 100644 src/mesa/main/run_mako.py diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index e71bccb..76cac4a 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -66,6 +66,7 @@ BUILT_SOURCES = \ main/get_hash.h \ main/format_info.c \ $(BUILDDIR)main/git_sha1.h \ + $(BUILDDIR)main/format_pack.c \ $(BUILDDIR)program/program_parse.tab.c \ $(BUILDDIR)program/lex.yy.c CLEANFILES = \ @@ -89,6 +90,14 @@ main/format_info.c: main/formats.csv \ $ $@.tmp; \ mv $@.tmp $@; +$(BUILDDIR)main/format_pack.c: main/format_pack.c.mako main/formats.csv \ + main/run_mako.py main/format_parser.py + $(AM_V_GEN)set -e; \ + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/run_mako.py \ + $ $(srcdir)/main/formats.csv $@.tmp; \ + cat $@.tmp | $(INDENT) $(INDENT_FLAGS) $@;\ +rm $@.tmp; + main/formats.c: main/format_info.c noinst_LTLIBRARIES = $(ARCH_LIBS) diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index 4755018..99fc497 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -50,7 +50,7 @@ MAIN_FILES = \ $(SRCDIR)main/fog.c \ $(SRCDIR)main/formatquery.c \ $(SRCDIR)main/formats.c \ - $(SRCDIR)main/format_pack.c \ + $(BUILDDIR)main/format_pack.c \ $(SRCDIR)main/format_unpack.c \ $(SRCDIR)main/format_utils.c \ $(SRCDIR)main/framebuffer.c \ diff --git a/src/mesa/main/format_convert.py b/src/mesa/main/format_convert.py new file mode 100644 index 000..0423427 --- /dev/null +++ b/src/mesa/main/format_convert.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# Copyright 2014 Intel Corporation +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# Software), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import format_parser as parser + +def __get_datatype(_type, size): + if _type == parser.FLOAT: + if size == 32: + return 'float' + elif size == 16: + return 'uint16_t' + else: + assert False + elif _type == parser.UNSIGNED: + if size = 8: + return 'uint8_t' + elif size = 16: + return 'uint16_t' + elif size = 32: + return 'uint32_t' + else: + assert False + elif _type == parser.SIGNED: + if size = 8: + return 'int8_t' + elif size = 16: + return 'int16_t' + elif size = 32: + return 'int32_t' + else: + assert False + else: + assert False + +def channel_datatype(c): + return