Supported Cg Shader profiles


from the main application (python) is there a way to know if the selected shader profile is supported by the graphics card?



enum  	ShaderModel  {
  SM00 = 0, SM11 = 1, SM20 = 2, SM2X = 3,
  SM30 = 4, SM40 = 5

( from … teGuardian)

Furthermore, there is gsg.get_supports_basic_shaders() that returns true if both arbfp1 and arbvp1 are supported, which are considered the ‘basic’ shader profiles.

Now that I think of it, it may be useful to have a get_supports_cg_profile(profile_string) though. But for now, you could use the two methods mentioned, use trial-and-error, or use ctypes to call a function in the Cg runtime.

I’ll add the function right now.

I have two questions though:

  1. Suppose a shader use texture arrays that requires NV_geometry_program4. Asking OpenGL if it supports the extension EXT_texture_arrays or asking through the Cg Runtime if the graphics card support the profile gp4*p isn’t the same thing?

  2. get_supports_cg_profile(profile_string) should be virtual in the GraphicsStateGuardian or should be implemented only for glGraphicsStateGuardian?


That would be great, thanks!

I think the function can take a string that is queried through the Cg runtime (the function name has ‘cg’ in the name anyway). I believe it has a function for parsing a string profile value, and another one for determining if it is available.

As I think ‘display’ doesn’t link to Cg, the method will need to be virtual and declared in the base GraphicsStateGuardian. In the GraphicsStateGuardian it would always return false, but in the GL and DX gsgs it would be overridden with a method that actually queries the Cg runtime.

Yeah it’s something like:


What do you think about this?

Thanks again

mmh, the function should be declared PUBLISHED in both the GSG and glGSG? I don’t see any PUBLISHED function in the glGSG.


For a virtual method, it’s sufficient to declare it PUBLISHED only in the parent class, i.e. in GSG. (Since glGSG is not processed by interrogate, it’s not actually possible to declare any non-virtual glGSG-specific methods PUBLISHED.)


I see.

thanks a lot

One more question:

I don’t see #include <Cg/cgD3D8.h> in dxGraphicsStateGuardian8, so I assume Cg is supported only in D3D9 right?


Ok, I have added the function GSG::get_supports_cg_profile(string name). I’ll tell Mike to commit it tomorrow.
I don’t want to be insistent but I would really like to understand if this is true?

I don’t have direct experience here, but it doesn’t sound like it ought to be the same thing.

In general, differently-named extensions, even two different extensions that provide similar functionality, are not equivalent. Thus, NV_geometry_program4 is a different extension than EXT_texture_arrays, and the presence of one doesn’t imply the presence of the other. Why not ask if OpenGL supports NV_geometry_program4, if that’s really what your shader specifically requires?

I don’t know about Cg profiles, but that’s a different thing too.


I think you are right. But at least looking at this chart it seems like asking if OpenGL supports NV_fragment_program4 is equivalent to ask the Cg runtime if the gp4fp profile is supported.

So my conclusion at this point would be:
EXT_texture_array is definitely not equivalent to NV_geometry_program4 thus if EXT_texture_arrays is available doesn’t mean gp4fp is supported.

thanks a lot