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 3 of 3

Thread: How to disable auto-optimization for GLSL

  1. #1
    Intern Contributor
    Join Date
    Jun 2011
    Posts
    90

    Red face How to disable auto-optimization for GLSL

    If I define a uniform variable in GLSL and do not use it in the main function, then at runtime there will be an error message saying "no such uniform named XXX". How to disable this kind of auto-optimization.

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2008
    Posts
    15
    Instead, use glGetUniformLocation(program, "uniform_name").
    This function returns -1 if uniform_name does not correspond to an active uniform variable in program

    i.e. If the function returns >=0, then it is okay to set the uniform

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    495
    Use a uniform block with the shared or std140 qualifiers. These have a fixed layout so that they can be shared between different shaders.

    Alternatively, force the variable to be used in some way, e.g. multiply it by a very small value (so that the effect isn't discernible) then add it to an output.

Posting Permissions

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