GLSL using Cg / MacOS

I know that GLSL won’t be supported anytime soon on MacOS X (At least not on MacOS 10.3).

But there is a something that really puzzled me :

On nVidia graphics card, GLSL is converted to a fragment program using Cg 1.3. In fact, there is just a couple of extensions check in order to use the best profile (using NV Vertex Program).

Cg 1.3 has been ported on Mac already, so why there is no such thing ?

In fact, Cg can even convert a GLSL program to ARB vs/ps !

For example:

cgc -profile arbvp1 -entry main -strict -oglsl -D__GLSL_CG_DATA_TYPES -D__GLSL_CG_STDLIB -D__GLSL_SAMPLER_RECT myGLSLVertexProgram.txt

cgc.exe -profile arbfp1 -entry main -strict -oglsl -D__GLSL_CG_DATA_TYPES -D__GLSL_CG_STDLIB -D__GLSL_SAMPLER_RECT myGLSLFragmentProgram.txt

Produces nice ARB vertex / program from a GLSL programs.

Maybe someone should write a ‘wrapper’ that simulate the GLSL calls on Mac, but using Cg for converting in back end. Also, provides that Wrapper for all version of MacOS like MacOS 10.3.

I know there might not handles all the cases, but it will probably compiles 99% of the existing GLSL code.

Is someone know about a such project ? a GLSL parser using Cg, emulating the GLSLang on MacOS or other ? I could start to write one (shouldn’t be too long), but this solution is so obvious, that I 'm pretty sure that a lot of people has already done such of thing.

It is more complicated than that. Read this .

Yes, I know, GLSL shoud be interpreted straight into the video card. But only the 3Dlabs Realizm does that.

But on ALL nVidia video cards, which have a better GLSL support than ATI for example, is actually using this way, or I you want the current drivers has Cg integrated and compiles the GLSL into assembly language :wink: :wink:

So this method is proven to work.

The point is that you can not guarantee that a GLSL program will compile into ARBvp/fp at all. Or if it does, it might not run on your hardware due to program length limits.

On the PC, Cg is compiled to various NVidia-specific extensions layered on ARB_vertex_program and ARB_fragment_program.

So, if you can get the ARBvp1.0- and ARBfp1.0-representable portion of GLSL this way, that’s great news, but it’s not even close to full GLSL support.

Yes but at least with Cg 1.3 and GLSL on MacOSX, you will get all the nVidia video cards working the same way on Windows (at least, using the the fp40 profile (which is ARB fragment + some nVidia extensions, etc…).

So GLSL could be fully exposed on nVidia video cards and not for ATI : That’s would be a good start.

Then, the question with ATI video cards.

On Windows, their GLSL implementation is far from being perfect (dependencies read limitations, no texture access in vertex program), but I guess that next generation of ATI video cards will solve that problem.

First, not expose GLSL for ATI, then try the ARB vs/ps profile and see what’s happening, and finally expose GLSL for them.

Of course this is not the ‘final’ solution for GLSL support, but at least, a ‘transition phase’.

Originally posted by arekkusu:
The point is that you can not guarantee that a GLSL program will compile into ARBvp/fp at all. Or if it does, it might not run on your hardware due to program length limits.
GLSL has a good error handling mechanism. So if the shader cannot compile in hardware, there is a message from the linker telling that GLSL will use software rendering instead. That’s fair enough.

Thoses limitations already exist on PC, there is plenty of cases where GLSL can run in software.

Again, it’s not the goal to have the perfect GLSL, at the first time, but at least an intermediate version of it.

the NVidia extensions that are required for the fp40 profile are not supported on Mac OS X.

You will get (some large subset of) the subset of GLSL that can be represented by ARBvp and ARBfp, nothing more.

Originally posted by OneSadCookie:
the NVidia extensions that are required for the fp40 profile are not supported on Mac OS X.

Indeed, GL_NV_fragment_XX and GL_NV_vertex_program_xx are not supported (just noticed it). - That’s maybe why we can’t see the nice nVidia OpenGL demos running on Mac (like the GF6800 demos which are OpenGL).

So, left the ARBfp/vp which powerful enough.

Maybe I’m confused but there is the cgc command line tool. Also, there is the cg framework you can put into x code. From this just read in the cg file and compile in your program on the fly. I’m just using this until opengl 2 is available on the mac. Simpler than using the cgc command line tool. Also, the cg framework has some calls for setting environment variables and things like that which make things a little easier.

Hope that helps.

Well that nice then :wink:

Btw, is there a profile for ATI Text Fragment Shader in Cg ?

I’m trying to find a ATI Text Fragment Shader parser for Windows that would use ATI Fragment Shader (Since ATI won’t release ATI_text_fragment_shader for Windows).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.