zink: fill in params for fs shader keys and flag shader for rebuild

we need to check for rebuild any time fb samples becomes 0 in order to remove
any writes to gl_SampleMask

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7193>
This commit is contained in:
Mike Blumenkrantz 2020-07-13 17:32:13 -04:00 committed by Marge Bot
parent ed7a5a5568
commit 9aa08221fa
3 changed files with 13 additions and 1 deletions

View File

@ -737,7 +737,11 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
zink_framebuffer_reference(screen, &ctx->framebuffer, fb);
zink_render_pass_reference(screen, &ctx->gfx_pipeline_state.render_pass, fb->rp);
ctx->gfx_pipeline_state.rast_samples = util_framebuffer_get_num_samples(state);
uint8_t rast_samples = util_framebuffer_get_num_samples(state);
/* in vulkan, gl_SampleMask needs to be explicitly ignored for sampleCount == 1 */
if ((ctx->gfx_pipeline_state.rast_samples > 1) != (rast_samples > 1))
ctx->dirty_shader_stages |= 1 << PIPE_SHADER_FRAGMENT;
ctx->gfx_pipeline_state.rast_samples = rast_samples;
ctx->gfx_pipeline_state.num_attachments = state->nr_cbufs;
ctx->gfx_pipeline_state.hash = 0;

View File

@ -180,6 +180,13 @@ shader_key_fs_gen(struct zink_context *ctx, struct zink_shader *zs, struct zink_
fs_key->shader_id = zs->shader_id;
//fs_key->flat_shade = ctx->rast_state->base.flatshade;
/* if gl_SampleMask[] is written to, we have to ensure that we get a shader with the same sample count:
* in GL, rast_samples==1 means ignore gl_SampleMask[]
* in VK, gl_SampleMask[] is never ignored
*/
if (zs->nir->info.outputs_written & (1 << FRAG_RESULT_SAMPLE_MASK))
fs_key->samples = !!ctx->fb_state.samples;
}
typedef void (*zink_shader_key_gen)(struct zink_context *ctx, struct zink_shader *zs, struct zink_shader_key *key);

View File

@ -29,6 +29,7 @@
struct zink_fs_key {
unsigned shader_id;
//bool flat_shade;
bool samples;
};
/* a shader key is used for swapping out shader modules based on pipeline states,