glsl/freedreno/panfrost: pass gl_context to the standalone compiler

This allows us to use the ctx with glsl_to_nir() in a following
patch.

Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Timothy Arceri 2019-02-22 11:51:24 +11:00
parent 15b83b3af9
commit 7530d4abfc
5 changed files with 15 additions and 8 deletions

View file

@ -34,6 +34,7 @@
* offline compile GLSL code and examine the resulting GLSL IR. * offline compile GLSL code and examine the resulting GLSL IR.
*/ */
#include "main/mtypes.h"
#include "standalone.h" #include "standalone.h"
static struct standalone_options options; static struct standalone_options options;
@ -91,8 +92,10 @@ main(int argc, char * const* argv)
usage_fail(argv[0]); usage_fail(argv[0]);
struct gl_shader_program *whole_program; 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) if (!whole_program)
usage_fail(argv[0]); usage_fail(argv[0]);

View file

@ -400,11 +400,9 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader)
extern "C" struct gl_shader_program * extern "C" struct gl_shader_program *
standalone_compile_shader(const struct standalone_options *_options, 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; int status = EXIT_SUCCESS;
static struct gl_context local_ctx;
struct gl_context *ctx = &local_ctx;
bool glsl_es = false; bool glsl_es = false;
options = _options; options = _options;

View file

@ -42,7 +42,8 @@ struct gl_shader_program;
struct gl_shader_program * standalone_compile_shader( struct gl_shader_program * standalone_compile_shader(
const struct standalone_options *options, 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); void standalone_compiler_cleanup(struct gl_shader_program *prog);

View file

@ -110,8 +110,9 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
struct gl_shader_program *prog; struct gl_shader_program *prog;
const nir_shader_compiler_options *nir_options = const nir_shader_compiler_options *nir_options =
ir3_get_compiler_options(compiler); 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) if (!prog)
errx(1, "couldn't parse `%s'", files[0]); errx(1, "couldn't parse `%s'", files[0]);

View file

@ -53,7 +53,9 @@ compile_shader(char **argv)
.do_link = true, .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; prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->info.stage = MESA_SHADER_FRAGMENT;
for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) { for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
@ -83,7 +85,9 @@ compile_blend(char **argv)
.glsl_version = 140, .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; prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->info.stage = MESA_SHADER_FRAGMENT;
midgard_program program; midgard_program program;