Subversion Repositories Kolibri OS

Rev

Rev 4358 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4632 Serge 1
 
2
 * Mesa 3-D graphics library
3
 *
4
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included
14
 * in all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
 * OTHER DEALINGS IN THE SOFTWARE.
23
 */
24
25
 
26
 * NOTE: Avoid using spaces in between '(' ')' and arguments, especially
27
 * with macros like CONST, LLBL that expand to CONCAT(...).  Putting spaces
28
 * in there will break the build on some platforms.
29
 */
30
31
 
32
#include "matypes.h"
33
#include "clip_args.h"
34
35
 
36
#define SRC1		REGOFF(4, ESI)
37
#define SRC2		REGOFF(8, ESI)
38
#define SRC3		REGOFF(12, ESI)
39
#define DST0		REGOFF(0, EDI)
40
#define DST1		REGOFF(4, EDI)
41
#define DST2		REGOFF(8, EDI)
42
#define DST3		REGOFF(12, EDI)
43
#define MAT0		REGOFF(0, EDX)
44
#define MAT1		REGOFF(4, EDX)
45
#define MAT2		REGOFF(8, EDX)
46
#define MAT3		REGOFF(12, EDX)
47
48
 
49
 
50
 * Table for clip test.
51
 *
52
 * 	bit6 = SRC3 < 0
53
 * 	bit5 = SRC2 < 0
54
 * 	bit4 = abs(S(2)) > abs(S(3))
55
 * 	bit3 = SRC1 < 0
56
 * 	bit2 = abs(S(1)) > abs(S(3))
57
 * 	bit1 = SRC0 < 0
58
 * 	bit0 = abs(S(0)) > abs(S(3))
59
 */
60
61
 
62
63
 
64
	D_BYTE 0x00, 0x01, 0x00, 0x02, 0x04, 0x05, 0x04, 0x06
65
	D_BYTE 0x00, 0x01, 0x00, 0x02, 0x08, 0x09, 0x08, 0x0a
66
	D_BYTE 0x20, 0x21, 0x20, 0x22, 0x24, 0x25, 0x24, 0x26
67
	D_BYTE 0x20, 0x21, 0x20, 0x22, 0x28, 0x29, 0x28, 0x2a
68
	D_BYTE 0x00, 0x01, 0x00, 0x02, 0x04, 0x05, 0x04, 0x06
69
	D_BYTE 0x00, 0x01, 0x00, 0x02, 0x08, 0x09, 0x08, 0x0a
70
	D_BYTE 0x10, 0x11, 0x10, 0x12, 0x14, 0x15, 0x14, 0x16
71
	D_BYTE 0x10, 0x11, 0x10, 0x12, 0x18, 0x19, 0x18, 0x1a
72
	D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x37, 0x35, 0x37, 0x36
73
	D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x3b, 0x39, 0x3b, 0x3a
74
	D_BYTE 0x2f, 0x2d, 0x2f, 0x2e, 0x27, 0x25, 0x27, 0x26
75
	D_BYTE 0x2f, 0x2d, 0x2f, 0x2e, 0x2b, 0x29, 0x2b, 0x2a
76
	D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x37, 0x35, 0x37, 0x36
77
	D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x3b, 0x39, 0x3b, 0x3a
78
	D_BYTE 0x1f, 0x1d, 0x1f, 0x1e, 0x17, 0x15, 0x17, 0x16
79
	D_BYTE 0x1f, 0x1d, 0x1f, 0x1e, 0x1b, 0x19, 0x1b, 0x1a
80
81
 
82
 
83
84
 
85
 * _mesa_x86_cliptest_points4
86
 *
87
 *   AL:  ormask
88
 *   AH:  andmask
89
 *   EBX: temp0
90
 *   ECX: temp1
91
 *   EDX: clipmask[]
92
 *   ESI: clip[]
93
 *   EDI: proj[]
94
 *   EBP: temp2
95
 */
96
97
 
98
#define ELFPIC
99
#endif
100
101
 
102
GLOBL GLNAME( _mesa_x86_cliptest_points4 )
103
HIDDEN(_mesa_x86_cliptest_points4)
104
GLNAME( _mesa_x86_cliptest_points4 ):
105
106
 
107
#define FRAME_OFFSET 20
108
#else
109
#define FRAME_OFFSET 16
110
#endif
111
	PUSH_L( ESI )
112
	PUSH_L( EDI )
113
	PUSH_L( EBP )
114
	PUSH_L( EBX )
115
116
 
117
	/* store pointer to clip_table on stack */
118
	CALL( LLBL(ctp4_get_eip) )
119
	ADD_L( CONST(_GLOBAL_OFFSET_TABLE_), EBX )
120
	MOV_L( REGOFF(clip_table@GOT, EBX), EBX )
121
	PUSH_L( EBX )
122
	JMP( LLBL(ctp4_clip_table_ready) )
123
124
 
125
	/* store eip in ebx */
126
	MOV_L( REGIND(ESP), EBX )
127
	RET
128
129
 
130
#endif
131
132
 
133
	MOV_L( ARG_DEST, EDI )
134
135
 
136
	MOV_L( ARG_OR, EBX )
137
138
 
139
	MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
140
141
 
142
	MOV_L( REGOFF(V4F_START, ESI), ESI )
143
144
 
145
	MOV_L( EAX, ARG_SOURCE )	/* put stride in ARG_SOURCE */
146
147
 
148
	MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
149
150
 
151
	ADD_L( EDX, ECX )
152
153
 
154
	CMP_L( ECX, EDX )
155
156
 
157
	MOV_B( REGIND(EBP), AH )
158
159
 
160
161
 
162
LLBL(ctp4_top):
163
164
 
165
	FDIV_S( SRC3 )		/* GH: don't care about div-by-zero */
166
167
 
168
	MOV_L( SRC2, EBX )
169
170
 
171
	ADD_L( EBP, EBP )	/* ebp = abs(S(3))*2 ; carry = sign of S(3) */
172
173
 
174
	ADD_L( EBX, EBX )	/* ebx = abs(S(2))*2 ; carry = sign of S(2) */
175
176
 
177
	CMP_L( EBX, EBP )	/* carry = abs(S(2))*2 > abs(S(3))*2 */
178
179
 
180
	MOV_L( SRC1, EBX )
181
182
 
183
184
 
185
	CMP_L( EBX, EBP )	/* carry = abs(S(1))*2 > abs(S(3))*2 */
186
187
 
188
	MOV_L( SRC0, EBX )
189
190
 
191
192
 
193
	CMP_L( EBX, EBP )	/* carry = abs(S(0))*2 > abs(S(3))*2 */
194
195
 
196
197
 
198
	MOV_L( REGIND(ESP), EBP )	/* clip_table */
199
200
 
201
#else
202
	MOV_B( REGOFF(clip_table,ECX), CL )
203
#endif
204
205
 
206
	AND_B( CL, AH )
207
208
 
209
	MOV_B( CL, REGIND(EDX) )
210
211
 
212
213
 
214
215
 
216
217
 
218
	MOV_L( CONST(0), DST1 )
219
	MOV_L( CONST(0), DST2 )
220
	MOV_L( CONST(0x3f800000), DST3 )
221
222
 
223
224
 
225
226
 
227
	FMUL2( ST(1), ST0 )
228
229
 
230
	FMUL2( ST(2), ST0 )
231
232
 
233
	FMUL2( ST(3), ST0 )
234
235
 
236
	FSTP_S( DST0 )		/* F1 F2 F3 */
237
	FSTP_S( DST1 )		/* F2 F3 */
238
	FSTP_S( DST2 )		/* F3 */
239
	FSTP_S( DST3 )		/* */
240
241
 
242
243
 
244
	ADD_L( CONST(16), EDI )
245
246
 
247
	CMP_L( EDX, ARG_CLIP )
248
249
 
250
251
 
252
	MOV_L( ARG_AND, EDX )
253
254
 
255
	MOV_B( AH, REGIND(EDX) )
256
257
 
258
259
 
260
#ifdef ELFPIC
261
	POP_L( ESI )			/* discard ptr to clip_table */
262
#endif
263
	POP_L( EBX )
264
	POP_L( EBP )
265
	POP_L( EDI )
266
	POP_L( ESI )
267
268
 
269
270
 
271
 
272
 
273
 
274
 
275
 
276
 
277
GLOBL GLNAME( _mesa_x86_cliptest_points4_np )
278
HIDDEN(_mesa_x86_cliptest_points4_np)
279
GLNAME( _mesa_x86_cliptest_points4_np ):
280
281
 
282
#define FRAME_OFFSET 20
283
#else
284
#define FRAME_OFFSET 16
285
#endif
286
	PUSH_L( ESI )
287
	PUSH_L( EDI )
288
	PUSH_L( EBP )
289
	PUSH_L( EBX )
290
291
 
292
	/* store pointer to clip_table on stack */
293
	CALL( LLBL(ctp4_np_get_eip) )
294
	ADD_L( CONST(_GLOBAL_OFFSET_TABLE_), EBX )
295
	MOV_L( REGOFF(clip_table@GOT, EBX), EBX )
296
	PUSH_L( EBX )
297
	JMP( LLBL(ctp4_np_clip_table_ready) )
298
299
 
300
	/* store eip in ebx */
301
	MOV_L( REGIND(ESP), EBX )
302
	RET
303
304
 
305
#endif
306
307
 
308
	/* slot */
309
310
 
311
	MOV_L( ARG_OR, EBX )
312
313
 
314
	MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
315
316
 
317
	MOV_L( REGOFF(V4F_START, ESI), ESI )
318
319
 
320
	ADD_L( EDX, ECX )
321
322
 
323
	CMP_L( ECX, EDX )
324
325
 
326
	MOV_B( REGIND(EBP), AH )
327
328
 
329
330
 
331
LLBL(ctp4_np_top):
332
333
 
334
	MOV_L( SRC2, EBX )
335
336
 
337
	ADD_L( EBP, EBP )	/* ebp = abs(S(3))*2 ; carry = sign of S(3) */
338
339
 
340
	ADD_L( EBX, EBX )	/* ebx = abs(S(2))*2 ; carry = sign of S(2) */
341
342
 
343
	CMP_L( EBX, EBP )	/* carry = abs(S(2))*2 > abs(S(3))*2 */
344
345
 
346
	MOV_L( SRC1, EBX )
347
348
 
349
350
 
351
	CMP_L( EBX, EBP )	/* carry = abs(S(1))*2 > abs(S(3))*2 */
352
353
 
354
	MOV_L( SRC0, EBX )
355
356
 
357
358
 
359
	CMP_L( EBX, EBP )	/* carry = abs(S(0))*2 > abs(S(3))*2 */
360
361
 
362
363
 
364
	MOV_L( REGIND(ESP), EBP )	/* clip_table */
365
366
 
367
#else
368
	MOV_B( REGOFF(clip_table,ECX), CL )
369
#endif
370
371
 
372
	AND_B( CL, AH )
373
374
 
375
	MOV_B( CL, REGIND(EDX) )
376
377
 
378
	/* slot */
379
380
 
381
	CMP_L( EDX, EDI )
382
383
 
384
385
 
386
	MOV_L( ARG_AND, EDX )
387
388
 
389
	MOV_B( AH, REGIND(EDX) )
390
391
 
392
393
 
394
#ifdef ELFPIC
395
	POP_L( ESI )			/* discard ptr to clip_table */
396
#endif
397
	POP_L( EBX )
398
	POP_L( EBP )
399
	POP_L( EDI )
400
	POP_L( ESI )
401
402
 
403
404
 
405
	.section .note.GNU-stack,"",%progbits
406
#endif
407