summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-11-06 15:07:11 -0700
committerBrian Paul <[email protected]>2008-11-06 15:07:11 -0700
commita7d9fde24cb8ecc59b0a6fc610135d851806295b (patch)
treecd8c0be11b4d53df11dcc7d42c1598565c10b840 /src/mesa
parentd177c9ddda2c452cf7d6696d89cf4458ef986f98 (diff)
parent2f1a29654a94a4194fa452e8049c4db67629e545 (diff)
Merge commit 'origin/gallium-0.1' into gallium-0.2
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/shader/shader_api.c20
-rw-r--r--src/mesa/shader/shader_api.h4
-rw-r--r--src/mesa/shader/slang/slang_link.c6
-rw-r--r--src/mesa/state_tracker/st_program.c16
-rw-r--r--src/mesa/state_tracker/st_program.h4
5 files changed, 46 insertions, 4 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 7f020fe5d3c..7a8501dcdd3 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1422,10 +1422,22 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
/**
- * Update the vertex and fragment program's TexturesUsed arrays.
+ * Update the vertex/fragment program's TexturesUsed array.
+ *
+ * This needs to be called after glUniform(set sampler var) is called.
+ * A call to glUniform(samplerVar, value) causes a sampler to point to a
+ * particular texture unit. We know the sampler's texture target
+ * (1D/2D/3D/etc) from compile time but the sampler's texture unit is
+ * set by glUniform() calls.
+ *
+ * So, scan the program->SamplerUnits[] and program->SamplerTargets[]
+ * information to update the prog->TexturesUsed[] values.
+ * Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX,
+ * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc.
+ * We'll use that info for state validation before rendering.
*/
-static void
-update_textures_used(struct gl_program *prog)
+void
+_mesa_update_shader_textures_used(struct gl_program *prog)
{
GLuint s;
@@ -1551,7 +1563,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
/* This maps a sampler to a texture unit: */
program->SamplerUnits[sampler] = texUnit;
- update_textures_used(program);
+ _mesa_update_shader_textures_used(program);
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
}
diff --git a/src/mesa/shader/shader_api.h b/src/mesa/shader/shader_api.h
index e7f12669156..ec1996ee98d 100644
--- a/src/mesa/shader/shader_api.h
+++ b/src/mesa/shader/shader_api.h
@@ -80,6 +80,10 @@ _mesa_lookup_shader(GLcontext *ctx, GLuint name);
extern void
+_mesa_update_shader_textures_used(struct gl_program *prog);
+
+
+extern void
_mesa_use_program(GLcontext *ctx, GLuint program);
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 11fdf3b9dc3..2074e842094 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -561,6 +561,9 @@ _slang_link(GLcontext *ctx,
if (fragProg && shProg->FragmentProgram) {
+ /* Compute initial program's TexturesUsed info */
+ _mesa_update_shader_textures_used(&shProg->FragmentProgram->Base);
+
/* notify driver that a new fragment program has been compiled/linked */
ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
&shProg->FragmentProgram->Base);
@@ -576,6 +579,9 @@ _slang_link(GLcontext *ctx,
}
if (vertProg && shProg->VertexProgram) {
+ /* Compute initial program's TexturesUsed info */
+ _mesa_update_shader_textures_used(&shProg->VertexProgram->Base);
+
/* notify driver that a new vertex program has been compiled/linked */
ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
&shProg->VertexProgram->Base);
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 55b52c37451..af0df22dc59 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -512,3 +512,19 @@ st_translate_fragment_program(struct st_context *st,
tgsi_dump( fs.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
}
+
+/**
+ * Debug- print current shader text
+ */
+void
+st_print_shaders(GLcontext *ctx)
+{
+ struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
+ if (shProg) {
+ GLuint i;
+ for (i = 0; i < shProg->NumShaders; i++) {
+ printf("GLSL shader %u of %u:\n", i, shProg->NumShaders);
+ printf("%s\n", shProg->Shaders[i]->Source);
+ }
+ }
+}
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 078e2c42a69..e2e5eddef22 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -151,4 +151,8 @@ st_translate_vertex_program(struct st_context *st,
const ubyte *fs_input_semantic_index);
+extern void
+st_print_shaders(GLcontext *ctx);
+
+
#endif