Mesa (gallium-0.1): gallium: if VERBOSE_GLSL flag is set, check for non-initialized uniforms at draw time
Brian Paul
brianp at kemper.freedesktop.org
Wed Nov 5 22:38:30 UTC 2008
Module: Mesa
Branch: gallium-0.1
Commit: 6282c38283ea81af1d950dbc1f82a6950e8350ae
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6282c38283ea81af1d950dbc1f82a6950e8350ae
Author: Brian Paul <brian.paul at tungstengraphics.com>
Date: Wed Nov 5 14:05:04 2008 -0700
gallium: if VERBOSE_GLSL flag is set, check for non-initialized uniforms at draw time
This will warn the user that the shader being run may be using uninitialized
uniform variables.
---
src/mesa/state_tracker/st_draw.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 61949a9..ed3ae3e 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -33,6 +33,7 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/macros.h"
+#include "shader/prog_uniform.h"
#include "vbo/vbo.h"
@@ -483,6 +484,28 @@ setup_non_interleaved_attribs(GLcontext *ctx,
+/**
+ * Prior to drawing, check that any uniforms referenced by the
+ * current shader have been set. If a uniform has not been set,
+ * issue a warning.
+ */
+static void
+check_uniforms(GLcontext *ctx)
+{
+ const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
+ if (shProg && shProg->LinkStatus) {
+ GLuint i;
+ for (i = 0; i < shProg->Uniforms->NumUniforms; i++) {
+ const struct gl_uniform *u = &shProg->Uniforms->Uniforms[i];
+ if (!u->Initialized) {
+ _mesa_warning(ctx,
+ "Using shader with uninitialized uniform: %s",
+ u->Name);
+ }
+ }
+ }
+}
+
/**
* This function gets plugged into the VBO module and is called when
@@ -516,6 +539,10 @@ st_draw_vbo(GLcontext *ctx,
vp = ctx->st->vp;
vs = &ctx->st->vp->state;
+ if (MESA_VERBOSE & VERBOSE_GLSL) {
+ check_uniforms(ctx);
+ }
+
/*
* Setup the vbuffer[] and velements[] arrays.
*/
More information about the mesa-commit
mailing list