PDA

View Full Version : Problem with vertexAttrib on macbook Pro



H.Stony
09-24-2006, 04:16 AM
render:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableVertexAttribArrayARB(AWXAlphaAttrib);
glEnableVertexAttribArrayARB(AWXFogOfWarAttrib);

glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboVertex);
glVertexPointer(3,GL_FLOAT,0,NULL);


glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboNormal);
glNormalPointer(GL_FLOAT,0,NULL);

glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboTexCoord);
glTexCoordPointer(2,GL_FLOAT,0,NULL);

glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboTextureWeig hts);
glVertexAttribPointerARB(AWXAlphaAttrib,4,GL_FLOAT ,0,0,NULL);

glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboFogOfWar);
glVertexAttribPointerARB(AWXFogOfWarAttrib,1,GL_FL OAT,0,0,NULL);

glDrawArrays(GL_TRIANGLES,0,part[0].planezahl*3);


glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableVertexAttribArrayARB(AWXAlphaAttrib);
glDisableVertexAttribArrayARB(AWXFogOfWarAttrib); setup:


glGenBuffersARB(1,&vboVertex);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboVertex);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*9*sizeof(float),vertices,GL_STATIC_DRAW _ARB);

glGenBuffersARB(1,&vboTexCoord);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboTexCoord);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*6*sizeof(float),texkoords,GL_STATIC_DRA W_ARB);

glGenBuffersARB(1,&vboFogOfWar);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboFogOfWar);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*sizeof(float)*3,fogOfWar,GL_DYNAMIC_DRA W_ARB);

glGenBuffersARB(1,&vboNormal);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboNormal);

glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*9*sizeof(float),normals,GL_STATIC_DRAW_ ARB);

glGenBuffersARB(1,&vboTextureWeights);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboTextureWeig hts);

glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*12*sizeof(float),texturGew,GL_STATIC_DR AW_ARB);

glGenBuffersARB(1,&vboBegehbarkeit);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboBegehbarkei t);

glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*sizeof(float)*3,begehbarkeitPerVertex,G L_STATIC_DRAW_ARB); everything works fine on iMac G5 with Geforce 5 and on PC with Geforce 6200 and X800 but on the macbook pro with X1600 i get terrible performance! the problem seems to be in the vertex shader:


attribute float fogOfWar;
attribute vec4 alphaData;

varying vec3 alphaDataPass;
varying vec3 fogOfWarPass;

void main()
{
vec3 normal, lightDir;
vec4 diffuse, ambient;
float NDotL;
vec4 ecPos;


ecPos = gl_ModelViewMatrix * gl_Vertex;
normal = normalize(gl_NormalMatrix*gl_Normal);
lightDir = normalize(vec3(gl_LightSource[0].position-ecPos));
NDotL = max(dot(normal,lightDir),0.0);
diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse;

ambient = vec4(0.2,0.2,0.2,1.0);

gl_FrontColor = NDotL * diffuse + ambient;


// Standardtexturkoordinaten
gl_TexCoord[0] = gl_MultiTexCoord0 * gl_TextureMatrix[0];

// Worldspace
gl_Position = ftransform();

alphaDataPass = alphaData.xyz;
fogOfWarPass = vec3(alphaData.w,fogOfWar,0.0);
} if i don't use the fogOfWar attribute in the vertexshader performance is OK. (this means about 120fps instead of 5).
i think its a driver problem. anybody familar with such a problem?

thanks

H.Stony
09-24-2006, 06:11 AM
it seems to be the combination of a vec4 and float per vertex.

OneSadCookie
09-24-2006, 06:32 PM
Make sure you file a bug report.

You could possibly work around it without having to change your other code using the preprocessor:


#if defined(MacX1600Bugs)
attribute vec4 fogOfWar;
#define fogOfWar (fogOfWar.x)
#else
attribute float fogOfWar;
#endif

H.Stony
09-24-2006, 11:07 PM
do you think, the vertex shader produces software fallback (only for vertex shader).
if i file a bug report they want a example or something like that. how do i find out that vertex shader is in softwaremode to show them the problem?

OneSadCookie
09-25-2006, 03:47 AM
I think "runs absurdly slowly" is enough.

You can check if you're running in software like this:


#if defined(__APPLE__)
* * glUseProgramObjectARB(shader->program);

* * GLint hardwareAccelerated;

* * CGLGetParameter(
* * * * CGLGetCurrentContext(),
* * * * kCGLCPGPUVertexProcessing,
* * * * &hardwareAccelerated);
* * if (!hardwareAccelerated)
* * {
* * * * fprintf(stderr,
* * * * * * "Warning: Vertex shader is NOT being hardware-accelerated\n");
* * }
* * CGLGetParameter(
* * * * CGLGetCurrentContext(),
* * * * kCGLCPGPUFragmentProcessing,
* * * * &hardwareAccelerated);
* * if (!hardwareAccelerated)
* * {
* * * * fprintf(stderr,
* * * * * * "Warning: Fragment shader is NOT being hardware-accelerated\n");
* * }

* * glUseProgramObjectARB(0);
*
#endif

arekkusu
09-25-2006, 06:53 AM
Run your shader in GLSLEditorSample. Look at the vertex and fragment status indicators in the preview window to tell if you are falling back to software.