Lines Matching defs:opts

101 static bool parse_cmdline(int argc, char *argv[], struct compiler_opts *opts)
112 opts->dump_c_array = true;
116 if (opts->entry)
119 opts->entry = optarg;
123 if (opts->file)
126 opts->file = optarg;
130 opts->dump_nir = true;
134 if (opts->out_file)
137 opts->out_file = optarg;
141 opts->dump_rogue = true;
145 if (opts->stage != MESA_SHADER_NONE)
149 opts->stage = MESA_SHADER_FRAGMENT;
151 opts->stage = MESA_SHADER_VERTEX;
167 if (opts->stage == MESA_SHADER_NONE || !opts->file) {
175 if (!opts->out_file)
176 opts->out_file = "out.bin";
178 if (!opts->entry)
179 opts->entry = "main";
188 struct compiler_opts opts = { .stage = MESA_SHADER_NONE, 0 };
205 if (!parse_cmdline(argc, argv, &opts))
209 input_data = os_read_file(opts.file, &input_size);
211 fprintf(stderr, "Failed to read file \"%s\".\n", opts.file);
229 ctx->nir[opts.stage] = rogue_spirv_to_nir(ctx,
230 opts.stage,
231 opts.entry,
236 if (!ctx->nir[opts.stage]) {
242 if (opts.dump_nir)
243 nir_print_shader(ctx->nir[opts.stage], stdout);
246 ctx->rogue[opts.stage] = rogue_nir_to_rogue(ctx, ctx->nir[opts.stage]);
247 if (!ctx->rogue[opts.stage]) {
253 if (opts.dump_rogue)
254 rogue_dump_shader(ctx->rogue[opts.stage], stdout);
257 ctx->binary[opts.stage] = rogue_to_binary(ctx, ctx->rogue[opts.stage]);
258 if (!ctx->binary[opts.stage]) {
264 if (opts.dump_c_array) {
265 printf("uint8_t shader_bytes[%zu] = {", ctx->binary[opts.stage]->size);
266 for (size_t u = 0U; u < ctx->binary[opts.stage]->size; ++u) {
270 printf("0x%02x, ", ctx->binary[opts.stage]->data[u]);
276 fp = fopen(opts.out_file, "wb");
278 fprintf(stderr, "Failed to open output file \"%s\".\n", opts.out_file);
282 bytes_written = fwrite(ctx->binary[opts.stage]->data,
284 ctx->binary[opts.stage]->size,
286 if (bytes_written != ctx->binary[opts.stage]->size) {
290 opts.out_file,
292 ctx->binary[opts.stage]->size);