summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-07-17 22:00:47 -0600
committerBrian Paul <[email protected]>2009-07-17 22:00:47 -0600
commitb96ae1b2c463d6d99ee0418083ef68f4027b7cd7 (patch)
treef34f89c267b940eb7408475bd0c2ff57c7fbe992 /src/mesa
parentf81f57e25db18b1c69f2f8076380603340fa2cda (diff)
parentcd10996d4f517c69e306eaf6dfb0654432651b3a (diff)
Merge branch 'mesa_7_5_branch'
Conflicts: Makefile progs/glsl/multitex.c src/mesa/main/enums.c src/mesa/main/state.c src/mesa/main/texenvprogram.c src/mesa/main/version.h
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/attrib.c8
-rw-r--r--src/mesa/main/imports.c125
-rw-r--r--src/mesa/main/mtypes.h7
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c23
4 files changed, 91 insertions, 72 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 476a24434cc..cb49c4cb076 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -849,7 +849,6 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate)
/* Restore texture object state for each target */
for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
const struct gl_texture_object *obj = NULL;
- GLfloat bordColor[4];
GLenum target;
obj = &texstate->SavedObj[u][tgt];
@@ -875,12 +874,7 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate)
_mesa_BindTexture(target, obj->Name);
- bordColor[0] = CHAN_TO_FLOAT(obj->BorderColor[0]);
- bordColor[1] = CHAN_TO_FLOAT(obj->BorderColor[1]);
- bordColor[2] = CHAN_TO_FLOAT(obj->BorderColor[2]);
- bordColor[3] = CHAN_TO_FLOAT(obj->BorderColor[3]);
-
- _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, bordColor);
+ _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, obj->BorderColor);
_mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority);
_mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, obj->WrapS);
_mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, obj->WrapT);
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 3fb67083a2d..1722579e82c 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -1021,6 +1021,22 @@ output_if_debug(const char *prefixString, const char *outputString,
}
}
+static const char *error_string( GLenum error );
+
+static void flush_delayed_errors( GLcontext *ctx )
+{
+ char s2[MAXSTRING];
+
+ if (ctx->ErrorDebugCount) {
+ _mesa_snprintf(s2, MAXSTRING, "%d similar %s errors",
+ ctx->ErrorDebugCount,
+ error_string(ctx->ErrorValue));
+
+ output_if_debug("Mesa: ", s2, GL_TRUE);
+
+ ctx->ErrorDebugCount = 0;
+ }
+}
/**
* Report a warning (a recoverable error condition) to stderr if
@@ -1034,10 +1050,12 @@ _mesa_warning( GLcontext *ctx, const char *fmtString, ... )
{
char str[MAXSTRING];
va_list args;
- (void) ctx;
va_start( args, fmtString );
(void) vsnprintf( str, MAXSTRING, fmtString, args );
va_end( args );
+
+ if (ctx)
+ flush_delayed_errors( ctx );
output_if_debug("Mesa warning", str, GL_TRUE);
}
@@ -1065,6 +1083,31 @@ _mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
}
+static const char *error_string( GLenum error )
+{
+ switch (error) {
+ case GL_NO_ERROR:
+ return "GL_NO_ERROR";
+ case GL_INVALID_VALUE:
+ return "GL_INVALID_VALUE";
+ case GL_INVALID_ENUM:
+ return "GL_INVALID_ENUM";
+ case GL_INVALID_OPERATION:
+ return "GL_INVALID_OPERATION";
+ case GL_STACK_OVERFLOW:
+ return "GL_STACK_OVERFLOW";
+ case GL_STACK_UNDERFLOW:
+ return "GL_STACK_UNDERFLOW";
+ case GL_OUT_OF_MEMORY:
+ return "GL_OUT_OF_MEMORY";
+ case GL_TABLE_TOO_LARGE:
+ return "GL_TABLE_TOO_LARGE";
+ case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
+ return "GL_INVALID_FRAMEBUFFER_OPERATION";
+ default:
+ return "unknown";
+ }
+}
/**
* Record an OpenGL state error. These usually occur when the user
@@ -1081,74 +1124,46 @@ _mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
void
_mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
{
- const char *debugEnv;
- GLboolean debug;
+ static GLint debug = -1;
- debugEnv = _mesa_getenv("MESA_DEBUG");
+ /* Check debug environment variable only once:
+ */
+ if (debug == -1) {
+ const char *debugEnv = _mesa_getenv("MESA_DEBUG");
#ifdef DEBUG
- if (debugEnv && _mesa_strstr(debugEnv, "silent"))
- debug = GL_FALSE;
- else
- debug = GL_TRUE;
+ if (debugEnv && _mesa_strstr(debugEnv, "silent"))
+ debug = GL_FALSE;
+ else
+ debug = GL_TRUE;
#else
- if (debugEnv)
- debug = GL_TRUE;
- else
- debug = GL_FALSE;
+ if (debugEnv)
+ debug = GL_TRUE;
+ else
+ debug = GL_FALSE;
#endif
+ }
- if (debug) {
- va_list args;
- char where[MAXSTRING];
- const char *errstr;
-
- va_start( args, fmtString );
- vsnprintf( where, MAXSTRING, fmtString, args );
- va_end( args );
-
- switch (error) {
- case GL_NO_ERROR:
- errstr = "GL_NO_ERROR";
- break;
- case GL_INVALID_VALUE:
- errstr = "GL_INVALID_VALUE";
- break;
- case GL_INVALID_ENUM:
- errstr = "GL_INVALID_ENUM";
- break;
- case GL_INVALID_OPERATION:
- errstr = "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- errstr = "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- errstr = "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- errstr = "GL_OUT_OF_MEMORY";
- break;
- case GL_TABLE_TOO_LARGE:
- errstr = "GL_TABLE_TOO_LARGE";
- break;
- case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
- errstr = "GL_INVALID_FRAMEBUFFER_OPERATION";
- break;
- default:
- errstr = "unknown";
- break;
+ if (debug) {
+ if (ctx->ErrorValue == error &&
+ ctx->ErrorDebugFmtString == fmtString) {
+ ctx->ErrorDebugCount++;
}
-
- {
+ else {
char s[MAXSTRING], s2[MAXSTRING];
va_list args;
+
+ flush_delayed_errors( ctx );
+
va_start(args, fmtString);
vsnprintf(s, MAXSTRING, fmtString, args);
va_end(args);
- _mesa_snprintf(s2, MAXSTRING, "%s in %s", errstr, s);
+ _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s);
output_if_debug("Mesa: User error", s2, GL_TRUE);
+
+ ctx->ErrorDebugFmtString = fmtString;
+ ctx->ErrorDebugCount = 0;
}
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d7e7d2ac21e..d0309f5e90d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2986,6 +2986,13 @@ struct __GLcontextRec
#endif
GLenum ErrorValue; /**< Last error code */
+
+ /**
+ * Recognize and silence repeated error debug messages in buggy apps.
+ */
+ const char *ErrorDebugFmtString;
+ GLuint ErrorDebugCount;
+
GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 909189f9d39..15f84b66382 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -237,14 +237,12 @@ do_memcpy(void *dest, const void *src, size_t n)
}
-static int
-logbase2(int n)
+static INLINE unsigned
+logbase2(unsigned n)
{
- GLint i = 1, log2 = 0;
- while (n > i) {
- i *= 2;
- log2++;
- }
+ unsigned log2 = 0;
+ while (n >>= 1)
+ ++log2;
return log2;
}
@@ -950,8 +948,9 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
/* Image is stored in hardware format in a buffer managed by the
* kernel. Need to explicitly map and unmap it.
*/
+ unsigned face = _mesa_tex_target_to_face(target);
- st_teximage_flush_before_map(ctx->st, stImage->pt, 0, level,
+ st_teximage_flush_before_map(ctx->st, stImage->pt, face, level,
PIPE_TRANSFER_READ);
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
@@ -1080,13 +1079,15 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
* from uploading the buffer under us.
*/
if (stImage->pt) {
+ unsigned face = _mesa_tex_target_to_face(target);
+
if (format == GL_DEPTH_COMPONENT &&
pf_is_depth_and_stencil(stImage->pt->format))
transfer_usage = PIPE_TRANSFER_READ_WRITE;
else
transfer_usage = PIPE_TRANSFER_WRITE;
- st_teximage_flush_before_map(ctx->st, stImage->pt, 0, level,
+ st_teximage_flush_before_map(ctx->st, stImage->pt, face, level,
transfer_usage);
texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset,
transfer_usage,
@@ -1213,7 +1214,9 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
int y;
if (stImage->pt) {
- st_teximage_flush_before_map(ctx->st, stImage->pt, 0, level,
+ unsigned face = _mesa_tex_target_to_face(target);
+
+ st_teximage_flush_before_map(ctx->st, stImage->pt, face, level,
PIPE_TRANSFER_WRITE);
texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
PIPE_TRANSFER_WRITE,