   Help with Cg
  Yeah so I'm a definatly a CG newbie. I'm having some difficulties getting the compiliation to work with DX9 - here's the Cg code - it's fairly simple.-------------------------------------------------------------struct OutParms {  float4 position : POSITION;  float4 color    : COLOR;};OutParms main(float2 position : POSITION){  OutParms OUT;  OUT.position = float4(position, 0, 1);  OUT.color    = float4(1, 0, 1, 1);  // RGBA green  return OUT;}-------------------------------------------------------------Now I compile this using the command line Cg compilerusing the profile settings of vs_1_1 and get-------------------------------------------------------------vs.1.1// DX8 Vertex shader generated by NVIDIA Cg compiler// cgc version 1.1.0003, build date Jul  7 2003  11:55:19// command line args: -entry main -profile vs_1_1// nv30vp backend compiling 'main' programdef c1, 1, 0, 1, 1def c0, 0, 1, 0, 0//vendor NVIDIA Corporation//version 1.0.02//profile vs_1_1//program main//var float2 position : $vin.POSITION : POSITION : 0 : 1//var float4 position : $vout.POSITION : POSITION : -1 : 1//var float4 color : $vout.COLOR : COLOR : -1 : 1//const c[1] = 1 0 1 1//const c[0] = 0 1 0 0mov oPos.xy, v0.xyyymov oPos.zw, c0.yyxymov oD0, c1// 3 instructions// 0 temp registers// End of program----------------------------------------------------------Which again is pretty simple. The problem is we're trying to copy the contents of v0, which doesnt look like it has been initialized into oPos. The internal D3DXAssembleShaderFromFile function of course fails and returns an error saying attempting to read from un-initialized variables. I added the linedcl_position v0Above the mov commands, and I assemble fine. I am not sure what to do. Compiling with vs_2_0 yields---------------------------------------------------------vs_2_0// DX9 Vertex shader generated by NVIDIA Cg compiler// cgc version 1.1.0003, build date Jul  7 2003  11:55:19// command line args: -entry main -profile vs_2_0// nv30vp backend compiling 'main' programdef c1, 1, 0, 1, 1def c0, 0, 1, 0, 0//vendor NVIDIA Corporation//version 1.0.02//profile vs_2_0//program main//var float2 position : $vin.POSITION : POSITION : 0 : 1//var float4 position : $vout.POSITION : POSITION : -1 : 1//var float4 color : $vout.COLOR : COLOR : -1 : 1//const c[1] = 1 0 1 1//const c[0] = 0 1 0 0dcl_position v0mov oPos.xy, v0.xyyymov oPos.zw, c0.yyxymov oD0, c1// 3 instructions// 0 temp registers// End of program-----------------------------------------------------------Which as you can see has the dcl_position v0 line in it. The problem is my card doesnt support vs_2_0 as CreateVertexshader fails when I use 2_0. So, am I going to have to add those dcl lines to all my compiled Cg programs? If I switch the vs_2_0 at the top to vs_1_1, I assemble fine. Not sure what to do.Any advice appreciated.Thanks!-ZayaEdit: Typo[edited by - Zaya on February 20, 2004 12:45:32 PM]
  i dont know cg, but in vs_1_0 you don''t need to declare the constant inputs (dcl_xx). in vs_1_1 you do so that''s why vs_1_0 compiles. however I think MS will beat us if anyone uses vs_1_0 ;  You may also want to try www.cgshaders.org for CG specific stuff.  But perhaps there are some people on this board that use CG that can help.neneboricua ;  I would, cept the site is down =( ;  Crap, you''re right.  Didn''t realize that.  sorry.  I''m sure someone on here uses CG and will be able to help. ;  I suppose you may need to do that. But why do you want to compile your shaders? Why not use them directly via the cgProgram or whatever? Then, you could use the compile function to compile the shader during runtime under the optimal profile. It''s much simpler to set parameters and stuff directly that way. ;  Normally, I would use the cgRuntime. The problem is, when I use the runtime with vs_1_1 it wont assemble (since both the cgc and the runtime libraries compile without the dcl_position v0) I get assemble errors. I was using cgc to figure out what was wrong. ;  Do you have the latest verison of cgc? Probably nVIDIA "rectified", or rather "added" this "feature" to the new compiler. Otherwise, writing "dcl_position v0" for every shader you write will be a real pain! ;  Downloaded the cg files a week ago, I may have to ask nvidia for help, since cgshaders.org is still down =/ah well-Zaya ;  You have to use additional option "-profileopts dcls" to compile into DX9 style vertex shader profile. 