mesa: Add support for the GL_KHR_context_flush_control extension
authorNeil Roberts <neil@linux.intel.com>
Tue, 23 Sep 2014 18:01:04 +0000 (19:01 +0100)
committerNeil Roberts <neil@linux.intel.com>
Tue, 28 Oct 2014 16:40:18 +0000 (16:40 +0000)
The GL side of this extension just provides an accessor via glGetIntegerv for
the value of GL_CONTEXT_RELEASE_BEHAVIOR so it is trivial to implement. There
is a constant on the context for the value of the enum which is initialised to
GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH. The extension is always enabled because it
doesn't need any driver interaction to retrieve the value.

If the value of the enum is anything but FLUSH then _mesa_make_current will
now refrain from calling _mesa_flush. This should only affect drivers that
explicitly change the enum to a non-default value.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mapi/glapi/gen/KHR_context_flush_control.xml [new file with mode: 0644]
src/mapi/glapi/gen/gl_API.xml
src/mesa/main/context.c
src/mesa/main/extensions.c
src/mesa/main/get_hash_params.py
src/mesa/main/mtypes.h

diff --git a/src/mapi/glapi/gen/KHR_context_flush_control.xml b/src/mapi/glapi/gen/KHR_context_flush_control.xml
new file mode 100644 (file)
index 0000000..bc72435
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_KHR_context_flush_control" number="168">
+    <enum name="CONTEXT_RELEASE_BEHAVIOR"            value="0x82FB"/>
+    <enum name="CONTEXT_RELEASE_BEHAVIOR_FLUSH"      value="0x82FC"/>
+</category>
+
+</OpenGLAPI>
index 534e6a0b403b03000d11d31d4b59c6bc71e4f309..e1b12462e34505fe0ef85aaeb56caad6f6f06be3 100644 (file)
 
 <xi:include href="ARB_texture_barrier.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"/>
+
 <!-- Non-ARB extensions sorted by extension number. -->
 
 <category name="GL_EXT_blend_color" number="2">
index 25b9bfc4cf6ed43eb743a4c5d6b5201de302b2e4..7c62dbc84dac5449badd7b11ece161289ec545c9 100644 (file)
@@ -719,6 +719,9 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
    /** GL_ARB_gpu_shader5 */
    consts->MinFragmentInterpolationOffset = MIN_FRAGMENT_INTERPOLATION_OFFSET;
    consts->MaxFragmentInterpolationOffset = MAX_FRAGMENT_INTERPOLATION_OFFSET;
+
+   /** GL_KHR_context_flush_control */
+   consts->ContextReleaseBehavior = GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH;
 }
 
 
@@ -1622,9 +1625,11 @@ _mesa_make_current( struct gl_context *newCtx,
    }
 
    if (curCtx && 
-      (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
+       (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
        /* make sure this context is valid for flushing */
-      curCtx != newCtx)
+       curCtx != newCtx &&
+       curCtx->Const.ContextReleaseBehavior ==
+       GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
       _mesa_flush(curCtx);
 
    /* We used to call _glapi_check_multithread() here.  Now do it in drivers */
index 15d66a7442537b723bcefa5366ec81ce6b1b4048..0df04c2e6982540156a11d5a39d30c8148dcc5be 100644 (file)
@@ -320,6 +320,7 @@ static const struct extension extension_table[] = {
 
    /* KHR extensions */
    { "GL_KHR_debug",                               o(dummy_true),                              GL,             2012 },
+   { "GL_KHR_context_flush_control",               o(dummy_true),                              GL       | ES2, 2014 },
 
    /* Vendor extensions */
    { "GL_3DFX_texture_compression_FXT1",           o(TDFX_texture_compression_FXT1),           GL,             1999 },
index aa9f282d821b54949340c3175444d39b35608668..a931d9d86c185f346ae4866d3e9b5e1a173ee239 100644 (file)
@@ -318,6 +318,9 @@ descriptor=[
   [ "PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_NAME_LENGTH), extra_INTEL_performance_query" ],
   [ "PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_DESC_LENGTH), extra_INTEL_performance_query" ],
   [ "PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL", "CONST(PERFQUERY_HAVE_GPA_EXTENDED_COUNTERS), extra_INTEL_performance_query" ],
+
+# GL_KHR_context_flush_control
+  [ "CONTEXT_RELEASE_BEHAVIOR", "CONTEXT_ENUM(Const.ContextReleaseBehavior), NO_EXTRA" ],
 ]},
 
 # GLES3 is not a typo.
index e1f1f1dde449372f454276ab65eb53bcc29fed1d..35f5f698478755e80a15d1b36d01df0bdd80598e 100644 (file)
@@ -3680,6 +3680,9 @@ struct gl_constants
 
    GLboolean FakeSWMSAA;
 
+   /** GL_KHR_context_flush_control */
+   GLenum ContextReleaseBehavior;
+
    struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
 };