Instruction limit of 128 exceeded

Started by
9 comments, last by mlt 15 years, 4 months ago
When I compile my vertex shader I get the error: (0) : error C6002: Instruction limit of 128 exceeded; 162 instructions needed to compile program 178 lines, 1 errors. It contains two functions that gets called in a loop that runs 3 times. I am writing on a Nvidia 9800 GTX+. Will it help to put each function in a seperate file? Any ideas on how to solve this problem?
Advertisement
Probably it can't execute more than 128 in a loop. Try to unroll your loops.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Coming from a D3D background...

The maximum number of instructions a VS 1.1 shader can have is 128. Your code is presumably longer than that, because your loops will be getting unrolled, and the function calls inlined.

You could move up to VS 2.0, which has a limit of 256 instructions per shader, or make your shader simpler in some other way (Which would speed up execution too).
How do I move to VS 2.0? I thought it was a matter of hardware support?
Quote:Original post by mlt
How do I move to VS 2.0? I thought it was a matter of hardware support?


What shading language are you using?
Quote:Original post by mlt
How do I move to VS 2.0? I thought it was a matter of hardware support?
In D3D (I'm not sure about OpenGL, but I imagine it's similar or the same), you compile a shader for a vertex shader version. You can compile a VS 3.0 shader on a card that can't even do vertex shaders in hardware, but you can only run a VS 3.0 shader on hardware that supports VS 3.0. The same goes for VS 2.0 and VS 1.1.

If your card can't do VS 2.0, then the only option you have is to simplify your shader somehow - it's just too complicated for VS 1.1.
Hi.

If you are using GLSL then you do not get to pick the shader model (unlike in the DirectX world, and the GLSL spec requires functionality that really needs SM3 hardware). As you are on a NVidia card, you could run NVemulate and make sure that your advanced hardware features are turned on.
I bet you're using cgc.exe and your cmdline args are incorrect, or too limiting.
Quote:Original post by HuntsMan
Quote:Original post by mlt
How do I move to VS 2.0? I thought it was a matter of hardware support?


What shading language are you using?




I am using Cg.
Change the Cg profile to fp40/vp40 or gp4fp/gp4vp. Both will make your shader not work on ATi. If ATi support is important, try compiling with Ashli and load somehow the resulting ARB-asm into Cg.

This topic is closed to new replies.

Advertisement