Some quotes from the DirectX Mailing List :
Link : http://discuss.microsoft.com/SCRIPTS/WA-MSD.EXE?A1=ind0207d&L=directxdev#20 See under Shader Optimizations.
Sounds more and more like Cg in essence is a compiler for Microsofts HLSL (not really NVIDIAs since the NVIDIA language is morphing into the Microsoft created language) that happens to compile to NVIDIA OpenGL extensions.
G~
HLSL is the abbreviation which Microsoft has been using for their High
Level Shading Language. It's part of the impending DX9 release.
And with Microsoft's compiler team I'd reckon they will do an awesome
job of optimizing code which is submitted to HLSL.
When Microsoft deliver HLSL it seems to me that the arguments for using
Cg (on DirectX) suddenly become much weaker.
>>The optimization can't be better than what you can do with the vertex
>shader. So Cg has an additional layer above the vertex shader has the
same
>restrictions at least.
>
> Yes, that's clear. But I was wondering if they know something we don't
>know about instruction re-arranging, etc. Or even vendor-specific
things,
>allthough I remember someone from nVidia saying that Cg is 100% free
from
>something like that. Anyway, it's still nice to have your shaders
>optimized automatically for you and then do your own further
>optimizations.
Strictly speaking they're working with the same facts that you get to work with so you might expect little or no differences.
You'd be wrong.
Human coding is very time consuming - especially vectorizing some algorithms which don't naturally express themselves in that way. And a compiler has the persistence to get that kind of stuff right.
Plus, yes, it can know all of the hardware specific issues relating to the platform. That means it can eliminate almost all possible stalls and should be able to do a great job.
And, then on the other hand... The June version of the compiler is pretty naïve about some things and may cost you as much as twice as many instructions as hand coding it.
So, that's complicated. Right now I'd say that optimiser has a long way
to go. But as a long term bet it's pretty safe to say that a compiler is a much more efficient way of handling the problem.
And because NVIDIA have released the source to the Cg compiler on an open licence basis it should be straightforward for other IHV's to compete - if they choose to do so.
On the other hand I'm not sure why a DirectX programmer would choose Cg over HLSL. They're supposed to be fully compatible so maybe it makes no difference, but at least you _know_ that HLSL will work with all
vendor's hardware.
Link : http://discuss.microsoft.com/SCRIPTS/WA-MSD.EXE?A1=ind0207d&L=directxdev#20 See under Shader Optimizations.
Sounds more and more like Cg in essence is a compiler for Microsofts HLSL (not really NVIDIAs since the NVIDIA language is morphing into the Microsoft created language) that happens to compile to NVIDIA OpenGL extensions.
G~