logical buffer load - slow framebuffer load - ios
Asked Answered
R

1

13

We are trying to figure out why we have a relatively slow FPS on iphone 4 and ipad 1. We are seeing this Category of warning in our open GL Analysis: Logical Buffer Load. The summary is "Slow framebuffer load". The recommendation says that the framebuffer must be loaded by the GPU before rendering. It recommends that we are failing to performa a fullscreen clear operation at the beginning fo each frame. However, we are doing this with glClear.

[EAGLContext setCurrentContext:_context];

glBindFramebuffer(GL_FRAMEBUFFER, _defaultFramebuffer);
glClear(GL_COLOR_BUFFER_BIT);

// Our OpenGL Drawing Occurs here

... ... ...

// hint to opengl to not bother with this buffer
const GLenum discards[]  = {GL_DEPTH_ATTACHMENT};
glBindFramebuffer(GL_FRAMEBUFFER, _defaultFramebuffer);
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, discards);

// present render
[_context presentRenderbuffer:GL_RENDERBUFFER];

We are not actually using a depth or stencil buffer.

This is happening when we render textures as tiles and it happens each time we load a new tile. It is pointing to our glDrawArrays command.

Any recommendations on how we can get rid of this warning?

If it helps at all, this is how we are setting up the layer:

eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
                                kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat,
                                nil];
Ruisdael answered 20/9, 2012 at 21:11 Comment(7)
I should note that while the analyzer points this out as a point of optimization, in my experience it's been a fairly minor one. Odds are, it has little to do with why your application is rendering slowly. Look at the OpenGL ES Driver instrument and see whether you are maxing out the renderer (fragment limited) or tiler (geometry limited).Kroll
We did run the openGL ES instrumentation and it seems that we are maxing out the fill-rate (fragments). We are only rendering 256x256 tiles that are filling up the visible area. Are there any apple specific extensions that we may need to look at, whether that's creating the textures or the way we are setting up the textures, or any other purpose?Ruisdael
As an update to this, we set glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES, GL_FASTEST); And that seems to have helped quite a bit with FPS.Ruisdael
Interesting. Are you using dFdx() or other derivative functions in your shaders somewhere?Kroll
actually we are not and I later figured out from Apple that wasn't the change that had the performance impact (GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES, GL_FASTEST). Actually what made the biggest difference is that we stopped using VBO for iOS. FPS went up by 20 when we stopped using VBOs. I am still seeing the "Logical Buffer Load", "Slow Frame Buffer Load" in the OpenGL-ES Analysis tools with xcode and cannot figure out how to fix it.Ruisdael
I have been finding exactly the same problem. I am calling glClear and also I tried explicitly discarding the framebuffer before drawing, but I still get these warnings.Specht
Have you tried to clear also GL_DEPTH_BUFFER_BIT? Perhaps the analyzer takes in account only the glClear calls and not the glDiscard calls. In this case the warning might not be strictly related to the performance.Publicity
B
0

After a lot of work and deliberation, I managed to figure this out in the end.

Ok I am using an open source library called GLESuperman. Its a great library which helps to debug these kind of issues and it can be used for drawing graphics - its pretty fast. Yes I have no idea why its called that... But its free and it works. Just search it up on Github. It gets updated very frequently and supports iOS 7 and higher.

Ok so to implement it, do the following:

// Import the framework into your Xcode project.
#import <GLESuperman/GLESuperman.h>

// Also you will need to import Core Graphics.
#import <CoreGraphics/CoreGraphics.h>

// In order to run it in debug mode and get 
// a live detailed report about things like FPS, do the following.
GLESuperman *debugData = [[GLESuperman alloc] init];
[debugData runGraphicDebug withRepeat:YES inBackground:YES];

// In order to draw graphics, do the following.
GLESuperman *graphicView = [[GLESuperman alloc] init];
[graphicView drawView:CGRectMake(0, 0, 50, 50];

// You can do other things too like add images/etc..
// Just look at the library documentation, it has everything.

[graphicView setAlpha:1.0];
[graphicView showGraphic];
Barefaced answered 12/3, 2015 at 10:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.