C++ Nvidia Cg question
I started using Nvidia Cg
shaders recently and everything looks and works fine if I'm doing it on the Nvidia GPU
(GTS250
in my case).
I tried launching the same (my own test application) on ATI HD4650
and saw no output. Right after that I started experimenting with test examples (provided with Nvidia Cg 3.0
) and 6/7 work, but the first one (which seems to be the simpliest) doesn't.
Here is the shader code:
// This is C2E1v_green from "The Cg Tutorial" (Addison-Wesley, ISBN
// 0321194969) by Randima Fernando and Mark J. Kilgard. See page 38.
struct C2E1v_Output {
float4 position : POSITION;
float3 color : COLOR;
};
C2E1v_Output C2E1v_green(float2 position : POSITION)
{
C2E1v_Output OUT;
OUT.position = float4(position,0,1);
OUT.color = float3(0,1,0);
return OUT;
}
I have no ideas why doesn't this simple shader work, while for example the same shader paired with the following passthru-shader does work (example 2 from the Nvidia Cg SDK
):
// This is C2E2f_passthru from "The Cg Tutorial" (Addison-Wesley, ISBN
// 0321194969) by Randima Fernando and Mark J. Kilgard. See page 53.
struct C2E2f_Output {
float4 color : COLOR;
};
C2E2f_Output C2E2f_passthru(float4 color : COLOR)
{
C2E2f_Output OUT;
OUT.color = color;
return OUT;
}
Did someone face the same troubles? Any ideas?
Thank you.
Update here: Turning on maximum debug output made the problem obvious:
vs_3_0 shader executed in hardware vertex processing mode can only be paired
with at least a ps_3_0 shader
The first example in that package was the only one wh开发者_如何学运维ich had ONLY vertex shader in it, without any (even simple passthrough) pixel shader. I have no idea why does Nvidia Cg runtime generates incompatible shader in this case, but it obviously failed only on a somewhat old GPU (ATI HD4650
).
Anyway, I was stupid enough to work without turning the debug output on.
2 Alex Farber: I guess you can post a dummy answer, so that I can award bounty to you, because you helped me realize that I forgot to turn debugging on. Thank you.
Set Debug DirectX version in the DirectX control panel and see trace output to get the reason of this failure.
BTW, I had the same situation with my pixel shader and got help in GameDev.net DirectX forum. I remember that finally I converted the shader to lowest version using SDK conversion tool, and it worked without pixel shader. According to GPU provider, this behavior is according to DirectX specification.
精彩评论