diff options
author | Kristian Høgsberg Kristensen <[email protected]> | 2016-05-23 22:49:51 -0700 |
---|---|---|
committer | Kristian Høgsberg Kristensen <[email protected]> | 2016-05-25 09:41:44 -0700 |
commit | 85008db1d51f923113832394d7f8d6b1868be882 (patch) | |
tree | 1d033fbf1ecc53d8f0d0699fae9de52cc7965345 /src/mesa | |
parent | f036eea2cf3012b6b7f9e1c7b317dd78811a1a3a (diff) |
i965: Enable GL_KHR_robustness
GL_KHR_robustness adds the GL_CONTEXT_LOST error and five new entry
points that we already implement. This patch adds a new dispatch table
that returns GL_CONTEXT_LOST from all entry points and implements the
GL_LOSE_CONTEXT_ON_RESET strategy by setting that table when we learn
that we've lost the context.
With the GL_CONTEXT_LOST reporting in place and dispatch for the new
entry points we can turn on GL_KHR_robustness.
Signed-off-by: Kristian Høgsberg Kristensen <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Acked-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_reset.c | 20 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_batchbuffer.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_extensions.c | 1 | ||||
-rw-r--r-- | src/mesa/main/context.c | 1 | ||||
-rw-r--r-- | src/mesa/main/context.h | 2 | ||||
-rw-r--r-- | src/mesa/main/extensions_table.h | 1 | ||||
-rw-r--r-- | src/mesa/main/getstring.c | 82 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 7 | ||||
-rw-r--r-- | src/mesa/main/tests/dispatch_sanity.cpp | 13 |
10 files changed, 130 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 51554757f5b..4b2220126a1 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1704,6 +1704,8 @@ gen7_emit_urb_state(struct brw_context *brw, /* brw_reset.c */ extern GLenum brw_get_graphics_reset_status(struct gl_context *ctx); +void +brw_check_for_reset(struct brw_context *brw); /* brw_compute.c */ extern void diff --git a/src/mesa/drivers/dri/i965/brw_reset.c b/src/mesa/drivers/dri/i965/brw_reset.c index e3182b1474f..df734e5f0fb 100644 --- a/src/mesa/drivers/dri/i965/brw_reset.c +++ b/src/mesa/drivers/dri/i965/brw_reset.c @@ -20,6 +20,9 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + +#include "main/context.h" + #include "brw_context.h" /** @@ -73,3 +76,20 @@ brw_get_graphics_reset_status(struct gl_context *ctx) return GL_NO_ERROR; } + +void +brw_check_for_reset(struct brw_context *brw) +{ + uint32_t reset_count; + uint32_t active; + uint32_t pending; + int err; + + err = drm_intel_get_reset_stats(brw->hw_ctx, &reset_count, &active, + &pending); + if (err) + return; + + if (active > 0 || pending > 0) + _mesa_set_context_lost_dispatch(&brw->ctx); +} diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index f220311842a..5a0db9f5db3 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -368,6 +368,9 @@ do_flush_locked(struct brw_context *brw) if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) do_batch_dump(brw); + if (brw->ctx.Const.ResetStrategy == GL_LOSE_CONTEXT_ON_RESET_ARB) + brw_check_for_reset(brw); + if (ret != 0) { fprintf(stderr, "intel_do_flush_locked failed: %s\n", strerror(-ret)); exit(1); diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c b/src/mesa/drivers/dri/i965/intel_extensions.c index feea6cac5f2..b8d75170d94 100644 --- a/src/mesa/drivers/dri/i965/intel_extensions.c +++ b/src/mesa/drivers/dri/i965/intel_extensions.c @@ -246,6 +246,7 @@ intelInitExtensions(struct gl_context *ctx) ctx->Extensions.EXT_texture_sRGB_decode = true; ctx->Extensions.EXT_texture_swizzle = true; ctx->Extensions.EXT_vertex_array_bgra = true; + ctx->Extensions.KHR_robustness = true; ctx->Extensions.AMD_seamless_cubemap_per_texture = true; ctx->Extensions.APPLE_object_purgeable = true; ctx->Extensions.ATI_separate_stencil = true; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 7c0a6ef340a..172c8548be9 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1367,6 +1367,7 @@ _mesa_free_context_data( struct gl_context *ctx ) free(ctx->BeginEnd); free(ctx->OutsideBeginEnd); free(ctx->Save); + free(ctx->ContextLost); /* Shared context state (display lists, textures, etc) */ _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 46444d2c427..ef19cc68d2d 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -158,6 +158,8 @@ _mesa_notifySwapBuffers(struct gl_context *gc); extern struct _glapi_table * _mesa_get_dispatch(struct gl_context *ctx); +extern void +_mesa_set_context_lost_dispatch(struct gl_context *ctx); extern GLboolean _mesa_valid_to_render(struct gl_context *ctx, const char *where); diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index a809023dcfe..e3c91ef427b 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -279,6 +279,7 @@ EXT(INTEL_performance_query , INTEL_performance_query EXT(KHR_context_flush_control , dummy_true , GLL, GLC, x , ES2, 2014) EXT(KHR_debug , dummy_true , GLL, GLC, 11, ES2, 2012) EXT(KHR_robust_buffer_access_behavior , ARB_robust_buffer_access_behavior , GLL, GLC, x , ES2, 2014) +EXT(KHR_robustness , KHR_robustness , GLL, GLC, x , ES2, 2012) EXT(KHR_texture_compression_astc_hdr , KHR_texture_compression_astc_hdr , GLL, GLC, x , ES2, 2012) EXT(KHR_texture_compression_astc_ldr , KHR_texture_compression_astc_ldr , GLL, GLC, x , ES2, 2012) diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 92f8a389cd9..125b03aeca6 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -31,7 +31,8 @@ #include "enums.h" #include "extensions.h" #include "mtypes.h" - +#include "macros.h" +#include "main/dispatch.h" /* for _gloffset_COUNT */ /** * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query. @@ -310,6 +311,82 @@ _mesa_GetError( void ) return e; } +static void +_context_lost_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, + GLint *values) +{ + GET_CURRENT_CONTEXT(ctx); + if (ctx) + _mesa_error(ctx, GL_CONTEXT_LOST, "GetSynciv(invalid call)"); + + if (pname == GL_SYNC_STATUS && bufSize >= 1) + *values = GL_SIGNALED; +} + +static void +_context_lost_GetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) +{ + GET_CURRENT_CONTEXT(ctx); + if (ctx) + _mesa_error(ctx, GL_CONTEXT_LOST, "GetQueryObjectuiv(context lost)"); + + if (pname == GL_QUERY_RESULT_AVAILABLE) + *params = GL_TRUE; +} + +static int +context_lost_nop_handler(void) +{ + GET_CURRENT_CONTEXT(ctx); + if (ctx) + _mesa_error(ctx, GL_CONTEXT_LOST, "context lost"); + + return 0; +} + +void +_mesa_set_context_lost_dispatch(struct gl_context *ctx) +{ + if (ctx->ContextLost == NULL) { + int numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT); + + ctx->ContextLost = malloc(numEntries * sizeof(_glapi_proc)); + if (!ctx->ContextLost) + return; + + _glapi_proc *entry = (_glapi_proc *) ctx->ContextLost; + unsigned i; + for (i = 0; i < numEntries; i++) + entry[i] = (_glapi_proc) context_lost_nop_handler; + + /* The ARB_robustness specification says: + * + * "* GetError and GetGraphicsResetStatus behave normally following a + * graphics reset, so that the application can determine a reset + * has occurred, and when it is safe to destroy and recreate the + * context. + * + * * Any commands which might cause a polling application to block + * indefinitely will generate a CONTEXT_LOST error, but will also + * return a value indicating completion to the application. Such + * commands include: + * + * + GetSynciv with <pname> SYNC_STATUS ignores the other + * parameters and returns SIGNALED in <values>. + * + * + GetQueryObjectuiv with <pname> QUERY_RESULT_AVAILABLE + * ignores the other parameters and returns TRUE in <params>." + */ + SET_GetError(ctx->ContextLost, _mesa_GetError); + SET_GetGraphicsResetStatusARB(ctx->ContextLost, _mesa_GetGraphicsResetStatusARB); + SET_GetSynciv(ctx->ContextLost, _context_lost_GetSynciv); + SET_GetQueryObjectuiv(ctx->ContextLost, _context_lost_GetQueryObjectuiv); + } + + ctx->CurrentDispatch = ctx->ContextLost; + _glapi_set_dispatch(ctx->CurrentDispatch); +} + /** * Returns an error code specified by GL_ARB_robustness, or GL_NO_ERROR. * \return current context status @@ -358,6 +435,9 @@ _mesa_GetGraphicsResetStatusARB( void ) mtx_unlock(&ctx->Shared->Mutex); } + if (status != GL_NO_ERROR) + _mesa_set_context_lost_dispatch(ctx); + if (!ctx->Driver.GetGraphicsResetStatus && (MESA_VERBOSE & VERBOSE_API)) _mesa_debug(ctx, "glGetGraphicsResetStatusARB always returns GL_NO_ERROR " diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b7b3ede57f1..e16663d2880 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3899,6 +3899,7 @@ struct gl_extensions GLboolean ATI_separate_stencil; GLboolean GREMEDY_string_marker; GLboolean INTEL_performance_query; + GLboolean KHR_robustness; GLboolean KHR_texture_compression_astc_hdr; GLboolean KHR_texture_compression_astc_ldr; GLboolean MESA_pack_invert; @@ -4302,7 +4303,11 @@ struct gl_context */ struct _glapi_table *BeginEnd; /** - * Tracks the current dispatch table out of the 3 above, so that it can be + * Dispatch table for when a graphics reset has happened. + */ + struct _glapi_table *ContextLost; + /** + * Tracks the current dispatch table out of the 4 above, so that it can be * re-set on glXMakeCurrent(). */ struct _glapi_table *CurrentDispatch; diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index c85bc54fe35..e81aaa26064 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -852,6 +852,12 @@ const struct function common_desktop_functions_possible[] = { // { "glTextureStorage3DMultisampleEXT", 43, -1 }, // XXX: Add to xml /* GL 4.5 */ + /* aliased versions checked above */ + //{ "glGetGraphicsResetStatus", 45, -1 }, + //{ "glReadnPixels", 45, -1 }, + //{ "glGetnUniformfv", 45, -1 }, + //{ "glGetnUniformiv", 45, -1 }, + //{ "glGetnUniformuiv", 45, -1 }, { "glMemoryBarrierByRegion", 45, -1 }, /* GL_ARB_internalformat_query */ @@ -2306,6 +2312,13 @@ const struct function gles2_functions_possible[] = { /* GL_EXT_polygon_offset_clamp */ { "glPolygonOffsetClampEXT", 11, -1 }, + /* GL_KHR_robustness */ + { "glGetGraphicsResetStatusKHR", 20, -1 }, + { "glReadnPixelsKHR", 20, -1 }, + { "glGetnUniformfvKHR", 20, -1 }, + { "glGetnUniformivKHR", 20, -1 }, + { "glGetnUniformuivKHR", 20, -1 }, + { NULL, 0, -1 } }; |