Problems with Fragment Shader and Texture indirections on Radeon

Hi there!

I’m writing a (german) introduction for glSlang, as a kind of a huge tutorial on that matter. And for this I wanted to also write a simple example to show and explain my readers a basic shader, but I directly ran into problems, as the following (simple) shader exceedes the maximum number of texture indirections :

uniform sampler2D texSamplerTMU0;
uniform sampler2D texSamplerTMU1;
uniform sampler2D texSamplerTMU2;
uniform sampler2D texSamplerTMU3;

void main(void)
{
 vec4 RGB = texture2D(texSamplerTMU0, vec2(gl_TexCoord[0]));

 gl_FragColor = texture2D(texSamplerTMU1, vec2(gl_TexCoord[0]))*RGB.r+
                texture2D(texSamplerTMU2, vec2(gl_TexCoord[0]))*RGB.g+
                texture2D(texSamplerTMU3, vec2(gl_TexCoord[0]))*RGB.b;
}

Since the Radeon is supposed to support far more than only four indirections, I’m a bit surprised, especially because I’m doing only one texturesample per texture unit.
Texturesamplers are set as follows (via glUniform1iARB in my App) :

glUniform1iARB(glSlang_GetUniLoc(ProgramObject, 'texSamplerTMU0'), 0);
glUniform1iARB(glSlang_GetUniLoc(ProgramObject, 'texSamplerTMU1'), 1);
glUniform1iARB(glSlang_GetUniLoc(ProgramObject, 'texSamplerTMU2'), 2);
glUniform1iARB(glSlang_GetUniLoc(ProgramObject, 'texSamplerTMU3'), 3);

I suppose that this is a problem with the beta glSlang-Implementation of Catalyst (using 3.10 here), cause the same shader works like a charm in ARB_FP.

Any help would be appreciated. I also tried a blur-shader in glSlang, where I encountered the same problem.

As far as I see there’s just one indirection and that shouldn’t be a problem.

I just tried out your shader and get the same results. But if I use only 2 depented reads it work:

void main(void)
{
vec4 RGB = texture2D(texSamplerTMU0, vec2(gl_TexCoord[0]));

gl_FragColor = texture2D(texSamplerTMU1, vec2(gl_TexCoord[0]))*RGB.r+
               texture2D(texSamplerTMU2, vec2(gl_TexCoord[0]))*RGB.g+
               texture2D(texSamplerTMU3, vec2(gl_TexCoord[0]))*RGB.b;

}

If it works with ARB_FP it seems to be a bug in GLslang compiler. That’s possible because their implementation has some major bugs yet.

PS: Where are you going to publish your german introductions to GLslang. I’m interested in it. If you need some help, mail me.

Thx for your quick response, so it really seems like a problem with the current glSlang-implementation in ATI’s drivers.

I’ve also noticed that it works with three reads (without sampling tmu3), so I’ll use that for the sample in my introduction.

@Introduction :
I’m a mod at the Delphi OpenGL Community over at http://www.delphigl.com and I’m also writing for them (and also was responsible for the gl1.5-Delphiheader along with two other people from the team). So I came up with the idea of a big german introduction to glSlang, that not only includes how to load glSlang-Shaders in Delphi, but also discusses the aspects of the glSlang-Language along with samples. I started yesterday an already wrote about 25 pages in a non-stop 14 hour typing-frenzy, so I don’t need any help there at the moment.

The only thing right now that’s missing is a small sampleshader that I’ll also discuss in that introduction (as I said before).

The introduction will be posted around first or second january next year, and if demanded I’ll also announce it here. But remember that it’ll only be in german, translating it to english would be a big effort, and since we’re a community more aimed at the german audience wouldn’t make much sence right now.

[This message has been edited by PanzerSchreck (edited 12-25-2003).]

25 pages… uff Great! :slight_smile:

With german language I don’t have any problems (I’m Austian… :-). But if that’s ok for you I’m interested to translate your paper to C++ (and maybe to English).

It’ll be about 30 pages (some more or less) in the end, cause of the example and I’ll also show some nice screenshots of some shaders (people don’t really like something until they see shiny and blinking Screenshots ).

A translation to C wouldn’t be necessary I think, cause most of the text deals with glSlang itself and that shouldn’t change across languages. There’s only one paragraph where I show how to load the shader in Delphi using our header and that too shouldn’t be too different from C

And as for the translation into english : Thx for your intereset, but our team decided not to translate our contents to english as of now, but that may (hopefully) change within the future. But my english is good, so I’ll then do that by myself.

Alright! I’m looking forward to read that introduction! :slight_smile:

Originally posted by PanzerSchreck:
[b]

[quote]

uniform sampler2D texSamplerTMU0;
uniform sampler2D texSamplerTMU1;
uniform sampler2D texSamplerTMU2;
uniform sampler2D texSamplerTMU3;

void main(void)
{
 vec4 RGB = texture2D(texSamplerTMU0, vec2(gl_TexCoord[0]));

 gl_FragColor = texture2D(texSamplerTMU1, vec2(gl_TexCoord[0]))*RGB.r+
                texture2D(texSamplerTMU2, vec2(gl_TexCoord[0]))*RGB.g+
                texture2D(texSamplerTMU3, vec2(gl_TexCoord[0]))*RGB.b;
}

[/b][/QUOTE]

You are correct that the compiler misses an opportunity here. I’d encourage you to sign up with ATI devrel.

In the meantime, a workaround is either:

uniform sampler2D Texture0;
uniform sampler2D Texture1;
uniform sampler2D Texture2;
uniform sampler2D Texture3;

void main(void)
{

vec2 TexCoord = vec2( gl_TexCoord[0] );

vec4 RGB = texture2D( Texture0, TexCoord );
gl_FragColor = texture2D( Texture1, TexCoord )*RGB.r
+ texture2D( Texture2, TexCoord )*RGB.g
+ texture2D( Texture3, TexCoord )*RGB.b;

}

or

uniform sampler2D Texture0;
uniform sampler2D Texture1;
uniform sampler2D Texture2;
uniform sampler2D Texture3;

void main(void)
{

vec4 RGB = texture2DProj( Texture0, gl_TexCoord[0] );
gl_FragColor = texture2DProj( Texture1, gl_TexCoord[0] )*RGB.r
+ texture2DProj( Texture2, gl_TexCoord[0] )*RGB.g
+ texture2DProj( Texture3, gl_TexCoord[0] )*RGB.b;

}

-mr. bill

Thx man! That workaround was what I needed right now.
Guess I’ll report it to ATI’s devrel, since I’ve already registered with them, but before sending such things to them, I’d like to clear if it’s really a problem and not my fault

Maybe I’m blind, but I don’t see any dependent texture read in the shader.Could you enlight me?

No, you’re not blind The problem with ATIs current glSlang-Implementation is, that it mistakes normal texture reads for independet texture reads. So this will hopefully get fixed in a future revision.

Just in case anyone is still interested, go here to read my german introduction on glSlang. It’s rather long and it’s aimed at delphi coders, so you’ll find many places where I tell some important differences between Delphi and C-Syntax. I’ve also tried to deliver as many samples on the usage of glSlang-functions as I felt like the specs are missing them.

[This message has been edited by PanzerSchreck (edited 01-12-2004).]

I have to say, that the tutorial is really great. It´s quite complete, and very easy to read and understand.
Really good work !

However you should let someone check the paper for grammar-mistakes, there are quite a few…

Jan.

The uniform handling is unsafe. You do not check if you get a valid location. This will produce GL errors in case uniforms are inactive.
I suggest to add a rock solid error checking tutorial for loading, compiling, linking and uniform handing.
(The HTML formatting didn’t adjust to the window width for me.)

@Jan2000 :
If you have ever written a huge tutorial (or whatsever), you most likely don’t have the motivation to read through it several times again just to find grammar-mistakes (since I already did that for spelling mistakes). But I’ll try to read over it again to eliminate those grammar mistakes if I can get my lazy self to do that

@Relic :
That’s true. But I suppose that most people using glSlang know how to spell their parameter names and also are aware of this. But thanks for that hint, I’ll add a small paragraph on that matter. And for the wrong HTML-Formatting : It’s because of some very long lines of code that don’t get split. I’ll try to fix that.

[This message has been edited by PanzerSchreck (edited 01-13-2004).]

there are any posibility to get your tutorial in English (or Spanish… ). do you have plans of translate it?

Originally posted by Ffelagund:
there are any posibility to get your tutorial in English (or Spanish… ). do you have plans of translate it?

No. As of now I have no plans to translate it into any other language (besides that, I don’t speak a single spanish word). But an english version of this may come in the future. So if you’re not able to read german, then just go for the shader specs (see 3DLabs’ page for more).

[This message has been edited by PanzerSchreck (edited 01-13-2004).]

those of you not understanding german i
suggest to read the OpenGL Shading Language paper from the opengl.org frontpage… most is written there too (except the examples)

nice read tho :]

[e] grammar

[This message has been edited by veal (edited 01-19-2004).]

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.