<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 12, 2016 at 1:05 AM, Samuel Iglesias Gonsálvez <span dir="ltr"><<a href="mailto:siglesias@igalia.com" target="_blank">siglesias@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Iago Toral Quiroga <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>><br>
<br>
At least i965 hardware does not have native support for fract() on doubles.<br>
---<br>
src/compiler/nir/nir.h | 1 +<br>
src/compiler/nir/nir_lower_double_ops.c | 14 ++++++++++++++<br>
2 files changed, 15 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index 7c9e498..4a57e74 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -2289,6 +2289,7 @@ typedef enum {<br>
nir_lower_dtrunc = (1 << 3),<br>
nir_lower_dfloor = (1 << 4),<br>
nir_lower_dceil = (1 << 5),<br>
+ nir_lower_dfract = (1 << 6)<br>
} nir_lower_doubles_options;<br>
<br>
void nir_lower_doubles(nir_shader *shader, nir_lower_doubles_options options);<br>
diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c<br>
index 66e2be4..0f42c21 100644<br>
--- a/src/compiler/nir/nir_lower_double_ops.c<br>
+++ b/src/compiler/nir/nir_lower_double_ops.c<br>
@@ -417,6 +417,12 @@ lower_ceil(nir_builder *b, nir_ssa_def *src)<br>
src));<br>
}<br>
<br>
+static nir_ssa_def *<br>
+lower_fract(nir_builder *b, nir_ssa_def *src)<br>
+{<br>
+ return nir_fsub(b, src, nir_ffloor(b, src));<br>
+}<br>
+<br>
static void<br>
lower_doubles_instr(nir_alu_instr *instr, nir_lower_doubles_options options)<br>
{<br>
@@ -455,6 +461,11 @@ lower_doubles_instr(nir_alu_instr *instr, nir_lower_doubles_options options)<br>
return;<br>
break;<br>
<br>
+ case nir_op_ffract:<br>
+ if (!(options & nir_lower_dfract))<br>
+ return;<br>
+ break;<br>
+<br>
default:<br>
return;<br>
}<br>
@@ -487,6 +498,9 @@ lower_doubles_instr(nir_alu_instr *instr, nir_lower_doubles_options options)<br>
case nir_op_fceil:<br>
result = lower_ceil(&bld, src);<br>
break;<br>
+ case nir_op_ffract:<br>
+ result = lower_fract(&bld, src);<br>
+ break;<br>
default:<br>
unreachable("unhandled opcode");<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>