Mesa (main): intel/clc: allow producing SPIRV files

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 21 11:54:39 UTC 2022


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

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Thu May  6 22:22:44 2021 +0300

intel/clc: allow producing SPIRV files

Useful to debug the parser.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13171>

---

 src/intel/compiler/intel_clc.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/intel_clc.c b/src/intel/compiler/intel_clc.c
index e2fb221d900..23a97de7ccf 100644
--- a/src/intel/compiler/intel_clc.c
+++ b/src/intel/compiler/intel_clc.c
@@ -261,6 +261,7 @@ print_usage(char *exec_name, FILE *f)
 "  -p, --platform <name>   Specify the target platform name.\n"
 "      --prefix <prefix>   Prefix for variable names in generated C code.\n"
 "  -g, --out <filename>    Specify the output filename.\n"
+"  -s, --spv <filename>    Specify the output filename for spirv.\n"
    , exec_name);
 }
 
@@ -277,10 +278,11 @@ int main(int argc, char **argv)
       {"prefix",     required_argument,   0, OPT_PREFIX},
       {"in",         required_argument,   0, 'i'},
       {"out",        required_argument,   0, 'o'},
+      {"spv",        required_argument,   0, 's'},
       {0, 0, 0, 0}
    };
 
-   char *entry_point = NULL, *platform = NULL, *outfile = NULL, *prefix = NULL;
+   char *entry_point = NULL, *platform = NULL, *outfile = NULL, *spv_outfile = NULL, *prefix = NULL;
    struct util_dynarray clang_args;
    struct util_dynarray input_files;
    struct util_dynarray spirv_objs;
@@ -294,7 +296,7 @@ int main(int argc, char **argv)
    util_dynarray_init(&spirv_ptr_objs, mem_ctx);
 
    int ch;
-   while ((ch = getopt_long(argc, argv, "he:p:o:", long_options, NULL)) != -1)
+   while ((ch = getopt_long(argc, argv, "he:p:s:o:", long_options, NULL)) != -1)
    {
       switch (ch)
       {
@@ -310,6 +312,9 @@ int main(int argc, char **argv)
       case 'o':
          outfile = optarg;
          break;
+      case 's':
+         spv_outfile = optarg;
+         break;
       case OPT_PREFIX:
          prefix = optarg;
          break;
@@ -412,6 +417,12 @@ int main(int argc, char **argv)
       return 1;
    }
 
+   if (spv_outfile) {
+      FILE *fp = fopen(spv_outfile, "w");
+      fwrite(final_spirv.data, final_spirv.size, 1, fp);
+      fclose(fp);
+   }
+
    struct clc_parsed_spirv parsed_spirv_data;
    if (!clc_parse_spirv(&final_spirv, &logger, &parsed_spirv_data)) {
       ralloc_free(mem_ctx);



More information about the mesa-commit mailing list