OpenGL robustness reset status and verification of recovered context data
0 reputation · 15 Dec 2020, 11:55 UTC
0 reputation · 15 Dec 2020, 11:55 UTC
OpenGL 4.5 core includes ARB_robustness with glGetGraphicsResetStatus reporting GL_NO_ERROR, GL_GUILTY_CONTEXT_RESET, GL_INNOCENT_CONTEXT_RESET or GL_UNKNOWN_CONTEXT_RESET for the current context.
The specification declares context contents undefined once the status is not GL_NO_ERROR and provides no portable query to determine which buffers, textures, programs or state survived. Reset notification strategy is fixed at context creation and detection is per-context, with no guarantee about other contexts in the process.
GL_UNKNOWN_CONTEXT_RESET is the ambiguous case where the application cannot distinguish its own fault from an OS or driver-initiated reset, and no further diagnostic token is defined.
Given these constraints, can any context state be considered trustworthy after a non-GL_NO_ERROR reset without full recreation? Does GL_UNKNOWN_CONTEXT_RESET require treating the context as total loss for portable behavior? Must multi-context applications independently assess each context for reset status?
No. After any robustness reset that returns a status other than GL_NO_ERROR (including GL_UNKNOWN_CONTEXT_RESET), the OpenGL 4.5 core specification declares the entire context contents undefined. Portable code must assume a total loss of all buffers, textures, programs, and state and must recreate the context or re‑initialize everything before continuing.
glGetGraphicsResetStatus; it returns GL_NO_ERROR, GL_GUILTY_CONTEXT_RESET, GL_INNOCENT_CONTEXT_RESET, or GL_UNKNOWN_CONTEXT_RESET.GL_NO_ERROR, all context state is undefined – there is no standard way to discover which resources survived.GL_UNKNOWN_CONTEXT_RESET is treated the same as the other reset values for portable behavior; no additional diagnostic token is defined.glGetGraphicsResetStatus for the context you are using.GL_NO_ERROR, destroy the context (or abandon it) and create a new one.Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 15 Dec 2020, 22:54 UTC
Reset status is per-context, not per-share-group or per-process. A non-GL_NO_ERROR result on one shared context does not automatically invalidate sibling contexts, so each rendering context must call glGetGraphicsResetStatus independently after a suspected GPU reset. On desktop OpenGL 4.5 core this assumes GL_ARB_robustness is present; OpenGL ES typically uses EXT_robustness or KHR_robustness with equivalent semantics. Object names may remain non-zero after a reset, but their contents and attachments are undefined for every non-GL_NO_ERROR status, including GL_INNOCENT_CONTEXT_RESET. Poll after SwapBuffers, eglSwapBuffers, or present, because resets can be reported asynchronously.