panfrost: Implement sRGB blend shaders
[mesa.git] / src / gallium / drivers / panfrost / nir / nir_lower_framebuffer.c
index ffb51c4c3a17eb8a127b43d34d3d31795e7fd5ae..887b3662dc306211116026ca5a81b2b9032a0646 100644 (file)
@@ -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);