diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build index 28b372b65fe..3e578732e8b 100644 --- a/src/compiler/nir/meson.build +++ b/src/compiler/nir/meson.build @@ -321,7 +321,7 @@ _libnir = static_library( 'nir', [files_libnir, spirv_info_c, nir_opt_algebraic_c, nir_opcodes_c, nir_opcodes_h, nir_constant_expressions_c, nir_builder_opcodes_h, - vtn_gather_types_c, nir_intrinsics_c, nir_intrinsics_h], + vtn_gather_types_c, nir_intrinsics_c, nir_intrinsics_h, vtn_generator_ids_h], include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_compiler, include_directories('../spirv')], c_args : [c_msvc_compat_args, no_override_init_args, _libnir_args], gnu_symbol_visibility : 'hidden', diff --git a/src/compiler/spirv/meson.build b/src/compiler/spirv/meson.build index c91d12a27d9..e3dd847883a 100644 --- a/src/compiler/spirv/meson.build +++ b/src/compiler/spirv/meson.build @@ -31,3 +31,10 @@ spirv_info_c = custom_target( output : 'spirv_info.c', command : [prog_python, '@INPUT0@', '@INPUT1@', '@OUTPUT@'], ) + +vtn_generator_ids_h = custom_target( + 'vtn_generator_ids.h', + input : files('vtn_generator_ids_h.py', 'spir-v.xml'), + output : 'vtn_generator_ids.h', + command : [prog_python, '@INPUT0@', '@INPUT1@', '@OUTPUT@'], +) diff --git a/src/compiler/spirv/spir-v.xml b/src/compiler/spirv/spir-v.xml new file mode 100644 index 00000000000..84aae2746ee --- /dev/null +++ b/src/compiler/spirv/spir-v.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 0c1ac862182..f236804cca7 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -5456,7 +5456,9 @@ vtn_create_builder(const uint32_t *words, size_t word_count, * commands. Prior to that, we need to fix them up ourselves. This * GLSLang fix caused them to bump to generator version 3. */ - b->wa_glslang_cs_barrier = (generator_id == 8 && generator_version < 3); + b->wa_glslang_cs_barrier = + (generator_id == vtn_generator_glslang_reference_front_end && + generator_version < 3); /* words[2] == generator magic */ unsigned value_id_bound = words[3]; diff --git a/src/compiler/spirv/vtn_generator_ids_h.py b/src/compiler/spirv/vtn_generator_ids_h.py new file mode 100644 index 00000000000..098c7d80d85 --- /dev/null +++ b/src/compiler/spirv/vtn_generator_ids_h.py @@ -0,0 +1,63 @@ +COPYRIGHT = """\ +/* + * Copyright © 2020 Valve Corporation + * + * 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, sublicense, + * 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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 argparse +import xml.etree.ElementTree as ET +from mako.template import Template + +TEMPLATE = Template("""\ +/* DO NOT EDIT - This file is generated automatically by vtn_generator_ids.py script */ + +""" + COPYRIGHT + """\ +<% +def get_name(generator): + name = generator.get('tool').lower() + name = name.replace('-', '') + name = name.replace(' ', '_') + name = name.replace('/', '_') + return name +%> +enum vtn_generator { +% for generator in root.find("./ids[@type='vendor']").findall('id'): +% if 'tool' in generator.attrib: + vtn_generator_${get_name(generator)} = ${generator.get('value')}, +% endif +% endfor + vtn_generator_max = 0xffff, +}; +""") + +if __name__ == "__main__": + p = argparse.ArgumentParser() + p.add_argument("xml") + p.add_argument("out") + pargs = p.parse_args() + + tree = ET.parse(pargs.xml) + root = tree.getroot() + + with open(pargs.out, 'w') as f: + f.write(TEMPLATE.render(root=root)) diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index f5f4ce8a9bb..a51a2bebde2 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -35,6 +35,7 @@ #include "util/u_dynarray.h" #include "nir_spirv.h" #include "spirv.h" +#include "vtn_generator_ids.h" struct vtn_builder; struct vtn_decoration;