Jump to content
  • Advertisement
Sign in to follow this  
Khaos Dragon

OpenGL CG vs HLSL

This topic is 4843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!