Skip to content
Snippets Groups Projects
Commit f601c39b authored by Luigi Santivetti's avatar Luigi Santivetti Committed by Eric Engestrom
Browse files

egl/dri2: try to bind old context if bindContext failed


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/mesa!5707>
(cherry picked from commit 2907faee)
parent eece36ec
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment