Re: [waffle] [PATCH 4/6] egl: Add support for robust access contexts.

2016-04-11 Thread Chad Versace
On 04/06/2016 08:59 AM, Bas Nieuwenhuizen wrote:
> Signed-off-by: Bas Nieuwenhuizen 
> ---
>  src/waffle/egl/wegl_config.c  | 16 
>  src/waffle/egl/wegl_context.c |  9 +
>  src/waffle/egl/wegl_display.c |  1 +
>  src/waffle/egl/wegl_display.h |  1 +
>  4 files changed, 27 insertions(+)
> 
> diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
> index a79bc53..1c3f416 100644
> --- a/src/waffle/egl/wegl_config.c
> +++ b/src/waffle/egl/wegl_config.c
> @@ -55,6 +55,22 @@ check_context_attrs(struct wegl_display *dpy,
>  return false;
>  }
>  
> +if (attrs->context_robust && !dpy->EXT_create_context_robustness &&
> +attrs->context_api != WAFFLE_CONTEXT_OPENGL) {
> +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
> + "EGL_EXT_create_context_robustness is required in order 
> to "
> + "request a robust access context for OpenGL ES");
> +return false;
> +}
> +
> +if (attrs->context_robust && !dpy->KHR_create_context &&
> +attrs->context_api == WAFFLE_CONTEXT_OPENGL) {
> +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
> + "EGL_KHR_create_context is required in order to "
> + "request a robust access context for OpenGL");
> +return false;
> +}
> +
>  switch (attrs->context_api) {
>  case WAFFLE_CONTEXT_OPENGL:
>  if (!wcore_config_attrs_version_eq(attrs, 10) && 
> !dpy->KHR_create_context) {
> diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
> index f4ee6cd..67cbc04 100644
> --- a/src/waffle/egl/wegl_context.c
> +++ b/src/waffle/egl/wegl_context.c
> @@ -95,6 +95,11 @@ create_real_context(struct wegl_config *config,
>  context_flags |= 
> EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
>  }
>  
> +if (attrs->context_robust) {
> +assert(dpy->KHR_create_context);
> +context_flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
> +}
> +
>  if (wcore_config_attrs_version_ge(attrs, 32))  {
>  assert(dpy->KHR_create_context);
>  switch (attrs->context_profile) {
> @@ -128,6 +133,10 @@ create_real_context(struct wegl_config *config,
>  assert(attrs->context_minor_version == 0);
>  }
>  
> +if (attrs->context_robust) {
> +attrib_list[i++] = EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT;
> +attrib_list[i++] = EGL_TRUE;
> +}
>  break;
>  
>  default:

Hi Bas,

This patch is correct for EGL <= 1.4. However, EGL 1.5 made
the EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT attribute (but not the flag)
legal for all OpenGL and OpenGL ES context versions.

From the EGL 1.5 (2014.08.27) spec:

3.7.1.5 OpenGL and OpenGL ES Robust Buffer Access

If the EGL_CONTEXT_OPENGL_ROBUST_ACCESS attribute is set to EGL_TRUE,
a context supporting robust buffer access will be created. OpenGL contexts
must support the GL_ARB_robustness extension, or equivalent core API
functional- ity. OpenGL ES contexts must support the GL_EXT_robustness
extension, or equivalent core API functionality.

This attribute is supported only for OpenGL and OpenGL ES contexts. If the
implementation does not support robust buffer access, context creation will
fail.

The default value of EGL_CONTEXT_OPENGL_ROBUST_ACCESS is EGL_ FALSE .

If you have time, please follow-up with a patch that unconditonally permits
WAFFLE_CONTEXT_ROBUST_ACCESS if the EGL version is >= 1.5.

If you don't have time, please let me know and I will find time to do it.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 4/6] egl: Add support for robust access contexts.

2016-04-06 Thread Bas Nieuwenhuizen
Signed-off-by: Bas Nieuwenhuizen 
---
 src/waffle/egl/wegl_config.c  | 16 
 src/waffle/egl/wegl_context.c |  9 +
 src/waffle/egl/wegl_display.c |  1 +
 src/waffle/egl/wegl_display.h |  1 +
 4 files changed, 27 insertions(+)

diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
index a79bc53..1c3f416 100644
--- a/src/waffle/egl/wegl_config.c
+++ b/src/waffle/egl/wegl_config.c
@@ -55,6 +55,22 @@ check_context_attrs(struct wegl_display *dpy,
 return false;
 }
 
+if (attrs->context_robust && !dpy->EXT_create_context_robustness &&
+attrs->context_api != WAFFLE_CONTEXT_OPENGL) {
+wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
+ "EGL_EXT_create_context_robustness is required in order 
to "
+ "request a robust access context for OpenGL ES");
+return false;
+}
+
+if (attrs->context_robust && !dpy->KHR_create_context &&
+attrs->context_api == WAFFLE_CONTEXT_OPENGL) {
+wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
+ "EGL_KHR_create_context is required in order to "
+ "request a robust access context for OpenGL");
+return false;
+}
+
 switch (attrs->context_api) {
 case WAFFLE_CONTEXT_OPENGL:
 if (!wcore_config_attrs_version_eq(attrs, 10) && 
!dpy->KHR_create_context) {
diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index f4ee6cd..67cbc04 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -95,6 +95,11 @@ create_real_context(struct wegl_config *config,
 context_flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
 }
 
+if (attrs->context_robust) {
+assert(dpy->KHR_create_context);
+context_flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
+}
+
 if (wcore_config_attrs_version_ge(attrs, 32))  {
 assert(dpy->KHR_create_context);
 switch (attrs->context_profile) {
@@ -128,6 +133,10 @@ create_real_context(struct wegl_config *config,
 assert(attrs->context_minor_version == 0);
 }
 
+if (attrs->context_robust) {
+attrib_list[i++] = EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT;
+attrib_list[i++] = EGL_TRUE;
+}
 break;
 
 default:
diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index 88fce7a..16af142 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -49,6 +49,7 @@ get_extensions(struct wegl_display *dpy)
 // pending emission.
 assert(wcore_error_get_code() == 0);
 
+dpy->EXT_create_context_robustness = 
waffle_is_extension_in_string(extensions, "EGL_EXT_create_context_robustness");
 dpy->KHR_create_context = waffle_is_extension_in_string(extensions, 
"EGL_KHR_create_context");
 
 return true;
diff --git a/src/waffle/egl/wegl_display.h b/src/waffle/egl/wegl_display.h
index 43b83ef..b82a2ec 100644
--- a/src/waffle/egl/wegl_display.h
+++ b/src/waffle/egl/wegl_display.h
@@ -37,6 +37,7 @@ struct wcore_display;
 struct wegl_display {
 struct wcore_display wcore;
 EGLDisplay egl;
+bool EXT_create_context_robustness;
 bool KHR_create_context;
 };
 
-- 
2.8.0

___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle