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. Kristensen's avatarKristian Høgsberg Kristensen <krh@bitplanet.net>
Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
Acked-by: Ilia Mirkin's avatarIlia Mirkin <imirkin@alum.mit.edu>
parent f036eea2
...@@ -218,7 +218,7 @@ GL 4.5, GLSL 4.50: ...@@ -218,7 +218,7 @@ GL 4.5, GLSL 4.50:
GL_ARB_shader_texture_image_samples DONE (i965, nv50, nvc0, r600, radeonsi) GL_ARB_shader_texture_image_samples DONE (i965, nv50, nvc0, r600, radeonsi)
GL_ARB_texture_barrier 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_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) GL_EXT_shader_integer_mix DONE (all drivers that support GLSL)
These are the extensions cherry-picked to make GLES 3.1 These are the extensions cherry-picked to make GLES 3.1
......
...@@ -60,6 +60,7 @@ Note: some of the new features are only available with certain drivers. ...@@ -60,6 +60,7 @@ Note: some of the new features are only available with certain drivers.
<li>GL_ATI_fragment_shader on all Gallium drivers</li> <li>GL_ATI_fragment_shader on all Gallium drivers</li>
<li>GL_EXT_base_instance on all drivers that support GL_ARB_base_instance</li> <li>GL_EXT_base_instance on all drivers that support GL_ARB_base_instance</li>
<li>GL_EXT_clip_cull_distance on all drivers that support GL_ARB_cull_distance</li> <li>GL_EXT_clip_cull_distance on all drivers that support GL_ARB_cull_distance</li>
<li>GL_KHR_robustness on i965</li>
<li>GL_OES_draw_buffers_indexed and GL_EXT_draw_buffers_indexed on all drivers that support GL_ARB_draw_buffers_blend</li> <li>GL_OES_draw_buffers_indexed and GL_EXT_draw_buffers_indexed on all drivers that support GL_ARB_draw_buffers_blend</li>
<li>GL_OES_gpu_shader5 and GL_EXT_gpu_shader5 on all drivers that support GL_ARB_gpu_shader5</li> <li>GL_OES_gpu_shader5 and GL_EXT_gpu_shader5 on all drivers that support GL_ARB_gpu_shader5</li>
<li>GL_OES_sample_shading on i965, nvc0, r600, radeonsi</li> <li>GL_OES_sample_shading on i965, nvc0, r600, radeonsi</li>
......
<?xml version="1.0"?>
<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
<!-- Note: no GLX protocol info yet. -->
<OpenGLAPI>
<category name="GL_KHR_robustness" number="170">
<enum name="GUILTY_CONTEXT_RESET" value="0x8253"/>
<enum name="INNOCENT_CONTEXT_RESET" value="0x8254"/>
<enum name="UNKNOWN_CONTEXT_RESET" value="0x8255"/>
<enum name="RESET_NOTIFICATION_STRATEGY" count="1" value="0x8256">
<size name="Get" mode="get"/>
</enum>
<enum name="LOSE_CONTEXT_ON_RESET" value="0x8252"/>
<enum name="NO_RESET_NOTIFICATION" value="0x8261"/>
<enum name="CONTEXT_FLAG_ROBUST_ACCESS_BIT" value="0x00000004"/>
<!-- This extension applies to both GL and ES. GL entrypoints have
no suffix, ES entrypoints have the KHR suffix. This file
defines entry points for GL. -->
<!-- GL definitions -->
<function name="GetGraphicsResetStatus" alias="GetGraphicsResetStatusARB">
<return type="GLenum"/>
</function>
<function name="ReadnPixels" alias="ReadnPixelsARB">
<param name="x" type="GLint"/>
<param name="y" type="GLint"/>
<param name="width" type="GLsizei"/>
<param name="height" type="GLsizei"/>
<param name="format" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="bufSize" type="GLsizei"/>
<param name="data" type="GLvoid *" output="true"/>
</function>
<function name="GetnUniformfv" alias="GetnUniformfvARB">
<param name="program" type="GLuint"/>
<param name="location" type="GLint"/>
<param name="bufSize" type="GLsizei"/>
<param name="params" type="GLfloat *" output="true"/>
</function>
<function name="GetnUniformiv" alias="GetnUniformivARB">
<param name="program" type="GLuint"/>
<param name="location" type="GLint"/>
<param name="bufSize" type="GLsizei"/>
<param name="params" type="GLint *" output="true"/>
</function>
<function name="GetnUniformuiv" alias="GetnUniformuivARB">
<param name="program" type="GLuint"/>
<param name="location" type="GLint"/>
<param name="bufSize" type="GLsizei"/>
<param name="params" type="GLuint *" output="true"/>
</function>
</category>
</OpenGLAPI>
<?xml version="1.0"?>
<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
<OpenGLAPI>
<category name="GL_KHR_robustness" number="190">
<enum name="GUILTY_CONTEXT_RESET_KHR" value="0x8253"/>
<enum name="INNOCENT_CONTEXT_RESET_KHR" value="0x8254"/>
<enum name="UNKNOWN_CONTEXT_RESET_KHR" value="0x8255"/>
<enum name="RESET_NOTIFICATION_STRATEGY_KHR" count="1" value="0x8256">
<size name="Get" mode="get"/>
</enum>
<enum name="LOSE_CONTEXT_ON_RESET_KHR" value="0x8252"/>
<enum name="NO_RESET_NOTIFICATION_KHR" value="0x8261"/>
<enum name="CONTEXT_FLAG_ROBUST_ACCESS_BIT_KHR" value="0x00000004"/>
<!-- This extension applies to both GL and ES. GL entrypoints have
no suffix, ES entrypoints have the KHR suffix. This file
defines entry points for ES. -->
<function name="GetGraphicsResetStatusKHR"
alias="GetGraphicsResetStatusARB" es2="2.0">
<return type="GLenum"/>
</function>
<function name="ReadnPixelsKHR" alias="ReadnPixelsARB" es2="2.0">
<param name="x" type="GLint"/>
<param name="y" type="GLint"/>
<param name="width" type="GLsizei"/>
<param name="height" type="GLsizei"/>
<param name="format" type="GLenum"/>
<param name="type" type="GLenum"/>
<param name="bufSize" type="GLsizei"/>
<param name="data" type="GLvoid *" output="true"/>
</function>
<function name="GetnUniformfvKHR" alias="GetnUniformfvARB" es2="2.0">
<param name="program" type="GLuint"/>
<param name="location" type="GLint"/>
<param name="bufSize" type="GLsizei"/>
<param name="params" type="GLfloat *" output="true"/>
</function>
<function name="GetnUniformivKHR" alias="GetnUniformivARB" es2="2.0">
<param name="program" type="GLuint"/>
<param name="location" type="GLint"/>
<param name="bufSize" type="GLsizei"/>
<param name="params" type="GLint *" output="true"/>
</function>
<function name="GetnUniformuivKHR" alias="GetnUniformuivARB" es2="2.0">
<param name="program" type="GLuint"/>
<param name="location" type="GLint"/>
<param name="bufSize" type="GLsizei"/>
<param name="params" type="GLuint *" output="true"/>
</function>
</category>
</OpenGLAPI>
...@@ -192,6 +192,8 @@ API_XML = \ ...@@ -192,6 +192,8 @@ API_XML = \
INTEL_performance_query.xml \ INTEL_performance_query.xml \
KHR_debug.xml \ KHR_debug.xml \
KHR_context_flush_control.xml \ KHR_context_flush_control.xml \
KHR_robustness.xml \
KHR_robustness_es.xml \
KHR_texture_compression_astc.xml \ KHR_texture_compression_astc.xml \
NV_conditional_render.xml \ NV_conditional_render.xml \
NV_primitive_restart.xml \ NV_primitive_restart.xml \
......
...@@ -924,6 +924,8 @@ ...@@ -924,6 +924,8 @@
</category> </category>
<xi:include href="KHR_robustness_es.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<category name="GL_EXT_base_instance" number="203"> <category name="GL_EXT_base_instance" number="203">
<function name="DrawArraysInstancedBaseInstanceEXT" es2="3.0" <function name="DrawArraysInstancedBaseInstanceEXT" es2="3.0"
......
...@@ -8288,6 +8288,9 @@ ...@@ -8288,6 +8288,9 @@
<xi:include href="KHR_context_flush_control.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="KHR_context_flush_control.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<!-- ARB extension 170 -->
<xi:include href="KHR_robustness.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<!-- ARB extension 171 --> <!-- ARB extension 171 -->
<xi:include href="ARB_pipeline_statistics_query.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="ARB_pipeline_statistics_query.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
......
...@@ -1704,6 +1704,8 @@ gen7_emit_urb_state(struct brw_context *brw, ...@@ -1704,6 +1704,8 @@ gen7_emit_urb_state(struct brw_context *brw,
/* brw_reset.c */ /* brw_reset.c */
extern GLenum extern GLenum
brw_get_graphics_reset_status(struct gl_context *ctx); brw_get_graphics_reset_status(struct gl_context *ctx);
void
brw_check_for_reset(struct brw_context *brw);
/* brw_compute.c */ /* brw_compute.c */
extern void extern void
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "main/context.h"
#include "brw_context.h" #include "brw_context.h"
/** /**
...@@ -73,3 +76,20 @@ brw_get_graphics_reset_status(struct gl_context *ctx) ...@@ -73,3 +76,20 @@ brw_get_graphics_reset_status(struct gl_context *ctx)
return GL_NO_ERROR; 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);
}
...@@ -368,6 +368,9 @@ do_flush_locked(struct brw_context *brw) ...@@ -368,6 +368,9 @@ do_flush_locked(struct brw_context *brw)
if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
do_batch_dump(brw); do_batch_dump(brw);
if (brw->ctx.Const.ResetStrategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
brw_check_for_reset(brw);
if (ret != 0) { if (ret != 0) {
fprintf(stderr, "intel_do_flush_locked failed: %s\n", strerror(-ret)); fprintf(stderr, "intel_do_flush_locked failed: %s\n", strerror(-ret));
exit(1); exit(1);
......
...@@ -246,6 +246,7 @@ intelInitExtensions(struct gl_context *ctx) ...@@ -246,6 +246,7 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.EXT_texture_sRGB_decode = true; ctx->Extensions.EXT_texture_sRGB_decode = true;
ctx->Extensions.EXT_texture_swizzle = true; ctx->Extensions.EXT_texture_swizzle = true;
ctx->Extensions.EXT_vertex_array_bgra = true; ctx->Extensions.EXT_vertex_array_bgra = true;
ctx->Extensions.KHR_robustness = true;
ctx->Extensions.AMD_seamless_cubemap_per_texture = true; ctx->Extensions.AMD_seamless_cubemap_per_texture = true;
ctx->Extensions.APPLE_object_purgeable = true; ctx->Extensions.APPLE_object_purgeable = true;
ctx->Extensions.ATI_separate_stencil = true; ctx->Extensions.ATI_separate_stencil = true;
......
...@@ -1367,6 +1367,7 @@ _mesa_free_context_data( struct gl_context *ctx ) ...@@ -1367,6 +1367,7 @@ _mesa_free_context_data( struct gl_context *ctx )
free(ctx->BeginEnd); free(ctx->BeginEnd);
free(ctx->OutsideBeginEnd); free(ctx->OutsideBeginEnd);
free(ctx->Save); free(ctx->Save);
free(ctx->ContextLost);
/* Shared context state (display lists, textures, etc) */ /* Shared context state (display lists, textures, etc) */
_mesa_reference_shared_state(ctx, &ctx->Shared, NULL); _mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
......
...@@ -158,6 +158,8 @@ _mesa_notifySwapBuffers(struct gl_context *gc); ...@@ -158,6 +158,8 @@ _mesa_notifySwapBuffers(struct gl_context *gc);
extern struct _glapi_table * extern struct _glapi_table *
_mesa_get_dispatch(struct gl_context *ctx); _mesa_get_dispatch(struct gl_context *ctx);
extern void
_mesa_set_context_lost_dispatch(struct gl_context *ctx);
extern GLboolean extern GLboolean
_mesa_valid_to_render(struct gl_context *ctx, const char *where); _mesa_valid_to_render(struct gl_context *ctx, const char *where);
......
...@@ -279,6 +279,7 @@ EXT(INTEL_performance_query , INTEL_performance_query ...@@ -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_context_flush_control , dummy_true , GLL, GLC, x , ES2, 2014)
EXT(KHR_debug , dummy_true , GLL, GLC, 11, ES2, 2012) 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_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_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) EXT(KHR_texture_compression_astc_ldr , KHR_texture_compression_astc_ldr , GLL, GLC, x , ES2, 2012)
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
#include "enums.h" #include "enums.h"
#include "extensions.h" #include "extensions.h"
#include "mtypes.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. * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query.
...@@ -310,6 +311,82 @@ _mesa_GetError( void ) ...@@ -310,6 +311,82 @@ _mesa_GetError( void )
return e; 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. * Returns an error code specified by GL_ARB_robustness, or GL_NO_ERROR.
* \return current context status * \return current context status
...@@ -358,6 +435,9 @@ _mesa_GetGraphicsResetStatusARB( void ) ...@@ -358,6 +435,9 @@ _mesa_GetGraphicsResetStatusARB( void )
mtx_unlock(&ctx->Shared->Mutex); mtx_unlock(&ctx->Shared->Mutex);
} }
if (status != GL_NO_ERROR)
_mesa_set_context_lost_dispatch(ctx);
if (!ctx->Driver.GetGraphicsResetStatus && (MESA_VERBOSE & VERBOSE_API)) if (!ctx->Driver.GetGraphicsResetStatus && (MESA_VERBOSE & VERBOSE_API))
_mesa_debug(ctx, _mesa_debug(ctx,
"glGetGraphicsResetStatusARB always returns GL_NO_ERROR " "glGetGraphicsResetStatusARB always returns GL_NO_ERROR "
......
...@@ -3899,6 +3899,7 @@ struct gl_extensions ...@@ -3899,6 +3899,7 @@ struct gl_extensions
GLboolean ATI_separate_stencil; GLboolean ATI_separate_stencil;
GLboolean GREMEDY_string_marker; GLboolean GREMEDY_string_marker;
GLboolean INTEL_performance_query; GLboolean INTEL_performance_query;
GLboolean KHR_robustness;
GLboolean KHR_texture_compression_astc_hdr; GLboolean KHR_texture_compression_astc_hdr;
GLboolean KHR_texture_compression_astc_ldr; GLboolean KHR_texture_compression_astc_ldr;
GLboolean MESA_pack_invert; GLboolean MESA_pack_invert;
...@@ -4302,7 +4303,11 @@ struct gl_context ...@@ -4302,7 +4303,11 @@ struct gl_context
*/ */
struct _glapi_table *BeginEnd; 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(). * re-set on glXMakeCurrent().
*/ */
struct _glapi_table *CurrentDispatch; struct _glapi_table *CurrentDispatch;
......
...@@ -852,6 +852,12 @@ const struct function common_desktop_functions_possible[] = { ...@@ -852,6 +852,12 @@ const struct function common_desktop_functions_possible[] = {
// { "glTextureStorage3DMultisampleEXT", 43, -1 }, // XXX: Add to xml // { "glTextureStorage3DMultisampleEXT", 43, -1 }, // XXX: Add to xml
/* GL 4.5 */ /* 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 }, { "glMemoryBarrierByRegion", 45, -1 },
/* GL_ARB_internalformat_query */ /* GL_ARB_internalformat_query */
...@@ -2306,6 +2312,13 @@ const struct function gles2_functions_possible[] = { ...@@ -2306,6 +2312,13 @@ const struct function gles2_functions_possible[] = {
/* GL_EXT_polygon_offset_clamp */ /* GL_EXT_polygon_offset_clamp */
{ "glPolygonOffsetClampEXT", 11, -1 }, { "glPolygonOffsetClampEXT", 11, -1 },
/* GL_KHR_robustness */
{ "glGetGraphicsResetStatusKHR", 20, -1 },
{ "glReadnPixelsKHR", 20, -1 },
{ "glGetnUniformfvKHR", 20, -1 },
{ "glGetnUniformivKHR", 20, -1 },
{ "glGetnUniformuivKHR", 20, -1 },
{ NULL, 0, -1 } { NULL, 0, -1 }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment