[waffle] [PATCH v2] glx: don't use ARB_create_context with pre 3.2 contexts
Emil Velikov
emil.l.velikov at gmail.com
Fri Apr 15 22:45:13 UTC 2016
This way if the user requests GL pre 3.2 context which lacks the
flags/extra bits which require ARB_create_context one can safely fall
back to the normal/legacy entry point.
This resolves piglits on non 3.2 capable drivers such as classic swrast,
nouveau_vieux and alike.
v2: The version should be 3.2 and not 3.0 as originally.
Cc: Ilia Mirkin <imirkin at alum.mit.edu>
Reviewed-by: Jose Fonseca <jfonseca at vmware.com> (v1)
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
src/waffle/glx/glx_config.c | 7 ++++---
src/waffle/glx/glx_context.c | 12 +++++++++++-
src/waffle/glx/glx_context.h | 16 ++++++++++++++++
3 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/waffle/glx/glx_config.c b/src/waffle/glx/glx_config.c
index 7792aa0..259e538 100644
--- a/src/waffle/glx/glx_config.c
+++ b/src/waffle/glx/glx_config.c
@@ -32,6 +32,7 @@
#include "wcore_error.h"
#include "glx_config.h"
+#include "glx_context.h"
#include "glx_display.h"
#include "glx_platform.h"
#include "glx_wrappers.h"
@@ -70,11 +71,11 @@ glx_config_check_context_attrs(struct glx_display *dpy,
switch (attrs->context_api) {
case WAFFLE_CONTEXT_OPENGL:
- if (!wcore_config_attrs_version_eq(attrs, 10) && !dpy->ARB_create_context) {
+ if (glx_context_needs_arb_create_context(attrs) &&
+ !dpy->ARB_create_context) {
wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
"GLX_ARB_create_context is required in order to "
- "request an OpenGL version not equal to the default "
- "value 1.0");
+ "request an OpenGL version greater or equal than 3.2");
return false;
}
else if (wcore_config_attrs_version_ge(attrs, 32) && !dpy->ARB_create_context_profile) {
diff --git a/src/waffle/glx/glx_context.c b/src/waffle/glx/glx_context.c
index 1f9290b..cb10e32 100644
--- a/src/waffle/glx/glx_context.c
+++ b/src/waffle/glx/glx_context.c
@@ -169,7 +169,17 @@ glx_context_create_native(struct glx_config *config,
struct glx_display *dpy = glx_display(config->wcore.display);
struct glx_platform *platform = glx_platform(dpy->wcore.platform);
- if (dpy->ARB_create_context) {
+ // Use ARB_create_context when we have
+ // - OpenGL version 1.0, or
+ // - OpenGL version 3.2 or greater, or
+ // - OpenGL with fwd_compat, or
+ // - Debug context
+ //
+ // The first one of the four is optional, the remainder hard requirement
+ // for the use of ARB_create_context.
+ if (dpy->ARB_create_context &&
+ (wcore_config_attrs_version_eq(&config->wcore.attrs, 10) ||
+ glx_context_needs_arb_create_context(&config->wcore.attrs))) {
bool ok;
// Choose a large size to prevent accidental overflow.
diff --git a/src/waffle/glx/glx_context.h b/src/waffle/glx/glx_context.h
index bb2a4dd..23ffd74 100644
--- a/src/waffle/glx/glx_context.h
+++ b/src/waffle/glx/glx_context.h
@@ -29,6 +29,7 @@
#include <GL/glx.h>
+#include "wcore_config_attrs.h"
#include "wcore_context.h"
#include "wcore_util.h"
@@ -55,3 +56,18 @@ glx_context_destroy(struct wcore_context *wc_self);
union waffle_native_context*
glx_context_get_native(struct wcore_context *wc_self);
+
+
+static inline bool
+glx_context_needs_arb_create_context(const struct wcore_config_attrs *attrs)
+{
+ if (attrs->context_api == WAFFLE_CONTEXT_OPENGL &&
+ (wcore_config_attrs_version_ge(attrs, 32) ||
+ attrs->context_forward_compatible))
+ return true;
+
+ if (attrs->context_debug)
+ return true;
+
+ return false;
+}
--
2.8.0
More information about the waffle
mailing list