Hi,
I have written a cg script as follows to perform a color-lookup for a 3D texture and compile it with the profile fp30.
The resultant fp30 assembly code was as it is in the program.
CG Script as follows …
half4 main(
uniform half AlphaModulation,
half3 TexCoord0 : TEXCOORD0,
uniform sampler3D Volume3D,
uniform sampler1D ColorTable) : COLOR
{
half4 outcolor = tex3D(Volume3D,TexCoord0);
outcolor = tex1D(ColorTable,outcolor.x);
outcolor.z *= AlphaModulation;
return outcolor;
}
Graphics card : GeForceFX Go5650
AlphaModulation is used to modulate the final alpha value which is obtained from ColorTable.
When outcolor.z *= AlphaModulation is executed the performance is 5.0 fps but when it is omitted, the performance shot to 11.9 fps.
Is this normal? I can achieve 11.9 fps inclusive of alpha modulation using texture shaders and register combiners.
Thanks Zengar,
It works at 11.9fps.
Is there something I m not specifying right to cg to get an output performance like what you did? Or do I have to learn hardcore fp30 assembly coding to get the best performance?
In what ways were the cg output fp30 code weird?
Cg compiler does a great job on optimising. But sometimes it also does funny things. In your case, for example it used one temporary more as it would need. BTW, what version of cg do you have? I would advice you to post-optimise programs after compilation. Cg is good but it still has bugs… I’m afraid of glslang
I m using compiler Release 1.1. Isn’t this the latest?
I guess I better learn the assembly way then. I need to implement shading etc. Guess cg does not fit the bill for now.
I thought cg would output the best code possible…