From: Kristian Høgsberg Kristensen Date: Tue, 24 May 2016 05:49:51 +0000 (-0700) Subject: i965: Enable GL_KHR_robustness X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=85008db1d51f923113832394d7f8d6b1868be882;p=mesa.git 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 Reviewed-by: Ian Romanick Acked-by: Ilia Mirkin --- diff --git a/docs/GL3.txt b/docs/GL3.txt index b5f03af245d..21ab46aae95 100644 --- a/docs/GL3.txt +++ b/docs/GL3.txt @@ -218,7 +218,7 @@ GL 4.5, GLSL 4.50: GL_ARB_shader_texture_image_samples DONE (i965, nv50, nvc0, r600, radeonsi) GL_ARB_texture_barrier DONE (i965, nv50, nvc0, r600, radeonsi) GL_KHR_context_flush_control DONE (all - but needs GLX/EGL extension to be useful) - GL_KHR_robustness not started (90% done with the ARB variant) + GL_KHR_robustness DONE (i965) GL_EXT_shader_integer_mix DONE (all drivers that support GLSL) These are the extensions cherry-picked to make GLES 3.1 diff --git a/docs/relnotes/11.3.0.html b/docs/relnotes/11.3.0.html index e6ed538b3ef..53e453a5518 100644 --- a/docs/relnotes/11.3.0.html +++ b/docs/relnotes/11.3.0.html @@ -60,6 +60,7 @@ Note: some of the new features are only available with certain drivers.
  • GL_ATI_fragment_shader on all Gallium drivers
  • GL_EXT_base_instance on all drivers that support GL_ARB_base_instance
  • GL_EXT_clip_cull_distance on all drivers that support GL_ARB_cull_distance
  • +
  • GL_KHR_robustness on i965
  • GL_OES_draw_buffers_indexed and GL_EXT_draw_buffers_indexed on all drivers that support GL_ARB_draw_buffers_blend
  • GL_OES_gpu_shader5 and GL_EXT_gpu_shader5 on all drivers that support GL_ARB_gpu_shader5
  • GL_OES_sample_shading on i965, nvc0, r600, radeonsi
  • diff --git a/src/mapi/glapi/gen/KHR_robustness.xml b/src/mapi/glapi/gen/KHR_robustness.xml new file mode 100644 index 00000000000..56bcfcc519a --- /dev/null +++ b/src/mapi/glapi/gen/KHR_robustness.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/KHR_robustness_es.xml b/src/mapi/glapi/gen/KHR_robustness_es.xml new file mode 100644 index 00000000000..84f6fd2cdb9 --- /dev/null +++ b/src/mapi/glapi/gen/KHR_robustness_es.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index 0759819a4cd..c511de932eb 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -192,6 +192,8 @@ API_XML = \ INTEL_performance_query.xml \ KHR_debug.xml \ KHR_context_flush_control.xml \ + KHR_robustness.xml \ + KHR_robustness_es.xml \ KHR_texture_compression_astc.xml \ NV_conditional_render.xml \ NV_primitive_restart.xml \ diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml index ce4c4c49bed..6886dab2fd1 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -924,6 +924,8 @@ + + + + + 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 SYNC_STATUS ignores the other + * parameters and returns SIGNALED in . + * + * + GetQueryObjectuiv with QUERY_RESULT_AVAILABLE + * ignores the other parameters and returns TRUE in ." + */ + 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 } };