aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_triemit.h
blob: f5979ee9a750bc0a1abf047e1e0519cb9655a99c (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef DO_DEBUG_VERTS
#define DO_DEBUG_VERTS 0
#endif 

#ifndef PRINT_VERTEX
#define PRINT_VERTEX(x) 
#endif

#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)
#elif defined(HAVE_LE32_VERTS)
#define COPY_DWORDS( j, vb, vertsize, v )				\
do {									\
   for ( j = 0 ; j < vertsize ; j++ )					\
      vb[j] = CPU_TO_LE32(((GLuint *)v)[j]);				\
   vb += vertsize;							\
} 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;

   if (DO_DEBUG_VERTS) {
      fprintf(stderr, "%s\n", __FUNCTION__);
      PRINT_VERTEX(v0);
      PRINT_VERTEX(v1);
      PRINT_VERTEX(v2);
      PRINT_VERTEX(v3);
   }
      
   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;

   if (DO_DEBUG_VERTS) {
      fprintf(stderr, "%s\n", __FUNCTION__);
      PRINT_VERTEX(v0);
      PRINT_VERTEX(v1);
      PRINT_VERTEX(v2);
      PRINT_VERTEX(v3);
   }
 
   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;

   if (DO_DEBUG_VERTS) {
      fprintf(stderr, "%s\n", __FUNCTION__);
      PRINT_VERTEX(v0);
      PRINT_VERTEX(v1);
      PRINT_VERTEX(v2);
   }

   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]);
   GLuint i,j;

   if (DO_DEBUG_VERTS) {
      fprintf(stderr, "%s\n", __FUNCTION__);
      PRINT_VERTEX(VERT(elts[0]));
      PRINT_VERTEX(VERT(elts[1]));
   }

   for (i = 2 ; i < n ; i++) {
      if (DO_DEBUG_VERTS) {
	 PRINT_VERTEX(VERT(elts[i]));
      }

      COPY_DWORDS( j, vb, vertsize, VERT(elts[i-1]) );
      COPY_DWORDS( j, vb, vertsize, VERT(elts[i]) );
      COPY_DWORDS( j, vb, vertsize, start );
   }
}