Bug 31013 - [r300g][glsl] Textures are black in Xonotic with offset mapping - r300 FP: Compiler Error: r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Summary: [r300g][glsl] Textures are black in Xonotic with offset mapping - r300 FP: Co...
Status: RESOLVED INVALID
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/r300 (show other bugs)
Version: git
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-20 14:04 UTC by Tomasz Czapiewski
Modified: 2010-10-30 12:51 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Screenshot of the problem - xonotic000023.jpg (46.49 KB, image/jpeg)
2010-10-20 14:05 UTC, Tomasz Czapiewski
Details
data/glsl/default.glsl - problematic shaders file (47.53 KB, application/octet-stream)
2010-10-20 14:06 UTC, Tomasz Czapiewski
Details
glxinfo (23.49 KB, text/plain)
2010-10-20 14:08 UTC, Tomasz Czapiewski
Details
RADEON_DEBUG=vp,fp log (579.59 KB, application/octet-stream)
2010-10-20 14:14 UTC, Tomasz Czapiewski
Details
RADEON_DEBUG=vp,fp log with both offset mapping and relief mapping (835.02 KB, application/octet-stream)
2010-10-20 14:19 UTC, Tomasz Czapiewski
Details

Description Tomasz Czapiewski 2010-10-20 14:04:32 UTC
When I enable "offset mapping" option in Xonotic (new open source FPS game, Nexuiz fork) all the textures are black and I get something like this on console:

Loading shaders from file glsl/default.glsl...
GLSL shader glsl/default.glsl flatcolor compiled.
GLSL shader glsl/default.glsl depth/shadow compiled.
GLSL shader glsl/default.glsl vertexcolor offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl vertexcolor glow offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping glow offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping glow offsetmapping reflectcube compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl refraction compiled.
GLSL shader glsl/default.glsl lightdirection diffuse glow offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl lightsource diffuse offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.

Simmilar logs with offset mapping+relief mapping:
GLSL shader glsl/default.glsl flatcolor compiled.
GLSL shader glsl/default.glsl depth/shadow compiled.
GLSL shader glsl/default.glsl vertexcolor compiled.
GLSL shader glsl/default.glsl vertexcolor glow compiled.
GLSL shader glsl/default.glsl flatcolor colormapping glow compiled.
GLSL shader glsl/default.glsl flatcolor colormapping compiled.
GLSL shader glsl/default.glsl flatcolor colormapping glow reflectcube compiled.
GLSL shader glsl/default.glsl refraction compiled.
Draw_CachePic: failed to load gfx/hud/luminos/dock
Draw_CachePic: failed to load gfx/hud/scoreboard_scoreboard_bg
GLSL shader glsl/default.glsl vertexcolor offsetmapping reliefmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl vertexcolor glow offsetmapping reliefmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor offsetmapping reliefmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping glow offsetmapping reliefmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping offsetmapping reliefmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping glow offsetmapping reliefmapping reflectcube compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl vertexcolor offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl vertexcolor glow offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping glow offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping offsetmapping compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
GLSL shader glsl/default.glsl flatcolor colormapping glow offsetmapping reflectcube compiled.
r300 FP: Compiler Error:
r300_fragprog_emit.c::begin_tex(): Too many texture indirections
Using a dummy shader instead.
Comment 1 Tomasz Czapiewski 2010-10-20 14:05:28 UTC
Created attachment 39596 [details]
Screenshot of the problem - xonotic000023.jpg
Comment 2 Tomasz Czapiewski 2010-10-20 14:06:48 UTC
Created attachment 39597 [details]
data/glsl/default.glsl - problematic shaders file
Comment 3 Tomasz Czapiewski 2010-10-20 14:08:49 UTC
Created attachment 39598 [details]
glxinfo

Graphic card: ATI Radeon 9600 256MB AGP (RV350)
Comment 4 Tomasz Czapiewski 2010-10-20 14:14:38 UTC
Created attachment 39600 [details]
RADEON_DEBUG=vp,fp log
Comment 5 Tomasz Czapiewski 2010-10-20 14:19:32 UTC
Created attachment 39601 [details]
RADEON_DEBUG=vp,fp log with both offset mapping and relief mapping

The RADEON_DEBUG=noops doesn't help either.
Comment 6 Tom Stellard 2010-10-20 19:26:01 UTC
Your hardware is not capable of executing these shaders.  The function OffsetMapping (from data/glsl/default.glsl) has three texture look-ups that depend on the value of the previous look-up.  This function is being called by two shaders that use its return value in a fourth texture look-up.  This creates four texture indirections, but this hardware only supports three.  I would recommend contacting the developers of this application and ask if they can come up with an alternate shader.
Comment 7 Tomasz Czapiewski 2010-10-21 01:19:49 UTC
Thank you very much, I've reported it to game developers as suggested.
Comment 8 Tomasz Czapiewski 2010-10-21 12:59:21 UTC
Game developers have just checked that the same shader works on Windows on the same chipset as mine and are suggesting that it might be "off-by-one in counting the indirections".
Comment 9 Alex Deucher 2010-10-21 13:42:48 UTC
r3xx/r4xx actually supports 4 indirections, so if the current code is limiting it to 3, it should be upped to 4.  See US_CONFIG.NLEVEL
Comment 10 Tomasz Czapiewski 2010-10-21 14:43:54 UTC
I'm reopening this bug report as suggested that my hardware supports 4 indirections but driver limits it to 3.

Btw, I've tried the modified shader with 3 indirections and then offset mapping worked properly but it's just a temporary build for test and it won't be included in official game source.
Comment 11 Tom Stellard 2010-10-23 00:45:06 UTC
(In reply to comment #9)
> r3xx/r4xx actually supports 4 indirections, so if the current code is limiting
> it to 3, it should be upped to 4.  See US_CONFIG.NLEVEL

Isn't the level 3 indirection limited to reading from input registers?
Comment 12 Alex Deucher 2010-10-23 09:29:24 UTC
(In reply to comment #11)
> (In reply to comment #9)
> > r3xx/r4xx actually supports 4 indirections, so if the current code is limiting
> > it to 3, it should be upped to 4.  See US_CONFIG.NLEVEL
> 
> Isn't the level 3 indirection limited to reading from input registers?

I though you could have up to 4 indirections in addition to the input, but it's been a while since I looked at 3xx.  If the shader works on the same hw using the proprietary driver, it would seem to indicate that was the case (barring some other bug).
Comment 13 Tom Stellard 2010-10-23 13:01:28 UTC
(In reply to comment #12)
> 
> I though you could have up to 4 indirections in addition to the input, but it's
> been a while since I looked at 3xx.  If the shader works on the same hw using
> the proprietary driver, it would seem to indicate that was the case (barring
> some other bug).

I looked at through the docs again, and I'm pretty sure you are right about this.  I think we need to start using the {ALU,TEXT}_OFFSET fields of US_CODE_OFFSET, to give us the input + 4 indirections.  I'll write a patch for this.
Comment 14 Tom Stellard 2010-10-26 21:08:20 UTC
(In reply to comment #13)
> (In reply to comment #12)
> > 
> > I though you could have up to 4 indirections in addition to the input, but it's
> > been a while since I looked at 3xx.  If the shader works on the same hw using
> > the proprietary driver, it would seem to indicate that was the case (barring
> > some other bug).
> 
> I looked at through the docs again, and I'm pretty sure you are right about
> this.  I think we need to start using the {ALU,TEXT}_OFFSET fields of
> US_CODE_OFFSET, to give us the input + 4 indirections.  I'll write a patch for
> this.

Ok, so it looks like I was wrong about this.  I input a shader with 4 indirections to the AMD Shader Analyzer and it crashed, so I'm pretty sure r300 is limited to 3 indirections.  I'm guessing that the reason this works on Windows with r300 hardware is because that driver has some sort of software fall-back, which r300g doesn't have.
Comment 15 Tomasz Czapiewski 2010-10-26 22:29:52 UTC
(In reply to comment #14)
> 
> Ok, so it looks like I was wrong about this.  I input a shader with 4
> indirections to the AMD Shader Analyzer and it crashed, so I'm pretty sure r300
> is limited to 3 indirections.  I'm guessing that the reason this works on
> Windows with r300 hardware is because that driver has some sort of software
> fall-back, which r300g doesn't have.

So does fglrx on Linux have this software fall-back, too? As now it's been confirmed that on fglrx on Linux it worked, too before fglrx dropped R300-R500 support.
And game developers have told me that this shader code was specially designed for Radeon 9600 (RV350) with fglrx.
Comment 16 Roland Scheidegger 2010-10-27 06:43:24 UTC
> Ok, so it looks like I was wrong about this.  I input a shader with 4
> indirections to the AMD Shader Analyzer and it crashed, so I'm pretty sure r300
> is limited to 3 indirections.  I'm guessing that the reason this works on
> Windows with r300 hardware is because that driver has some sort of software
> fall-back, which r300g doesn't have.

I dunno maybe the driver does some tricks like trying to move out the calculation leading to the first texture lookup back to the vertex shader? No idea if that would actually work...
Comment 17 Tomasz Czapiewski 2010-10-30 12:51:32 UTC
You were right, it was really too many indirections (game engine GLSL code has changed but comment not) and current testing of last working fglrx for r300 cards on old Ubuntu 8.10 prove it - simmilar behaviour on fglrx and r300g. Some time ago OffsetMapping could work on fglrx as it was using -1 indirections compared to now. The simplified GLSL OffsetMapping code in game has been now pushed to Xonotic git master and works again.

Sorry for mislead and yours occupied time trying to resolve a problem in bug report which could not be fixed in driver.


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.