From 1fd28e1eb49e054c41446b1d91f5113f77b2bc79 Mon Sep 17 00:00:00 2001 From: IgorA Date: Tue, 2 Dec 2014 15:43:43 +0000 Subject: [PATCH] fix vertex color; add primitives: GL_QUADS, GL_POLYGONS git-svn-id: svn://kolibrios.org@5213 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../libraries/TinyGL/asm_fork/clip.asm | 21 ++----- .../libraries/TinyGL/asm_fork/vertex.asm | 56 ++++++++++++------- .../libraries/TinyGL/asm_fork/zbuffer.inc | 16 +++--- 3 files changed, 48 insertions(+), 45 deletions(-) diff --git a/programs/develop/libraries/TinyGL/asm_fork/clip.asm b/programs/develop/libraries/TinyGL/asm_fork/clip.asm index f7bf17004c..988b4f93f8 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/clip.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/clip.asm @@ -702,7 +702,7 @@ pushad mov ebx,[p0] mov ecx,[p1] mov edx,[p2] - + mov edi,[ebx+offs_vert_clip_code] mov dword[cc],edi mov eax,[ecx+offs_vert_clip_code] @@ -719,8 +719,8 @@ pushad sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] mov dword[norm],edi fild dword[norm] - mov esi,dword[ecx+offs_vert_zp+offs_zbup_y] - sub esi,dword[ebx+offs_vert_zp+offs_zbup_y] + mov edi,dword[ecx+offs_vert_zp+offs_zbup_y] + sub edi,dword[ebx+offs_vert_zp+offs_zbup_y] mov dword[norm],edi fimul dword[norm] mov edi,dword[ecx+offs_vert_zp+offs_zbup_x] @@ -770,6 +770,7 @@ pushad cmp dword[front],0 je @f stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx + jmp .end_f @@: stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx jmp .end_f @@ -801,20 +802,6 @@ pushad mov ecx,[p1] mov edx,[p2] -if DEBUG ;(1) gl_draw_triangle_clip -pushad - stdcall dbg_print,txt_sp,m_1 - add ebx,offs_vert_color - add ecx,offs_vert_color - add edx,offs_vert_color - stdcall gl_print_matrix,ebx,1 - stdcall gl_print_matrix,ecx,1 - stdcall gl_print_matrix,edx,1 -popad -end if - -; finit ;??? - mov edi,[ebx+offs_vert_clip_code] mov [cc],edi mov eax,[ecx+offs_vert_clip_code] diff --git a/programs/develop/libraries/TinyGL/asm_fork/vertex.asm b/programs/develop/libraries/TinyGL/asm_fork/vertex.asm index 04d2be473c..8d7cc4e6e8 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/vertex.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/vertex.asm @@ -46,8 +46,8 @@ endl rep movsd mov eax,[context] - cmp dword[eax+offs_cont_color_material_enabled],1 - jne @f + cmp dword[eax+offs_cont_color_material_enabled],0 + je @f mov dword[q],OP_Material mov ecx,[eax+offs_cont_current_color_material_mode] mov dword[q+4],ecx @@ -55,7 +55,8 @@ endl mov dword[q+8],ecx mov esi,[p] add esi,4 - mov edi,dword[q+12] ;edi = [q3] + mov edi,ebp + sub edi,16 ;edi = &q[3] mov ecx,4 rep movsd stdcall glopMaterial, eax,[q] @@ -147,11 +148,7 @@ endl add ecx,offs_cont_matrix_model_projection ; precompute projection matrix stdcall gl_M4_Mul, ecx,dword[edx+offs_cont_matrix_stack_ptr+4],dword[edx+offs_cont_matrix_stack_ptr] -;if DEBUG ;glopBegin - ;stdcall gl_print_matrix,ecx,4 - ;stdcall gl_print_matrix,[edx+offs_cont_matrix_stack_ptr+4],4 - ;stdcall gl_print_matrix,[edx+offs_cont_matrix_stack_ptr],4 -;end if + ; test to accelerate computation mov dword[edx+offs_cont_matrix_model_projection_no_w_transform],0 fldz @@ -455,6 +452,10 @@ pushad .els_0: mov eax,[edx+offs_cont_current_color] mov [ebx+offs_vert_color],eax + mov eax,[edx+offs_cont_current_color+4] + mov [ebx+offs_vert_color+4],eax + mov eax,[edx+offs_cont_current_color+8] + mov [ebx+offs_vert_color+8],eax @@: ; tex coords @@ -570,11 +571,23 @@ pushad jne @f cmp dword[n],4 jne .end_f -; c->vertex[2].edge_flag = 0; -; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]); -; c->vertex[2].edge_flag = 1; -; c->vertex[0].edge_flag = 0; -; gl_draw_triangle(c, &c->vertex[0], &c->vertex[2], &c->vertex[3]); + mov eax,[edx+offs_cont_vertex] + add eax,2*sizeof.GLVertex + mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[2].edge_flag = 0 + push eax + sub eax,sizeof.GLVertex + push eax + sub eax,sizeof.GLVertex + stdcall gl_draw_triangle, edx,eax ;v0,v1,v2 + mov dword[eax+offs_vert_edge_flag],0 ;context.vertex[0].edge_flag = 0 + add eax,2*sizeof.GLVertex + mov dword[eax+offs_vert_edge_flag],1 ;context.vertex[2].edge_flag = 1 + add eax,sizeof.GLVertex + push eax + sub eax,sizeof.GLVertex + push eax + sub eax,2*sizeof.GLVertex + stdcall gl_draw_triangle, edx,eax ;v0,v2,v3 xor eax,eax mov dword[n],eax jmp .end_f @@ -591,10 +604,7 @@ pushad jmp .end_f @@: cmp dword[edx+offs_cont_begin_type],GL_POLYGON - jne @f - ;... - jmp .end_f - @@: + je .end_f ; default: ; gl_fatal_error("glBegin: type %x not handled\n", c->begin_type); ; } @@ -607,7 +617,7 @@ popad endp align 4 -proc glopEnd uses eax ebx, context:dword, p:dword +proc glopEnd uses eax ebx ecx, context:dword, p:dword mov eax,[context] ; assert(c->in_begin == 1); @@ -628,8 +638,14 @@ proc glopEnd uses eax ebx, context:dword, p:dword @@: ;while (ebx >= 3) cmp ebx,3 jl .end_i - dec ebx -; gl_draw_triangle(c, &c->vertex[i], &c->vertex[0], &c->vertex[i - 1]); + dec ebx + mov ecx,ebx + imul ecx,sizeof.GLVertex + add ecx,[eax+offs_cont_vertex] + push ecx ;ecx = &context.vertex[i] + sub ecx,sizeof.GLVertex + push ecx ;ecx = &context.vertex[i-1] + stdcall gl_draw_triangle, eax,[eax+offs_cont_vertex] jmp @b .end_i: mov dword[eax+offs_cont_in_begin],0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc b/programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc index f32aad54fd..e79c9cea4d 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc +++ b/programs/develop/libraries/TinyGL/asm_fork/zbuffer.inc @@ -8,17 +8,17 @@ ZB_Z_BITS equ 16 ZB_POINT_Z_FRAC_BITS equ 14 -ZB_POINT_S_MIN equ ( (1 shl 13) ) +ZB_POINT_S_MIN equ (1 shl 13) ZB_POINT_S_MAX equ ( (1 shl 22)-(1 shl 13) ) -ZB_POINT_T_MIN equ ( (1 shl 21) ) +ZB_POINT_T_MIN equ (1 shl 21) ZB_POINT_T_MAX equ ( (1 shl 30)-(1 shl 21) ) -ZB_POINT_RED_MIN equ ( (1 shl 10) ) -ZB_POINT_RED_MAX equ ( (1 shl 16)-(1 shl 10) ) -ZB_POINT_GREEN_MIN equ ( (1 shl 9) ) -ZB_POINT_GREEN_MAX equ ( (1 shl 16)-(1 shl 9) ) -ZB_POINT_BLUE_MIN equ ( (1 shl 10) ) -ZB_POINT_BLUE_MAX equ ( (1 shl 16)-(1 shl 10) ) +ZB_POINT_RED_MIN equ (1 shl 8) +ZB_POINT_RED_MAX equ ( (1 shl 16)-1 ) +ZB_POINT_GREEN_MIN equ (1 shl 8) +ZB_POINT_GREEN_MAX equ ( (1 shl 16)-1 ) +ZB_POINT_BLUE_MIN equ (1 shl 8) +ZB_POINT_BLUE_MAX equ ( (1 shl 16)-1 ) ; display modes ZB_MODE_5R6G5B equ 1 ; true color 16 bits