diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 8b66f8277a8..bb0ba070123 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -435,44 +435,17 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, NIR_PASS_V(nir, nir_lower_samplers, shader_program); } -struct gl_program * -st_nir_get_mesa_program(struct gl_context *ctx, - struct gl_shader_program *shader_program, - struct gl_linked_shader *shader) +static void +set_st_program(struct gl_program *prog, + struct gl_shader_program *shader_program, + nir_shader *nir) { - struct st_context *st = st_context(ctx); - struct gl_program *prog; - - validate_ir_tree(shader->ir); - - prog = shader->Program; - - prog->Parameters = _mesa_new_parameter_list(); - - _mesa_copy_linked_program_data(shader_program, shader); - _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader, - prog->Parameters); - - if (ctx->_Shader->Flags & GLSL_DUMP) { - _mesa_log("\n"); - _mesa_log("GLSL IR for linked %s program %d:\n", - _mesa_shader_stage_to_string(shader->Stage), - shader_program->Name); - _mesa_print_ir(_mesa_get_log_file(), shader->ir, NULL); - _mesa_log("\n\n"); - } - - prog->ExternalSamplersUsed = gl_external_samplers(prog); - _mesa_update_shader_textures_used(shader_program, prog); - struct st_vertex_program *stvp; struct st_common_program *stp; struct st_fragment_program *stfp; struct st_compute_program *stcp; - nir_shader *nir = st_glsl_to_nir(st, prog, shader_program, shader->Stage); - - switch (shader->Stage) { + switch (prog->info.stage) { case MESA_SHADER_VERTEX: stvp = (struct st_vertex_program *)prog; stvp->shader_program = shader_program; @@ -500,10 +473,43 @@ st_nir_get_mesa_program(struct gl_context *ctx, stcp->tgsi.prog = nir_shader_clone(NULL, nir); break; default: - assert(!"should not be reached"); - return NULL; + unreachable("unknown shader stage"); } +} + +struct gl_program * +st_nir_get_mesa_program(struct gl_context *ctx, + struct gl_shader_program *shader_program, + struct gl_linked_shader *shader) +{ + struct st_context *st = st_context(ctx); + struct gl_program *prog; + + validate_ir_tree(shader->ir); + + prog = shader->Program; + + prog->Parameters = _mesa_new_parameter_list(); + + _mesa_copy_linked_program_data(shader_program, shader); + _mesa_generate_parameters_list_for_uniforms(ctx, shader_program, shader, + prog->Parameters); + + if (ctx->_Shader->Flags & GLSL_DUMP) { + _mesa_log("\n"); + _mesa_log("GLSL IR for linked %s program %d:\n", + _mesa_shader_stage_to_string(shader->Stage), + shader_program->Name); + _mesa_print_ir(_mesa_get_log_file(), shader->ir, NULL); + _mesa_log("\n\n"); + } + + prog->ExternalSamplersUsed = gl_external_samplers(prog); + _mesa_update_shader_textures_used(shader_program, prog); + + nir_shader *nir = st_glsl_to_nir(st, prog, shader_program, shader->Stage); + set_st_program(prog, shader_program, nir); return prog; } |