<div dir="ltr">Eric, I can't test this patch because it only affects your driver.<br></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 12, 2018 at 6:23 PM Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">A while ago, we added a bunch of format conversion helpers; we should<br>
use them instead of hand-rolling sRGB conversions.<br>
---<br>
 src/compiler/nir/nir_lower_tex.c | 21 +++------------------<br>
 1 file changed, 3 insertions(+), 18 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c<br>
index 1ccd253320c..4da025a9e34 100644<br>
--- a/src/compiler/nir/nir_lower_tex.c<br>
+++ b/src/compiler/nir/nir_lower_tex.c<br>
@@ -37,6 +37,7 @@<br>
<br>
 #include "nir.h"<br>
 #include "nir_builder.h"<br>
+#include "nir_format_convert.h"<br>
<br>
 static void<br>
 project_src(nir_builder *b, nir_tex_instr *tex)<br>
@@ -711,24 +712,8 @@ linearize_srgb_result(nir_builder *b, nir_tex_instr *tex)<br>
<br>
    b->cursor = nir_after_instr(&tex->instr);<br>
<br>
-   static const unsigned swiz[4] = {0, 1, 2, 0};<br>
-   nir_ssa_def *comp = nir_swizzle(b, &tex->dest.ssa, swiz, 3, true);<br>
-<br>
-   /* Formula is:<br>
-    *    (comp <= 0.04045) ?<br>
-    *          (comp / 12.92) :<br>
-    *          pow((comp + 0.055) / 1.055, 2.4)<br>
-    */<br>
-   nir_ssa_def *low  = nir_fmul(b, comp, nir_imm_float(b, 1.0 / 12.92));<br>
-   nir_ssa_def *high = nir_fpow(b,<br>
-                                nir_fmul(b,<br>
-                                         nir_fadd(b,<br>
-                                                  comp,<br>
-                                                  nir_imm_float(b, 0.055)),<br>
-                                         nir_imm_float(b, 1.0 / 1.055)),<br>
-                                nir_imm_float(b, 2.4));<br>
-   nir_ssa_def *cond = nir_fge(b, nir_imm_float(b, 0.04045), comp);<br>
-   nir_ssa_def *rgb  = nir_bcsel(b, cond, low, high);<br>
+   nir_ssa_def *rgb =<br>
+      nir_format_srgb_to_linear(b, nir_channels(b, &tex->dest.ssa, 0x7));<br>
<br>
    /* alpha is untouched: */<br>
    nir_ssa_def *result = nir_vec4(b,<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>