PDA

View Full Version : CgFX vs D3DX FX (Bug in CgFX?)


6600gt
10-01-06, 10:54 PM
According to the FAQ for Cg 1.5, NVIDIA states that any valid D3DX Effect or HLSL shader program that works in D3DX but not in Cg will be treated as a bug and be promptly fixed... However, I'm not sure who to contact to back up that claim, so I'm posting the example here. The following effect is valid in D3DX, but not in Cg 1.5 (final, haven't tested the beta releases, but I assume it will be the same result):


Texture Tex0;
const string inputStreamFormat = "posctex1";

vertexshader vSdr =
decl
{
stream 0;
float v0[3];
D3DCOLOR v2;
float v3[2];
}
asm
{
vs.1.1
dcl_position v0
dcl_color v2
dcl_texcoord v3
m4x4 oPos, v0, c0
mov oD0, v2
mov oT0.xy, v3.xy
};

pixelshader pSdr =
asm
{
ps.1.1

tex t0
mul_x2_sat r0.rgb, t0, v0
+mul r0.a, t0, v0
};

Technique t_0
{
Pass p_0
{
Texture[0] = <Tex0>;
VertexShader = <vSdr>;
PixelShader = <pSdr>;
}
}


Using D3DX, it works fine, but using Cg, I get the following error:


(15) : error C1060: incompatible types in initialization
(38) : error C1060: incompatible types in initialization
(52) : error C8001: Unknown state 'texture'
(54) : error C8001: Unknown state 'vertexshader'
(55) : error C8001: Unknown state 'pixelshader'


My code to create this effect is very simple:


/* Declare all variables and assign the CgFX text to effect_text */
...
cg_ctx = cgCreateContext();
cg_effect = cgCreateEffect(cg_ctx, effect_text, NULL);
if (!cg_effect) {
printf("Error:\n%s\n", cgGetLastListing(cg_ctx));
}
...


Am I missing some type of program setup step, or is this actually a Cg bug? Thanks in advance!