[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: Cg, GLSL and uniform parameters



Miguel Osorio wrote:

My most important problem right now is figuring out how to manage uniform parameters for GPU programs.
Yeah - that's a hard design decision.

> nVidia's Cg Runtime API offers some neat functionalities for this, plus it has the advantage of being
> able to compile programs on the fly for various profiles. Thing is, the engine supports OpenGL exclusively,
> so I have spent some time reading and learning about the OpenGL Shading Language also.

Yes - that's going to be important over the next year or so.

In the process I've noted that the API functionality that comes with the ARB_shader_objects extension
> also promotes easy ways to manipulate uniform parameters and stuff.

Yeah - but that's obsoleted by GLSL.   I believe that the machine code level ARB shaders will not turn
into full-blown OpenGL functionality.

If I use Cg and want to be able to support various profiles without writing specific shaders for each
> one, I can't really go ahead and use some of the facilities of the ARB_vertex_program and
> ARB_fragment_program extensions, which allow direct access to OpenGL states, just like GLSL.

Well, those extensions work with Cg *if* you compile using the ARB profile.  They don't work with
the nVidia-specific profiles.

> For what I have seen until now, most uniform parameters defined in shaders correspond to OpenGL
> states anyway....

Not in most of my shaders!

...so I could save some trouble by working directly with GLSL or exclusively with versions (present
> and future) of ARB_vertex_program and ARB_fragment_program.

We are in an ugly little corner right now where Cg is a mess - and GLSL isn't here yet.   I'm planning
to support *BOTH* Cg-with-ARB-profiles *AND* GLSL - and *NOT* support Cg-with-nVidia-profiles.

It seems reasonably possible to write shaders that work with both GLSL and Cg-with-ARB-profiles with
a minimum of '#define/#ifdef' stuff.

That seems to be a reasonably do-able thing...but it's a pain.  We really needed GLSL to come out a
year ago.

Do you think it would be worth working with Cg and allowing a little more flexibility, though having
> some more trouble coding management for generic uniform parameters, or should I stick with options
> that allow direct access to OpenGL states (GLSL and ARB_vertex/fragment_program) and save myself some
> trouble?

I think you should consider quite carefully whether you truly need access to the classical OpenGL
states.   I've found that being free of that mess is the best thing that ever happened to OpenGL.
There are a few OpenGL states that can usefully be passed through as Uniforms - but you certainly
don't need all of them.

---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1@airmail.net>    WorkEmail: <sjbaker@link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net    http://tuxaqfh.sf.net
           http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----