glsl/standalone: Make all standalone contexts have NewProgram set.
authorEmma Anholt <emma@anholt.net>
Wed, 1 Mar 2023 00:12:33 +0000 (16:12 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 22 Mar 2023 22:52:45 +0000 (22:52 +0000)
It was in the standalone compiler but not unit tests.  Only the standalone
compiler had done linking and needed it, so far.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21886>

src/compiler/glsl/standalone.cpp
src/compiler/glsl/standalone_scaffolding.cpp

index 16f4c4c..e8e4012 100644 (file)
@@ -96,24 +96,6 @@ private:
    set *variables;
 };
 
-static void
-init_gl_program(struct gl_program *prog, bool is_arb_asm, gl_shader_stage stage)
-{
-   prog->RefCount = 1;
-   prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
-   prog->info.use_legacy_math_rules = is_arb_asm;
-   prog->info.stage = stage;
-}
-
-static struct gl_program *
-new_program(UNUSED struct gl_context *ctx, gl_shader_stage stage,
-            UNUSED GLuint id, bool is_arb_asm)
-{
-   struct gl_program *prog = rzalloc(NULL, struct gl_program);
-   init_gl_program(prog, is_arb_asm, stage);
-   return prog;
-}
-
 static const struct standalone_options *options;
 
 static void
@@ -327,8 +309,6 @@ initialize_context(struct gl_context *ctx, gl_api api)
    /* GL_ARB_explicit_uniform_location, GL_MAX_UNIFORM_LOCATIONS */
    ctx->Const.MaxUserAssignableUniformLocations =
       4 * MESA_SHADER_STAGES * MAX_UNIFORMS;
-
-   ctx->Driver.NewProgram = new_program;
 }
 
 /* Returned string will have 'ctx' as its ralloc owner. */
index 6396d3e..aa02880 100644 (file)
@@ -178,6 +178,25 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
    shProg->data->NumAtomicBuffers = 0;
 }
 
+
+static void
+init_gl_program(struct gl_program *prog, bool is_arb_asm, gl_shader_stage stage)
+{
+   prog->RefCount = 1;
+   prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
+   prog->info.use_legacy_math_rules = is_arb_asm;
+   prog->info.stage = stage;
+}
+
+static struct gl_program *
+standalone_new_program(UNUSED struct gl_context *ctx, gl_shader_stage stage,
+                       UNUSED GLuint id, bool is_arb_asm)
+{
+   struct gl_program *prog = rzalloc(NULL, struct gl_program);
+   init_gl_program(prog, is_arb_asm, stage);
+   return prog;
+}
+
 void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
 {
    memset(ctx, 0, sizeof(*ctx));
@@ -271,6 +290,8 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
       memcpy(&ctx->Const.ShaderCompilerOptions[sh], &options, sizeof(options));
 
    _mesa_locale_init();
+
+   ctx->Driver.NewProgram = standalone_new_program;
 }
 
 struct gl_shader_program *