Mesa (master): mesa: add TexShadow field to prog_instruction

Brian Paul brianp at kemper.freedesktop.org
Fri Feb 20 21:08:57 UTC 2009


Module: Mesa
Branch: master
Commit: 44e018c09e7aeba9fd9f4c380da224bd6622c470
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=44e018c09e7aeba9fd9f4c380da224bd6622c470

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Feb 20 13:42:08 2009 -0700

mesa: add TexShadow field to prog_instruction

If the instruction is TEX/TXP/TXL/etc the TexShadow field will be true if
the instruction is a texture fetch with shadow compare.

---

 src/mesa/main/texenvprogram.c      |   19 +++++++++++++------
 src/mesa/shader/arbprogparse.c     |    3 +++
 src/mesa/shader/prog_instruction.h |    3 +++
 src/mesa/shader/prog_print.c       |    2 ++
 4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index af51a20..d2a9e35 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -736,6 +736,7 @@ static struct ureg emit_texld( struct texenv_fragment_program *p,
 			       GLuint destmask,
 			       GLuint tex_unit,
 			       GLuint tex_idx,
+                               GLuint tex_shadow,
 			       struct ureg coord )
 {
    struct prog_instruction *inst = emit_op( p, op, 
@@ -747,6 +748,7 @@ static struct ureg emit_texld( struct texenv_fragment_program *p,
    
    inst->TexSrcTarget = tex_idx;
    inst->TexSrcUnit = tex_unit;
+   inst->TexShadow = tex_shadow;
 
    p->program->Base.NumTexInstructions++;
 
@@ -1160,22 +1162,27 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
 static void load_texture( struct texenv_fragment_program *p, GLuint unit )
 {
    if (is_undef(p->src_texture[unit])) {
-      GLuint dim = p->state->unit[unit].source_index;
+      GLuint texTarget = p->state->unit[unit].source_index;
       struct ureg texcoord = register_input(p, FRAG_ATTRIB_TEX0+unit);
       struct ureg tmp = get_tex_temp( p );
 
-      if (dim == TEXTURE_UNKNOWN_INDEX)
+      if (texTarget == TEXTURE_UNKNOWN_INDEX)
          program_error(p, "TexSrcBit");
 			  
       /* TODO: Use D0_MASK_XY where possible.
        */
       if (p->state->unit[unit].enabled) {
-	 p->src_texture[unit] = emit_texld( p, OPCODE_TXP,
-					    tmp, WRITEMASK_XYZW, 
-					    unit, dim, texcoord );
+         GLboolean shadow = GL_FALSE;
 
-	 if (p->state->unit[unit].shadow)
+	 if (p->state->unit[unit].shadow) {
 	    p->program->Base.ShadowSamplers |= 1 << unit;
+            shadow = GL_TRUE;
+         }
+
+	 p->src_texture[unit] = emit_texld( p, OPCODE_TXP,
+					    tmp, WRITEMASK_XYZW, 
+					    unit, texTarget, shadow,
+                                            texcoord );
 
          p->program->Base.SamplersUsed |= (1 << unit);
          /* This identity mapping should already be in place
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 2e0fc36..62edb7f 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -3104,6 +3104,9 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst,
                break;
          }
 
+         if (shadow_tex)
+            fp->TexShadow = 1;
+
          /* Don't test the first time a particular sampler is seen.  Each time
           * after that, make sure the shadow state is the same.
           */
diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h
index 84dd98b..e3bb7ac 100644
--- a/src/mesa/shader/prog_instruction.h
+++ b/src/mesa/shader/prog_instruction.h
@@ -396,6 +396,9 @@ struct prog_instruction
    
    /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */
    GLuint TexSrcTarget:3;
+
+   /** True if tex instruction should do shadow comparison */
+   GLuint TexShadow:1;
    /*@}*/
 
    /**
diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c
index 516ea73..80be51c 100644
--- a/src/mesa/shader/prog_print.c
+++ b/src/mesa/shader/prog_print.c
@@ -592,6 +592,8 @@ _mesa_fprint_instruction_opt(FILE *f,
       default:
          ;
       }
+      if (inst->TexShadow)
+         _mesa_fprintf(f, " SHADOW");
       fprint_comment(f, inst);
       break;
 




More information about the mesa-commit mailing list