Subversion Repositories Kolibri OS

Rev

Rev 6523 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6523 Rev 8062
Line 56... Line 56...
56
		mov dword[q+4],ecx
56
		mov dword[q+4],ecx
57
		mov ecx,[eax+GLContext.current_color_material_type]
57
		mov ecx,[eax+GLContext.current_color_material_type]
58
		mov dword[q+8],ecx
58
		mov dword[q+8],ecx
59
		mov esi,[p]
59
		mov esi,[p]
60
		add esi,4
60
		add esi,4
61
		mov edi,ebp
-
 
62
		sub edi,16 ;edi = &q[3]
61
		lea edi,[ebp-16] ;edi = &q[3]
63
		mov ecx,4
62
		mov ecx,4
64
		rep movsd
63
		rep movsd
65
		;mov edi,ebp
64
		;mov edi,ebp
66
		sub edi,28 ;edi = &q
65
		sub edi,28 ;edi = &q
67
		stdcall glopMaterial, eax,edi
66
		stdcall glopMaterial, eax,edi
Line 142... Line 141...
142
	.if_0:
141
	.if_0:
143
if DEBUG ;context.matrix_stack_ptr[0]
142
if DEBUG ;context.matrix_stack_ptr[0]
144
	stdcall gl_print_matrix,dword[edx+GLContext.matrix_stack_ptr],4
143
	stdcall gl_print_matrix,dword[edx+GLContext.matrix_stack_ptr],4
145
end if
144
end if
146
		; precompute inverse modelview
145
		; precompute inverse modelview
147
		mov ebx,ebp
-
 
148
		sub ebx,sizeof.M4
146
		lea ebx,[ebp-sizeof.M4]
149
		stdcall gl_M4_Inv, ebx,dword[edx+GLContext.matrix_stack_ptr]
147
		stdcall gl_M4_Inv, ebx,dword[edx+GLContext.matrix_stack_ptr]
150
if DEBUG ;tmp
148
if DEBUG ;tmp
151
	stdcall dbg_print,txt_sp,txt_nl
149
	stdcall dbg_print,txt_sp,txt_nl
152
	stdcall gl_print_matrix,ebx,4
150
	stdcall gl_print_matrix,ebx,4
153
end if
151
end if
154
		push ebx
152
		push ebx
155
		mov ebx,edx
-
 
156
		add ebx,GLContext.matrix_model_view_inv
153
		lea ebx,[edx+GLContext.matrix_model_view_inv]
157
		stdcall gl_M4_Transpose, ebx
154
		stdcall gl_M4_Transpose, ebx
158
if DEBUG ;context.matrix_model_view_inv
155
if DEBUG ;context.matrix_model_view_inv
159
	stdcall dbg_print,txt_sp,txt_nl
156
	stdcall dbg_print,txt_sp,txt_nl
160
	stdcall gl_print_matrix,ebx,4
157
	stdcall gl_print_matrix,ebx,4
161
end if
158
end if
162
		jmp .end_if_0
159
		jmp .end_if_0
163
align 4
160
align 4
164
	@@:
161
	@@:
165
		mov ecx,edx
-
 
166
		add ecx,GLContext.matrix_model_projection
162
		lea ecx,[edx+GLContext.matrix_model_projection]
167
		; precompute projection matrix
163
		; precompute projection matrix
168
		stdcall gl_M4_Mul, ecx,dword[edx+GLContext.matrix_stack_ptr+4],dword[edx+GLContext.matrix_stack_ptr]
164
		stdcall gl_M4_Mul, ecx,dword[edx+GLContext.matrix_stack_ptr+4],dword[edx+GLContext.matrix_stack_ptr]
Line 169... Line 165...
169
 
165
 
170
		; test to accelerate computation
166
		; test to accelerate computation
Line 190... Line 186...
190
		ffree st0 ;0.0
186
		ffree st0 ;0.0
191
		fincstp
187
		fincstp
192
	.end_if_0:
188
	.end_if_0:
Line 193... Line 189...
193
 
189
 
194
		; test if the texture matrix is not Identity
-
 
195
		mov eax,edx
190
		; test if the texture matrix is not Identity
196
		add eax,GLContext.matrix_stack_ptr+8
191
		lea eax,[edx+GLContext.matrix_stack_ptr+8]
197
		stdcall gl_M4_IsId,eax
192
		stdcall gl_M4_IsId,eax
198
		xor eax,1
193
		xor eax,1
Line 199... Line 194...
199
		mov dword[edx+GLContext.apply_texture_matrix],eax
194
		mov dword[edx+GLContext.apply_texture_matrix],eax
Line 263... Line 258...
263
align 4
258
align 4
264
	@@:
259
	@@:
265
		; eye coordinates needed for lighting
260
		; eye coordinates needed for lighting
266
		mov ebx,dword[eax+GLContext.matrix_stack_ptr]
261
		mov ebx,dword[eax+GLContext.matrix_stack_ptr]
267
		finit
262
		finit
268
		fld dword[edx+offs_vert_coord+offs_X]
263
		fld dword[edx+GLVertex.coord+offs_X]
269
		fld dword[edx+offs_vert_coord+offs_Y]
264
		fld dword[edx+GLVertex.coord+offs_Y]
270
		fld dword[edx+offs_vert_coord+offs_Z]
265
		fld dword[edx+GLVertex.coord+offs_Z]
Line 271... Line 266...
271
 
266
 
272
		mov ecx,4
267
		mov ecx,4
273
		.cycle_0:
268
		.cycle_0:
274
			fld dword[ebx]     ;st0 = m[0]
269
			fld dword[ebx]     ;st0 = m[0]
Line 278... Line 273...
278
			faddp              ;st0 = v.coord.X * m[0] + v.coord.Y * m[1]
273
			faddp              ;st0 = v.coord.X * m[0] + v.coord.Y * m[1]
279
			fld dword[ebx+8]   ;st0 = m[2]
274
			fld dword[ebx+8]   ;st0 = m[2]
280
			fmul st0,st2       ;st0 *= v.coord.Z
275
			fmul st0,st2       ;st0 *= v.coord.Z
281
			fadd dword[ebx+12] ;st0 += m[3]
276
			fadd dword[ebx+12] ;st0 += m[3]
282
			faddp              ;st0 = v.ec.X
277
			faddp              ;st0 = v.ec.X
283
			fstp dword[edx+offs_vert_ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
278
			fstp dword[edx+GLVertex.ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
284
			add ebx,16 ;следущая строка матрицы
279
			add ebx,16 ;следущая строка матрицы
285
			add edx,4  ;следущая координата вектора
280
			add edx,4  ;следущая координата вектора
286
		loop .cycle_0
281
		loop .cycle_0
287
		ffree st0
282
		ffree st0
288
		fincstp
283
		fincstp
Line 293... Line 288...
293
 
288
 
294
		; projection coordinates
289
		; projection coordinates
295
		mov ebx,dword[eax+GLContext.matrix_stack_ptr+4]
290
		mov ebx,dword[eax+GLContext.matrix_stack_ptr+4]
Line 296... Line 291...
296
		mov edx,[v]
291
		mov edx,[v]
297
 
292
 
298
		fld dword[edx+offs_vert_ec+offs_X]
293
		fld dword[edx+GLVertex.ec+offs_X]
299
		fld dword[edx+offs_vert_ec+offs_Y]
294
		fld dword[edx+GLVertex.ec+offs_Y]
Line 300... Line 295...
300
		fld dword[edx+offs_vert_ec+offs_Z]
295
		fld dword[edx+GLVertex.ec+offs_Z]
301
		fld dword[edx+offs_vert_ec+offs_W]
296
		fld dword[edx+GLVertex.ec+offs_W]
302
 
297
 
303
		mov ecx,4
298
		mov ecx,4
Line 311... Line 306...
311
			fmul st0,st3       ;st0 *= v.ec.Z
306
			fmul st0,st3       ;st0 *= v.ec.Z
312
			faddp              ;st0 = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2]
307
			faddp              ;st0 = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2]
313
			fld dword[ebx+12]  ;st0 = m[3]
308
			fld dword[ebx+12]  ;st0 = m[3]
314
			fmul st0,st2       ;st0 *= v.ec.W
309
			fmul st0,st2       ;st0 *= v.ec.W
315
			faddp              ;st0 = v.pc.X
310
			faddp              ;st0 = v.pc.X
316
			fstp dword[edx+offs_vert_pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + v.ec.W * m[3]
311
			fstp dword[edx+GLVertex.pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + v.ec.W * m[3]
317
			add ebx,16 ;следущая строка матрицы
312
			add ebx,16 ;следущая строка матрицы
318
			add edx,4  ;следущая координата вектора
313
			add edx,4  ;следущая координата вектора
319
		loop .cycle_1
314
		loop .cycle_1
320
		ffree st0
315
		ffree st0
321
		fincstp
316
		fincstp
Line 324... Line 319...
324
		ffree st0
319
		ffree st0
325
		fincstp
320
		fincstp
326
		ffree st0
321
		ffree st0
327
		fincstp
322
		fincstp
Line 328... Line -...
328
 
-
 
329
		mov ebx,eax
323
 
330
		add ebx,GLContext.matrix_model_view_inv
-
 
331
		mov edi,eax
324
		lea ebx,[eax+GLContext.matrix_model_view_inv]
332
		add edi,GLContext.current_normal
325
		lea edi,[eax+GLContext.current_normal]
Line 333... Line 326...
333
		mov edx,[v]
326
		mov edx,[v]
334
 
327
 
335
		fld dword[edi] ;edi = &n
328
		fld dword[edi] ;edi = &n
Line 336... Line 329...
336
		fld dword[edi+offs_Y]
329
		fld dword[edi+offs_Y]
Line 337... Line 330...
337
		fld dword[edi+offs_Z]
330
		fld dword[edi+offs_Z]
338
 
331
 
339
		add edx,offs_vert_normal
332
		add edx,GLVertex.normal
340
 
333
 
Line 374... Line 367...
374
		jmp .end_els
367
		jmp .end_els
375
align 4
368
align 4
376
	.els_0:
369
	.els_0:
377
		; no eye coordinates needed, no normal
370
		; no eye coordinates needed, no normal
378
		; NOTE: W = 1 is assumed
371
		; NOTE: W = 1 is assumed
379
		mov ebx,eax
-
 
380
		add ebx,GLContext.matrix_model_projection
372
		lea ebx,[eax+GLContext.matrix_model_projection]
Line 381... Line 373...
381
 
373
 
382
		finit
374
		finit
383
		fld dword[edx+offs_vert_coord+offs_X]
375
		fld dword[edx+GLVertex.coord+offs_X]
384
		fld dword[edx+offs_vert_coord+offs_Y]
376
		fld dword[edx+GLVertex.coord+offs_Y]
Line 385... Line -...
385
		fld dword[edx+offs_vert_coord+offs_Z]
-
 
386
 
377
		fld dword[edx+GLVertex.coord+offs_Z]
Line 387... Line 378...
387
		mov esi,edx
378
 
388
		add esi,offs_vert_pc
379
		lea esi,[edx+GLVertex.pc]
389
 
380
 
390
		fld dword[ebx]     ;st0 = m[0]
381
		fld dword[ebx]     ;st0 = m[0]
Line 447... Line 438...
447
	fincstp
438
	fincstp
Line 448... Line 439...
448
 
439
 
449
if DEBUG ;gl_vertex_transform
440
if DEBUG ;gl_vertex_transform
450
	stdcall dbg_print,f_vt,txt_nl
441
	stdcall dbg_print,f_vt,txt_nl
451
	mov edx,[v]
442
	mov edx,[v]
452
	add edx,offs_vert_pc
443
	add edx,GLVertex.pc
453
	stdcall gl_print_matrix,edx,1
444
	stdcall gl_print_matrix,edx,1
454
end if
445
end if
455
	mov edx,[v]
446
	mov edx,[v]
456
	stdcall gl_clipcode, dword[edx+offs_vert_pc+offs_X], dword[edx+offs_vert_pc+offs_Y],\
447
	stdcall gl_clipcode, dword[edx+GLVertex.pc+offs_X], dword[edx+GLVertex.pc+offs_Y],\
457
		dword[edx+offs_vert_pc+offs_Z], dword[edx+offs_vert_pc+offs_W]
448
		dword[edx+GLVertex.pc+offs_Z], dword[edx+GLVertex.pc+offs_W]
458
	mov dword[edx+offs_vert_clip_code],eax
449
	mov dword[edx+GLVertex.clip_code],eax
459
popad
450
popad
460
	ret
451
	ret
Line 461... Line 452...
461
endp
452
endp
Line 501... Line 492...
501
	add ebx,[edx+GLContext.vertex]
492
	add ebx,[edx+GLContext.vertex]
502
	inc dword[n]
493
	inc dword[n]
Line 503... Line 494...
503
 
494
 
504
	mov esi,[p]
495
	mov esi,[p]
505
	add esi,4
-
 
506
	mov edi,ebx
496
	add esi,4
507
	add edi,offs_vert_coord ;edi = &v.coord
497
	lea edi,[ebx+GLVertex.coord] ;edi = &v.coord
508
	mov ecx,4
498
	mov ecx,4
Line 509... Line 499...
509
	rep movsd
499
	rep movsd
Line 515... Line 505...
515
	je .els_0
505
	je .els_0
516
		stdcall gl_shade_vertex, edx,ebx
506
		stdcall gl_shade_vertex, edx,ebx
517
		jmp @f
507
		jmp @f
518
align 4
508
align 4
519
	.els_0:
509
	.els_0:
520
		mov esi,edx
-
 
521
		add esi,GLContext.current_color
510
		lea esi,[edx+GLContext.current_color]
522
		mov edi,ebx
-
 
523
		add edi,offs_vert_color ;edi = &v.color
511
		lea edi,[ebx+GLVertex.color] ;edi = &v.color
524
		mov ecx,4
512
		mov ecx,4
525
		rep movsd
513
		rep movsd
526
	@@:
514
	@@:
Line 527... Line 515...
527
 
515
 
528
	; tex coords
516
	; tex coords
529
	cmp dword[edx+GLContext.texture_2d_enabled],0
517
	cmp dword[edx+GLContext.texture_2d_enabled],0
530
	je @f
518
	je @f
531
		cmp dword[edx+GLContext.apply_texture_matrix],0
519
		cmp dword[edx+GLContext.apply_texture_matrix],0
532
		je .els_1
-
 
533
			mov eax,edx
520
		je .els_1
534
			add eax,GLContext.current_tex_coord
521
			lea eax,[edx+GLContext.current_tex_coord]
535
			push eax ;&context.current_tex_coord
-
 
536
			mov eax,ebx
522
			push eax ;&context.current_tex_coord
537
			add eax,offs_vert_tex_coord
523
			lea eax,[ebx+GLVertex.tex_coord]
538
			stdcall gl_M4_MulV4, eax, dword[edx+GLContext.matrix_stack_ptr+8]
524
			stdcall gl_M4_MulV4, eax, dword[edx+GLContext.matrix_stack_ptr+8]
539
			jmp @f
525
			jmp @f
540
align 4
526
align 4
541
		.els_1:
-
 
542
			mov esi,edx
527
		.els_1:
543
			add esi,GLContext.current_tex_coord
-
 
544
			mov edi,ebx
528
			lea esi,[edx+GLContext.current_tex_coord]
545
			add edi,offs_vert_tex_coord
529
			lea edi,[ebx+GLVertex.tex_coord]
546
			mov ecx,4
530
			mov ecx,4
547
			rep movsd
531
			rep movsd
Line 548... Line 532...
548
	@@:
532
	@@:
549
 
533
 
550
	; precompute the mapping to the viewport
534
	; precompute the mapping to the viewport
551
	cmp dword[ebx+offs_vert_clip_code],0
535
	cmp dword[ebx+GLVertex.clip_code],0
552
	jne @f
536
	jne @f
Line 553... Line 537...
553
		stdcall gl_transform_to_viewport, edx,ebx
537
		stdcall gl_transform_to_viewport, edx,ebx
554
	@@:
538
	@@:
555
 
539
 
Line 556... Line 540...
556
	; edge flag
540
	; edge flag
557
	mov eax,[edx+GLContext.current_edge_flag]
541
	mov eax,[edx+GLContext.current_edge_flag]
558
	mov dword[ebx+offs_vert_edge_flag],eax ;v.edge_flag = context.current_edge_flag
542
	mov dword[ebx+GLVertex.edge_flag],eax ;v.edge_flag = context.current_edge_flag
559
 
543
 
Line 583... Line 567...
583
	jne @f
567
	jne @f
584
		.li_loop:
568
		.li_loop:
585
		cmp dword[n],1
569
		cmp dword[n],1
586
		jne .els_2
570
		jne .els_2
587
			mov esi,[edx+GLContext.vertex]
571
			mov esi,[edx+GLContext.vertex]
588
			mov edi,esi
-
 
589
			add edi,2*sizeof.GLVertex
572
			lea edi,[esi+2*sizeof.GLVertex]
590
			mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
573
			mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
591
			rep movsd ;context.vertex[2] = context.vertex[0]
574
			rep movsd ;context.vertex[2] = context.vertex[0]
592
			jmp .end_f
575
			jmp .end_f
593
align 4
576
align 4
594
		.els_2:
577
		.els_2:
595
		cmp dword[n],2
578
		cmp dword[n],2
596
		jne .end_f ;else if (n == 2)
579
		jne .end_f ;else if (n == 2)
597
			mov eax,[edx+GLContext.vertex]
580
			mov edi,[edx+GLContext.vertex]
598
			push eax
-
 
599
			mov edi,eax
-
 
600
			add eax,sizeof.GLVertex
581
			lea esi,[edi+sizeof.GLVertex]
601
			mov esi,eax
-
 
602
			stdcall gl_draw_line, edx, eax
582
			stdcall gl_draw_line, edx, esi, edi
603
			mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
583
			mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
604
			rep movsd ;context.vertex[0] = context.vertex[1]
584
			rep movsd ;context.vertex[0] = context.vertex[1]
605
			mov dword[n],1
585
			mov dword[n],1
606
		jmp .end_f
586
		jmp .end_f
607
align 4
587
align 4
Line 660... Line 640...
660
	jne @f
640
	jne @f
661
		cmp dword[n],3
641
		cmp dword[n],3
662
		jne .end_f
642
		jne .end_f
663
			mov eax,[edx+GLContext.vertex]
643
			mov eax,[edx+GLContext.vertex]
664
			mov [esp-12],eax
644
			mov [esp-12],eax
665
			add eax,sizeof.GLVertex
645
			lea edi,[eax+sizeof.GLVertex]
666
			mov [esp-8],eax
646
			mov [esp-8],edi
667
			mov edi,eax
-
 
668
			add eax,sizeof.GLVertex
647
			lea esi,[edi+sizeof.GLVertex]
669
			mov [esp-4],eax
648
			mov [esp-4],esi
670
			mov esi,eax
-
 
671
			sub esp,12
649
			sub esp,12
672
			stdcall gl_draw_triangle, edx ;v0,v1,v2
650
			stdcall gl_draw_triangle, edx ;v0,v1,v2
673
			mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
651
			mov ecx,(sizeof.GLVertex)/4 ;((...)/4) что-бы использовать movsd вместо movsb
674
			rep movsd ;context.vertex[1] = context.vertex[2]
652
			rep movsd ;context.vertex[1] = context.vertex[2]
675
			mov dword[n],2
653
			mov dword[n],2
Line 680... Line 658...
680
	jne @f
658
	jne @f
681
		cmp dword[n],4
659
		cmp dword[n],4
682
		jne .end_f
660
		jne .end_f
683
			mov eax,[edx+GLContext.vertex]
661
			mov eax,[edx+GLContext.vertex]
684
			add eax,2*sizeof.GLVertex
662
			add eax,2*sizeof.GLVertex
685
			mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[2].edge_flag = 0
663
			mov dword[eax+GLVertex.edge_flag],0 ;context.vertex[2].edge_flag = 0
686
			push eax
664
			push eax
687
			sub eax,sizeof.GLVertex
665
			sub eax,sizeof.GLVertex
688
			push eax
666
			push eax
689
			sub eax,sizeof.GLVertex
667
			sub eax,sizeof.GLVertex
690
			stdcall gl_draw_triangle, edx,eax ;v0,v1,v2
668
			stdcall gl_draw_triangle, edx,eax ;v0,v1,v2
691
			mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[0].edge_flag = 0
669
			mov dword[eax+GLVertex.edge_flag],0 ;context.vertex[0].edge_flag = 0
692
			add eax,2*sizeof.GLVertex
670
			add eax,2*sizeof.GLVertex
693
			mov dword[eax+offs_vert_edge_flag],1 ;context.vertex[2].edge_flag = 1
671
			mov dword[eax+GLVertex.edge_flag],1 ;context.vertex[2].edge_flag = 1
694
			add eax,sizeof.GLVertex
672
			add eax,sizeof.GLVertex
695
			push eax
673
			push eax
696
			sub eax,sizeof.GLVertex
674
			sub eax,sizeof.GLVertex
697
			push eax
675
			push eax
698
			sub eax,2*sizeof.GLVertex
676
			sub eax,2*sizeof.GLVertex