summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/clear.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 63388f42ee..b4de864326 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -36,6 +36,8 @@
#include "colormac.h"
#include "state.h"
+#include <unistd.h> /* Needed for usleep() */
+
#if _HAVE_FULL_GL
@@ -59,6 +61,20 @@ _mesa_ClearIndex( GLfloat c )
#endif
+/* Nasty workaround - the same as CLAMP(x, min, max), but fudged to avoid
+ * some kind of problematic copmiler optimisation */
+static GLfloat clamp_clear(GLclampf x, GLfloat min, GLfloat max)
+{
+ if ( x > max ) {
+ return max;
+ }
+ if ( x < min ) {
+ return min;
+ }
+ usleep(1);
+ return x;
+}
+
/**
* Specify the clear values for the color buffers.
*
@@ -80,10 +96,10 @@ _mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- tmp[0] = CLAMP(red, 0.0F, 1.0F);
- tmp[1] = CLAMP(green, 0.0F, 1.0F);
- tmp[2] = CLAMP(blue, 0.0F, 1.0F);
- tmp[3] = CLAMP(alpha, 0.0F, 1.0F);
+ tmp[0] = clamp_clear(red, 0.0F, 1.0F);
+ tmp[1] = clamp_clear(green, 0.0F, 1.0F);
+ tmp[2] = clamp_clear(blue, 0.0F, 1.0F);
+ tmp[3] = clamp_clear(alpha, 0.0F, 1.0F);
if (TEST_EQ_4V(tmp, ctx->Color.ClearColor))
return; /* no change */