Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Problems with Fragment Shader and Texture indirections on Radeon

  1. #1
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    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 :
    Code :
    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) :
    Code :
    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.

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: Problems with Fragment Shader and Texture indirections on Radeon

    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:

    Code :
    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.
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  3. #3
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: Problems with Fragment Shader and Texture indirections on Radeon

    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).]

  4. #4
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: Problems with Fragment Shader and Texture indirections on Radeon

    25 pages... *uff* Great! :-)

    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).
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  5. #5
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: Problems with Fragment Shader and Texture indirections on Radeon

    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.

  6. #6
    Member Regular Contributor
    Join Date
    Apr 2002
    Location
    Austria
    Posts
    328

    Re: Problems with Fragment Shader and Texture indirections on Radeon

    Alright! I'm looking forward to read that introduction! :-)
    There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

    There is another theory which states that this has already happened...

  7. #7
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Marlboro MA
    Posts
    90

    Re: Problems with Fragment Shader and Texture indirections on Radeon

    Originally posted by PanzerSchreck:

    Code :
    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;
    }
    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:

    Code :
    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

    Code :
    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

  8. #8
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: Problems with Fragment Shader and Texture indirections on Radeon

    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

  9. #9
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,932

    Re: Problems with Fragment Shader and Texture indirections on Radeon

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

  10. #10
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: Problems with Fragment Shader and Texture indirections on Radeon

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •