arbfp1 + CG

I apologize if this is not a fully opengl question, but this is the best place to get info on opengl related issues online.

I am compiling a cg fragment program for profile arbfp1 using nvidia cgc compiler. However, as I look at the resulting assembly code, it seems to be missing certain functions. In my cg code I have a main function that calls some additional user functions to do intersection testing. The main code is being compiled but the supporting functions are not. The functions are being used to modify some vectors, which are eventually used to set a color for each pixel. I do not have the code with me, but I can post it later if needed. Anyone know what the problem is. Should I use some special marker for these functions.

Thanks in advance.

arbfp1 does not support subroutines (unless you use an NV option for nv4x cards) so what’s happening is the code in your functions are being directly placed in the spot where it was called (when it gets converted to assembly). So in the assembly output, you wont see anything that looks like subroutine calls. I would like to see your cg code and arbfp1 code outputs to verify anyway.


You are right. I took a look at the code, and the instructions where there. I assumed the code was being inlined, but probably, I made a mistake in a previous version of the code, and the smart compiler optimization removed the subroutine code that was not being used. I am now having a new problem. When trying to load the fragment program in opengl, I get invalid operation I do as follows

glGenProgramARB( 1, &id );

->Error GL invalid operation


Am I missing something? I will post the arbfp1 code ASAP.

Try placing a glGetError call before the code you posted there that loads a program. The invalid gl operation means some operation happened that is not allowed in the current state. Placing glGetError calls all over the place will help narrow down what’s going on.


I traced the problem, I believe to the CGC compiler.
It seems to be appending invisible garbage characters at the end of the output file which is causing an invalid character error in opengl fragment program loader. Anyone know about this?