fix rev 6100 and optimize
git-svn-id: svn://kolibrios.org@6101 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2cff28512d
commit
b096a68434
@ -685,17 +685,15 @@ pushad
|
||||
stdcall specbuf_get_buffer, edx, dword[ecx+offs_mate_shininess_i], dword[ecx+offs_mate_shininess]
|
||||
mov edi,eax ;edi = specbuf
|
||||
mov dword[idx],SPECULAR_BUFFER_SIZE ;idx = SPECULAR_BUFFER_SIZE
|
||||
fld1
|
||||
fcomp
|
||||
fstsw ax
|
||||
fild dword[idx]
|
||||
sahf
|
||||
jbe @f ;if(dot_spec < 1.0) st0=1 st1=dot_spec
|
||||
fmul st0,st1 ;idx *= dot_spec
|
||||
|
||||
;idx = (int)(dot_spec*SPECULAR_BUFFER_SIZE)
|
||||
fimul dword[idx]
|
||||
fistp dword[idx]
|
||||
;if (idx > SPECULAR_BUFFER_SIZE) idx = SPECULAR_BUFFER_SIZE
|
||||
cmp dword[idx],SPECULAR_BUFFER_SIZE
|
||||
jle @f
|
||||
mov dword[idx],SPECULAR_BUFFER_SIZE
|
||||
@@:
|
||||
fistp dword[idx]
|
||||
ffree st0 ;dot_spec
|
||||
fincstp
|
||||
shl dword[idx],2
|
||||
add edi,dword[idx]
|
||||
fld dword[edi+offs_spec_buf] ;dot_spec = specbuf.buf[idx]
|
||||
|
@ -8,21 +8,23 @@ locals
|
||||
val dd ? ;float
|
||||
f_inc dd ? ;float
|
||||
endl
|
||||
mov dword[val],0.0f
|
||||
mov dword[f_inc],SPECULAR_BUFFER_SIZE
|
||||
fld1
|
||||
fidiv dword[f_inc]
|
||||
fstp dword[f_inc] ;f_inc = 1.0f/SPECULAR_BUFFER_SIZE
|
||||
mov ebx,[buf]
|
||||
add ebx,offs_spec_buf
|
||||
mov dword[ebx],0.0 ;buf.buf[0] = 0.0
|
||||
xor ecx,ecx
|
||||
inc ecx
|
||||
fld dword[shininess] ;сначала берем y
|
||||
fld1
|
||||
fidiv dword[f_inc]
|
||||
fst dword[f_inc] ;f_inc = 1.0f/SPECULAR_BUFFER_SIZE
|
||||
fst dword[val]
|
||||
align 4
|
||||
.cycle_0: ;for (i = 0; i <= SPECULAR_BUFFER_SIZE; i++)
|
||||
.cycle_0: ;for (i = 1; i <= SPECULAR_BUFFER_SIZE; i++)
|
||||
cmp ecx,SPECULAR_BUFFER_SIZE
|
||||
jg @f
|
||||
;Вычисляем x^y
|
||||
fld dword[val] ;сначала берем y
|
||||
fld dword[shininess] ;а потом x
|
||||
|
||||
fyl2x ;Стек FPU теперь содержит: st0=z=y*log2(x):
|
||||
;Теперь считаем 2**z:
|
||||
fld st0 ;Создаем еще одну копию z
|
||||
@ -35,15 +37,22 @@ align 4
|
||||
fxch st1
|
||||
fstp st ;Результат остается на вершине стека st0
|
||||
|
||||
fstp dword[ebx] ;buf.buf[i] = pow(val, shininess)
|
||||
add ebx,4
|
||||
fstp dword[ebx] ;buf.buf[i] = pow(val, shininess)
|
||||
ffree st0 ;испорченный shininess
|
||||
fincstp
|
||||
|
||||
fld dword[shininess] ;сначала берем y
|
||||
fld dword[val]
|
||||
fadd dword[f_inc]
|
||||
fstp dword[val] ;val += f_inc
|
||||
fst dword[val] ;val += f_inc
|
||||
inc ecx
|
||||
jmp .cycle_0
|
||||
@@:
|
||||
ffree st0 ;val
|
||||
fincstp
|
||||
ffree st0 ;shininess
|
||||
fincstp
|
||||
ret
|
||||
endp
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user