All of lore.kernel.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@freedesktop.org
To: dri-devel@lists.freedesktop.org
Subject: [Bug 27901] New: GLSL cos/sin functions broken on Mesa R600 driver
Date: Thu, 29 Apr 2010 12:09:06 -0700 (PDT)	[thread overview]
Message-ID: <bug-27901-502@http.bugs.freedesktop.org/> (raw)

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

           Summary: GLSL cos/sin functions broken on Mesa R600 driver
           Product: Mesa
           Version: git
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: medium
         Component: Drivers/DRI/R600
        AssignedTo: dri-devel@lists.freedesktop.org
        ReportedBy: alain.perrot@gmail.com


As I was playing with OpenGL examples from Joe Groff's blog at
http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html,
I noticed that the cos and sin GLSL functions are broken on the Mesa R600
driver. Other trigonometric functions may be broken as well.

The blog entries provide two versions of a sample program that blend two images
together using GLSL. The blend factor is computed from a timestamp using the
sin function.

There's no problem with the example from chapter 2 where the blend factor is
computed on the CPU (source code at http://github.com/jckarter/hello-gl).

Mesa R600 driver fails to properly run the example from chapter 3 where the
blend factor is computed on the GPU using the GLSL sin function. Mesa software
renderer has no problem running this example (source code at
http://github.com/jckarter/hello-gl-ch3).


Looking at GLSL 1.10 spec, R600 ISA doc and R600 driver code (function
assemble_TRIG in r700_assembler.c), I guess there is two problems :

1. both the GLSL cos/sin functions and R600 hardware expects the angle to be
specified in radians, but the assemble_TRIG function divides the specified
angle by 2 * PI (the result is no more radians).

2. R600 hardware expects the angle to be in the range [-PI, PI] while GLSL does
not specify a range, and the assemble_TRIG function does not clip the angle in
the required range.


A quick and dirty hack to make the example from chapter 3 work with R600 driver
is to clip the timestamp to the [-PI, PI] range and then to multiply it by 2 *
PI :

--- hello-gl.c.old      2010-04-29 20:55:55.000000000 +0200
+++ hello-gl.c  2010-04-29 20:56:12.000000000 +0200
@@ -202,7 +202,10 @@
 static void update_timer(void)
 {
     int milliseconds = glutGet(GLUT_ELAPSED_TIME);
-    g_resources.timer = (float)milliseconds * 0.001f;
+    g_resources.timer = fmodf((float)milliseconds * 0.001f, 2.0f *
3.1415926535897f);
+    if(g_resources.timer > 3.1415926535897f)
+        g_resources.timer -= 2.0f * 3.1415926535897f;
+    g_resources.timer *= 2.0f * 3.1415926535897f;
     glutPostRedisplay();
 }


My config:
RV670 (Radeon HD 3870)
Kubuntu 10.04 "Lucid Lynx" 64-bit
Linux kernel 2.6.34-rc5 from Ubuntu Mainline Kernel PPA
libdrm, radeon, Mesa, Xorg from Xorg-edgers PPA

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

             reply	other threads:[~2010-04-29 19:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-29 19:09 bugzilla-daemon [this message]
2010-05-17 22:10 ` [Bug 27901] GLSL cos/sin functions broken on Mesa R600 driver bugzilla-daemon
2010-05-19  2:25 ` bugzilla-daemon
2010-05-19  2:33 ` bugzilla-daemon
2010-05-19 22:58 ` bugzilla-daemon
2010-05-19 23:46   ` Conn Clark
2010-05-19 23:46 ` bugzilla-daemon
2010-05-20 19:39 ` bugzilla-daemon
2010-05-20 19:46 ` bugzilla-daemon
2010-05-20 19:48 ` bugzilla-daemon
2010-05-21  0:40 ` bugzilla-daemon
2010-05-21  1:08   ` Conn Clark
2010-05-21  1:08 ` bugzilla-daemon
2010-05-21  7:48 ` bugzilla-daemon
2010-05-21 16:32 ` bugzilla-daemon
2010-05-21 18:13 ` bugzilla-daemon
2010-05-21 18:56   ` Conn Clark
2010-05-21 18:56 ` bugzilla-daemon
2010-05-21 20:45 ` bugzilla-daemon
2010-05-21 21:04 ` bugzilla-daemon
2010-06-07 16:17 ` bugzilla-daemon
2010-06-07 16:30 ` bugzilla-daemon
2010-06-08 12:53 ` bugzilla-daemon
2010-06-08 16:09   ` Conn Clark
2010-06-08 16:09 ` bugzilla-daemon
2010-06-08 16:26 ` bugzilla-daemon
2010-06-08 16:36 ` bugzilla-daemon
2010-07-29 14:58 ` bugzilla-daemon
2010-07-29 16:12 ` bugzilla-daemon
2010-08-03 17:05 ` bugzilla-daemon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27901-502@http.bugs.freedesktop.org/ \
    --to=bugzilla-daemon@freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.