summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_vb_program.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/tnl/t_vb_program.c')
-rw-r--r--src/mesa/tnl/t_vb_program.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index dc954bcba1..5fb83c2b01 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -66,6 +66,7 @@ struct vp_stage_data {
GLvector4f results[VERT_RESULT_MAX];
GLvector4f ndcCoords; /**< normalized device coords */
+ GLfloat *clipdistance[MAX_CLIP_PLANES];
GLubyte *clipmask; /**< clip flags */
GLubyte ormask, andmask; /**< for clipping */
};
@@ -77,6 +78,7 @@ struct vp_stage_data {
static void
userclip( GLcontext *ctx,
GLvector4f *clip,
+ GLfloat *clipdistance[MAX_CLIP_PLANES],
GLubyte *clipmask,
GLubyte *clipormask,
GLubyte *clipandmask )
@@ -105,6 +107,8 @@ userclip( GLcontext *ctx,
clipmask[i] |= CLIP_USER_BIT;
}
+ clipdistance[p][i] = dp;
+
STRIDE_F(coord, stride);
}
@@ -131,13 +135,16 @@ do_ndc_cliptest(GLcontext *ctx, struct vp_stage_data *store)
store->ormask = 0;
store->andmask = CLIP_FRUSTUM_BITS;
+ tnl_clip_prepare(ctx);
+
if (tnl->NeedNdcCoords) {
VB->NdcPtr =
_mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
&store->ndcCoords,
store->clipmask,
&store->ormask,
- &store->andmask );
+ &store->andmask,
+ !ctx->Transform.DepthClamp );
}
else {
VB->NdcPtr = NULL;
@@ -145,7 +152,8 @@ do_ndc_cliptest(GLcontext *ctx, struct vp_stage_data *store)
NULL,
store->clipmask,
&store->ormask,
- &store->andmask );
+ &store->andmask,
+ !ctx->Transform.DepthClamp );
}
if (store->andmask) {
@@ -160,6 +168,7 @@ do_ndc_cliptest(GLcontext *ctx, struct vp_stage_data *store)
ctx->VertexProgram.Current->IsPositionInvariant)) {
userclip( ctx,
VB->ClipPtr,
+ store->clipdistance,
store->clipmask,
&store->ormask,
&store->andmask );
@@ -167,6 +176,9 @@ do_ndc_cliptest(GLcontext *ctx, struct vp_stage_data *store)
if (store->andmask) {
return GL_FALSE;
}
+
+ memcpy(VB->ClipDistancePtr, store->clipdistance,
+ sizeof(store->clipdistance));
}
VB->ClipAndMask = store->andmask;
@@ -510,6 +522,10 @@ init_vp(GLcontext *ctx, struct tnl_pipeline_stage *stage)
_mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
+ for (i = 0; i < MAX_CLIP_PLANES; i++)
+ store->clipdistance[i] =
+ (GLfloat *) ALIGN_MALLOC(sizeof(GLfloat) * size, 32);
+
return GL_TRUE;
}
@@ -533,6 +549,9 @@ dtr(struct tnl_pipeline_stage *stage)
_mesa_vector4f_free( &store->ndcCoords );
ALIGN_FREE( store->clipmask );
+ for (i = 0; i < MAX_CLIP_PLANES; i++)
+ ALIGN_FREE(store->clipdistance[i]);
+
FREE( store );
stage->privatePtr = NULL;
}