Part of the Khronos Group

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Intern Contributor
    Join Date
    Jun 2011

    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
    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
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    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