[Bf-committers] EGL_CONTEXT_LOST and GL_ARB_create_context_robustness

Brecht Van Lommel brechtvanlommel at pandora.be
Wed Jul 31 06:52:50 CEST 2013


Hi,

On Wed, Jul 31, 2013 at 5:48 AM, Jason Wilkins
<jason.a.wilkins at gmail.com> wrote:
> 1) There must be a baseline OpenGL state that all functions can assume
> before they execute.  They must restore this state when they complete
> (although some state, like the current color, which is almost always
> changed, can be assumed to be in some random state and left as is after
> completion).  With this assumption it wouldn't matter if the context were
> recreated because the baseline will be restored.

This is basically GPU_state_init I think? Calling that after a context
loss should enough, there isn't really other state that is assumed to
be there beyond what is set in that function.

> 2) No data structure can contain a raw resource identifier, because that
> resource may disappear and become invalid at any time.  All resources need
> to centrally registered along with a callback function and the data needed
> to restore them.  If the context is lost then this will be caught at the
> next SwapBuffers and all of the callbacks will be executed, restoring the
> resources in a newly minted context.

When you say "at any time" is that only after a swapbuffers? I
couldn't find the docs explaining when exactly this can happen. If it
happens in the middle of our drawing code that's going to be tricky,
but if not it should be doable.

> Resources include texture objects, vertex array objects, vertex buffer
> objects, frame buffer objects, etc.  Anything with a Gen/Delete function
> pair.  Interestingly enough, Blender does a lot of drawing with DrawPixels,
> and those functions would actually keep working just fine after a context
> loss (but are deprecated and also are not a part of ES...)
>
> Since the registered resources can change after being created this means
> all of the functions for each resource will need to be wrapped so that the
> cached copy of the resource can be updated.

I don't fully understand this yet, but can't we detect if the context
is lost after swap buffers and then clear all our opengl data? Things
like VBOs, shaders and image textures are created as needed in the
drawing code already. There's a few other things like the icon and
font textures that might need to be cleared too, but generally it
seems easier to just clear stuff and let Blender create it on demand
rather than to create some wrapper. Especially since the wrapper would
take up memory to store copies of the buffers.

Brecht.


More information about the Bf-committers mailing list