Skip to main content
GameDev.net gamedev.net
🔒 Locked

Cg and fp40 profile with OpenGL

Started by ekaekap Oct 3, 2005 at 5:43 AM 1 replies 2k views
Original Post
ekaekap
ekaekap
I try to run a Cg program that uses branching, but I can't get the fp40 profile working correctly. If I run this code:
assert(cgGLIsProfileSupported(CG_FRAGMENT_FP40));
cgGLEnableProfile(CG_FRAGMENT_FP40);
fragProg = cgCreateProgramFromFile(context, CG_SOURCE, filename, CG_FRAGMENT_FP40, "big_frag_prog", 0);
assert(cgIsProgram(fragProg));
cgGLLoadProgram(fragProg); // This line fails!

The last line fails with:
Compiling Cg fragment program: big_frag_prog
Cg error:
CG ERROR : The program could nod load.
(0) : warning C6504: Unknown profile option 'NumTexInstructionSlots' ignored
(0) : warning C6504: Unknown profile option 'NumMathInstructionSlots' ignored
(0) : warning C6504: Unknown profile option 'MaxTexIndirections' ignored
(0) : warning C6504: Unknown profile option 'MaxDrawBuffers' ignored

The profile options it mentions belongs to the arbfp1 profile (at least according to 'cgc -h'), so I think it somehow tries to compile using the arbfp1 profile anyway. Anyone have any idea what the problem could be? I have initialized both GL_ARB_FRAGMENT_PROGRAM and GL_NV_FRAGMENT_PROGRAM2. I use Cg 1.4.0-rc1 (the latest, I think). EDIT: uses tags [Edited by - ekaekap on October 3, 2005 9:07:26 AM]
silvermace
silvermace
whats your video card + driver set + platform specs? This will only work on OpenGL 2.0.x drivers on GeForce 6600-7800 series, and you should also be able to pull it off on 6200's.
ekaekap
ekaekap
GeForce 6800 GT
OpenGL 2.0.0
Forceware 78.01

I've been looking into it a bit more, and it seems that all Cg programs where the loops aren't unrolled are affected. I've also noted that the program compiles fine with cgc, but the resulting .fp-file cannot be loaded with glProgramStringARB() nor run through nvshaderperf.

I've made an example. Put this in a file boxfil.cg:
#define WIDTH 64 #define HEIGHT 64 void boxfilt   (float2 texcoord : TEXCOORD0,    uniform samplerRECT image,    out float4 res : COLOR0) {     int x, y;     res = 0.0f;     for(y = 0; y < HEIGHT; y++) {         for(x = 0; x < WIDTH; x++) {             res += texRECT(image, texcoord + float2(x, y));         }     }     res /= (WIDTH * HEIGHT); }

Compile it with cgc:

cgc boxfilt.cg -profile fp40 -entry boxfilt -o boxfilt.fp

Then run boxfilt.fp through nvshaderperf:

nvshaderperf.exe -a NV40-GT boxfilt.fp

Then I get several errors like this:

line 30, column 13: error: variable not valid as a source register

If I try to load it with glProgramStringARB(), I get the same errors.

If I force cgc to unroll the loops (by using fewer iterations and -unroll none), it works fine.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.