mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
st/mesa: assign driver locations for VS inputs for NIR before caching
fix up edge flags in the NIR pass, because st/mesa doesn't touch the inputs after caching Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
eaffdad108
commit
28199aeee5
5 changed files with 15 additions and 9 deletions
|
|
@ -39,6 +39,11 @@ lower_impl(nir_function_impl *impl)
|
|||
glsl_vec4_type(), "edgeflag_in");
|
||||
in->data.location = VERT_ATTRIB_EDGEFLAG;
|
||||
|
||||
/* The edge flag is the last input in st/mesa. */
|
||||
assert(shader->num_inputs == util_bitcount64(shader->info.inputs_read));
|
||||
in->data.driver_location = shader->num_inputs++;
|
||||
shader->info.inputs_read |= BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG);
|
||||
|
||||
out = nir_variable_create(shader, nir_var_shader_out,
|
||||
glsl_vec4_type(), "edgeflag_out");
|
||||
out->data.location = VARYING_SLOT_EDGE;
|
||||
|
|
|
|||
|
|
@ -83,9 +83,12 @@ st_nir_fixup_varying_slots(struct st_context *st, struct exec_list *var_list)
|
|||
* (This isn't the case with, for ex, FS inputs, which only need to agree
|
||||
* on varying-slot w/ the VS outputs)
|
||||
*/
|
||||
static void
|
||||
st_nir_assign_vs_in_locations(nir_shader *nir)
|
||||
void
|
||||
st_nir_assign_vs_in_locations(struct nir_shader *nir)
|
||||
{
|
||||
if (nir->info.stage != MESA_SHADER_VERTEX)
|
||||
return;
|
||||
|
||||
bool removed_inputs = false;
|
||||
|
||||
nir->num_inputs = util_bitcount64(nir->info.inputs_read);
|
||||
|
|
@ -93,10 +96,7 @@ st_nir_assign_vs_in_locations(nir_shader *nir)
|
|||
/* NIR already assigns dual-slot inputs to two locations so all we have
|
||||
* to do is compact everything down.
|
||||
*/
|
||||
if (var->data.location == VERT_ATTRIB_EDGEFLAG) {
|
||||
/* bit of a hack, mirroring st_translate_vertex_program */
|
||||
var->data.driver_location = nir->num_inputs++;
|
||||
} else if (nir->info.inputs_read & BITFIELD64_BIT(var->data.location)) {
|
||||
if (nir->info.inputs_read & BITFIELD64_BIT(var->data.location)) {
|
||||
var->data.driver_location =
|
||||
util_bitcount64(nir->info.inputs_read &
|
||||
BITFIELD64_MASK(var->data.location));
|
||||
|
|
@ -851,9 +851,6 @@ void
|
|||
st_nir_assign_varying_locations(struct st_context *st, nir_shader *nir)
|
||||
{
|
||||
if (nir->info.stage == MESA_SHADER_VERTEX) {
|
||||
/* Needs special handling so drvloc matches the vbo state: */
|
||||
st_nir_assign_vs_in_locations(nir);
|
||||
|
||||
nir_assign_io_var_locations(&nir->outputs,
|
||||
&nir->num_outputs,
|
||||
nir->info.stage);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ bool
|
|||
st_link_nir(struct gl_context *ctx,
|
||||
struct gl_shader_program *shader_program);
|
||||
|
||||
void st_nir_assign_vs_in_locations(struct nir_shader *nir);
|
||||
void st_nir_assign_varying_locations(struct st_context *st,
|
||||
struct nir_shader *nir);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ st_nir_finish_builtin_shader(struct st_context *st,
|
|||
|
||||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
|
||||
st_nir_assign_vs_in_locations(nir);
|
||||
st_nir_assign_varying_locations(st, nir);
|
||||
|
||||
st_nir_lower_samplers(screen, nir, NULL, NULL);
|
||||
|
|
|
|||
|
|
@ -400,6 +400,8 @@ st_finalize_nir_before_variants(struct nir_shader *nir)
|
|||
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, true);
|
||||
}
|
||||
|
||||
st_nir_assign_vs_in_locations(nir);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue