swrast: restore !shader check around add_specular()
[mesa.git] / src / mesa / swrast / s_atifragshader.c
index 467b8652d817bbddcb3dfbda86a1fa5cdecf6c76..5fefae6c42b38ce1cf3928acd3a68ce11b42c363 100644 (file)
@@ -1,5 +1,4 @@
 /*
- *
  * Copyright (C) 2004  David Airlie   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "atifragshader.h"
-#include "macros.h"
-#include "program.h"
-
-#include "s_atifragshader.h"
+#include "main/glheader.h"
+#include "main/colormac.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "shader/program.h"
+#include "shader/atifragshader.h"
+#include "swrast/s_atifragshader.h"
 
 
 /**
@@ -49,17 +47,12 @@ static void
 fetch_texel(GLcontext * ctx, const GLfloat texcoord[4], GLfloat lambda,
            GLuint unit, GLfloat color[4])
 {
-   GLchan rgba[4];
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
 
    /* XXX use a float-valued TextureSample routine here!!! */
    swrast->TextureSample[unit](ctx, ctx->Texture.Unit[unit]._Current,
                                1, (const GLfloat(*)[4]) texcoord,
-                               &lambda, &rgba);
-   color[0] = CHAN_TO_FLOAT(rgba[0]);
-   color[1] = CHAN_TO_FLOAT(rgba[1]);
-   color[2] = CHAN_TO_FLOAT(rgba[2]);
-   color[3] = CHAN_TO_FLOAT(rgba[3]);
+                               &lambda, (GLfloat (*)[4]) color);
 }
 
 static void
@@ -268,7 +261,7 @@ handle_pass_op(struct atifs_machine *machine, struct atifs_setupinst *texinst,
    if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) {
       pass_tex -= GL_TEXTURE0_ARB;
       COPY_4V(machine->Registers[idx],
-             span->array->texcoords[pass_tex][column]);
+             span->array->attribs[FRAG_ATTRIB_TEX0 + pass_tex][column]);
    }
    else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI) {
       pass_tex -= GL_REG_0_ATI;
@@ -290,7 +283,8 @@ handle_sample_op(GLcontext * ctx, struct atifs_machine *machine,
 
    if (coord_source >= GL_TEXTURE0_ARB && coord_source <= GL_TEXTURE7_ARB) {
       coord_source -= GL_TEXTURE0_ARB;
-      COPY_4V(tex_coords, span->array->texcoords[coord_source][column]);
+      COPY_4V(tex_coords,
+              span->array->attribs[FRAG_ATTRIB_TEX0 + coord_source][column]);
    }
    else if (coord_source >= GL_REG_0_ATI && coord_source <= GL_REG_5_ATI) {
       coord_source -= GL_REG_0_ATI;
@@ -573,8 +567,8 @@ init_machine(GLcontext * ctx, struct atifs_machine *machine,
         machine->Registers[i][j] = 0.0;
    }
 
-   COPY_4V(inputs[ATI_FS_INPUT_PRIMARY], span->array->color.sz4.rgba[col]);
-   COPY_4V(inputs[ATI_FS_INPUT_SECONDARY], span->array->color.sz4.spec[col]);
+   COPY_4V(inputs[ATI_FS_INPUT_PRIMARY], span->array->attribs[FRAG_ATTRIB_COL0][col]);
+   COPY_4V(inputs[ATI_FS_INPUT_SECONDARY], span->array->attribs[FRAG_ATTRIB_COL1][col]);
 }
 
 
@@ -592,8 +586,6 @@ _swrast_exec_fragment_shader(GLcontext * ctx, SWspan *span)
    /* incoming colors should be floats */
    ASSERT(span->array->ChanType == GL_FLOAT);
 
-   ctx->_CurrentProgram = GL_FRAGMENT_SHADER_ATI;
-
    for (i = 0; i < span->end; i++) {
       if (span->array->mask[i]) {
         init_machine(ctx, &machine, shader, span, i);
@@ -605,10 +597,8 @@ _swrast_exec_fragment_shader(GLcontext * ctx, SWspan *span)
            const GLfloat *colOut = machine.Registers[0];
             /*fprintf(stderr,"outputs %f %f %f %f\n",
               colOut[0], colOut[1], colOut[2], colOut[3]); */
-            COPY_4V(span->array->color.sz4.rgba[i], colOut);
+            COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], colOut);
         }
       }
    }
-
-   ctx->_CurrentProgram = 0;
 }