summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_span.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast/s_span.c')
-rw-r--r--src/mesa/swrast/s_span.c70
1 files changed, 55 insertions, 15 deletions
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 02901a7ed94..11457723b09 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -37,7 +37,7 @@
#include "imports.h"
#include "s_atifragshader.h"
-#include "s_alpha.h"
+#include "s_alpha.h"
#include "s_arbshader.h"
#include "s_blend.h"
#include "s_context.h"
@@ -434,7 +434,8 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
GLfloat r = span->tex[u][2];
GLfloat q = span->tex[u][3];
GLuint i;
- if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled) {
+ if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled ||
+ ctx->ShaderObjects._FragmentShaderPresent) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
@@ -485,7 +486,8 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
GLfloat r = span->tex[u][2];
GLfloat q = span->tex[u][3];
GLuint i;
- if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled) {
+ if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled ||
+ ctx->ShaderObjects._FragmentShaderPresent) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
@@ -568,7 +570,8 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
GLfloat r = span->tex[0][2];
GLfloat q = span->tex[0][3];
GLuint i;
- if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled) {
+ if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled ||
+ ctx->ShaderObjects._FragmentShaderPresent) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
@@ -619,7 +622,8 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
GLfloat r = span->tex[0][2];
GLfloat q = span->tex[0][3];
GLuint i;
- if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled) {
+ if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled ||
+ ctx->ShaderObjects._FragmentShaderPresent) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->dwdx;
GLfloat w = span->w;
@@ -668,6 +672,38 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
/**
+ * Fill in the span.varying array from the interpolation values.
+ */
+static void
+interpolate_varying(GLcontext *ctx, struct sw_span *span)
+{
+ GLuint i, j;
+
+ ASSERT(span->interpMask & SPAN_VARYING);
+ ASSERT(!(span->arrayMask & SPAN_VARYING));
+
+ span->arrayMask |= SPAN_VARYING;
+
+ for (i = 0; i < MAX_VARYING_VECTORS; i++) {
+ for (j = 0; j < VARYINGS_PER_VECTOR; j++) {
+ const GLfloat dvdx = span->varStepX[i][j];
+ GLfloat v = span->var[i][j];
+ const GLfloat dwdx = span->dwdx;
+ GLfloat w = span->w;
+ GLuint k;
+
+ for (k = 0; k < span->end; k++) {
+ GLfloat invW = 1.0f / w;
+ span->array->varying[k][i][j] = v * invW;
+ v += dvdx;
+ w += dwdx;
+ }
+ }
+ }
+}
+
+
+/**
* Apply the current polygon stipple pattern to a span of pixels.
*/
static void
@@ -1139,6 +1175,10 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
interpolate_texcoords(ctx, span);
}
+ if (ctx->ShaderObjects._FragmentShaderPresent) {
+ interpolate_varying(ctx, span);
+ }
+
/* This is the normal place to compute the resulting fragment color/Z.
* As an optimization, we try to defer this until after Z/stencil
* testing in order to try to avoid computing colors that we won't
@@ -1155,11 +1195,11 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
if (span->interpMask & SPAN_FOG)
interpolate_fog(ctx, span);
- /* Compute fragment colors with fragment program or texture lookups */
- if (ctx->ShaderObjects._FragmentShaderPresent) {
- if (span->interpMask & SPAN_Z)
- _swrast_span_interpolate_z (ctx, span);
- _swrast_exec_arbshader (ctx, span);
+ /* Compute fragment colors with fragment program or texture lookups */
+ if (ctx->ShaderObjects._FragmentShaderPresent) {
+ if (span->interpMask & SPAN_Z)
+ _swrast_span_interpolate_z (ctx, span);
+ _swrast_exec_arbshader (ctx, span);
}
else if (ctx->FragmentProgram._Active) {
/* frag prog may need Z values */
@@ -1240,11 +1280,11 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
if (span->interpMask & SPAN_FOG)
interpolate_fog(ctx, span);
- if (ctx->ShaderObjects._FragmentShaderPresent) {
- if (span->interpMask & SPAN_Z)
- _swrast_span_interpolate_z (ctx, span);
- _swrast_exec_arbshader (ctx, span);
- }
+ if (ctx->ShaderObjects._FragmentShaderPresent) {
+ if (span->interpMask & SPAN_Z)
+ _swrast_span_interpolate_z (ctx, span);
+ _swrast_exec_arbshader (ctx, span);
+ }
else if (ctx->FragmentProgram._Active)
_swrast_exec_fragment_program( ctx, span );
else if (ctx->ATIFragmentShader._Enabled)