pouët.net

Go to bottom

HLSL or Cg - Which is better?

category: general [glöplog]
Can someone comment on the differences between HLSL and Cg? Which are used more often in demos, and why?
added on the 2009-07-27 22:30:07 by trc_wm trc_wm
use ASM.
added on the 2009-07-27 22:31:04 by kusma kusma
is de musicdisk al af? :P
trc: you know you're going into the old "d3d vs ogl" discussion again, dont you :D
added on the 2009-07-27 22:32:12 by Gargaj Gargaj
OH NOES! I don't want to go there..

I want to focus on D3D only. Or is HLSL/Cg strictly OGL?
added on the 2009-07-27 22:33:45 by trc_wm trc_wm
what are the differences between C64 basic and C16 basic?
bonus question: which is used more often in demos, and why?
added on the 2009-07-27 22:38:25 by blala blala
HLSL = DirectX, GLSL = OpenGL, Cg = nVidia. Choose GLSL if you don't want to limit yourself to one OS or vendor.
added on the 2009-07-27 22:42:44 by xTr1m xTr1m
Answer: There is very little difference.

Commodore _bought_ an early version of Microsoft Basic from Bill Gates. Bill made a mistake by not licensing Basic. By licensing, he would have made a fortune. While Microsoft upgraded its Basic, Commodore refused to go back to Microsoft for a newer version because, by this time, Bill had realized his mistake and would have asked far more $$$. Therefore, Commodore had to upgrade the software themselves and they didn't think a good Basic was worth the extra effort. Therefore, if you want to do anything useful with a C64, you have to POKE yourself to death.

In conclusion, neither Basic is used in demos as assembler is much more efficient.

Now, back to the question at hand: HLSL or Cg?
added on the 2009-07-27 22:44:24 by trc_wm trc_wm
XTr1m: thanks! that's helpful.
added on the 2009-07-27 22:45:41 by trc_wm trc_wm
for D3D i use HLSL. that way no extra tools and such to use.
added on the 2009-07-27 22:45:44 by blackpawn blackpawn
what xTr1m said
added on the 2009-07-27 22:50:48 by qwesza qwesza
Quote:
Now, back to the question at hand: HLSL or Cg?

Quote:
Answer: There is very little difference.
added on the 2009-07-27 22:54:06 by blala blala
HLSL and Cg are exactly the same thing.

The only significant difference from what I remember is that the Cg compiler is slightly more strict, for example it won't let you imply that a float is actually a float4 with the same value in .xyzw or something like that, you will have to avoid ambiguous syntax.

And like Blackpawn said, if you're to use DX only, stick to HLSL, that's less extra tools in the chain (= less potential errors or issues)
added on the 2009-07-28 00:08:32 by keops keops
maar... is je musicdisk al af dan?
Keops i've encountered a number of differences between the two but yeah these can all be traced back to more strictness in the cg compiler. For example if you have a float x and write x/5: in hlsl it's interpreted as a float division, but in cg it's an int division. (Unless you write x/5.0f)
Also, if you have a float4, hlsl lets you access the values like an array even with another variable, like x[y]=0. In cg this did not compile.
added on the 2009-07-28 09:56:36 by BoyC BoyC
in my experience cg's compiler does a worse job of optimising than hlsl's, and it's quite a bit slower too.
added on the 2009-07-28 10:00:33 by smash smash
Step into a time machine and step out of it as soon as Open CL killed everything else.
added on the 2009-07-28 10:11:06 by tomaes tomaes
Smash: oh... so that's why my shaders seem to be less fast on PS3 than on 360 ;)
added on the 2009-07-28 21:14:04 by keops keops
What about GLSL?
...don't you like it? :(
added on the 2009-07-28 22:22:03 by xernobyl xernobyl
Who cares about OpenGL ?
added on the 2009-07-29 00:01:54 by Wiz Wiz
zernobyl/wiz, don't go there..
Although it's funny how the cg compiler is considered more strict, considering how sloppy nvidias cgc-based glsl compiler is.
added on the 2009-07-29 02:22:32 by Psycho Psycho
I was thinking the same. I'm sure nvidia's sloppy glsl compiler is responsible for half of the 'nvidia only' demos, yet their CG compiler is really strict?!
added on the 2009-07-29 10:17:04 by psonice psonice
keops: no comment :)
added on the 2009-07-29 10:23:07 by smash smash
I do suck at optimising.
added on the 2009-07-29 10:36:47 by cg_ cg_
Quote:
I'm sure nvidia's sloppy glsl compiler is responsible for half of the 'nvidia only' demos

I'm pretty sure it has nothing to do with nvidia, and everything with the braindead ati opengl drivers. Tell me for example, why on bloody earth would a radeon x1600, with ps3 and everything, run a ~10 line shader in software which even the *friggin gma950* can run in hardware?
added on the 2009-07-29 12:23:26 by blala blala

login

Go to top