Baccanno
05-26-2011, 02:06 AM
Hello there,
I'm having very big performance issues with float textures.
I have a common shader calling a function called
float getGrammarParamAt( float i )
and I'm linking these two function depending on if I'm using RGBA texture or array (I also have a version for luminance only textures, size is 4 time bigger and performances are even lowest)
// grammar parameters
uniform float[300] grammarParam;
float getGrammarParamAt( float i )
{
return grammarParam[i];
}
// grammar parameters
uniform sampler2D grammarTexture;
uniform vec3 grammarTextureInformation;
float getGrammarParamAt( float i )
{
//i * 1/(length-1)
float index = i * grammarTextureInformation.x;
//cheap modulo 4
float mod4 = i * 0.25 - floor( i * 0.25 );
vec4 val = texture2D( grammarTexture , vec2( index , 0.0 ) );
if ( mod4 == 0.0 ) return val.x;
else if ( mod4 == 0.25 ) return val.y;
else if ( mod4 == 0.5 ) return val.z;
else return val.w;
}
The two codes are working properly however in first case if I have 80 fps it is going down to 6-7 with textures access. I'm making the same number of calls (the common shader does not change)
I got a GeForce 260GTX and under Fedora 14.
My guess is that it can be link to :
- Drivers ?
- Texture access is damn 10 times slower than array access ?
- The huge slow down comes from the if statements in the function ?
My texture or array is loaded only once.
Do someone had this issue before or have any clue to enhance this ?
(For the one who may ask, I want to use a texture because array is far to limited in term of size)
Thanks
I'm having very big performance issues with float textures.
I have a common shader calling a function called
float getGrammarParamAt( float i )
and I'm linking these two function depending on if I'm using RGBA texture or array (I also have a version for luminance only textures, size is 4 time bigger and performances are even lowest)
// grammar parameters
uniform float[300] grammarParam;
float getGrammarParamAt( float i )
{
return grammarParam[i];
}
// grammar parameters
uniform sampler2D grammarTexture;
uniform vec3 grammarTextureInformation;
float getGrammarParamAt( float i )
{
//i * 1/(length-1)
float index = i * grammarTextureInformation.x;
//cheap modulo 4
float mod4 = i * 0.25 - floor( i * 0.25 );
vec4 val = texture2D( grammarTexture , vec2( index , 0.0 ) );
if ( mod4 == 0.0 ) return val.x;
else if ( mod4 == 0.25 ) return val.y;
else if ( mod4 == 0.5 ) return val.z;
else return val.w;
}
The two codes are working properly however in first case if I have 80 fps it is going down to 6-7 with textures access. I'm making the same number of calls (the common shader does not change)
I got a GeForce 260GTX and under Fedora 14.
My guess is that it can be link to :
- Drivers ?
- Texture access is damn 10 times slower than array access ?
- The huge slow down comes from the if statements in the function ?
My texture or array is loaded only once.
Do someone had this issue before or have any clue to enhance this ?
(For the one who may ask, I want to use a texture because array is far to limited in term of size)
Thanks