egl: Implement EGL_KHR_context_flush_control
authorAdam Jackson <ajax@redhat.com>
Thu, 22 Sep 2016 07:47:55 +0000 (03:47 -0400)
committerAdam Jackson <ajax@redhat.com>
Mon, 6 Nov 2017 21:09:03 +0000 (16:09 -0500)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h
src/egl/main/eglapi.c
src/egl/main/eglcontext.c
src/egl/main/eglcontext.h
src/egl/main/egldisplay.h

index 44cddfd0ed54c325becd8e2a28123801f1477a11..b486be748735b7adf7856f96022c4307a00f2c43 100644 (file)
@@ -92,7 +92,7 @@
 #define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1)
 #endif
 
-#define NUM_ATTRIBS 10
+#define NUM_ATTRIBS 12
 
 static void
 dri_set_background_context(void *loaderPrivate)
@@ -457,6 +457,7 @@ static const struct dri2_extension_match optional_core_extensions[] = {
    { __DRI2_RENDERER_QUERY, 1, offsetof(struct dri2_egl_display, rendererQuery) },
    { __DRI2_INTEROP, 1, offsetof(struct dri2_egl_display, interop) },
    { __DRI_IMAGE, 1, offsetof(struct dri2_egl_display, image) },
+   { __DRI2_FLUSH_CONTROL, 1, offsetof(struct dri2_egl_display, flush_control) },
    { NULL, 0, 0 }
 };
 
@@ -766,6 +767,9 @@ dri2_setup_screen(_EGLDisplay *disp)
       }
 #endif
    }
+
+   if (dri2_dpy->flush_control)
+      disp->Extensions.KHR_context_flush_control = EGL_TRUE;
 }
 
 void
@@ -1227,6 +1231,11 @@ dri2_fill_context_attribs(struct dri2_egl_context *dri2_ctx,
       ctx_attribs[pos++] = val;
    }
 
+   if (dri2_ctx->base.ReleaseBehavior == EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR) {
+      ctx_attribs[pos++] = __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR;
+      ctx_attribs[pos++] = __DRI_CTX_RELEASE_BEHAVIOR_NONE;
+   }
+
    *num_attribs = pos;
 
    return true;
index cd2487ab226521d3e1c62a51fadce51d63f201c5..0ec8f44dce293bf548f59b623291a0ab460c7e14 100644 (file)
@@ -164,6 +164,7 @@ struct dri2_egl_display
    const __DRIdri2Extension       *dri2;
    const __DRIswrastExtension     *swrast;
    const __DRI2flushExtension     *flush;
+   const __DRI2flushControlExtension *flush_control;
    const __DRItexBufferExtension  *tex_buffer;
    const __DRIimageExtension      *image;
    const __DRIrobustnessExtension *robustness;
index 215332f99cbb9a600829c7e862bb57554e0c6f40..76dabba2eb516c6899e2b181ba1f0e72a4ad2acb 100644 (file)
@@ -494,6 +494,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
 
    _EGL_CHECK_EXTENSION(KHR_cl_event2);
    _EGL_CHECK_EXTENSION(KHR_config_attribs);
+   _EGL_CHECK_EXTENSION(KHR_context_flush_control);
    _EGL_CHECK_EXTENSION(KHR_create_context);
    _EGL_CHECK_EXTENSION(KHR_create_context_no_error);
    _EGL_CHECK_EXTENSION(KHR_fence_sync);
index 8c64f9ab82e8dbe1f898b09330afa34508f7e3ff..18c1bc59acc1a65a0ca4a0be69d3e408b39b63ca 100644 (file)
@@ -386,6 +386,15 @@ _eglParseContextAttribList(_EGLContext *ctx, _EGLDisplay *dpy,
             break;
          }
 
+      case EGL_CONTEXT_RELEASE_BEHAVIOR_KHR:
+         if (val == EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR ||
+             val == EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR) {
+            ctx->ReleaseBehavior = val;
+         } else {
+            err = EGL_BAD_ATTRIBUTE;
+         }
+         break;
+
       default:
          err = EGL_BAD_ATTRIBUTE;
          break;
@@ -588,6 +597,7 @@ _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy, _EGLConfig *conf,
    ctx->Profile = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
    ctx->ResetNotificationStrategy = EGL_NO_RESET_NOTIFICATION_KHR;
    ctx->ContextPriority = EGL_CONTEXT_PRIORITY_MEDIUM_IMG;
+   ctx->ReleaseBehavior = EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR;
 
    err = _eglParseContextAttribList(ctx, dpy, attrib_list);
    if (err == EGL_SUCCESS && ctx->Config) {
index a75236831360a181558b4b4378d8c2b2f46e5090..8d97ef9eab90aca4cd3d728287a0747ef5b142df 100644 (file)
@@ -64,6 +64,7 @@ struct _egl_context
    EGLint ResetNotificationStrategy;
    EGLint ContextPriority;
    EGLBoolean NoError;
+   EGLint ReleaseBehavior;
 
    /* The real render buffer when a window surface is bound */
    EGLint WindowRenderBuffer;
index 952bfe53f00d50c8a770dae709b0c7d628ade4d9..981cbf4ca0605bf15acf2c084a41fe291bc21259 100644 (file)
@@ -112,6 +112,7 @@ struct _egl_extensions
 
    EGLBoolean KHR_cl_event2;
    EGLBoolean KHR_config_attribs;
+   EGLBoolean KHR_context_flush_control;
    EGLBoolean KHR_create_context;
    EGLBoolean KHR_fence_sync;
    EGLBoolean KHR_get_all_proc_addresses;