From 443ef18f0c95af9c3c93a2e7d62362e8da6d3a8e Mon Sep 17 00:00:00 2001 From: Pavel Asyutchenko Date: Fri, 8 Oct 2021 00:23:50 +0300 Subject: [PATCH] llvmpipe: enable per-sample shading when FB fetch is used This matches specifications of both color and ZS fetch extensions. Cc: mesa-stable Signed-off-by: Pavel Asyutchenko Reviewed-By: Mike Blumenkrantz Part-of: --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 6c32b1dcec0..300c8db234f 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -4257,7 +4257,30 @@ make_variant_key(struct llvmpipe_context *lp, if (key->multisample) { key->coverage_samples = util_framebuffer_get_num_samples(&lp->framebuffer); - key->min_samples = lp->min_samples == 1 ? 1 : key->coverage_samples; + /* Per EXT_shader_framebuffer_fetch spec: + * + * "1. How is framebuffer data treated during multisample rendering? + * + * RESOLVED: Reading the value of gl_LastFragData produces a different + * result for each sample. This implies that all or part of the shader be + * run once for each sample, but has no additional implications on fragment + * shader input variables which may still be interpolated per pixel by the + * implementation." + * + * ARM_shader_framebuffer_fetch_depth_stencil spec further says: + * + * "(1) When multisampling is enabled, does the shader run per sample? + * + * RESOLVED. + * + * This behavior is inherited from either EXT_shader_framebuffer_fetch or + * ARM_shader_framebuffer_fetch as described in the interactions section. + * If neither extension is supported, the shader runs once per fragment." + * + * Therefore we should always enable per-sample shading when FB fetch is used. + */ + if (lp->min_samples > 1 || shader->info.base.uses_fbfetch) + key->min_samples = key->coverage_samples; } key->nr_cbufs = lp->framebuffer.nr_cbufs;