This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: Gbm_surface_lock_front_buffer() issue

Part Number: AM5728


Tool/software: Linux

Hello,

I have wrote a texture rendering code based on kmscube. 

The strange thing is that as I draw more texture, gbm_surface_lock_front_buffer() is slower.

Approximately It took about 22ms to draw a texture 10 times. ( texture size is 1024 x 1024, but the size of the texture does not matter much )

Also I found that the time it takes to execute gbm_surface_lock_front_buffer() varies depending on whether or not the GL_BLEND is applied.

below is the simplified code.

void GenTex() {
    glGenTextures( 1, &tb )
    glBindTexture( GL_TEXTURE_2D, tb );                               
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); 
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); 
    glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 1024, 1024, 0,        
                  GL_RGBA, GL_UNSIGNED_BYTE, lpOut );                
}
void Draw() {
    glEnable( GL_BLEND );
    glBlendFuncSeparate( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
                         GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
    glClearColor( 0.0, 0.0, 0.0, 0.0 );
    glClear( GL_COLOR_BUFFER_BIT );

    glUseProgram( prog );
    glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, lpPos );
    glEnableVertexAttribArray( 0 );
    glVertexAttribPointer( 1, 2, GL_FLOAT, GL_FALSE, 0, lpTex );
    glEnableVertexAttribArray( 1 );

    glActiveTexture( GL_TEXTURE0 );
    glBindTexture( GL_TEXTURE_2D, tb );
    glUniform1i( m_TexLoc, 0 );

    for (int i = 0; i < 10; i++) {
	glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 ); // Draw 10 times
    }
    glBindTexture( GL_TEXTURE_2D, 0 );
    glDisableVertexAttribArray( 0 );
    glDisableVertexAttribArray( 1 );
}
void Run() {
    lpContext->SetCurrent(); //eglMakeCurrent(...);

    for (;;) {

        Draw(); // Draw texture

        eglSwapBuffers( lpContext->GetEGLDisplay(), lpContext->GetEGLSurface() );

        next_bo = gbm_surface_lock_front_buffer( gbm.surface ); // Take a long time...

        fb = drm_fb_get_from_bo(next_bo);
        drmModePageFlip(drm.fd, drm.crtc_id[DISP_ID], fb->fb_id,   
                        DRM_MODE_PAGE_FLIP_EVENT, &waiting_for_flip);     
        while (waiting_for_flip) {                                       
            ret = select(drm.fd + 1, &fds, NULL, NULL, NULL);            
            if (ret < 0) {                                               
                printf("select err: %s\n", strerror(errno));             
                return ret;                                              
            } else if (ret == 0) {                                       
                printf("select timeout!\n");                             
                return -1;                                               
            } else if (FD_ISSET(0, &fds)) {                              
                continue;                                                
            }                                                            
            drmHandleEvent(drm.fd, &evctx);                              
        }                                                                
        gbm_surface_release_buffer( gbm.surface, bo );
        bo = next_bo;
    }

    lpContext->ReleaseCurrent(); //eglMakeCurrent(...);

}

Drawing 10 textures one at a time, or drawing 1 texture 10 times doesn't  affect the result. 

gbm_surface_lock_front_buffer()  average time: 

Draw count Disable Blending Enable Blending
1 4.5 ms 5 ms
10 5 ms 22 ms
50 10 ms 98 ms

What is purpose of gbm_surface_lock_front_buffer() , and why it takes so long to execute?

I want draw 10~30 texture per one frame, and FPS must be at least 90 ( I have 3 display, each display should have 30 FPS )

Could you give me some advice on this? 

- sdk version

processor-sdk 3.01.00.06
ddk 1.14.3699939 git hash: 0086977
ddk-um 1.14.3699939 git hash: d184140

P.S. I want test it on PVR SDK,  does AM5728 support PowerVR SDK? if so how can I get it?

Best regards