Mesa (master): panfrost: Implement sRGB blend shaders

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 6 13:09:08 UTC 2020


Module: Mesa
Branch: master
Commit: dadfca3775bf2c5086947ab63e64dc67d8e8373a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dadfca3775bf2c5086947ab63e64dc67d8e8373a

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Sat Jan  4 12:14:57 2020 -0500

panfrost: Implement sRGB blend shaders

We use the lowering in nir_format_convert. There are native ops for this
so this is far from optimal and not remotely efficient but as with most
blend shader things right now, it's hard enough to get it working, so
let's focus on that for now. We'll make it fast later (once we have
GLES3 stable, we can start optimizing these things).

Fixes dEQP-GLES3.functional.fragment_ops.blend.fbo_srgb.*

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso at collabora.com>

---

 src/gallium/drivers/panfrost/nir/nir_lower_framebuffer.c | 16 ++++++++++++++++
 src/gallium/drivers/panfrost/pan_context.c               |  8 --------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/panfrost/nir/nir_lower_framebuffer.c b/src/gallium/drivers/panfrost/nir/nir_lower_framebuffer.c
index ffb51c4c3a1..887b3662dc3 100644
--- a/src/gallium/drivers/panfrost/nir/nir_lower_framebuffer.c
+++ b/src/gallium/drivers/panfrost/nir/nir_lower_framebuffer.c
@@ -338,6 +338,22 @@ nir_lower_framebuffer(nir_shader *shader, enum pipe_format format,
                /* Grab the input color */
                nir_ssa_def *c_nir = nir_ssa_for_src(&b, intr->src[1], 4);
 
+               /* Apply sRGB transform */
+
+               if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
+                  nir_ssa_def *rgb = nir_channels(&b, c_nir, 0x7);
+                  nir_ssa_def *trans = nir_format_linear_to_srgb(&b, rgb);
+
+                  nir_ssa_def *comp[4] = {
+                     nir_channel(&b, trans, 0),
+                     nir_channel(&b, trans, 1),
+                     nir_channel(&b, trans, 2),
+                     nir_channel(&b, c_nir, 3),
+                  };
+
+                  c_nir = nir_vec(&b, comp, 4);
+               }
+
                /* Format convert */
                nir_ssa_def *converted = nir_shader_to_native(&b, c_nir, format_desc, bits, homogenous_bits);
 
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 8c911b5d001..9c51f423f86 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1037,14 +1037,6 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                                 SET_BIT(rts[i].flags, MALI_BLEND_SRGB, is_srgb);
                                 SET_BIT(rts[i].flags, MALI_BLEND_NO_DITHER, !ctx->blend->base.dither);
 
-                                /* TODO: sRGB in blend shaders is currently
-                                 * unimplemented. Contact me (Alyssa) if you're
-                                 * interested in working on this. We have
-                                 * native Midgard ops for helping here, but
-                                 * they're not well-understood yet. */
-
-                                assert(!(is_srgb && blend[i].is_shader));
-
                                 if (blend[i].is_shader) {
                                         rts[i].blend.shader = blend[i].shader.gpu | blend[i].shader.first_tag;
                                 } else {




More information about the mesa-commit mailing list