summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2015-02-05 11:59:22 +0100
committerAdam Jackson <ajax@redhat.com>2015-06-03 09:05:36 -0400
commite0bb4a1ec7a720207831732230535fc8d86fc409 (patch)
tree2d64efe004b37484c2ac8e75fb249fdc2d7d98e0
parent9d4c8ff6736e737a98586e29d02c0afadbd35b5f (diff)
glamor: check max native ALU instructions
When using glamor (either in Xephyr or Xwayland) on hardware with too low instructions limit, glamor fallbacks to sw due to large shaders. This makes glamor unbearably slow on such hardware. Check reported value for GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB and fail in glamor_init() if the limit is lower than 128. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=88316 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eric Anholt <eric@anholt.net> (cherry picked from commit 4218a1e066cf39bb980ebbc9f69536c85232da5c)
-rw-r--r--glamor/glamor.c32
-rw-r--r--glamor/glamor_priv.h2
2 files changed, 34 insertions, 0 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c
index 6a3b336ab..a8cc810d1 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -305,6 +305,35 @@ glamor_create_screen_resources(ScreenPtr screen)
return ret;
}
+static Bool
+glamor_check_instruction_count(int gl_version)
+{
+ GLint max_native_alu_instructions;
+
+ /* Avoid using glamor if the reported instructions limit is too low,
+ * as this would cause glamor to fallback on sw due to large shaders
+ * which ends up being unbearably slow.
+ */
+ if (gl_version < 30) {
+ if (!epoxy_has_gl_extension("GL_ARB_fragment_program")) {
+ ErrorF("GL_ARB_fragment_program required\n");
+ return FALSE;
+ }
+
+ glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
+ GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB,
+ &max_native_alu_instructions);
+ if (max_native_alu_instructions < GLAMOR_MIN_ALU_INSTRUCTIONS) {
+ LogMessage(X_WARNING,
+ "glamor requires at least %d instructions (%d reported)\n",
+ GLAMOR_MIN_ALU_INSTRUCTIONS, max_native_alu_instructions);
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
/** Set up glamor for an already-configured GL context. */
Bool
glamor_init(ScreenPtr screen, unsigned int flags)
@@ -384,6 +413,9 @@ glamor_init(ScreenPtr screen, unsigned int flags)
ErrorF("Require OpenGL version 2.1 or later.\n");
goto fail;
}
+
+ if (!glamor_check_instruction_count(gl_version))
+ goto fail;
} else {
if (gl_version < 20) {
ErrorF("Require Open GLES2.0 or later.\n");
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 60070e9e6..d9b38af60 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -1097,4 +1097,6 @@ void glamor_xv_render(glamor_port_private *port_priv);
#include "glamor_font.h"
+#define GLAMOR_MIN_ALU_INSTRUCTIONS 128 /* Minimum required number of native ALU instructions */
+
#endif /* GLAMOR_PRIV_H */