Shader Program size limit

It seems that when my shader program exceeds a certain number of lines, it will fail to compile. What’s the size limit for a shader program?

Here is a copy and paste from http://stackoverflow.com/questions/2617957/glsl-maximum-number-of-instructions

At first glance it looks more or less accurate. Maybe you should post the shader code for specific instruction on what you might do differently. Maybe if you show the code that is working and the code that is not, there may be some obvious solution to your problem.

//------------------------------------------------------------------------------------------------------------------------------------------------------------------

Instruction slots: The total number of instructions that the hardware can accomodate in local memory.
Executed instructions: The maximum number of instructions that will execute (including instructions that run several times in a loop)
A single GLSL instruction can map to a dozen or more instructions
Several GLSL instructions can map to a single instruction depending on the optimizer's quality (e.g. multiply-add, dot, lerp)
Limited temp registers (only 32) may require more instructions than necessary on pre-SM4 hardware (no such problem with 4096).
Swizzling usually does not cost extra instructions nowadays, but does on some older hardware, and may in some situations on some hardware (esp. gl_FragColor is such a candidate)
Regardless of actual instructions, OpenGL 2.0 compatible hardware is limited to 8 dependent texture fetches (unlimited on hardware that can do OpenGL 2.1 or better)

You have these guaranteed minimums (most cards have more):

512 instruction slots for vertex and pixel shaders on OpenGL 2.x (SM3) capable hardware
    65536 executed instructions
4096 vertex and 65536 pixel shader instruction slots on 3.x (SM4) hardware
    65536 executed vertex shader instructions, unlimited pixel shader instructions
At least 24 dynamic branches possible on 2.x (SM3) hardware
Fully dynamic branching (no limits) on SM4 hardware
Only conditional move available on SM2.x, everything else must be accomodated by code duplication and loop unrolling, or must fail

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