Problem with vertexAttrib on macbook Pro

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,vboTextureWeights);
        glVertexAttribPointerARB(AWXAlphaAttrib,4,GL_FLOAT,0,0,NULL);

		glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboFogOfWar);
		glVertexAttribPointerARB(AWXFogOfWarAttrib,1,GL_FLOAT,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_DRAW_ARB);
        
        glGenBuffersARB(1,&vboFogOfWar);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboFogOfWar);
        glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*sizeof(float)*3,fogOfWar,GL_DYNAMIC_DRAW_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,vboTextureWeights);
	
        glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*12*sizeof(float),texturGew,GL_STATIC_DRAW_ARB);
		
		glGenBuffersARB(1,&vboBegehbarkeit);
		glBindBufferARB(GL_ARRAY_BUFFER_ARB,vboBegehbarkeit);
		
		glBufferDataARB(GL_ARRAY_BUFFER_ARB,part[frame].planezahl*sizeof(float)*3,begehbarkeitPerVertex,GL_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

it seems to be the combination of a vec4 and float per vertex.

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

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?

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
");
    }
    CGLGetParameter(
        CGLGetCurrentContext(),
        kCGLCPGPUFragmentProcessing,
        &hardwareAccelerated);
    if (!hardwareAccelerated)
    {
        fprintf(stderr,
            "Warning: Fragment shader is NOT being hardware-accelerated
");
    }

    glUseProgramObjectARB(0);
 
#endif

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.

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