diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 25339aeb63e..edb0c1d344f 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -135,9 +135,8 @@ make_nir_clear_vertex_shader(struct st_context *st, bool layered) VARYING_SLOT_LAYER }; - return st_nir_make_passthrough_shader(st, shader_name, MESA_SHADER_VERTEX, - layered ? 2 : 1, inputs, outputs, - NULL, (1 << 1)); + return st_nir_make_passthrough_vs(st, shader_name, layered ? 2 : 1, inputs, + outputs, (1 << 1)); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 609cdfd5378..4ce64badfab 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -302,9 +302,7 @@ st_make_passthrough_vertex_shader(struct st_context *st) { VARYING_SLOT_POS, VARYING_SLOT_COL0, VARYING_SLOT_TEX0 }; st->passthrough_vs = - st_nir_make_passthrough_shader(st, "drawpixels VS", - MESA_SHADER_VERTEX, 3, - inputs, outputs, NULL, 0); + st_nir_make_passthrough_vs(st, "drawpixels VS", 3, inputs, outputs, 0); } diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c index cb5ba13a5c2..5313d3ecc1a 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.c +++ b/src/mesa/state_tracker/st_cb_drawtex.c @@ -109,10 +109,8 @@ lookup_shader(struct st_context *st, } CachedShaders[i].handle = - st_nir_make_passthrough_shader(st, "st/drawtex VS", - MESA_SHADER_VERTEX, - num_attribs, inputs, - slots, NULL, 0); + st_nir_make_passthrough_vs(st, "st/drawtex VS", num_attribs, inputs, + slots, 0); NumCachedShaders++; diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h index 70557c5a033..f87b9d9e629 100644 --- a/src/mesa/state_tracker/st_nir.h +++ b/src/mesa/state_tracker/st_nir.h @@ -64,14 +64,12 @@ st_nir_finish_builtin_shader(struct st_context *st, struct nir_shader *nir); void * -st_nir_make_passthrough_shader(struct st_context *st, - const char *shader_name, - gl_shader_stage stage, - unsigned num_vars, - const unsigned *input_locations, - const gl_varying_slot *output_locations, - unsigned *interpolation_modes, - unsigned sysval_mask); +st_nir_make_passthrough_vs(struct st_context *st, + const char *shader_name, + unsigned num_vars, + const unsigned *input_locations, + const gl_varying_slot *output_locations, + unsigned sysval_mask); void * st_nir_make_clearcolor_shader(struct st_context *st); diff --git a/src/mesa/state_tracker/st_nir_builtins.c b/src/mesa/state_tracker/st_nir_builtins.c index 7b08cbe4016..191ebdbe390 100644 --- a/src/mesa/state_tracker/st_nir_builtins.c +++ b/src/mesa/state_tracker/st_nir_builtins.c @@ -103,44 +103,41 @@ st_nir_finish_builtin_shader(struct st_context *st, } /** - * Make a simple shader that copies inputs to corresponding outputs. + * Make a simple vertex shader that copies inputs to corresponding outputs. */ void * -st_nir_make_passthrough_shader(struct st_context *st, - const char *shader_name, - gl_shader_stage stage, - unsigned num_vars, - const unsigned *input_locations, - const gl_varying_slot *output_locations, - unsigned *interpolation_modes, - unsigned sysval_mask) +st_nir_make_passthrough_vs(struct st_context *st, + const char *shader_name, + unsigned num_vars, + const unsigned *input_locations, + const gl_varying_slot *output_locations, + unsigned sysval_mask) { - const struct glsl_type *vec4 = glsl_vec4_type(); const nir_shader_compiler_options *options = - st_get_nir_compiler_options(st, stage); + st_get_nir_compiler_options(st, MESA_SHADER_VERTEX); - nir_builder b = nir_builder_init_simple_shader(stage, options, + nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_VERTEX, options, "%s", shader_name); + b.shader->info.io_lowered = true; for (unsigned i = 0; i < num_vars; i++) { - nir_variable *in; + nir_def *in; + if (sysval_mask & (1 << i)) { - in = nir_create_variable_with_location(b.shader, nir_var_system_value, - input_locations[i], - glsl_int_type()); + nir_variable *var = + nir_create_variable_with_location(b.shader, nir_var_system_value, + input_locations[i], + glsl_int_type()); + in = nir_load_var(&b, var); } else { - in = nir_create_variable_with_location(b.shader, nir_var_shader_in, - input_locations[i], vec4); + in = nir_load_input(&b, 4, 32, nir_imm_int(&b, 0), + .io_semantics.location = input_locations[i]); } - if (interpolation_modes) - in->data.interpolation = interpolation_modes[i]; - nir_variable *out = - nir_create_variable_with_location(b.shader, nir_var_shader_out, - output_locations[i], in->type); - out->data.interpolation = in->data.interpolation; - - nir_copy_var(&b, out, in); + nir_store_output(&b, in, nir_imm_int(&b, 0), + .src_type = output_locations[i] == VARYING_SLOT_LAYER ? + nir_type_int32 : nir_type_float32, + .io_semantics.location = output_locations[i]); } return st_nir_finish_builtin_shader(st, b.shader);