From e99418919c77731d64daec6d3a663b612cebdb0e Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 17 Nov 2024 20:18:31 -0400 Subject: [PATCH] asahi/clc: drop getopt I don't think it's buying us anything anymore. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/clc/asahi_clc.c | 76 +++++--------------------------------- src/asahi/lib/agx_device.c | 3 +- src/asahi/lib/meson.build | 5 +-- 3 files changed, 12 insertions(+), 72 deletions(-) diff --git a/src/asahi/clc/asahi_clc.c b/src/asahi/clc/asahi_clc.c index 7a47fc1bcaf..12d305b42bd 100644 --- a/src/asahi/clc/asahi_clc.c +++ b/src/asahi/clc/asahi_clc.c @@ -12,7 +12,6 @@ #include "nir_serialize.h" #include -#include #include #include #include @@ -283,68 +282,19 @@ print_u32_data(FILE *fp, const char *prefix, const char *arr_name, fprintf(fp, "\n};\n"); } -static void -print_usage(char *exec_name, FILE *f) -{ - fprintf( - f, - "Usage: %s [options] -- [clang args]\n" - "Options:\n" - " -h --help Print this help.\n" - " --prefix Prefix for variable names in generated C code.\n" - " -o, --out Specify the output filename.\n" - " -i, --in Specify one input filename. Accepted multiple times.\n" - " -s, --spv Specify the output filename for spirv.\n" - " -v, --verbose Print more information during compilation.\n", - exec_name); -} - -#define OPT_PREFIX 1000 - int main(int argc, char **argv) { - static struct option long_options[] = { - {"help", no_argument, 0, 'h'}, - {"prefix", required_argument, 0, OPT_PREFIX}, - {"in", required_argument, 0, 'i'}, - {"out", required_argument, 0, 'o'}, - {"verbose", no_argument, 0, 'v'}, - {0, 0, 0, 0}, - }; + if (argc != 3) { + fprintf(stderr, "Usage: %s [input spir-v] [output header]\n", argv[0]); + return 1; + } + + const char *infile = argv[1]; + const char *outfile = argv[2]; - char *infile = NULL, *outfile = NULL, *prefix = NULL; void *mem_ctx = ralloc_context(NULL); - int ch; - while ((ch = getopt_long(argc, argv, "he:p:i:o:v", long_options, NULL)) != - -1) { - switch (ch) { - case 'h': - print_usage(argv[0], stdout); - return 0; - case 'o': - outfile = optarg; - break; - case 'i': - infile = optarg; - break; - case OPT_PREFIX: - prefix = optarg; - break; - default: - fprintf(stderr, "Unrecognized option \"%s\".\n", optarg); - print_usage(argv[0], stderr); - return 1; - } - } - - if (infile == NULL || outfile == NULL || prefix == NULL) { - fprintf(stderr, "Missing required argument.\n"); - print_usage(argv[0], stderr); - return -1; - } - int fd = open(infile, O_RDONLY); if (fd < 0) { fprintf(stderr, "Failed to open %s\n", infile); @@ -362,10 +312,7 @@ main(int argc, char **argv) return 1; } - FILE *fp = stdout; - if (outfile != NULL) - fp = fopen(outfile, "w"); - + FILE *fp = fopen(outfile, "w"); glsl_type_singleton_init_or_ref(); fprintf(fp, "/*\n"); @@ -410,14 +357,11 @@ main(int argc, char **argv) struct blob blob; blob_init(&blob); nir_serialize(&blob, nir, true /* strip */); - print_u32_data(fp, prefix, "nir", (const uint32_t *)blob.data, blob.size); + print_u32_data(fp, "libagx", "nir", (const uint32_t *)blob.data, blob.size); blob_finish(&blob); glsl_type_singleton_decref(); - - if (fp != stdout) - fclose(fp); - + fclose(fp); ralloc_free(mem_ctx); return 0; } diff --git a/src/asahi/lib/agx_device.c b/src/asahi/lib/agx_device.c index ac1cdd29ebe..e66e1f2d486 100644 --- a/src/asahi/lib/agx_device.c +++ b/src/asahi/lib/agx_device.c @@ -570,8 +570,7 @@ agx_open_device(void *memctx, struct agx_device *dev) glsl_type_singleton_init_or_ref(); struct blob_reader blob; - blob_reader_init(&blob, (void *)libagx_shaders_nir, - sizeof(libagx_shaders_nir)); + blob_reader_init(&blob, (void *)libagx_nir, sizeof(libagx_nir)); dev->libagx = nir_deserialize(memctx, &agx_nir_options, &blob); dev->helper = agx_build_helper(dev); diff --git a/src/asahi/lib/meson.build b/src/asahi/lib/meson.build index 9cfa3e06309..126970ad450 100644 --- a/src/asahi/lib/meson.build +++ b/src/asahi/lib/meson.build @@ -54,10 +54,7 @@ libagx_shaders = custom_target( 'libagx_shaders.h', input : libagx_spv, output : 'libagx_shaders.h', - command : [ - prog_asahi_clc, '--prefix', 'libagx_shaders', - '--in', libagx_spv, '-o', '@OUTPUT@' - ], + command : [prog_asahi_clc, libagx_spv, '@OUTPUT@'], env: ['MESA_SHADER_CACHE_DISABLE=true'], depends : [prog_asahi_clc], )