mesa/st: Don't expect prog->nir to already exist
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Thu, 22 Aug 2019 18:23:51 +0000 (11:23 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 10 Sep 2019 21:36:46 +0000 (14:36 -0700)
There's no such case, if we load prog->nir from the shader cache, we
shouldn't hit this path.

Suggested-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/state_tracker/st_glsl_to_nir.cpp

index fead0ccc6253bbd73646fa7713575e953eaccca5..39203435515d968d8130a6f0498fb18c06bd0aa0 100644 (file)
@@ -633,6 +633,8 @@ st_link_nir(struct gl_context *ctx,
       struct gl_program *prog = shader->Program;
       _mesa_copy_linked_program_data(shader_program, shader);
 
+      assert(!prog->nir);
+
       if (shader_program->data->spirv) {
          const nir_shader_compiler_options *options =
             st->ctx->Const.ShaderCompilerOptions[shader->Stage].NirOptions;
@@ -640,7 +642,6 @@ st_link_nir(struct gl_context *ctx,
          prog->Parameters = _mesa_new_parameter_list();
          /* Parameters will be filled during NIR linking. */
 
-         /* TODO: Properly handle or dismiss `if (prog->nir)` case. */
          prog->nir = _mesa_spirv_to_nir(ctx, shader_program, shader->Stage, options);
          set_st_program(prog, shader_program, prog->nir);
       } else {
@@ -670,11 +671,9 @@ st_link_nir(struct gl_context *ctx,
             st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions;
          assert(options);
 
-         if (!prog->nir) {
-            prog->nir = glsl_to_nir(st->ctx, shader_program, shader->Stage, options);
-            set_st_program(prog, shader_program, prog->nir);
-            st_nir_preprocess(st, prog, shader_program, shader->Stage);
-         }
+         prog->nir = glsl_to_nir(st->ctx, shader_program, shader->Stage, options);
+         set_st_program(prog, shader_program, prog->nir);
+         st_nir_preprocess(st, prog, shader_program, shader->Stage);
       }
 
       last_stage = i;