hippynerd

05-27-2005, 10:12 PM

Is it just me, or is accessing a uniform array with a non-constant variable, faster under Cg than GLSL?

I'll try to post more specific details later, but the gist is that

uniform float array[10];

void main(){

int i = 4;

float val = array[i];

}

Will drop a framerate from 400 to 40fps.

Under a simmilar example in CG, around 30,000 verticies are rendered without a significant performane decrease, when they access a uniform array in the same manner.

The reason I want to do this is I would like to have a lookup table for a certian custom mathematical operation I'm using. I could use a texture for the lookup, but then this lookup would have be be performed in the texture shader, and I'd rather not have this, as a number of mathematical operations need to be performed based on the lookup value.

I'll try to post more specific details later, but the gist is that

uniform float array[10];

void main(){

int i = 4;

float val = array[i];

}

Will drop a framerate from 400 to 40fps.

Under a simmilar example in CG, around 30,000 verticies are rendered without a significant performane decrease, when they access a uniform array in the same manner.

The reason I want to do this is I would like to have a lookup table for a certian custom mathematical operation I'm using. I could use a texture for the lookup, but then this lookup would have be be performed in the texture shader, and I'd rather not have this, as a number of mathematical operations need to be performed based on the lookup value.