Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: AMD : glLinkProgram error with uniform Struct

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2011
    Posts
    4

    AMD : glLinkProgram error with uniform Struct

    Hey,

    I think I've just encountered AMD driver bug.
    Compiling following shaders is fine. However, when calling glLinkProgram on program with attached shaders I get unexpected error and linking fails.

    On Nvidia everything works correctly.

    Vertex :

    // glslv

    #version 150

    struct VertParams {
    vec4 _mPosition;
    vec4 _mVertexColor;
    };

    struct InUniformParams {
    vec4 _mModelViewProj[4];
    };

    vec4 _outHPosition1;
    uniform InUniformParams _inVU1;
    vec4 _r0003;
    in vec4 POSITION;

    // main procedure, the original name was main
    void main()
    {


    _r0003 = POSITION.x*_inVU1._mModelViewProj[0];
    _r0003 = _r0003 + POSITION.y*_inVU1._mModelViewProj[1];
    _r0003 = _r0003 + POSITION.z*_inVU1._mModelViewProj[2];
    _r0003 = _r0003 + POSITION.w*_inVU1._mModelViewProj[3];
    _outHPosition1 = _r0003;
    gl_Position = _r0003;
    } // main end
    Fragment :

    // glslf

    #version 150

    struct InUniformParams {
    vec4 _mColor;
    };

    uniform InUniformParams _inVU1;
    out vec4 COL0;

    // main procedure, the original name was main
    void main()
    {
    COL0 = _inVU1._mColor;
    } // main end
    What is even more surprising is the fact that program links correctly on AMD if I remove uniform struct in fragment shader - just declare uniform vec4 _mColor; and use it directly.

    AMD support? Anyone Any ideas?

    btw. cheers everyone - first time posting here ;]

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2011
    Posts
    4

    Re: AMD : glLinkProgram error with uniform Struct

    Didn't mention before : Catalyst 11.7, Win 7 64bit

  3. #3
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,793

    Re: AMD : glLinkProgram error with uniform Struct

    However, when calling glLinkProgram on program with attached shaders I get unexpected error and linking fails.
    What error do you get specifically.

    On Nvidia everything works correctly.
    That's not surprising, since this looks like something that NVIDIA's Cg-to-GLSL compiler coughed up. That's not to say that it is wrong, but it does do a lot of unusual things (structs with one member, pretending that a matrix is 4 vec4's for no particular reason, etc).

    Have you considered writing the GLSL by hand? You'll be less likely to hit corner cases that drivers may not handle correctly.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2011
    Posts
    4

    Re: AMD : glLinkProgram error with uniform Struct

    Hi. Thx for reply.

    The problem with glLinkProgram error is that it is actually a string : 'unexpected error' . Nothing more in the log.

    And yeas actually this code is from cg to glsl compilation. Unfortunately we've got the whole shading node based workflow setup in cg including shader builder, therefore rewriting the whole thing to pure glsl is somewhat non preferable atm.

    However, this code should actually still compile according to glsl specification.

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2011
    Posts
    4

    Re: AMD : glLinkProgram error with uniform Struct

    I discovered what was wrong.

    My uniform in Vertex shader was having the same name as the uniform in Fragment shader.
    I thought that should be distinguished by shader domain. Apparently it is not.

    I would assume that two uniforms with different struct types, but same names in two different domains should compile without a problem as they should have different resources and different actual names because of flattening of struct.
    However, it is understandable that this is not the proper clear code. Lack of error code was a bit misleading.
    I will rewrite the rules for our uniforms.

    Thx for help. Topic closed.

Posting Permissions

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