New: Casting floating point variable to integer not working properly while constant gets converted properly
https://bugs.freedesktop.org/show_bug.cgi?id=70327
Priority: medium
Bug ID: 70327
Assignee: [email protected]
Summary: Casting floating point variable to integer not working
properly while constant gets converted properly
Severity: normal
Classification: Unclassified
OS: Linux (All)
Reporter: [email protected]
Hardware: All
Status: NEW
Version: git
Component: Drivers/Gallium/r600
Product: Mesa
Created attachment 87353
--> https://bugs.freedesktop.org/attachment.cgi?id=87353&action=edit
Full rendered scene with bug visible
I've recently been working on converting the shaders used by the Dolphin emulator to use integers instead of floating point numbers (for better emulation accuracy). This seems to have exposed a bug in the r600g driver possibly related to float->int casting.
The core of the issue is this GLSL code line:
"iprev.rgb = (iprev.rgb * (int(256.0-fog))) / 256;" (*)
where fog has been initialized before as "float fog = clamp(ze - fog_uniform.z, 0.0, 1.0);"
The point is, while "fog" seems to be zero (a "fog==0.0" condition in the code will return true), the pixel shader result of (*) is different than the one that I get by substituting "fog" with 0.0. This gets very apparent in the rendered scene, cf
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #1 from [email protected] ---
...cf. first attachment "Full rendered scene with bug visible". Second attachement "Full rendered scene with software renderer" shows the same scene rendered properly with "LIBGL_ALWAYS_SOFTWARE=1" (I don't know if it was using llvmpipe or swrast, took halve a minute to render if that says anything).
I'll provide a way to reproduce the issue in a followup comment.
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #2 from [email protected] --- Created attachment 87355
--> https://bugs.freedesktop.org/attachment.cgi?id=87355&action=edit
Full rendered scene with software renderer
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
[email protected] changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #87353|0 |1
is obsolete| |
--- Comment #3 from [email protected] --- Created attachment 87356
--> https://bugs.freedesktop.org/attachment.cgi?id=87356&action=edit
Full rendered scene with bug visible
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #4 from [email protected] ---
Created attachment 87357
--> https://bugs.freedesktop.org/attachment.cgi?id=87357&action=edit
dff file to reproduce the issue by rendering a subset of the reference scene in Dolphin
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #5 from [email protected] --- Created attachment 87359
--> https://bugs.freedesktop.org/attachment.cgi?id=87359&action=edit
Output of R600_DEBUG=vs,ps,fs,sbdisasm when rendering the reduced scene
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #6 from [email protected] ---
Steps the reproduce the issue:
1. Clone the dolphin repository from the url provided at
http://code.google.com/p/dolphin-emu/source/checkout
2. Checkout the tev_fixes_new branch at commit 5d8cfade42ce .
3. Build Dolphin with the build instructions outlined at
http://code.google.com/p/dolphin-emu/wiki/Linux_Build . We use CMake for our build system, so if you're familiar with that you should be able to get it running quickly.
4. run "dolphin-emu -b -e <path to the attached dff file>". Alternatively, run Dolphin normally and open the dff file manually.
5. You should be able to see Mario (the main character of the game in the rendered scene), and only Mario (I removed all unimportant stuff from the scene). If you don't, try to make sure things work all by running any gamecube demo elf (sorry, got no link) and following the instructions at
http://wiki.dolphin-emu.org/index.php?title=FifoPlayer under "How to play back a fifo log?"
Basically, r600g renders the broken screenshot that I attached, while the software renderer renders the scene fine. Replacing "fog" in the "iprev.rgb = (iprev.rgb * (int(256.0-fog))) / 256;" line with "0.0" makes the scene render correctly.
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #7 from [email protected] --- Created attachment 87360
--> https://bugs.freedesktop.org/attachment.cgi?id=87360&action=edit
Sample GLSL shader that is used during rendering the glitched character
Attached you find one of the glitched GLSL shaders which uses the mentioned line at line 149.
Sorry for the dumb source layout, that's because the shaders aren't hand written but automatically generated.
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #8 from [email protected] ---
Created attachment 87361
--> https://bugs.freedesktop.org/attachment.cgi?id=87361&action=edit
R600_DEBUG=vs,ps,fs,sbdisasm for small scene with the shader that we actually use
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #9 from [email protected] ---
Created attachment 87362
--> https://bugs.freedesktop.org/attachment.cgi?id=87362&action=edit
R600_DEBUG=vs,ps,fs,sbdisasm for small scene with the shader where I replaced "fog" with "0.0" in the problematic line
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #10 from Vadim Girlin <[email protected]> --- Created attachment 87364
--> https://bugs.freedesktop.org/attachment.cgi?id=87364&action=edit
patch
This patch should fix the issue (only compile-tested so far, I can't test with r600g card right now, but hopefully it's simple enough to be correct).
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
--- Comment #11 from [email protected] --- I can confirm that the patch fixes the issue, thanks :)
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
[Bug 70327] Casting floating point variable to integer not working properly while constant gets converted properly
In reply to [email protected]https://bugs.freedesktop.org/show_bug.cgi?id=70327
Fabio Pedretti <[email protected]> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED--- Comment #12 from Fabio Pedretti <[email protected]> --- Applied in
http://cgit.freedesktop.org/mesa/mesa/commit/?id=10ddeb910ba8386a6b46396d827aed4116091b0b
Signature · 2 lines
You are receiving this mail because: You are the assignee for the bug.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel