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;
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;
}