summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl/t_vb_vertex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/tnl/t_vb_vertex.c')
-rw-r--r--src/mesa/tnl/t_vb_vertex.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
index 4734754ea40..2a61ff11779 100644
--- a/src/mesa/tnl/t_vb_vertex.c
+++ b/src/mesa/tnl/t_vb_vertex.c
@@ -44,6 +44,7 @@ struct vertex_stage_data {
GLvector4f eye;
GLvector4f clip;
GLvector4f proj;
+ GLfloat *clipdistance[MAX_CLIP_PLANES];
GLubyte *clipmask;
GLubyte ormask;
GLubyte andmask;
@@ -56,11 +57,12 @@ struct vertex_stage_data {
/* This function implements cliptesting for user-defined clip planes.
* The clipping of primitives to these planes is implemented in
- * t_render_clip.h.
+ * t_vp_cliptmp.h.
*/
#define USER_CLIPTEST(NAME, SZ) \
static void NAME( GLcontext *ctx, \
GLvector4f *clip, \
+ GLfloat *clipdistances[MAX_CLIP_PLANES], \
GLubyte *clipmask, \
GLubyte *clipormask, \
GLubyte *clipandmask ) \
@@ -88,6 +90,8 @@ static void NAME( GLcontext *ctx, \
clipmask[i] |= CLIP_USER_BIT; \
} \
\
+ clipdistances[p][i] = dp; \
+ \
STRIDE_F(coord, stride); \
} \
\
@@ -107,8 +111,9 @@ USER_CLIPTEST(userclip3, 3)
USER_CLIPTEST(userclip4, 4)
static void (*(usercliptab[5]))( GLcontext *,
- GLvector4f *, GLubyte *,
- GLubyte *, GLubyte * ) =
+ GLvector4f *,
+ GLfloat *[MAX_CLIP_PLANES],
+ GLubyte *, GLubyte *, GLubyte * ) =
{
NULL,
NULL,
@@ -214,12 +219,16 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
if (ctx->Transform.ClipPlanesEnabled) {
usercliptab[VB->ClipPtr->size]( ctx,
VB->ClipPtr,
+ store->clipdistance,
store->clipmask,
&store->ormask,
&store->andmask );
if (store->andmask)
return GL_FALSE;
+
+ memcpy(VB->ClipDistancePtr, store->clipdistance,
+ sizeof(store->clipdistance));
}
VB->ClipAndMask = store->andmask;
@@ -236,6 +245,7 @@ static GLboolean init_vertex_stage( GLcontext *ctx,
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
struct vertex_stage_data *store;
GLuint size = VB->Size;
+ unsigned i;
stage->privatePtr = CALLOC(sizeof(*store));
store = VERTEX_STAGE_DATA(stage);
@@ -247,8 +257,17 @@ static GLboolean init_vertex_stage( GLcontext *ctx,
_mesa_vector4f_alloc( &store->proj, 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);
if (!store->clipmask ||
+ !store->clipdistance[0] ||
+ !store->clipdistance[1] ||
+ !store->clipdistance[2] ||
+ !store->clipdistance[3] ||
+ !store->clipdistance[4] ||
+ !store->clipdistance[5] ||
!store->eye.data ||
!store->clip.data ||
!store->proj.data)
@@ -262,10 +281,16 @@ static void dtr( struct tnl_pipeline_stage *stage )
struct vertex_stage_data *store = VERTEX_STAGE_DATA(stage);
if (store) {
+ unsigned i;
+
_mesa_vector4f_free( &store->eye );
_mesa_vector4f_free( &store->clip );
_mesa_vector4f_free( &store->proj );
ALIGN_FREE( store->clipmask );
+
+ for (i = 0; i < MAX_CLIP_PLANES; i++)
+ ALIGN_FREE(store->clipdistance[i]);
+
FREE(store);
stage->privatePtr = NULL;
stage->run = init_vertex_stage;