[Bug 86755] [gen7][gen8] glmark2 -b jellyfish misrendered

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Apr 1 12:10:43 PDT 2015


https://bugs.freedesktop.org/show_bug.cgi?id=86755

--- Comment #8 from Ville Syrjala <ville.syrjala at linux.intel.com> ---
(In reply to Samuel Iglesias from comment #7)
> Created attachment 113982 [details] [review]
> glmark2 jellyfish vertex shader patch
> 
> I confirm that this is happening in SNB (gen6) too.
> 
> I modified the jellyfish vertex shader (attached patch) to have the sin()
> function argument to be within the range of [0, 2*PI) radians by using the
> modulo operation. In this case, it renders fine.
> 
> I think this is the same problem explained here:
> 
> http://lists.freedesktop.org/archives/mesa-dev/2014-December/072429.html

Oh, I hadn't noticed your comment here. I came to the same conclusion just
today when I was wondering about this again. I actually went and read throught
the entire asm the vertex shader looking for an error, and when I didn't find
one I figured it could be the sin(), so I cooked up some kind of kludge to fix
it on the Mesa side. I could hve avoided all that if I'd checked this bug first
:) But it was a good exercise anyway, learning a bit of gen asm and looking at
the i965 compiler a bit.

Here's my hack for anyone interested:

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 26a3b9f..85c8f69 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -343,8 +343,19 @@ vec4_visitor::emit_math(enum opcode opcode,
                         const dst_reg &dst,
                         const src_reg &src0, const src_reg &src1)
 {
-   vec4_instruction *math =
-      emit(opcode, dst, fix_math_operand(src0), fix_math_operand(src1));
+   vec4_instruction *math;
+
+   if (opcode == SHADER_OPCODE_SIN || opcode == SHADER_OPCODE_COS) {
+      dst_reg tmp = dst_reg(this, glsl_type::vec4_type);
+      emit(MUL(tmp, src0, brw_imm_f(1.0 / (2.0 * M_PI))));
+      emit(RNDZ(tmp, src_reg(tmp)));
+      emit(MUL(tmp, src_reg(tmp), brw_imm_f(2.0 * M_PI)));
+      emit(ADD(tmp, src0, negate(src_reg(tmp))));
+      math = emit(opcode, dst, fix_math_operand(src_reg(tmp)),
fix_math_operand(src1));
+   } else {
+      math = emit(opcode, dst, fix_math_operand(src0),
fix_math_operand(src1));
+   }

    if (brw->gen == 6 && dst.writemask != WRITEMASK_XYZW) {
       /* MATH on Gen6 must be align1, so we can't do writemasks. */

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20150401/c5242ff2/attachment.html>


More information about the intel-3d-bugs mailing list