summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/draw/draw_vertex_shader.c
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-10-03 10:08:45 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-10-03 10:33:38 -0400
commitcdd38d487a311e6c71b76382d428f5dc26caf067 (patch)
treeae874c5348965c70aabcc6e9a6b5f2ac24775885 /src/mesa/pipe/draw/draw_vertex_shader.c
parenta7e997cfc5d909eebbc16ba5b0362e9778f01561 (diff)
Unify handling of userplanes and regular planes to simplify
the clipping code. (really done by Keith)
Diffstat (limited to 'src/mesa/pipe/draw/draw_vertex_shader.c')
-rw-r--r--src/mesa/pipe/draw/draw_vertex_shader.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c
index 6e8036825d..d17496a24f 100644
--- a/src/mesa/pipe/draw/draw_vertex_shader.c
+++ b/src/mesa/pipe/draw/draw_vertex_shader.c
@@ -40,17 +40,27 @@
#include "pipe/tgsi/exec/tgsi_core.h"
+
+static INLINE float dot4(const float *a, const float *b)
+{
+ float result = (a[0]*b[0] +
+ a[1]*b[1] +
+ a[2]*b[2] +
+ a[3]*b[3]);
+
+ return result;
+}
+
static INLINE unsigned
-compute_clipmask(float cx, float cy, float cz, float cw)
+compute_clipmask(const float *clip, const float (*plane)[4], unsigned nr)
{
unsigned mask = 0;
+ unsigned i;
- if (-cx + cw < 0) mask |= CLIP_RIGHT_BIT;
- if ( cx + cw < 0) mask |= CLIP_LEFT_BIT;
- if (-cy + cw < 0) mask |= CLIP_TOP_BIT;
- if ( cy + cw < 0) mask |= CLIP_BOTTOM_BIT;
- if (-cz + cw < 0) mask |= CLIP_FAR_BIT;
- if ( cz + cw < 0) mask |= CLIP_NEAR_BIT;
+ for (i = 0; i < nr; i++) {
+ if (dot4(clip, plane[i]) < 0)
+ mask |= (1<<i);
+ }
return mask;
}
@@ -127,13 +137,18 @@ run_vertex_program(struct draw_context *draw,
unsigned slot;
float x, y, z, w;
- /* Handle attr[0] (position) specially: */
+ /* Handle attr[0] (position) specially:
+ *
+ * XXX: Computing the clipmask should be done in the vertex
+ * program as a set of DP4 instructions appended to the
+ * user-provided code.
+ */
x = vOut[j]->clip[0] = machine->Outputs[0].xyzw[0].f[j];
y = vOut[j]->clip[1] = machine->Outputs[0].xyzw[1].f[j];
z = vOut[j]->clip[2] = machine->Outputs[0].xyzw[2].f[j];
w = vOut[j]->clip[3] = machine->Outputs[0].xyzw[3].f[j];
- vOut[j]->clipmask = compute_clipmask(x, y, z, w) | draw->user_clipmask;
+ vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
vOut[j]->edgeflag = 1;
/* divide by w */