zink: take location_frac into account in lower_line_smooth_gs

blender-demo-cube_diorama trace in traces-db hits this.

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22575>
(cherry picked from commit 8ca13afe15)
This commit is contained in:
SoroushIMG 2023-04-17 18:44:50 +01:00 committed by Dylan Baker
parent 98fda79ad9
commit 5f7f5c68cc
2 changed files with 19 additions and 14 deletions

View file

@ -1694,7 +1694,7 @@
"description": "zink: take location_frac into account in lower_line_smooth_gs",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -567,8 +567,8 @@ struct lower_line_smooth_state {
nir_variable *line_coord_out;
nir_variable *prev_pos;
nir_variable *pos_counter;
nir_variable *prev_varyings[VARYING_SLOT_MAX],
*varyings[VARYING_SLOT_MAX];
nir_variable *prev_varyings[VARYING_SLOT_MAX][4],
*varyings[VARYING_SLOT_MAX][4]; // location_frac
};
static bool
@ -583,10 +583,11 @@ lower_line_smooth_gs_store(nir_builder *b,
// we take care of position elsewhere
gl_varying_slot location = var->data.location;
unsigned location_frac = var->data.location_frac;
if (location != VARYING_SLOT_POS) {
assert(state->varyings[location]);
assert(intrin->src[1].is_ssa);
nir_store_var(b, state->varyings[location],
nir_store_var(b, state->varyings[location][location_frac],
intrin->src[1].ssa,
nir_intrinsic_write_mask(intrin));
nir_instr_remove(&intrin->instr);
@ -664,8 +665,9 @@ lower_line_smooth_gs_emit_vertex(nir_builder *b,
for (int i = 0; i < 4; ++i) {
nir_foreach_variable_with_modes(var, b->shader, nir_var_shader_out) {
gl_varying_slot location = var->data.location;
if (state->prev_varyings[location])
nir_copy_var(b, var, state->prev_varyings[location]);
unsigned location_frac = var->data.location_frac;
if (state->prev_varyings[location][location_frac])
nir_copy_var(b, var, state->prev_varyings[location][location_frac]);
}
nir_store_var(b, state->pos_out,
nir_fadd(b, prev, nir_fmul(b, line_offets[i],
@ -678,8 +680,9 @@ lower_line_smooth_gs_emit_vertex(nir_builder *b,
for (int i = 4; i < 8; ++i) {
nir_foreach_variable_with_modes(var, b->shader, nir_var_shader_out) {
gl_varying_slot location = var->data.location;
if (state->varyings[location])
nir_copy_var(b, var, state->varyings[location]);
unsigned location_frac = var->data.location_frac;
if (state->varyings[location][location_frac])
nir_copy_var(b, var, state->varyings[location][location_frac]);
}
nir_store_var(b, state->pos_out,
nir_fadd(b, curr, nir_fmul(b, line_offets[i],
@ -694,8 +697,9 @@ lower_line_smooth_gs_emit_vertex(nir_builder *b,
nir_copy_var(b, state->prev_pos, state->pos_out);
nir_foreach_variable_with_modes(var, b->shader, nir_var_shader_out) {
gl_varying_slot location = var->data.location;
if (state->varyings[location])
nir_copy_var(b, state->prev_varyings[location], state->varyings[location]);
unsigned location_frac = var->data.location_frac;
if (state->varyings[location][location_frac])
nir_copy_var(b, state->prev_varyings[location][location_frac], state->varyings[location][location_frac]);
}
// update prev_pos and pos_counter for next vertex
@ -757,17 +761,18 @@ lower_line_smooth_gs(nir_shader *shader)
memset(state.prev_varyings, 0, sizeof(state.prev_varyings));
nir_foreach_variable_with_modes(var, shader, nir_var_shader_out) {
gl_varying_slot location = var->data.location;
unsigned location_frac = var->data.location_frac;
if (location == VARYING_SLOT_POS)
continue;
char name[100];
snprintf(name, sizeof(name), "__tmp_%d", location);
state.varyings[location] =
snprintf(name, sizeof(name), "__tmp_%d_%d", location, location_frac);
state.varyings[location][location_frac] =
nir_variable_create(shader, nir_var_shader_temp,
var->type, name);
snprintf(name, sizeof(name), "__tmp_prev_%d", location);
state.prev_varyings[location] =
snprintf(name, sizeof(name), "__tmp_prev_%d_%d", location, location_frac);
state.prev_varyings[location][location_frac] =
nir_variable_create(shader, nir_var_shader_temp,
var->type, name);
}