glsl/freedreno/panfrost: pass gl_context to the standalone compiler
authorTimothy Arceri <tarceri@itsqueeze.com>
Fri, 22 Feb 2019 00:51:24 +0000 (11:51 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Wed, 6 Mar 2019 23:05:20 +0000 (23:05 +0000)
This allows us to use the ctx with glsl_to_nir() in a following
patch.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/glsl/main.cpp
src/compiler/glsl/standalone.cpp
src/compiler/glsl/standalone.h
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
src/gallium/drivers/panfrost/midgard/cmdline.c

index a730c0339177837e0dc0f56268759cc40dd21f6b..2ff561e011dd011254e3eb888efe1cc1d274a983 100644 (file)
@@ -34,6 +34,7 @@
  * offline compile GLSL code and examine the resulting GLSL IR.
  */
 
+#include "main/mtypes.h"
 #include "standalone.h"
 
 static struct standalone_options options;
@@ -91,8 +92,10 @@ main(int argc, char * const* argv)
       usage_fail(argv[0]);
 
    struct gl_shader_program *whole_program;
+   static struct gl_context local_ctx;
 
-   whole_program = standalone_compile_shader(&options, argc - optind, &argv[optind]);
+   whole_program = standalone_compile_shader(&options, argc - optind,
+                                             &argv[optind], &local_ctx);
 
    if (!whole_program)
       usage_fail(argv[0]);
index add4e4ea478d86bfaf7160858fb792ba91f56b98..06869a0b3dc8cb40f289463792b5071e8cabdceb 100644 (file)
@@ -400,11 +400,9 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader)
 
 extern "C" struct gl_shader_program *
 standalone_compile_shader(const struct standalone_options *_options,
-      unsigned num_files, char* const* files)
+      unsigned num_files, char* const* files, struct gl_context *ctx)
 {
    int status = EXIT_SUCCESS;
-   static struct gl_context local_ctx;
-   struct gl_context *ctx = &local_ctx;
    bool glsl_es = false;
 
    options = _options;
index 5029e168119ef8539887ad01132c9d1e8ce3be57..d9e14f798a33c1093a09672aee4e13619e14a23b 100644 (file)
@@ -42,7 +42,8 @@ struct gl_shader_program;
 
 struct gl_shader_program * standalone_compile_shader(
       const struct standalone_options *options,
-      unsigned num_files, char* const* files);
+      unsigned num_files, char* const* files,
+      struct gl_context *ctx);
 
 void standalone_compiler_cleanup(struct gl_shader_program *prog);
 
index 872bcb28469cd4c8ae950d3c2659ef7b2efd43a4..0850618bc3ddb7996ed7e2ff6780c5f5d4de5cc8 100644 (file)
@@ -110,8 +110,9 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
        struct gl_shader_program *prog;
        const nir_shader_compiler_options *nir_options =
                        ir3_get_compiler_options(compiler);
+       static struct gl_context local_ctx;
 
-       prog = standalone_compile_shader(&options, num_files, files);
+       prog = standalone_compile_shader(&options, num_files, files, &local_ctx);
        if (!prog)
                errx(1, "couldn't parse `%s'", files[0]);
 
index 1aa0323bb0dda9f57fd3aa8ce5de094ea6145489..7326402dd09f1a19aded0ad20be04aac3f65888c 100644 (file)
@@ -53,7 +53,9 @@ compile_shader(char **argv)
                 .do_link = true,
         };
 
-        prog = standalone_compile_shader(&options, 2, argv);
+        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;
 
         for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
@@ -83,7 +85,9 @@ compile_blend(char **argv)
                 .glsl_version = 140,
         };
 
-        prog = standalone_compile_shader(&options, 1, argv);
+        static struct gl_context local_ctx;
+
+        prog = standalone_compile_shader(&options, 1, argv, &local_ctx);
         prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->info.stage = MESA_SHADER_FRAGMENT;
 
         midgard_program program;