CG vs HLSL

Started by
4 comments, last by EvilDecl81 18 years, 11 months ago
I am sorry if this has been asked before though I could not find any definitive information via Googling. Coming from the opengl side, I am wondering if the CG vs HLSL situtation is similar to the CG vs GLSL situation. I have heard that CG is almost exactly the same as HLSL syntax wise, but I am also wondering which one people think is better and which has wider hardware support.
Advertisement
CG is pretty much nVidia only. No other company is supporting it at all.

HLSL is supported by pretty much all the companies making video cards.

If you are making a D3D game then do yourself a favor and use HLSL.
ATi supports Cg. I haven't encountered problemareas yet, personally.
What about cheap third party GPUs like Intel's?
ATI supports CG in D3D?

Just because you may be able to run CG stuff on an ATI card doesn't mean ATI supports it.

As far as I know, ATI has not written custom backends for CG like nVidia has. So you are only getting generic shader backend code.

Quote:Original post by Khaos Dragon
I am sorry if this has been asked before though I could not find any definitive information via Googling.

Coming from the opengl side, I am wondering if the CG vs HLSL situtation is similar to the CG vs GLSL situation. I have heard that CG is almost exactly the same as HLSL syntax wise, but I am also wondering which one people think is better and which has wider hardware support.



It is a completly different scenario in D3D then GL - the driver does not consume the language direclty, it takes an assembly token stream. Therefore, _all_ D3D hardware supports HLSL, and it has no idea if the shader came from HLSL or came from user written assembly. Since CG produces a token stream as well, all hardware technically supports Cg shaders, except that Nvidia may not have spent much time on shader targets that are specific to ATI hardware (e.g. ps_2_0)

It's only a matter of what shader targets a hardwaer suppots, but there aren't that many. If you don't know, compile to ps_2_0, its always a safe bet (until you blow your instruction count).

Essentially, the only difference between Cg and HLSL in D3D land is the actual implementation of the compiler. You can just try both of them and see how they work for your needs.
EvilDecl81

This topic is closed to new replies.

Advertisement