r600: Update the PS state when MSAA-ness changes, too.

Avoids a regression when enabling shader precompilation, where the
precompile would happen with MSAA disabled (so no sample mask export) but
we'd never catch up to the shader being rendered with MSAA.

Doesn't fix any current testcases, though.

Acked-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14427>
This commit is contained in:
Emma Anholt 2022-01-06 17:09:11 -08:00 committed by Marge Bot
parent e0429d9fef
commit f07b8a0cac
4 changed files with 29 additions and 16 deletions

View File

@ -3335,9 +3335,16 @@ void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader
};
unsigned spi_baryc_cntl = 0, sid, tmp, num = 0;
unsigned z_export = 0, stencil_export = 0, mask_export = 0;
unsigned sprite_coord_enable = rctx->rasterizer ? rctx->rasterizer->sprite_coord_enable : 0;
uint32_t spi_ps_input_cntl[32];
/* Pull any state we use out of rctx. Make sure that any additional
* state added to this list is also checked in the caller in
* r600_update_derived_state().
*/
bool sprite_coord_enable = rctx->rasterizer ? rctx->rasterizer->sprite_coord_enable : 0;
bool flatshade = rctx->rasterizer ? rctx->rasterizer->flatshade : 0;
bool msaa = rctx->framebuffer.nr_samples > 1 && rctx->ps_iter_samples > 0;
if (!cb->buf) {
r600_init_command_buffer(cb, 64);
} else {
@ -3389,8 +3396,7 @@ void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader
if (rshader->input[i].name == TGSI_SEMANTIC_POSITION ||
rshader->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT ||
(rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR &&
rctx->rasterizer && rctx->rasterizer->flatshade)) {
(rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR && flatshade)) {
tmp |= S_028644_FLAT_SHADE(1);
}
@ -3412,8 +3418,7 @@ void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader
z_export = 1;
if (rshader->output[i].name == TGSI_SEMANTIC_STENCIL)
stencil_export = 1;
if (rshader->output[i].name == TGSI_SEMANTIC_SAMPLEMASK &&
rctx->framebuffer.nr_samples > 1 && rctx->ps_iter_samples > 0)
if (rshader->output[i].name == TGSI_SEMANTIC_SAMPLEMASK && msaa)
mask_export = 1;
}
if (rshader->uses_kill)
@ -3512,8 +3517,8 @@ void evergreen_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader
shader->ps_depth_export = z_export | stencil_export | mask_export;
shader->sprite_coord_enable = sprite_coord_enable;
if (rctx->rasterizer)
shader->flatshade = rctx->rasterizer->flatshade;
shader->flatshade = flatshade;
shader->msaa = msaa;
}
void evergreen_update_es_state(struct pipe_context *ctx, struct r600_pipe_shader *shader)

View File

@ -172,6 +172,7 @@ struct r600_pipe_shader {
struct r600_resource *bo;
unsigned sprite_coord_enable;
unsigned flatshade;
unsigned msaa;
unsigned pa_cl_vs_out_cntl;
unsigned nr_ps_color_outputs;
unsigned ps_color_export_mask;

View File

@ -2446,7 +2446,14 @@ void r600_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *sha
unsigned tmp, sid, ufi = 0;
int need_linear = 0;
unsigned z_export = 0, stencil_export = 0, mask_export = 0;
unsigned sprite_coord_enable = rctx->rasterizer ? rctx->rasterizer->sprite_coord_enable : 0;
/* Pull any state we use out of rctx. Make sure that any additional
* state added to this list is also checked in the caller in
* r600_update_derived_state().
*/
bool sprite_coord_enable = rctx->rasterizer ? rctx->rasterizer->sprite_coord_enable : 0;
bool flatshade = rctx->rasterizer ? rctx->rasterizer->flatshade : 0;
bool msaa = rctx->framebuffer.nr_samples > 1 && rctx->ps_iter_samples > 0;
if (!cb->buf) {
r600_init_command_buffer(cb, 64);
@ -2473,8 +2480,7 @@ void r600_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *sha
if (rshader->input[i].name == TGSI_SEMANTIC_POSITION ||
rshader->input[i].interpolate == TGSI_INTERPOLATE_CONSTANT ||
(rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR &&
rctx->rasterizer && rctx->rasterizer->flatshade))
(rshader->input[i].interpolate == TGSI_INTERPOLATE_COLOR && flatshade))
tmp |= S_028644_FLAT_SHADE(1);
if (rshader->input[i].name == TGSI_SEMANTIC_PCOORD ||
@ -2503,8 +2509,7 @@ void r600_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *sha
z_export = 1;
if (rshader->output[i].name == TGSI_SEMANTIC_STENCIL)
stencil_export = 1;
if (rshader->output[i].name == TGSI_SEMANTIC_SAMPLEMASK &&
rctx->framebuffer.nr_samples > 1 && rctx->ps_iter_samples > 0)
if (rshader->output[i].name == TGSI_SEMANTIC_SAMPLEMASK && msaa)
mask_export = 1;
}
db_shader_control |= S_02880C_Z_EXPORT_ENABLE(z_export);
@ -2585,8 +2590,8 @@ void r600_update_ps_state(struct pipe_context *ctx, struct r600_pipe_shader *sha
shader->ps_depth_export = z_export | stencil_export | mask_export;
shader->sprite_coord_enable = sprite_coord_enable;
if (rctx->rasterizer)
shader->flatshade = rctx->rasterizer->flatshade;
shader->flatshade = flatshade;
shader->msaa = msaa;
}
void r600_update_vs_state(struct pipe_context *ctx, struct r600_pipe_shader *shader)

View File

@ -1909,9 +1909,11 @@ static bool r600_update_derived_state(struct r600_context *rctx)
rctx->rasterizer->sprite_coord_enable != rctx->ps_shader->current->sprite_coord_enable ||
rctx->rasterizer->flatshade != rctx->ps_shader->current->flatshade)) {
if (unlikely(!ps_dirty && rctx->ps_shader && rctx->rasterizer &&
bool msaa = rctx->framebuffer.nr_samples > 1 && rctx->ps_iter_samples > 0;
if (unlikely(rctx->ps_shader &&
((rctx->rasterizer->sprite_coord_enable != rctx->ps_shader->current->sprite_coord_enable) ||
(rctx->rasterizer->flatshade != rctx->ps_shader->current->flatshade)))) {
(rctx->rasterizer->flatshade != rctx->ps_shader->current->flatshade) ||
(msaa != rctx->ps_shader->current->msaa)))) {
if (rctx->b.chip_class >= EVERGREEN)
evergreen_update_ps_state(ctx, rctx->ps_shader->current);