Merge branch 'origin' into glsl-compiler-1
[mesa.git] / src / mesa / drivers / dri / r200 / r200_vertprog.c
index b5afe51d82468b37ca82a07b34a14e4555f0f04c..6089d617c6b68cca15fa91487d740962a670a7d4 100644 (file)
@@ -34,14 +34,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "macros.h"
 #include "enums.h"
 #include "program.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_statevars.h"
+#include "shader/programopt.h"
+#include "tnl/tnl.h"
 
 #include "r200_context.h"
 #include "r200_vertprog.h"
 #include "r200_ioctl.h"
 #include "r200_tcl.h"
-#include "program_instruction.h"
-#include "programopt.h"
-#include "tnl/tnl.h"
 
 #if SWIZZLE_X != VSF_IN_COMPONENT_X || \
     SWIZZLE_Y != VSF_IN_COMPONENT_Y || \
@@ -460,9 +462,9 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte
 
    /* for fogc, can't change mesa_vp, as it would hose swtnl, and exp with
       base e isn't directly available neither. */
-   if (mesa_vp->Base.OutputsWritten & VERT_RESULT_FOGC && !vp->fogpidx) {
+   if ((mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) && !vp->fogpidx) {
       struct gl_program_parameter_list *paramList;
-      GLint tokens[6] = { STATE_FOG_PARAMS, 0, 0, 0, 0, 0 };
+      gl_state_index tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
       paramList = mesa_vp->Base.Parameters;
       vp->fogpidx = _mesa_add_state_reference(paramList, tokens);
    }
@@ -476,6 +478,8 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte
 
    for(i = 0; i < VERT_ATTRIB_MAX; i++)
       vp->inputs[i] = -1;
+   for(i = 0; i < 15; i++)
+      vp->inputmap_rev[i] = 255;
    free_inputs = 0x2ffd;
 
 /* fglrx uses fixed inputs as follows for conventional attribs.
@@ -498,34 +502,41 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte
 /* may look different when using idx buf / input_route instead of se_vtx_fmt? */
    if (mesa_vp->Base.InputsRead & VERT_BIT_POS) {
       vp->inputs[VERT_ATTRIB_POS] = 0;
+      vp->inputmap_rev[0] = VERT_ATTRIB_POS;
       free_inputs &= ~(1 << 0);
       array_count++;
    }
    if (mesa_vp->Base.InputsRead & VERT_BIT_WEIGHT) {
-   /* we don't actually handle that later. Then again, we don't have to... */
       vp->inputs[VERT_ATTRIB_WEIGHT] = 12;
+      vp->inputmap_rev[1] = VERT_ATTRIB_WEIGHT;
       array_count++;
    }
    if (mesa_vp->Base.InputsRead & VERT_BIT_NORMAL) {
       vp->inputs[VERT_ATTRIB_NORMAL] = 1;
+      vp->inputmap_rev[2] = VERT_ATTRIB_NORMAL;
       array_count++;
    }
    if (mesa_vp->Base.InputsRead & VERT_BIT_COLOR0) {
       vp->inputs[VERT_ATTRIB_COLOR0] = 2;
+      vp->inputmap_rev[4] = VERT_ATTRIB_COLOR0;
       free_inputs &= ~(1 << 2);
       array_count++;
    }
    if (mesa_vp->Base.InputsRead & VERT_BIT_COLOR1) {
       vp->inputs[VERT_ATTRIB_COLOR1] = 3;
+      vp->inputmap_rev[5] = VERT_ATTRIB_COLOR1;
       free_inputs &= ~(1 << 3);
       array_count++;
    }
    if (mesa_vp->Base.InputsRead & VERT_BIT_FOG) {
       vp->inputs[VERT_ATTRIB_FOG] = 15; array_count++;
+      vp->inputmap_rev[3] = VERT_ATTRIB_FOG;
+      array_count++;
    }
    for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX5; i++) {
       if (mesa_vp->Base.InputsRead & (1 << i)) {
         vp->inputs[i] = i - VERT_ATTRIB_TEX0 + 6;
+        vp->inputmap_rev[8 + i - VERT_ATTRIB_TEX0] = i;
         free_inputs &= ~(1 << (i - VERT_ATTRIB_TEX0 + 6));
         array_count++;
       }
@@ -548,6 +559,9 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte
            if (free_inputs & (1 << j)) {
               free_inputs &= ~(1 << j);
               vp->inputs[i] = j;
+              if (j == 0) vp->inputmap_rev[j] = i; /* mapped to pos */
+              else if (j < 12) vp->inputmap_rev[j + 2] = i; /* mapped to col/tex */
+              else vp->inputmap_rev[j + 1] = i; /* mapped to pos1 */
               break;
            }
         }
@@ -1205,6 +1219,9 @@ r200ProgramStringNotify(GLcontext *ctx, GLenum target, struct gl_program *prog)
       r200_translate_vertex_program(ctx, vp);
       rmesa->curr_vp_hw = NULL;
       break;
+   case GL_FRAGMENT_SHADER_ATI:
+      rmesa->afs_loaded = NULL;
+      break;
    }
    /* need this for tcl fallbacks */
    _tnl_program_string(ctx, target, prog);