Skip to content
  • Luigi Santivetti's avatar
    egl/dri2: try to bind old context if bindContext failed · f601c39b
    Luigi Santivetti authored and Eric Engestrom's avatar Eric Engestrom committed
    This change mostly touches error handling code paths, where a
    bug was found when the DRI driver failed to bind a new DRI
    context. Specifically, the reason for it to fail was the window
    system unable (for whatever reason) to provide the DRI drawable
    with a buffer. In this instance, Mesa un-does the EGL bindings,
    but doesn't restore the old DRI context, hence remaining in a
    funny state. It's worth mentioning that despite trying, there
    is no guarantee that the old DRI context can be restored,
    depending on the runtime.
    
    Before this change, if bindContext() failed then
    dri2_make_current() would rebind the old EGL context and
    surfaces and return EGL_BAD_MATCH. However, it wouldn't rebind
    the DRI context and surfaces, thus leaving it in an
    inconsistent and unrecoverable state.
    
    After this change, dri2_make_current() tries to bind the old
    DRI context and surfaces when bindContext() failed. If unable
    to do so, it leaves EGL and the DRI driver in a consistent
    state, it reports an error and returns EGL_BAD_MATCH.
    
    Fixes: 4e8f95f6
    
     ("egl_dri2: Always unbind old contexts")
    
    Signed-off-by: default avatarLuigi Santivetti <luigi.santivetti@imgtec.com>
    Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
    Acked-by: Eric Engestrom's avatarEric Engestrom <eric@engestrom.ch>
    Part-of: <mesa!5707>
    (cherry picked from commit 2907faee)
    f601c39b