From: <bug...@fr...> - 2010-03-24 11:36:50
|
http://bugs.freedesktop.org/show_bug.cgi?id=27286 Summary: Mod function returns wrong value Product: Mesa Version: unspecified Platform: Other OS/Version: All Status: NEW Severity: normal Priority: medium Component: Mesa core AssignedTo: mes...@li... ReportedBy: kar...@ar... The following shader returns incorrect output. It looks like the GLSL Compiler doesnt implement mod correctly. varying vec var1; void main (void) { gl_FragColor = vec4(mod(4.0, 2.0), 0.0, 0.0, 1.0); } It should be the same as, varying vec var1; void main (void) { float var = 4.0 - (2.0 * (floor(4.0/2.0)) ); //According to spec gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); } -- Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. |
From: <bug...@fr...> - 2010-03-24 11:41:50
|
http://bugs.freedesktop.org/show_bug.cgi?id=27286 Karthik Hariharakrishnan <kar...@ar...> changed: What |Removed |Added ---------------------------------------------------------------------------- OS/Version|All |Linux (All) Platform|Other |x86 (IA32) Version|unspecified |7.6 --- Comment #1 from Karthik Hariharakrishnan <kar...@ar...> 2010-03-24 04:41:43 PST --- Changing the version of Mesa, Hardware and OS info in bug -- Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. |
From: <bug...@fr...> - 2010-03-24 14:53:41
|
http://bugs.freedesktop.org/show_bug.cgi?id=27286 --- Comment #2 from Brian Paul <bri...@gm...> 2010-03-24 07:53:33 PST --- Can you provide a stand-alone test program that demonstrates this? I tried it myself and I got the expected result: mod(4.0, 2.0) returns 0.0 Mesa's mod() function is implemented just as the spec says: float mod(const float a, const float b) { float oneOverB; __asm float_rcp oneOverB, b; __retVal = a - b * floor(a * oneOverB); } -- Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. |
From: <bug...@fr...> - 2010-03-24 15:13:18
|
http://bugs.freedesktop.org/show_bug.cgi?id=27286 --- Comment #3 from Karthik Hariharakrishnan <kar...@ar...> 2010-03-24 08:13:10 PST --- (In reply to comment #2) > Can you provide a stand-alone test program that demonstrates this? > > I tried it myself and I got the expected result: mod(4.0, 2.0) returns 0.0 > > Mesa's mod() function is implemented just as the spec says: > > float mod(const float a, const float b) > { > float oneOverB; > __asm float_rcp oneOverB, b; > __retVal = a - b * floor(a * oneOverB); > } > Hi Brian, Could you try running the program against the library in lib/gallium. export LD_LIBRARY_PATH=<blah>/Mesa-7.7/lib/gallium The test passes when the following is set export LD_LIBRARY_PATH=<blah>/Mesa-7.7/lib/ Thanks -- Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. |
From: <bug...@fr...> - 2010-03-24 15:37:50
|
http://bugs.freedesktop.org/show_bug.cgi?id=27286 --- Comment #4 from Brian Paul <bri...@gm...> 2010-03-24 08:37:42 PST --- OK, looks like I wasn't running w/ X86/SSE codegen enabled. Looks like a bug in that code. I'll try to take a look in a while. -- Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. |
From: <bug...@fr...> - 2010-03-26 00:24:34
|
http://bugs.freedesktop.org/show_bug.cgi?id=27286 --- Comment #5 from Brian Paul <bri...@gm...> 2010-03-25 17:23:47 PST --- Off-hand, I _think_ this is an issue with the SSE rcp (reciprocol) instruction. Per the comment in the code, I think we need to produce a more accurate result: static void emit_rcp ( struct x86_function *func, unsigned xmm_dst, unsigned xmm_src ) { /* On Intel CPUs at least, this is only accurate to 12 bits -- not * good enough. Need to either emit a proper divide or use the * iterative technique described below in emit_rsqrt(). */ sse2_rcpps( func, make_xmm( xmm_dst ), make_xmm( xmm_src ) ); } Maybe someone handier with SSE can try to fix this. The emit_rsqrt() function further down uses a Newton-Raphson step to improve the results. That could help. -- Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. |