From d38f99baecb8335421b392ecc38435a42d7b372c Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Tue, 14 Nov 2017 09:03:45 +1100 Subject: st/glsl_to_nir: create set_st_program() helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- src/mesa/state_tracker/st_glsl_to_nir.cpp | 74 +++++++++++++++++-------------- 1 file changed, 40 insertions(+), 34 deletions(-) (limited to 'src/mesa/state_tracker') 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; } -- cgit v1.2.3