Advertisement

Is Cg fast enough?

Started by June 29, 2003 11:51 AM
3 comments, last by ZMaster 21 years, 8 months ago
Hi, I just wanted to know if it makes a difference if I use NVidia''s Cg or the normal, assembly like, shader language. I mean is NVidia''s Cg slower because it is C-like and high-level based? Thx, Flo
I think Cg would only be slower then it''s compiling the higher level language into assembly style shader code.

But remember, you can do this at built time instead of runtime and just generate normal asm shader code. Then I''d assume it would be just as fast, as long as NVidia got it right


-Nate
"Always forgive your enemies, nothing annoys them more.."
Advertisement
Oh, I see, so you can convert the Cg shader into a ASM shader and use it like a normal fragment program in OpenGL? I did''t knew that - Thanks!
how else would cg run on your graphics card? It''s not like your cpu knows how to interpret C code.

The tradeoffs between using Cg and shader asm are similar to the tradeoffs between C and asm. I would highly recommend using Cg. Remember, high level doesn''t have to mean slow.
I think that the compiler will improve with time. GPUs are less sophisticated (feature-wise) than CPUs (no referencing for example) and generating optimal asm code should be quite straightfoward for an experienced compiler programmer.

If you ever took a look at the Stanford Shading Language, you would have figured out that the compiler is actually very efficient. I saw an example in wich the compiled code is only 10% longer than the manually written shader (and this does not means it runs 10% slower).

I''m very positive about Cg and I wouldn''t mind some performance hit considering the amount of time gained back (which can be used to develop better frustrum culling or lodding thus increasing performance).

Previously "Krohm"

This topic is closed to new replies.

Advertisement