Is iOS glGenerateMipmap synchronous or possibly asynchronous?

I am developing an iPad app that uses large textures in OpenGL ES. When the scene first loads, I get a large black artifact on the ceiling for several frames, as seen in the image below. As if the higher mipmap levels are not yet full. In subsequent frames, the ceiling is displayed correctly.

This problem was just starting when I started using mipmapping. One possible explanation is that the call to glGenerateMipmap () does its work asynchronously, creating some kind of mipmap creation worker (in a separate process or possibly in the GPU) and returning.

Is this possible, or am I barking the wrong tree?

Higher mipmap levels don't exist

+4
source share
3 answers

In one context, all operations will be performed in order. However, in your last answer, you mentioned using a second thread. To do this, you must create a second general context: it is always forbidden to re-enter the OpenGL context. If a common context is already in use, there are some more synchronization rules that you should follow, documented at http://developer.apple.com/library/ios/ipad/#DOCUMENTATION/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithOpenGLESContexts/WorkingwithOpenGttextLtmlTlhtmlPenhtml

+3
source

It must be synchronous; OpenGL itself does not have a real concept of streaming (except for the implicit asynchronous dialogue between the CPU and GPU).

A good way to diagnose this would be to switch to GL_LINEAR_MIPMAP_LINEAR . If this is really a problem with low-resolution cards that do not appear longer, you will see that the unpleasant areas on the ceiling are mixed with each other, and not the current black or the correct effect.

A second assumption based on the output would be the problem of clearing the depth buffer.

+2
source

I followed @Tommy's suggestion and switched to GL_LINEAR_MIPMAP_LINEAR . Now the black or right effect has changed to the attenuation between the right and black.

I assume that although we all know that OpenGL is a pipeline (and therefore asynchronous unless you retrieve state synchronization or explanations), we tend to forget it. Of course, I did this when I did not draw, but downloaded and set up the textures.

Once I confirmed the nature of the problem, I added glFinish () after loading all my textures, and the problem disappeared. (Btw, my drawing cycle is in the foreground, and my texture loading cycle - because it takes so much time and impairs interactivity - is in the background. Also, since this may vary by platform, I use iOS5 on iPad 2 )

+1
source

Source: https://habr.com/ru/post/1401687/


All Articles