https://bugs.freedesktop.org/show_bug.cgi?id=63520
Priority: medium Bug ID: 63520 Assignee: dri-devel@lists.freedesktop.org Summary: r300g regression (RV380): Strange rendering of light sources in Penumbra (bisected) Severity: normal Classification: Unclassified OS: Linux (All) Reporter: pj_beers@hotmail.com Hardware: x86 (IA32) Status: NEW Version: 9.0 Component: Drivers/Gallium/r300 Product: Mesa
Created attachment 77936 --> https://bugs.freedesktop.org/attachment.cgi?id=77936&action=edit Bad rendering screen 1
Since mesa-9.0, light is rendered incorrectly in the Penumbra games (Overture, Black Plague, Requiem). I find it hard to describe so I've included two good and two bad screenshots from two scenes to illustrate the problem. For, fixing this bug would mean rendering of light sources as in the "good" screenshots.
I've bisected (between mesa-8.0 and mesa-9.0) and the first bad commit is 134a0a5ff88851c971fb95863317f640b5b9fa3a , r300/compiler: Use the smart scheduler for r300 cards. I then checked out current master and reverting this commit fixes the problem in master.
I compiled mesa with the following options: --with-dri-drivers="radeon,swrast" --with-gallium-drivers="r300,swrast" --enable-gallium-llvm --enable-texture-float --enable-gallium-g3dvl --enable-glx-tls --enable-motif --enable-xvmc
My system is Slackware 14.0 with kernel 3.7.6, libdrm-2.4.42 and xf86-video-ati-7.1.0.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #1 from PJBrs pj_beers@hotmail.com --- Created attachment 77937 --> https://bugs.freedesktop.org/attachment.cgi?id=77937&action=edit Good rendering screen 1
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #2 from PJBrs pj_beers@hotmail.com --- Created attachment 77938 --> https://bugs.freedesktop.org/attachment.cgi?id=77938&action=edit Bad rendering screen 2
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #3 from PJBrs pj_beers@hotmail.com --- Created attachment 77939 --> https://bugs.freedesktop.org/attachment.cgi?id=77939&action=edit Good rendering screen 2
https://bugs.freedesktop.org/show_bug.cgi?id=63520
PJBrs pj_beers@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #77936|text/plain |image/png mime type| |
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #4 from PJBrs pjbrs@floorenpj.xs4all.nl --- I've run the Penumbra Requiem game with RADEON_DEBUG=fp,vp and captured the output. I made two attachments. The file named "Goodlog" is the log with mesa version snb_magic_9030_g342cac7 (commit 342cac71669662abad3435fd13ecf28d073874c3). The file named "badlog" is the output with mesa version snb-magic-9031-g134a0a5 (commit 134a0a5ff88851c971fb95863317f640b5b9fa3a). Let me know if any other information is needed.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #5 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 78616 --> https://bugs.freedesktop.org/attachment.cgi?id=78616&action=edit First bad penumbra output with RADEON_DEBUG=fp,vp
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #6 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 78617 --> https://bugs.freedesktop.org/attachment.cgi?id=78617&action=edit Last good penumbra output with RADEON_DEBUG=fp,vp
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #7 from PJBrs pjbrs@floorenpj.xs4all.nl --- Tom Stellard suggested that I do a binary search for incorrectly rendered shaders. I first compared debug log differences between old and smart schedulers. The logs show that eight shader programs are compiled differently by the two schedulers (I assume that a shader program is identified by "pc=$number" in the log.) For each of these shader programs I've listed the number of fragment program instructions and the number of hardware program instruction, for both old and smart scheduler:
#instructions: fp old: fp smart: hwp old: hwp smart: Shader program: pc=8 14 12 8 7 pc=9 25 24 19 19 pc=10 22 22 17 18 pc=11 9 8 4 4 pc=15 6 5 3 2 pc=17 26 26 18 18 pc=18 20 19 11 11 pc=19 7 6 3 3
fp=fragment program hwp=hardware program
I then did a binary analysis by trying different numbers for max_alu_instructions. I started with 15. With max_alu=15, there are some differences in shading between old and smart schedulers. Same with max_alu=8. With lower max_alu (tested 4, 6 and 7), these differences disappear. I did not notice any other differences in rendering between old and smart schedulers for max_alu=<15. However, I did not yet see the bug that I initially noticed when I reported it, so I tested further with max_alu=20.
With max_alu=20, the smart scheduler displays the lighting bug that I initially wanted to report. With max_alu=17 and max_alu=18, rendering is the same as with max_alu=15 for both old and smart schedulars. With max_alu=19, a new difference in rendering between old and smart schedulers is introduced. A final difference is introduced with max_alu=20, which shows the bug that I originally saw. So, in sum, at least three shader programs are rendered differently by the old and smart schedulers--the first difference appears with max_alu=8, the second with max_alu=19 and the third difference with max_alu=20.
The first difference suggests that "pc=8" is rendered incorrectly, since it has 7 instructions in the smart scheduler. Apparently, it does not do anything with the old scheduler (which results in 8 instructions), but increasing max_alu does not change those rendering bits rendered incorrectly by the smart scheduler. The second difference is either caused by shader program "pc=17", which consist of 18 instructions in both schedulers, or by "pc=10" which consists of 17 instructions with the old scheduler and 18 instructions with the smart scheduler. It's hard to say which shader program is rendered incorrectly (if not both are), because, with the old scheduler, there are rendering differences between max_alu=17 and max_alu=18. As the smart renderer shows no differences between max_alu=17 and max_alu=18, these must be caused by "pc=10". The third incorrectly rendered shader program would be "pc=9", with 19 instructions.
What would a good starting point for searching the bug be? I think comparing the compilations for pc=19 and pc=8, because those almost certainly are rendered incorrectly due to changes in the scheduler. I've added screenshots and logs insofar I thought was necessary. I have more available, but I don't want to clog this report. I hope that the filenames speak for themselves :-) Please let me know what else I can do.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #8 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79150 --> https://bugs.freedesktop.org/attachment.cgi?id=79150&action=edit Screenshot, maxALU=8, old renderer
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #9 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79152 --> https://bugs.freedesktop.org/attachment.cgi?id=79152&action=edit Screenshot, maxALU=8, smart renderer
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #10 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79154 --> https://bugs.freedesktop.org/attachment.cgi?id=79154&action=edit Log RADEON_DEBUG=fp,vp, maxALU=8, old renderer
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #11 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79155 --> https://bugs.freedesktop.org/attachment.cgi?id=79155&action=edit Log RADEON_DEBUG=fp,vp, maxALU=8, smart renderer
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #12 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79156 --> https://bugs.freedesktop.org/attachment.cgi?id=79156&action=edit Screenshot, maxALU=20, old renderer
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #13 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79157 --> https://bugs.freedesktop.org/attachment.cgi?id=79157&action=edit Screenshot, maxALU=20, smart renderer
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #14 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79158 --> https://bugs.freedesktop.org/attachment.cgi?id=79158&action=edit Log RADEON_DEBUG=fp,vp, maxALU=20, old renderer
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #15 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79160 --> https://bugs.freedesktop.org/attachment.cgi?id=79160&action=edit Log RADEON_DEBUG=fp,vp, maxALU=20, smart renderer
https://bugs.freedesktop.org/show_bug.cgi?id=63520
PJBrs pjbrs@floorenpj.xs4all.nl changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #79156|text/plain |image/png mime type| |
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #16 from PJBrs pjbrs@floorenpj.xs4all.nl --- To be clear-- with "trying different numbers for max_alu_instructions", I mean changing c->Base.max_alu_insts into a number (e.g., 15) in line 157 of the file src/gallium/drivers/r300/compiler/r300_fragprog_emit.c.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #17 from Tom Stellard tstellar@gmail.com --- Thanks for identifying the bad shaders, this saved me a lot of work. I spotted a bug in the "pc=8" shader:
6: TEX temp[1].x, temp[1].z___, 1D[3] SEM_WAIT SEM_ACQUIRE;
This instruction is wrong because TEX instructions can't swizzle their source operands. For 1D textures, the coordinate is always read from the x component.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #18 from Tom Stellard tstellar@gmail.com --- Created attachment 79572 --> https://bugs.freedesktop.org/attachment.cgi?id=79572&action=edit Possible Fix
Does this patch fix the bug? If not can you post the output of RADEON_DEBUG=fp,vp with this patch applied.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #19 from PJBrs pjbrs@floorenpj.xs4all.nl --- Created attachment 79628 --> https://bugs.freedesktop.org/attachment.cgi?id=79628&action=edit Log with possible fix
Hi, thanks for the patch! Unfortunately, it does not appear to do anything that I can see, the bug(s?) are still there. I've attached the log as per your request. Let me know if I can help in any other way.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #20 from PJBrs pjbrs@floorenpj.xs4all.nl --- P.s., I did a quick glance at the difference between the first bad log and the log with the patch (sdiff badlog patch-test.log | less). It seems as if shader pc8 now is truncated or something...
https://bugs.freedesktop.org/show_bug.cgi?id=63520
Tom Stellard tstellar@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #79572|0 |1 is obsolete| | Attachment #79628|0 |1 is obsolete| |
--- Comment #21 from Tom Stellard tstellar@gmail.com --- Created attachment 80888 --> https://bugs.freedesktop.org/attachment.cgi?id=80888&action=edit Possible fix v2
The first patch I posted was incorrect, so it actually had no effect on the shader program. This new patch should fix the issue with texture swizzles. Can you test this out? If the rendering is still incorrect with this new patch, can you repost the output of RADEON_DEBUG=fp,vp with this patch applied.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #22 from PJBrs pjbrs@floorenpj.xs4all.nl --- This fixes it!--great, thanks very much! Is this patch already in master? And will it also go in the 9.0 / 9.1 stable branches?
Anyway, thanks very much again for your time, glad I could be of some help too.
https://bugs.freedesktop.org/show_bug.cgi?id=63520
Fabio Pedretti fabio.ped@libero.it changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED
--- Comment #23 from Fabio Pedretti fabio.ped@libero.it --- Fixed in master: http://cgit.freedesktop.org/mesa/mesa/commit/?id=24fa43675f32bc81c7252f3ddce...
https://bugs.freedesktop.org/show_bug.cgi?id=63520
--- Comment #24 from madbiologist s.j.turner@uqconnect.net --- The fix is now also in Mesa 9.1.
dri-devel@lists.freedesktop.org