Hi all,
I’m struggling with the syntax for passing an array (sized or unsized, doesn’t matter) to a function in Cg. Basically, I wanna do something like this:
inline float Foo(float testArray[])
{
//
// Cg code here
//
}
But it won’t compile. The compilation error is unhelpful - it just says syntax error. Initially, I thought it was because the array had to be sized, e.g.:
inline float Foo(float testArray[4])
{
//
// Cg code here
//
}
But this is not the case. What’s up with this? Why won’t it accept arrays as parameters to functions in Cg? The Cg Reference Manual from NVidia has syntax almost identical to this in its examples. Look at page 400 in the example of cgSetArraySize, for example, they’re using a Cg stub defined like this:
float4 main(float4 myarray[])
{
/* ... */
}
Which indicates to me this is supposed to be perfectly legal… Is it because I’m on too low a shader model? I’m compiling to #pragma target 3.0 because I can’t get it to accept anything higher. It reverts to 2.0 if I try to put #pragma target 4.0 or #pragma target 5.0 instead. So perhaps Shader Model 3.0 doesn’t support arrays as parameters, or…?
Thanks a bunch in advance for any help!