freedreno/ir3: standalone compiler updates
authorRob Clark <robdclark@gmail.com>
Fri, 9 Nov 2018 14:17:03 +0000 (09:17 -0500)
committerRob Clark <robdclark@gmail.com>
Tue, 27 Nov 2018 20:44:02 +0000 (15:44 -0500)
Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c

index bf80195..39f6c12 100644 (file)
@@ -103,29 +103,42 @@ static nir_shader *
 load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
 {
        static const struct standalone_options options = {
-                       .glsl_version = 140,
+                       .glsl_version = 460,
                        .do_link = true,
        };
        struct gl_shader_program *prog;
+       const nir_shader_compiler_options *nir_options =
+                       ir3_get_compiler_options(compiler);
 
        prog = standalone_compile_shader(&options, num_files, files);
        if (!prog)
                errx(1, "couldn't parse `%s'", files[0]);
 
-       nir_shader *nir = glsl_to_nir(prog, stage, ir3_get_compiler_options(compiler));
+       nir_shader *nir = glsl_to_nir(prog, stage, nir_options);
 
        /* required NIR passes: */
-       /* TODO cmdline args for some of the conditional lowering passes? */
+       if (nir_options->lower_all_io_to_temps ||
+                       nir->info.stage == MESA_SHADER_VERTEX ||
+                       nir->info.stage == MESA_SHADER_GEOMETRY) {
+               NIR_PASS_V(nir, nir_lower_io_to_temporaries,
+                               nir_shader_get_entrypoint(nir),
+                               true, true);
+       } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
+               NIR_PASS_V(nir, nir_lower_io_to_temporaries,
+                               nir_shader_get_entrypoint(nir),
+                               true, false);
+       }
 
-       NIR_PASS_V(nir, nir_lower_io_to_temporaries,
-                       nir_shader_get_entrypoint(nir),
-                       true, true);
        NIR_PASS_V(nir, nir_lower_global_vars_to_local);
        NIR_PASS_V(nir, nir_split_var_copies);
        NIR_PASS_V(nir, nir_lower_var_copies);
 
        NIR_PASS_V(nir, nir_split_var_copies);
        NIR_PASS_V(nir, nir_lower_var_copies);
+       nir_print_shader(nir, stdout);
+       NIR_PASS_V(nir, gl_nir_lower_atomics, prog, true);
+       NIR_PASS_V(nir, nir_lower_atomics_to_ssbo, 8);
+       nir_print_shader(nir, stdout);
 
        switch (stage) {
        case MESA_SHADER_VERTEX:
@@ -152,6 +165,8 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
                                &nir->num_outputs,
                                ir3_glsl_type_size);
                break;
+       case MESA_SHADER_COMPUTE:
+               break;
        default:
                errx(1, "unhandled shader stage: %d", stage);
        }
@@ -396,6 +411,12 @@ int main(int argc, char **argv)
                                errx(1, "in SPIR-V mode, an entry point must be specified");
                        entry = argv[n];
                        n++;
+               } else if (strcmp(ext, ".comp") == 0) {
+                       if (s.from_tgsi || from_spirv)
+                               errx(1, "cannot mix GLSL/TGSI/SPIRV");
+                       if (num_files >= ARRAY_SIZE(filenames))
+                               errx(1, "too many GLSL files");
+                       stage = MESA_SHADER_COMPUTE;
                } else if (strcmp(ext, ".frag") == 0) {
                        if (s.from_tgsi || from_spirv)
                                errx(1, "cannot mix GLSL/TGSI/SPIRV");