From: Alyssa Rosenzweig Date: Wed, 14 Aug 2019 19:21:23 +0000 (-0700) Subject: pan/bifrost: Stub out standalone compiler X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fca491c0e100ac89295dfa36ddcb63d6cb839bed;p=mesa.git pan/bifrost: Stub out standalone compiler We don't actually have a standalone compiler in-tree yet, but let's get prepared for when we do. Signed-off-by: Ryan Houdek Signed-off-by: Alyssa Rosenzweig --- diff --git a/src/panfrost/bifrost/cmdline.c b/src/panfrost/bifrost/cmdline.c index 9fd7094ebe1..4a30d7ec9f6 100644 --- a/src/panfrost/bifrost/cmdline.c +++ b/src/panfrost/bifrost/cmdline.c @@ -21,13 +21,55 @@ * SOFTWARE. */ +#include "disassemble.h" + #include "main/mtypes.h" #include "compiler/glsl/standalone.h" #include "compiler/glsl/glsl_to_nir.h" +#include "compiler/glsl/gl_nir.h" #include "compiler/nir_types.h" -#include "disassemble.h" #include "util/u_dynarray.h" +static void +compile_shader(char **argv) +{ + struct gl_shader_program *prog; + nir_shader *nir[2]; + unsigned shader_types[2] = { + MESA_SHADER_VERTEX, + MESA_SHADER_FRAGMENT, + }; + + struct standalone_options options = { + .glsl_version = 430, + .do_link = true, + }; + + static struct gl_context local_ctx; + + prog = standalone_compile_shader(&options, 2, argv, &local_ctx); + prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->info.stage = MESA_SHADER_FRAGMENT; + +#if 0 + struct bifrost_program compiled; + for (unsigned i = 0; i < 2; ++i) { + nir[i] = glsl_to_nir(&local_ctx, prog, shader_types[i], &bifrost_nir_options); + NIR_PASS_V(nir[i], nir_lower_global_vars_to_local); + NIR_PASS_V(nir[i], nir_split_var_copies); + NIR_PASS_V(nir[i], nir_lower_var_copies); + + NIR_PASS_V(nir[i], nir_lower_alu_to_scalar, NULL); + + /* before buffers and vars_to_ssa */ + NIR_PASS_V(nir[i], gl_nir_lower_bindless_images); + + NIR_PASS_V(nir[i], gl_nir_lower_buffers, prog); + NIR_PASS_V(nir[i], nir_opt_constant_folding); + bifrost_compile_shader_nir(nir[i], &compiled); + } +#endif +} + static void disassemble(const char *filename) { @@ -56,7 +98,10 @@ main(int argc, char **argv) printf("Pass a command\n"); exit(1); } - if (strcmp(argv[1], "disasm") == 0) { + if (strcmp(argv[1], "compile") == 0) { + compile_shader(&argv[2]); + } + else if (strcmp(argv[1], "disasm") == 0) { disassemble(argv[2]); } return 0;