summaryrefslogtreecommitdiff
path: root/xc/extras/Mesa/src/tnl_dd/t_dd_triemit.h
blob: 39c4a20c49fe656889562a7934a3df6e991cb21d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

#if defined(USE_X86_ASM)
#define COPY_DWORDS( j, vb, vertsize, v )				\
do {									\
	int __tmp;							\
	__asm__ __volatile__( "rep ; movsl"				\
			      : "=%c" (j), "=D" (vb), "=S" (__tmp)	\
			      : "0" (vertsize),				\
			        "D" ((long)vb),				\
			        "S" ((long)v) );			\
} while (0)
#else
#define COPY_DWORDS( j, vb, vertsize, v )				\
do {									\
   for ( j = 0 ; j < vertsize ; j++ )					\
      vb[j] = ((GLuint *)v)[j];						\
   vb += vertsize;							\
} while (0)
#endif



#if HAVE_QUADS
static __inline void TAG(quad)( CTX_ARG,
				VERTEX *v0,
				VERTEX *v1,
				VERTEX *v2,
				VERTEX *v3 )
{
   GLuint vertsize = GET_VERTEX_DWORDS();
   GLuint *vb = (GLuint *)ALLOC_VERTS( 4, vertsize);
   GLuint j;

   COPY_DWORDS( j, vb, vertsize, v0 );
   COPY_DWORDS( j, vb, vertsize, v1 );
   COPY_DWORDS( j, vb, vertsize, v2 );
   COPY_DWORDS( j, vb, vertsize, v3 );
}
#else
static __inline void TAG(quad)( CTX_ARG,
				VERTEX *v0,
				VERTEX *v1,
				VERTEX *v2,
				VERTEX *v3 )
{
   GLuint vertsize = GET_VERTEX_DWORDS();
   GLuint *vb = (GLuint *)ALLOC_VERTS(  6, vertsize);
   GLuint j;

   COPY_DWORDS( j, vb, vertsize, v0 );
   COPY_DWORDS( j, vb, vertsize, v1 );
   COPY_DWORDS( j, vb, vertsize, v3 );
   COPY_DWORDS( j, vb, vertsize, v1 );
   COPY_DWORDS( j, vb, vertsize, v2 );
   COPY_DWORDS( j, vb, vertsize, v3 );
}
#endif


static __inline void TAG(triangle)( CTX_ARG,
				    VERTEX *v0,
				    VERTEX *v1,
				    VERTEX *v2 )
{
   GLuint vertsize = GET_VERTEX_DWORDS();
   GLuint *vb = (GLuint *)ALLOC_VERTS( 3, vertsize);
   GLuint j;

   COPY_DWORDS( j, vb, vertsize, v0 );
   COPY_DWORDS( j, vb, vertsize, v1 );
   COPY_DWORDS( j, vb, vertsize, v2 );
}


#if HAVE_LINES
static __inline void TAG(line)( CTX_ARG,
				VERTEX *v0,
				VERTEX *v1 )
{
   GLuint vertsize = GET_VERTEX_DWORDS();
   GLuint *vb = (GLuint *)ALLOC_VERTS( 2, vertsize);
   GLuint j;

   COPY_DWORDS( j, vb, vertsize, v0 );
   COPY_DWORDS( j, vb, vertsize, v1 );
}
#endif

#if HAVE_POINTS
static __inline void TAG(point)( CTX_ARG,
				 VERTEX *v0 )
{
   GLuint vertsize = GET_VERTEX_DWORDS();
   GLuint *vb = (GLuint *)ALLOC_VERTS( 1, vertsize);
   int j;

   COPY_DWORDS( j, vb, vertsize, v0 );
}
#endif


static void TAG(fast_clipped_poly)( GLcontext *ctx, const GLuint *elts,
				    GLuint n )
{
   LOCAL_VARS
   GLuint vertsize = GET_VERTEX_DWORDS();
   GLuint *vb = (GLuint *)ALLOC_VERTS( (n-2) * 3, vertsize );
   const GLuint *start = (const GLuint *)VERT(elts[0]);
   int i,j;

   for (i = 2 ; i < n ; i++) {
      COPY_DWORDS( j, vb, vertsize, VERT(elts[i-1]) );
      COPY_DWORDS( j, vb, vertsize, VERT(elts[i]) );
      COPY_DWORDS( j, vb, vertsize, start );
   }
}