PDA

View Full Version : Cg ridiculousity



HellKnight
05-11-2005, 10:40 AM
Greetings!

Well, I haven't been looking closely at the graphics industry for the past two years now, so there are things concerning recent developments I can't fully cath up with... I'm saying this because I'm not really sure what kind of problem I'm confronted with, maybe I'm overlooking something trivial (which could easily be the case).

I'm basically trying to run a Cg program :)

It may be funny, but following the Cg docs, I initialize a cg context, load the program and eventually enable a FP profile. So far so good. Checking Cg errors says everythins's alright...

At rendering time, I set up the shader state (for the sake of simplicity I'm just binding the loaded FP CG program) and render the world.

A black screen.

At first I thought it'd be maybe a depth testing problem (I didn't set the DEPTH FP output, so it could have been possible that the default value is on the near clip plane, so all fragments would be discarded) so I disabled depth testing, as well as stencil testing. Then I simplified the FP shader to simply return a red value (expecting a red screen)...

Nothing.

Desperated, I decided to check ALL Cg errors, and Eureka! there was it: after the binding of the FP program the Cg runtime sayed: "profile not supported". Considering the fact, that I loaded the fp program, enabled the profile etc AND checked all errors in between (and there were none), I was a little bit confused....

Any ideas?

I'm using latest Nvidia drivers and a GForce 6600 Gt...

Thanks for any responses...

HellKnight
05-11-2005, 10:43 AM
Ah yes, it'd be trivial if that'd be the problem... I forgot to say that I tried ALL possible FP profiles....

dorbie
05-11-2005, 10:52 AM
Cg's language capability is limited by the underlying profile, i.e. the instruction set you're allowing Cg to compile for.

It is likely that you are performing an operation that is simply illegal for your target profile, perhaps because you are compiling to a profile that is more limited than it needs to be for your hardware, for example arbvp1.

You may also have done something like attempt to compile a vertex program for a fragment profile or vice versa.

Try a simple shader to start with and make sure you can get it working first.

dorbie
05-11-2005, 10:54 AM
You appended while I was typing.

Try a simple program, you may be trying something that isn't supported on your hardware.

HellKnight
05-11-2005, 11:24 AM
Well that's what I thought too. However, if I'd been compiling the program with a profile too primitive, I'd have gotten a compile error. Anyway here's the "red" shader I'm using:

float4 main() : COLOR

{

float4 col;

col.x = 1.0;

col.y = 0.0;

col.z = 0.0;

return col;

} // main

The point is the Cg runtime reports "profile not supported" after binding that program (NOT afer loading it or enabling the profile). That's the interesting part....

dorbie
05-11-2005, 02:48 PM
Do you have a valid current OpenGL context when you bind it?

P.S. moving to the shader forum, you'll get better eyes on your problem there.

rcpedersen
05-15-2005, 01:11 AM
cgSetErrorCallback(cgErrorCallback);
cgContext = NULL;
cgContext = cgCreateContext();
if(cgContext == NULL)
{
return GENERIC_FAILURE;
}
cgGLSetManageTextureParameters(cgContext, true);
cgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
if(cgFragmentProfile == CG_PROFILE_UNKNOWN)
{
return GENERIC_FAILURE;
}
cgGLSetOptimalOptions(cgFragmentProfile);
cgVertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
if(cgVertexProfile == CG_PROFILE_UNKNOWN)
{
return GENERIC_FAILURE;
}
cgGLSetOptimalOptions(cgVertexProfile);

HellKnight
05-15-2005, 06:18 AM
No, this doesn't help me either. Well, it seems as the only one supported profile is arbfp1 and nv20 (and an error "profile not supported" is reported AFTER binding the program, not after enabling it, or even querying its availability (with cgGLIsProfileSupportd)), even arbvp1 isn't supported and the vertex program I'm using is way too complicated for nv20.... And note that I'm using a GF 6600 GT with the latest NVidia drivers (for 98 - I didn't have time to port the code to linux and not willing to spend money on a MS OS; however I don't think that's the problem)....

rcpedersen
05-15-2005, 12:14 PM
I must admit it is difficult to judge wether you use the cg interface correctly or not. You would have to supply some more information about how and when you perform what. As with regular sw most errors steam from miss use ;-)

jra101
05-16-2005, 08:16 AM
The 6600 GT should support all profiles Cg supports. I'm not sure what error you are running into but if you email me a zip of your demo I'll try it with the latest internal Cg builds and see if the problem has already been fixed.