Array initialization


I have a little (big) problem initializing const arrays. On ATI cards only works this way:

const float vec[3]=vec3; //Works :slight_smile:

but in my Nvidia card this way only works with arrays bigger than 1 (stupid and strange, is´n it?), so:

const float vec[3]=vec3; //It is fine
const float vec[1]=vec1; //Fails! cast not allowed error

There is another C like way used in nvidia cg shaders that works on my nvidia card but not in on ATI, so it is unuseful.

Is there any standard way to init const arrays that works on all cards?

PD: I need const arrays with values known at compilation time, not uniforms, because of compiler optimizations


Is there any standard way to init const arrays that works on all cards?

Well, the specification just says what is supposed to happen. All you can do is avoid using arrays of length 1 for now and file a bug report to NVIDIA for not allowing 1-length arrays.

Try removing the const. NVidia drivers are pretty smart about seeing that things are const without you telling it and performing the appropriate optimizations. Not sure about ATI.

removing const doesn´t work, i have “solved” it making a 2 sized array when I need a 1 sized, it works in my program beacause of how it is made, but can be a bad solution for other programs, so I expect nvidia solve this issue…

Thanks for your help!

const float vec[3]=vec3;???
What the [censored] is vec?
That should be
const float myarray[3]=float3;

const float myotherarray[1]=float1;

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.