Mesa (main): llvmpipe: enable per-sample shading when FB fetch is used

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 22 05:02:10 UTC 2022


Module: Mesa
Branch: main
Commit: 443ef18f0c95af9c3c93a2e7d62362e8da6d3a8e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=443ef18f0c95af9c3c93a2e7d62362e8da6d3a8e

Author: Pavel Asyutchenko <sventeam at yandex.ru>
Date:   Fri Oct  8 00:23:50 2021 +0300

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 <sventeam at yandex.ru>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13979>

---

 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;
 



More information about the mesa-commit mailing list