st/mesa: don't call ProgramStringNotify in glsl_to_nir
authorMarek Olšák <marek.olsak@amd.com>
Wed, 13 Nov 2019 04:46:37 +0000 (23:46 -0500)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 26 Nov 2019 20:14:10 +0000 (15:14 -0500)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/state_tracker/st_cb_program.c
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 3a62212..0bc6e90 100644 (file)
@@ -114,6 +114,9 @@ st_program_string_notify( struct gl_context *ctx,
    struct st_context *st = st_context(ctx);
    struct st_program *stp = (struct st_program *) prog;
 
+   /* GLSL-to-NIR should not end up here. */
+   assert(!stp->shader_program);
+
    if (target == GL_FRAGMENT_PROGRAM_ARB ||
        target == GL_FRAGMENT_SHADER_ATI) {
       if (target == GL_FRAGMENT_SHADER_ATI) {
@@ -124,18 +127,15 @@ st_program_string_notify( struct gl_context *ctx,
       }
 
       st_release_fp_variants(st, stp);
-      if (!stp->shader_program && /* not GLSL->NIR */
-          !st_translate_fragment_program(st, stp))
+      if (!st_translate_fragment_program(st, stp))
          return false;
    } else if (target == GL_VERTEX_PROGRAM_ARB) {
       st_release_vp_variants(st, stp);
-      if (!stp->shader_program && /* not GLSL->NIR */
-          !st_translate_vertex_program(st, stp))
+      if (!st_translate_vertex_program(st, stp))
          return false;
    } else {
       st_release_common_variants(st, stp);
-      if (!stp->shader_program && /* not GLSL->NIR */
-          !st_translate_common_program(st, stp))
+      if (!st_translate_common_program(st, stp))
          return false;
    }
 
index 9f41a7a..f8f1ee3 100644 (file)
@@ -790,11 +790,12 @@ st_link_nir(struct gl_context *ctx,
          continue;
 
       struct gl_program *prog = shader->Program;
+      struct st_program *stp = st_program(prog);
       st_glsl_to_nir_post_opts(st, prog, shader_program);
 
       /* Initialize st_vertex_program members. */
       if (i == MESA_SHADER_VERTEX)
-         st_prepare_vertex_program(st_program(prog));
+         st_prepare_vertex_program(stp);
 
       /* Get pipe_stream_output_info. */
       if (i == MESA_SHADER_VERTEX ||
@@ -804,12 +805,14 @@ st_link_nir(struct gl_context *ctx,
 
       st_store_ir_in_disk_cache(st, prog, true);
 
-      if (!ctx->Driver.ProgramStringNotify(ctx,
-                                           _mesa_shader_stage_to_program(i),
-                                           prog)) {
-         _mesa_reference_program(ctx, &shader->Program, NULL);
-         return false;
-      }
+      if (prog->info.stage == MESA_SHADER_VERTEX)
+        st_release_vp_variants(st, stp);
+      else if (prog->info.stage == MESA_SHADER_FRAGMENT)
+        st_release_fp_variants(st, stp);
+      else
+        st_release_common_variants(st, stp);
+
+      st_finalize_program(st, prog);
 
       /* The GLSL IR won't be needed anymore. */
       ralloc_free(shader->ir);