From b4dae617cd9fd732412fc349472abe4a1e1c2e97 Mon Sep 17 00:00:00 2001 From: IgorA Date: Mon, 1 Feb 2016 23:20:41 +0000 Subject: [PATCH] library speed optimize, fix gears git-svn-id: svn://kolibrios.org@6126 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../TinyGL/asm_fork/examples/gears.asm | 6 ++- .../libraries/TinyGL/asm_fork/ztriangle.asm | 51 ++++++++----------- .../libraries/TinyGL/asm_fork/ztriangle.inc | 14 ++--- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/gears.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/gears.asm index b3b244cb54..03a5d40228 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/gears.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/gears.asm @@ -805,16 +805,16 @@ endl ; draw inside radius cylinder stdcall [glBegin], GL_QUAD_STRIP mov dword[i],0 + finit @@: cmp dword[i],ebx jg @f - finit fld1 fld1 faddp fldpi - fmulp + fmul st0,st1 fimul dword[i] fidiv dword[teeth] fst dword[angle] ;angle = i * 2.0*M_PI / teeth @@ -849,6 +849,8 @@ endl call [glNormal3f];, -cos(angle), -sin(angle), 0.0 call [glVertex3f];, r0*cos(angle), r0*sin(angle), -width*0.5 call [glVertex3f];, r0*cos(angle), r0*sin(angle), width*0.5 + ffree st0 ;2.0 + fincstp inc dword[i] jmp @b @@: diff --git a/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm index 2c78459dc4..8642f521d6 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm @@ -12,7 +12,7 @@ if TGL_FEATURE_RENDER_BITS eq 24 mov eax,[ecx+offs_zbup_b] mov [colorB],ah ;colorB=p2.b>>8 ;else -; color=RGB_TO_PIXEL(p2->r,p2->g,p2->b); +;color=RGB_TO_PIXEL(p2.r,p2.g,p2.b) end if } @@ -20,13 +20,11 @@ macro PUT_PIXEL _a { local .end_0 mov eax,[z] - shr eax, ZB_POINT_Z_FRAC_BITS - mov [zz],eax - mov ebx,[pz] - cmp ax,word[ebx+2*_a] ;if (zz >= pz[_a]) + shr eax,ZB_POINT_Z_FRAC_BITS + cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) jl .end_0 ;edi = pp - mov word[ebx+2*_a],ax ;пишем в буфер глубины новое значение + mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение if TGL_FEATURE_RENDER_BITS eq 24 mov al,[colorR] mov ah,[colorG] @@ -34,7 +32,7 @@ if TGL_FEATURE_RENDER_BITS eq 24 mov al,[colorB] mov byte[edi+3*_a +2],al ;else -; pp[_a]=color; +;pp[_a]=color end if .end_0: mov eax,[dzdx] @@ -70,12 +68,10 @@ macro PUT_PIXEL _a local .end_0 mov eax,[z] shr eax,ZB_POINT_Z_FRAC_BITS - mov [zz],eax - mov ebx,[pz] - cmp ax,word[ebx+2*_a] ;if (zz >= pz[_a]) + cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) jl .end_0 ;edi = pp - mov word[ebx+2*_a],ax ;пишем в буфер глубины новое значение + mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение if TGL_FEATURE_RENDER_BITS eq 24 mov ebx,[or1] mov eax,[og1] @@ -85,7 +81,7 @@ if TGL_FEATURE_RENDER_BITS eq 24 mov byte[edi+3*_a +2],ah end if ;if TGL_FEATURE_RENDER_BITS eq 32 -; pp[_a] = RGB_TO_PIXEL(or1, og1, ob1); +;pp[_a] = RGB_TO_PIXEL(or1, og1, ob1) ;end if .end_0: mov eax,[dzdx] @@ -126,12 +122,10 @@ macro PUT_PIXEL _a local .end_0 mov eax,[z] shr eax,ZB_POINT_Z_FRAC_BITS - mov [zz],eax - mov ebx,[pz] - cmp ax,word[ebx+2*_a] ;if (zz >= pz[_a]) + cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) jl .end_0 ;edi = pp - mov word[ebx+2*_a],ax ;пишем в буфер глубины новое значение + mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение if TGL_FEATURE_RENDER_BITS eq 24 mov ebx,[t] and ebx,0x3fc00000 @@ -144,7 +138,7 @@ if TGL_FEATURE_RENDER_BITS eq 24 mov al,byte[ebx+2] mov byte[edi+3*_a +2],al ;pp[3 * _a + 2]= ptr[2] else -; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14]; +;pp[_a]=texture[((t & 0x3FC00000) | s) >> 14] end if .end_0: mov eax,[dzdx] @@ -196,12 +190,10 @@ macro PUT_PIXEL _a local .end_0 mov eax,[z] shr eax,ZB_POINT_Z_FRAC_BITS - mov [zz],eax - mov ebx,[pz] - cmp ax,word[ebx+2*_a] ;if (zz >= pz[_a]) + cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) jl .end_0 ;edi = pp - mov word[ebx+2*_a],ax ;пишем в буфер глубины новое значение + mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение if TGL_FEATURE_RENDER_BITS eq 24 mov ebx,[t] and ebx,0x3fc00000 @@ -246,10 +238,9 @@ fld1 fstp dword[zinv] ;zinv = 1.0 / fz imul edi,PSZB add edi,[pp1] ;pp = (pp1 + x1 * PSZB) - mov eax,[x1] - shl eax,1 - add eax,[pz1] - mov [pz],eax ;pz = pz1 + x1 + mov esi,[x1] + shl esi,1 + add esi,[pz1] ;pz = pz1 + x1 mov eax,[z1] mov [z],eax ;z = z1 mov eax,[sz1] @@ -291,7 +282,7 @@ fld1 PUT_PIXEL 5 PUT_PIXEL 6 PUT_PIXEL 7 - add dword[pz],2*NB_INTERP ;pz += NB_INTERP + add esi,2*NB_INTERP ;pz += NB_INTERP add edi,NB_INTERP*PSZB ;pp += NB_INTERP * PSZB sub dword[n],NB_INTERP ;n -= NB_INTERP fld dword[ndszdx] @@ -323,7 +314,7 @@ align 4 cmp dword[n],0 jl .cycle_3_end PUT_PIXEL 0 - add dword[pz],2 ;pz += 1 + add esi,2 ;pz += 1 add edi,PSZB ;pp += PSZB dec dword[n] jmp .cycle_3 @@ -365,12 +356,10 @@ macro PUT_PIXEL _a local .end_0 mov eax,[z] shr eax,ZB_POINT_Z_FRAC_BITS - mov [zz],eax - mov ebx,[pz] - cmp ax,word[ebx+2*_a] ;if (zz >= pz[_a]) + cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) jl .end_0 ;edi = pp - mov word[ebx+2*_a],ax ;пишем в буфер глубины новое значение + mov word[esi+2*_a],ax ;пишем в буфер глубины новое значение fild dword[z] fld dword[s_z] fdiv st0,st1 diff --git a/programs/develop/libraries/TinyGL/asm_fork/ztriangle.inc b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.inc index 5cb0995ae3..b86313224a 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/ztriangle.inc +++ b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.inc @@ -52,10 +52,7 @@ x2 dd ? ;int dx2dy2 dd ? ;int - pz dd ? ;unsigned short * z dd ? ;uint - zz dd ? ;uint - n dd ? ;int - длинна горизонтальной линии в пикселях if INTERP_Z eq 1 @@ -693,10 +690,9 @@ else add edi,[pp1] ;pp = pp1 + x1 * PSZB if INTERP_Z eq 1 - mov eax,[x1] - shl eax,1 - add eax,[pz1] - mov [pz],eax + mov esi,[x1] + shl esi,1 + add esi,[pz1] mov eax,[z1] mov [z],eax end if @@ -759,7 +755,7 @@ end if PUT_PIXEL 2 PUT_PIXEL 3 if INTERP_Z eq 1 - add dword[pz],8 ;=4*sizeof(uint) + add esi,8 ;=4*sizeof(uint) end if add edi,4*PSZB sub dword[n],4 @@ -799,7 +795,7 @@ if INTERP_RGB eq 1 end if PUT_PIXEL 0 if INTERP_Z eq 1 - add dword[pz],2 ;=sizeof(uint) + add esi,2 ;=sizeof(uint) end if add edi,PSZB dec dword[n]