PDA

View Full Version : CgFX best practices



andras
11-10-2006, 07:32 AM
Preamble: This thread feels somewhat off-topic for these message boards, so if you know of a better place to discuss this, then please let me know! I couldn't find any discussion groups that focus on Cg..

If my vertex shader uses uniforms or samplers I have two choices. I could pass them in as parameters, or use them as globals.
In either case, they will be global in the CgFX file, just in one case I'll pass in the global explicitly.

Is there any good reason to do this one way or the other? The advantages of passing in as params is that it feels a bit cleaner, and would let me pass in different parameters for different passes. But are there any disadvantages that I miss?

Also, if I use globals only, is the compiler smart enough, to bind in only the uniforms that I actually use?

zed
11-10-2006, 12:31 PM
www.gpgpu.org (http://www.gpgpu.org) seems to have quite a bit of cg stuff in it


Also, if I use globals only, is the compiler smart enough, to bind in only the uniforms that I actually use?yes it discards them, u can view this yourself if u check the generated asm

sorry i cant answer the other question (ive only been using cg for a couple of weeks + havent looked into it fully)