st/mesa: switch st_nir_make_passthrough_shader to IO intrinsics

also simplify it to only make VS because it's only used for VS.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32779>
This commit is contained in:
Marek Olšák
2024-12-24 12:47:48 -05:00
committed by Marge Bot
parent ec68f0492b
commit eeea99210f
5 changed files with 34 additions and 44 deletions

View File

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

View File

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

View File

@@ -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++;

View File

@@ -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);

View File

@@ -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);