Bug 28860 - [r300g] Yo Frankie - shaders not working: Too many instructions
Summary: [r300g] Yo Frankie - shaders not working: Too many instructions
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/r300 (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Default DRI bug account
QA Contact:
URL: http://www.yofrankie.org/
Whiteboard:
Keywords:
: 29683 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-06-30 13:01 UTC by Sven Arvidsson
Modified: 2010-11-24 16:03 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Backtrace of crash (9.73 KB, text/plain)
2010-07-02 15:22 UTC, Sven Arvidsson
Details
Yo Frankie screenshot (105.67 KB, image/png)
2010-07-08 14:50 UTC, Sven Arvidsson
Details
Failing shaders (628.78 KB, text/plain)
2010-07-10 13:11 UTC, Tom Stellard
Details
Hacked together presubtract support (21.10 KB, patch)
2010-07-13 23:10 UTC, Tom Stellard
Details | Splinter Review
Yo Frankie screenshot (96.08 KB, image/png)
2010-07-14 12:37 UTC, Sven Arvidsson
Details
Log produced with RADEON_DEBUG=fp (583.00 KB, application/octet-stream)
2010-08-20 22:48 UTC, Rubén Fernández
Details
Improved screenshot (377.67 KB, image/png)
2010-09-04 03:45 UTC, Rubén Fernández
Details
Improved log with RADEON_DEBUG=fp (878.91 KB, application/octet-stream)
2010-09-04 03:47 UTC, Rubén Fernández
Details
Improved log with RADEON_DEBUG=fp, part 2 (744.64 KB, application/octet-stream)
2010-09-04 03:48 UTC, Rubén Fernández
Details
Screenshot with presub (97.64 KB, image/jpeg)
2010-09-08 06:58 UTC, Sven Arvidsson
Details
Screenshot with the "presub" branch (662.30 KB, image/png)
2010-09-08 15:56 UTC, Rubén Fernández
Details
Log generated with RADEON_DEBUG=fp, part 1 (878.91 KB, application/octet-stream)
2010-09-08 15:57 UTC, Rubén Fernández
Details
38569: Log generated with "presub" branch and RADEON_DEBUG=fp, part 2 (777.12 KB, application/octet-stream)
2010-09-08 15:58 UTC, Rubén Fernández
Details
Status as of commit c1928c7f1065876345d00477eac5558f4cf85158 (440.71 KB, image/png)
2010-11-15 18:25 UTC, Rubén Fernández
Details
With Tom Stellard's most recent patches (425.88 KB, image/png)
2010-11-22 11:49 UTC, Rubén Fernández
Details

Description Sven Arvidsson 2010-06-30 13:01:42 UTC
The game "Yo Frankie" crashes if run with shaders turned on:

r300 FP: Compiler Error:
Too many hardware temporaries usedUsing a dummy shader instead.
If there's an 'unknown opcode' message, please file a bug report and attach this
 log.
[...]
yofrankie-linux-i386.bin: state_tracker/st_mesa_to_tgsi.c:181: dst_register: Assertion `t->outputMapping[index] < (sizeof(t->outputs)/sizeof(*(t->outputs)))' failed.

I'm attaching a log captured with RADEON_DEBUG="fp".

System environment:
-- system architecture: 32-bit
-- Linux distribution: Debian unstable
-- GPU: RV570
-- Model: Asus EAX1950Pro 256MB
-- Display connector: DVI

-- xf86-video-ati: 801e83227a59a29eea425ea612083bbf2b536c30
-- xserver: 1.8.1.901
-- mesa: 75acb896c6da758d03e86f8725d6ca0cb2c6ad82
-- drm: 6ea2bda5f5ec8f27359760ce580fdad3df0464df
-- kernel: 2.6.35-rc3
Comment 1 Sven Arvidsson 2010-06-30 13:03:51 UTC
Log was too large to attach, so here it is instead:
http://whiz.se/temp/yofrankie-fp.log.gz
Comment 2 Sven Arvidsson 2010-06-30 13:07:55 UTC
dmesg output:

[30481.511833] [drm:r100_cs_track_check] *ERROR* [drm] Buffer too small for color buffer 0 (need 1310720 have 1228800) !
[30481.511837] [drm:r100_cs_track_check] *ERROR* [drm] color buffer 0 (640 4 0 512)
[30481.511839] [drm:radeon_cs_ioctl] *ERROR* Invalid command stream !
[30481.858013] [drm:r100_cs_track_check] *ERROR* [drm] Buffer too small for color buffer 0 (need 1310720 have 1228800) !
[30481.858017] [drm:r100_cs_track_check] *ERROR* [drm] color buffer 0 (640 4 0 512)
[30481.858019] [drm:radeon_cs_ioctl] *ERROR* Invalid command stream !
Comment 3 Pavel Ondračka 2010-07-02 13:40:49 UTC
(In reply to comment #0)
> yofrankie-linux-i386.bin: state_tracker/st_mesa_to_tgsi.c:181: dst_register:
> Assertion `t->outputMapping[index] <
> (sizeof(t->outputs)/sizeof(*(t->outputs)))' failed.

This looks similar to bug 28169, should be fixed with commit 6e83420ee0ccb2228fab0f86a6e8bf8a6aefe57a
Comment 4 Sven Arvidsson 2010-07-02 15:22:54 UTC
Created attachment 36701 [details]
Backtrace of crash

(In reply to comment #3)
> 
> This looks similar to bug 28169, should be fixed with commit
> 6e83420ee0ccb2228fab0f86a6e8bf8a6aefe57a

Still crashes with the same assertion failure. I'm attaching a backtrace.
Comment 5 Sven Arvidsson 2010-07-08 14:50:51 UTC
Created attachment 36892 [details]
Yo Frankie screenshot

Now using git master 61a26cdfdc9c75a83c0d362c973d5436fe077be4 it no longer crashes, but the game does look kinda trippy ;-)
Comment 6 Tom Stellard 2010-07-08 23:24:11 UTC
Can you post the output with RADEON_DEBUG=fp from the most recent git version.
Comment 7 Sven Arvidsson 2010-07-09 06:46:32 UTC
(In reply to comment #6)
> Can you post the output with RADEON_DEBUG=fp from the most recent git version.

Sure, here's a new log from git master 8a8e311d8c3c60982d101826a4aa013672730e6c
http://whiz.se/temp/yofrankie-fp.log.gz
Comment 8 Tom Stellard 2010-07-10 13:11:05 UTC
Created attachment 36940 [details]
Failing shaders

I pulled 1 of the 3 failing shaders from the error log.  If you have some familiarity with assembly code, you can look through the log and try to find optimization opportunities that would reduce the number of instructions we need to emit.  This would be very helpful. I would recommend looking at the code after the dataflow passes, because at this point most of our optimizations have already been done.  If you are unsure of what the instructions do, their definitions are in this file: src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h
Comment 9 Sven Arvidsson 2010-07-11 10:05:51 UTC
(In reply to comment #8)
> 
> I pulled 1 of the 3 failing shaders from the error log.  If you have some
> familiarity with assembly code, you can look through the log and try to find
> optimization opportunities that would reduce the number of instructions we need
> to emit.  This would be very helpful. I would recommend looking at the code
> after the dataflow passes, because at this point most of our optimizations have
> already been done.  If you are unsure of what the instructions do, their
> definitions are in this file:
> src/mesa/drivers/dri/r300/compiler/radeon_opcodes.h

Thanks for having a look at the bug! Unfortunately I don't think I can be of much help, this sounds like something well above my meager skills.
Comment 10 Tom Stellard 2010-07-13 23:10:59 UTC
Created attachment 37010 [details] [review]
Hacked together presubtract support

Can you try again with this patch applied to master and post the output with RADEON_DEBUG=fp.  Also, if you notice anything new that this patch breaks, let me know.
Comment 11 Sven Arvidsson 2010-07-14 12:37:34 UTC
Created attachment 37050 [details]
Yo Frankie screenshot

Awesome, thanks for taking an interest!

It's still not working correctly, I'm attaching a new screenshot. I'm also getting these errors now:

 radeon: The kernel rejected CS, see dmesg for more information.

 Jul 14 21:28:43 zoe kernel: [21717.383601] [drm:r100_cs_track_check] *ERROR* [drm] Buffer too small for color buffer 0 (need 1310720 have 1228800) !
 Jul 14 21:28:43 zoe kernel: [21717.383605] [drm:r100_cs_track_check] *ERROR* [drm] color buffer 0 (640 4 0 512)
 Jul 14 21:28:43 zoe kernel: [21717.383607] [drm:radeon_cs_ioctl] *ERROR* Invalid command stream !

The log file at http://whiz.se/temp/yofrankie-fp.log.gz has been updated.
Comment 12 Marek Olšák 2010-07-14 22:46:06 UTC
If you revert 8c836f7f740c6f74511c727c7bed0680ddba9974, do those messages go away?
Comment 13 Sven Arvidsson 2010-07-15 04:58:11 UTC
(In reply to comment #12)
> If you revert 8c836f7f740c6f74511c727c7bed0680ddba9974, do those messages go
> away?

No, no difference.
Comment 14 Tom Stellard 2010-08-19 07:25:01 UTC
Can you try again with the latest git version and post the output of RADEON_DEBUG=fp.
Comment 15 Tom Stellard 2010-08-20 06:55:03 UTC
*** Bug 29683 has been marked as a duplicate of this bug. ***
Comment 16 Rubén Fernández 2010-08-20 22:48:14 UTC
Created attachment 38035 [details]
Log produced with RADEON_DEBUG=fp

There you go. Created with a RV505 (Radeon X1550) with the latest git (as of commit 0eac4b8740d4434037677166f2339e894d4ebac4 "evergreen : initial support driver code.")
Comment 17 Rubén Fernández 2010-09-04 03:44:48 UTC
The situation with yo frankie has improved somewhat with the most recent builds; my guess is that commit a35faa6a41eb8a240f8e6086853653e9a21e75bd helped, since it reduced considerably the number of instructions generated by the IR generator
Comment 18 Rubén Fernández 2010-09-04 03:45:57 UTC
Created attachment 38425 [details]
Improved screenshot

This screenshot shows the status as of september 4
Comment 19 Rubén Fernández 2010-09-04 03:47:40 UTC
Created attachment 38426 [details]
Improved log with RADEON_DEBUG=fp

This log was too long to attach; I'll upload it in two parts; just join them with "cat" in order to obtain a bzip2-compressed text file
Comment 20 Rubén Fernández 2010-09-04 03:48:45 UTC
Created attachment 38427 [details]
Improved log with RADEON_DEBUG=fp, part 2

"cat" it with part 1 to obtain yofrankie-debug-fp-improved.txt.bz2
Comment 21 Tom Stellard 2010-09-07 22:23:35 UTC
Can you try again with the presub-rebase-v2 branch from git://anongit.freedesktop.org/~tstellar/mesa and post the output of RADEON_DEBUG=fp and a screenshot.

To test this branch from your mesa git directory do:

git fetch git://anongit.freedesktop.org/~tstellar/mesa presub-rebase-v2:presub-rebase-v2

git checkout presub-rebase-v2

Then configure and build like normal.
Comment 22 Sven Arvidsson 2010-09-08 06:58:31 UTC
Created attachment 38549 [details]
Screenshot with presub

(In reply to comment #21)
> Can you try again with the presub-rebase-v2 branch from
> git://anongit.freedesktop.org/~tstellar/mesa and post the output of
> RADEON_DEBUG=fp and a screenshot.
> 

I'm attaching a new screenshot, log is too big to attach so it's available here:
http://www.whiz.se/temp/log.gz
Comment 23 Rubén Fernández 2010-09-08 15:56:04 UTC
Created attachment 38568 [details]
Screenshot with the "presub" branch

Your branch seems to improve some things (the tree trunk now looks OK) and break others (the water and the main character look wrong); in any case, I'll keep your branch on speed dial if you need me to test anything.
Comment 24 Rubén Fernández 2010-09-08 15:57:15 UTC
Created attachment 38569 [details]
Log generated with RADEON_DEBUG=fp, part 1
Comment 25 Rubén Fernández 2010-09-08 15:58:39 UTC
Created attachment 38570 [details]
38569: Log generated with "presub" branch and RADEON_DEBUG=fp, part 2

join with part 1 to get yofrankie-presub.txt.bz2
Comment 26 Marek Olšák 2010-11-13 12:36:27 UTC
Is this still an issue with current mesa git?
Comment 27 Sven Arvidsson 2010-11-15 06:02:45 UTC
(In reply to comment #26)
> Is this still an issue with current mesa git?

The game segfaults with current git. I'll try to bisect and file a new bug for this regression.
Comment 28 Rubén Fernández 2010-11-15 18:23:31 UTC
(In reply to comment #26)
> Is this still an issue with current mesa git?

As of commit c1928c7f1065876345d00477eac5558f4cf85158, I still get incorrect rendering; I'll attach a screenshot
Comment 29 Rubén Fernández 2010-11-15 18:25:27 UTC
Created attachment 40301 [details]
Status as of commit c1928c7f1065876345d00477eac5558f4cf85158
Comment 30 Tom Stellard 2010-11-21 21:50:15 UTC
Can you try this again with the latest git master?
Comment 31 Rubén Fernández 2010-11-22 11:47:25 UTC
(In reply to comment #30)
> Can you try this again with the latest git master?

A dramatic improvement! Now it is almost completely correct; the only misrenderings I can see (I'll attach a screenshot) are:

1) you can see the triangle edges in the main character, and
2) his shadow is completely black (should show the ground texture, only darker).

And I still get the "too many instructions" errors:

r300 FP: Compiler Error:
emit_tex: Too many instructionsUsing a dummy shader instead.
r300 FP: Compiler Error:
r500_fragprog_emit.c::emit_paired(): emit_alu: Too many instructions
Using a dummy shader instead.
r300 FP: Compiler Error:
r500_fragprog_emit.c::emit_paired(): emit_alu: Too many instructions
Using a dummy shader instead.

Don't know if they have to do with this remaining misrenderings, tho.

Plus, it takes two full minutes to compile the shaders before starting the
game; but that's an optimization problem, not of functionality.

But, all in all, the game works almost perfectly now. I think we are almost ready to close this bug.
Comment 32 Rubén Fernández 2010-11-22 11:49:15 UTC
Created attachment 40483 [details]
With Tom Stellard's most recent patches

Compare with https://bugs.freedesktop.org/attachment.cgi?id=38000, the correct rendering
Comment 33 Marek Olšák 2010-11-22 13:14:39 UTC
1) I guess the reason the shadow is black is we don't implement GL_ARB_shadow_ambient. With the driver which can render the shadow correctly, try to set this environment variable:

MESA_EXTENSION_OVERRIDE=-GL_ARB_shadow_ambient

to temporarily disable GL_ARB_shadow_ambient, and see if the shadow becomes black.

2) I know of the wireframe issue, it's been bugging me since ever. It can be seen e.g. in ETQW on the water and in Nexuiz with GLSL enabled. I think it only shows up on R500.
Comment 34 Rubén Fernández 2010-11-22 17:44:34 UTC
(In reply to comment #33)
> 1) I guess the reason the shadow is black is we don't implement
> GL_ARB_shadow_ambient. With the driver which can render the shadow correctly,
> try to set this environment variable:
> 
> MESA_EXTENSION_OVERRIDE=-GL_ARB_shadow_ambient
> 
> to temporarily disable GL_ARB_shadow_ambient, and see if the shadow becomes
> black.

The driver that renders correctly is the proprietary one, which doesn't use Mesa variables.


> 2) I know of the wireframe issue, it's been bugging me since ever. It can be
> seen e.g. in ETQW on the water and in Nexuiz with GLSL enabled. I think it only
> shows up on R500.

I can also see it in the water in sauerbraten (although it is almost
imperceptible there); You can count on me to debug/test that.
Comment 35 Sven Arvidsson 2010-11-24 15:09:34 UTC
(In reply to comment #27)
> 
> The game segfaults with current git. I'll try to bisect and file a new bug for
> this regression.

Bug 31907 has been filed for this, in case anyone else has the same problem.
Comment 36 Marek Olšák 2010-11-24 16:03:21 UTC
(In reply to comment #34)
> (In reply to comment #33)
> > 1) I guess the reason the shadow is black is we don't implement
> > GL_ARB_shadow_ambient. With the driver which can render the shadow correctly,
> > try to set this environment variable:
> > 
> > MESA_EXTENSION_OVERRIDE=-GL_ARB_shadow_ambient
> > 
> > to temporarily disable GL_ARB_shadow_ambient, and see if the shadow becomes
> > black.
> 
> The driver that renders correctly is the proprietary one, which doesn't use
> Mesa variables.

OK then, let's assume it's because GL_ARB_shadow_ambient is missing, therefore it's not a bug, it's a feature.

> > 2) I know of the wireframe issue, it's been bugging me since ever. It can be
> > seen e.g. in ETQW on the water and in Nexuiz with GLSL enabled. I think it only
> > shows up on R500.
> 
> I can also see it in the water in sauerbraten (although it is almost
> imperceptible there); You can count on me to debug/test that.

I'd like to have a separate bug for this issue, though it's not like I know how to fix it.

Since there is no other reported misrendering related to this bug, I am closing it.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.