Updated 'View3ds' sources till ver. 0.057

git-svn-id: svn://kolibrios.org@1931 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Yogev Ezra 2011-05-14 23:39:27 +00:00
parent 83c504b87c
commit b7b5de288c
7 changed files with 125 additions and 105 deletions

View File

@ -687,10 +687,10 @@ ret 34
push .t_bmap push .t_bmap
push dword .cey2 push dword .cey2
push .cex2 push .cex2
push dword .cey1
push .cex1
push dword .cby2 push dword .cby2
push .cbx2 push .cbx2
push dword .cey1
push .cex1
push dword .cby1 push dword .cby1
push .cbx1 push .cbx1
push ecx push ecx
@ -712,10 +712,10 @@ bump_line_z:
.y equ dword [ebp+4] .y equ dword [ebp+4]
.bx1 equ [ebp+8] ; --- .bx1 equ [ebp+8] ; ---
.by1 equ dword [ebp+12] ; | .by1 equ dword [ebp+12] ; |
.bx2 equ [ebp+16] ; | .ex1 equ [ebp+16] ; |
.by2 equ dword [ebp+20] ; |> bump and env coords .ey1 equ dword [ebp+20] ; |> bump and env coords
.ex1 equ [ebp+24] ; |> shifted shl ROUND .bx2 equ [ebp+24] ; |> shifted shl ROUND
.ey1 equ dword [ebp+28] ; | .by2 equ dword [ebp+28] ; |
.ex2 equ [ebp+32] ; | .ex2 equ [ebp+32] ; |
.ey2 equ dword [ebp+36] ; --- .ey2 equ dword [ebp+36] ; ---
.bmap equ dword [ebp+40] .bmap equ dword [ebp+40]
@ -770,8 +770,8 @@ if Ext=NON
mov edx,.ey1 mov edx,.ey1
xchg edx,.ey2 xchg edx,.ey2
mov .ey1,edx mov .ey1,edx
else end if
if Ext = MMX
movq mm0,.bx1 movq mm0,.bx1
movq mm1,.ex1 movq mm1,.ex1
movq mm2,.bx2 movq mm2,.bx2
@ -780,7 +780,12 @@ else
movq .ex2,mm1 movq .ex2,mm1
movq .bx1,mm2 movq .bx1,mm2
movq .ex1,mm3 movq .ex1,mm3
end if
if Ext >= SSE
movups xmm0,.bx1
movups xmm1,.bx2
movups .bx2,xmm0
movups .bx1,xmm1
end if end if
mov edx,.z1 mov edx,.z1

View File

@ -636,6 +636,8 @@ make_random_lights:
.temp2 equ ebp-8 ; - light vector generate variables .temp2 equ ebp-8 ; - light vector generate variables
.temp3 equ ebp-12 .temp3 equ ebp-12
.max equ 800 .max equ 800
RDTSC
mov [rand_seed],ax
push ebp push ebp
mov ebp,esp mov ebp,esp
sub esp,12 sub esp,12

View File

@ -1,3 +1,14 @@
View3ds 0.057 - April 2011.
1. By opening file bigger then ~18 KB, and choosing env mode program terminate.
I remove this bug
-----------------------------------------------------------------------------------
View3ds 0.056 - February 2011.
1. MMX optimizations in 2tex mode (file two_tex.inc).
2. Tiny SSE optimizations (file BUMP_CAT.INC).
3. Bit (two instructions) improved random light generation procedure.
-----------------------------------------------------------------------------------
View3ds 0.055 - January 2011. View3ds 0.055 - January 2011.
1. SSE optimizations (file BUMP_TEX.INC). 1. SSE optimizations (file BUMP_TEX.INC).
2. Compiles correctly in newest FASM. 2. Compiles correctly in newest FASM.

View File

@ -716,8 +716,8 @@ ret 34
push .cz1 push .cz1
push .cz2 push .cz2
push .z_buff push .z_buff
push .t_emap
push .t_bmap push .t_bmap
push .t_emap
push dword .cey2 push dword .cey2
push .cex2 push .cex2
push dword .cey1 push dword .cey1
@ -743,39 +743,31 @@ two_tex_line_z:
;-------------- edi - pointer to screen buffer ;-------------- edi - pointer to screen buffer
;stack - another parameters : ;stack - another parameters :
.y equ dword [ebp+4] .y equ dword [ebp+4]
.bx1q equ [ebp+8] .bx1 equ [ebp+8] ; ---
.bx1 equ dword [ebp+8] ; --- .by1 equ [ebp+12] ; |
.by1 equ dword [ebp+12] ; | .bx2 equ [ebp+16] ; |
.bx2q equ [ebp+16] .by2 equ [ebp+20] ; |> b. texture and e. texture coords
.bx2 equ dword [ebp+16] ; | .ex1 equ [ebp+24] ; |> shifted shl ROUND
.by2 equ dword [ebp+20] ; |> b. texture and e. texture coords .ey1 equ [ebp+28] ; |
.ex1q equ [ebp+24] .ex2 equ [ebp+32] ; |
.ex1 equ dword [ebp+24] ; |> shifted shl ROUND .ey2 equ [ebp+36] ; ---
.ey1 equ dword [ebp+28] ; | .emap equ [ebp+40] ; b texture offset
.ex2q equ [ebp+32] .bmap equ [ebp+44] ; e texture offset
.ex2 equ dword [ebp+32] ; |
.ey2 equ dword [ebp+36] ; ---
.bmap equ dword [ebp+40] ; b texture offset
.emap equ dword [ebp+44] ; e texture offset
.z_buff equ dword [ebp+48] .z_buff equ dword [ebp+48]
.z2 equ dword [ebp+52] ; -- |> z coords shifted .z2 equ dword [ebp+52] ; -- |> z coords shifted
.z1 equ dword [ebp+56] ; -- shl CATMULL_SHIFT .z1 equ dword [ebp+56] ; -- shl CATMULL_SHIFT
.x1 equ dword [ebp-4] .x1 equ dword [ebp-4]
.x2 equ dword [ebp-8] .x2 equ dword [ebp-8]
.dbx equ dword [ebp-12] .dbx equ [ebp-12]
.dby equ dword [ebp-16] .dex equ [ebp-16]
.dbyq equ qword [ebp-16] ; - new .dby equ [ebp-20]
.dex equ dword [ebp-20] .dey equ [ebp-24]
.dey equ dword [ebp-24]
.deyq equ qword [ebp-24] ; - new
.dz equ dword [ebp-28] .dz equ dword [ebp-28]
.cbx equ dword [ebp-32] .cbx equ [ebp-32]
.cby equ dword [ebp-36] .cex equ [ebp-36]
.cbyq equ qword [ebp-36] ; - new .cby equ [ebp-40]
.cex equ dword [ebp-40] .cey equ [ebp-44]
.cey equ dword [ebp-44]
.ceyq equ qword [ebp-44] ; - new
.cz equ dword [ebp-48] .cz equ dword [ebp-48]
.czbuff equ dword [ebp-52] .czbuff equ dword [ebp-52]
@ -807,14 +799,14 @@ if Ext=NON
xchg edx,.ey2 xchg edx,.ey2
mov .ey1,edx mov .ey1,edx
else else
movq mm0,.bx1q movq mm0,.bx1
movq mm1,.ex1q movq mm1,.ex1
movq mm2,.bx2q movq mm2,.bx2
movq mm3,.ex2q movq mm3,.ex2
movq .bx2q,mm0 movq .bx2,mm0
movq .ex2q,mm1 movq .ex2,mm1
movq .bx1q,mm2 movq .bx1,mm2
movq .ex1q,mm3 movq .ex1,mm3
end if end if
mov edx,.z1 mov edx,.z1
xchg edx,.z2 xchg edx,.z2
@ -831,7 +823,7 @@ end if
mov ebx,.x2 mov ebx,.x2
sub ebx,.x1 sub ebx,.x1
if Ext=SSE if Ext>=SSE
sub esp,16 sub esp,16
cvtsi2ss xmm3,ebx ;rcps cvtsi2ss xmm3,ebx ;rcps
@ -847,22 +839,22 @@ if Ext=SSE
; movlhps xmm1,xmm1 ; movlhps xmm1,xmm1
; cvtpi2ps xmm1,mm3 ; cvtpi2ps xmm1,mm3
cvtpi2ps xmm0,.bx1q ;mm0 cvtpi2ps xmm0,.bx1 ;mm0 ; bx1; by1
movlhps xmm0,xmm0 movlhps xmm0,xmm0
cvtpi2ps xmm0,.ex1q ;mm2 cvtpi2ps xmm0,.ex1 ;mm2 ; ex1; ey1
cvtpi2ps xmm1,.bx2q ;mm1 cvtpi2ps xmm1,.bx2 ;mm1 ; bx2; by2
movlhps xmm1,xmm1 movlhps xmm1,xmm1
cvtpi2ps xmm1,.ex2q ;mm3 cvtpi2ps xmm1,.ex2 ;mm3 ; ex2; ey2
subps xmm1,xmm0 subps xmm1,xmm0
; hi lo
divps xmm1,xmm3 ; xmm1 -> dby; dbx; dey; dex
divps xmm1,xmm3 shufps xmm1,xmm1,11011000b
shufps xmm1,xmm1,10110001b
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords
movhlps xmm1,xmm1 movhlps xmm1,xmm1
cvtps2pi mm1,xmm1 cvtps2pi mm1,xmm1
movq .deyq,mm0 movq .dex,mm0 ; hi - lo -> dbx, dex
movq .dbyq,mm1 movq .dey,mm1 ; hi - lo -> dby, dey
else else
@ -872,14 +864,14 @@ else
idiv ebx idiv ebx
push eax push eax
mov eax,.by2 ; calc .dby mov eax,.ex2 ; calc .dby
sub eax,.by1 sub eax,.ex1
cdq cdq
idiv ebx idiv ebx
push eax push eax
mov eax,.ex2 ; calc .dex mov eax,.by2 ; calc .dex
sub eax,.ex1 sub eax,.by1
cdq cdq
idiv ebx idiv ebx
push eax push eax
@ -942,18 +934,18 @@ end if
mov ecx,.x2 mov ecx,.x2
sub ecx,.x1 sub ecx,.x1
; init current variables ; init current variables
push .bx1 .by1 .ex1 .ey1 .z1 esi push dword .bx1 ;.by1 .ex1 .ey1 .z1 esi
; push .by1 push dword .ex1
; push .ex1 push dword .by1
; push .ey1 push dword .ey1
; push .z1 ; current z shl CATMULL_SHIFT push .z1 ; current z shl CATMULL_SHIFT
; push esi push esi
if Ext >= MMX if Ext >= MMX
pxor mm0,mm0 pxor mm0,mm0
movq mm3,.ceyq movq mm3,.cex ; hi - lo -> cbx; cex
movq mm4,.cbyq movq mm4,.cey ; hi - lo -> cby; cey
; movq mm5,mm3 ; movq mm5,mm3
; movq mm6,mm4 ; movq mm6,mm4
; psrad mm5,ROUND ; psrad mm5,ROUND
@ -976,35 +968,42 @@ else
end if end if
jge .skip jge .skip
;if Ext=NON if Ext=NON
mov eax,.cby mov eax,.cby
mov esi,.cbx mov esi,.cbx
sar eax,ROUND sar eax,ROUND
sar esi,ROUND sar esi,ROUND
;else
; movd eax,mm6
; psrlq mm6,32
; movd esi,mm6
;end if
shl eax,TEX_SHIFT ;- shl eax,TEX_SHIFT ;-
add esi,eax add esi,eax
lea esi,[esi*3] ;- ; esi - current b. texture addres lea esi,[esi*3] ;- ; esi - current b. texture addres
add esi,.bmap add esi,.bmap
;if Ext=NON
mov ebx,.cex ;.cex - current env map X mov ebx,.cex ;.cex - current env map X
mov eax,.cey ;.cey - current env map y mov eax,.cey ;.cey - current env map y
sar ebx,ROUND sar ebx,ROUND
sar eax,ROUND sar eax,ROUND
;else
; movd eax,mm5
; psrlq mm5,32
; movd ebx,mm5
;end if
shl eax,TEX_SHIFT shl eax,TEX_SHIFT
add ebx,eax add ebx,eax
lea ebx,[ebx*3] lea ebx,[ebx*3]
add ebx,.emap add ebx,.emap
else
movq mm5,.cey
psrad mm5,ROUND
pslld mm5,TEX_SHIFT
movq mm6,.cex
psrad mm6,ROUND
paddd mm5,mm6
movq mm6,mm5
paddd mm5,mm5
paddd mm5,mm6
paddd mm5,.emap
movd esi,mm5
psrlq mm5,32
movd ebx,mm5
end if
if Ext>=MMX if Ext>=MMX
movd mm1,[esi] movd mm1,[esi]
movd mm2,[ebx] movd mm2,[ebx]
@ -1056,14 +1055,14 @@ end if
add .cey,eax add .cey,eax
else else
add edx,4 add edx,4
paddd mm3,.deyq paddd mm3,.dex
paddd mm4,.dbyq paddd mm4,.dey
; movq mm5,mm3 ; movq mm5,mm3
; movq mm6,mm4 ; movq mm6,mm4
; psrad mm5,ROUND ; psrad mm5,ROUND
; psrad mm6,ROUND ; psrad mm6,ROUND
movq .ceyq,mm3 movq .cex,mm3
movq .cbyq,mm4 movq .cey,mm4
end if end if
mov eax,.dz mov eax,.dz
add .cz,eax add .cz,eax

View File

@ -1,5 +1,5 @@
; application : View3ds ver. 0.055 - tiny .3ds files viewer. ; application : View3ds ver. 0.057 - tiny .3ds files viewer.
; compiler : FASM ; compiler : FASM
; system : KolibriOS ; system : KolibriOS
; author : Macgub aka Maciej Guba ; author : Macgub aka Maciej Guba
@ -81,7 +81,7 @@ START: ; start of execution
call normalize_all_light_vectors call normalize_all_light_vectors
call init_triangles_normals2 call init_triangles_normals2
call init_point_normals call init_point_normals
; call init_envmap2 call init_envmap2
call init_envmap_cub call init_envmap_cub
call generate_texture2 call generate_texture2
call init_sincos_tab call init_sincos_tab
@ -141,7 +141,8 @@ still:
jne .next_m6 jne .next_m6
cmp [dr_flag],2 cmp [dr_flag],2
jne @f jne @f
call init_envmap2 ; call init_envmap2 ; <----! this don't works in env mode
; and more than ~18 kb objects
; call init_envmap_cub2 ; call init_envmap_cub2
@@: @@:
cmp [dr_flag],4 cmp [dr_flag],4
@ -174,15 +175,15 @@ still:
call make_random_lights ; 'env ' 2 call make_random_lights ; 'env ' 2
call normalize_all_light_vectors ; 'bump' 3 call normalize_all_light_vectors ; 'bump' 3
call do_color_buffer ; intit color_map ; 'tex ' 4 call do_color_buffer ; intit color_map ; 'tex ' 4
cmp [emboss_flag],1 ; 'pos ' 5 ; cmp [emboss_flag],1 ; 'pos ' 5
je @f ; 'dots' 6 ; je @f ; 'dots' 6
cmp [dr_flag],8 ; cmp [dr_flag],8
jge @f ; jge @f
cmp [dr_flag],2 ; 'txgr' 7 ; cmp [dr_flag],2 ; 'txgr' 7
jl .next_m5 ; '2tex' 8 ; jl .next_m5 ; '2tex' 8
cmp [dr_flag],3 ; 'btex' 9 ; cmp [dr_flag],3 ; 'btex' 9
jg .next_m5 ; jg .next_m5
@@: ; @@:
call init_envmap2 ; update env map if shading model = environment or bump call init_envmap2 ; update env map if shading model = environment or bump
.next_m5: .next_m5:
cmp ah,11 cmp ah,11
@ -376,8 +377,8 @@ still:
mov esi,angle_x mov esi,angle_x
mov edi,matrix mov edi,matrix
call make_rotation_matrix call make_rotation_matrix
; RDTSC RDTSC
; push eax push eax
mov esi,[points_normals_ptr] mov esi,[points_normals_ptr]
mov edi,[points_normals_rot_ptr] mov edi,[points_normals_rot_ptr]
mov ebx,matrix mov ebx,matrix
@ -425,8 +426,8 @@ still:
@@: @@:
call fill_Z_buffer ; make background call fill_Z_buffer ; make background
.non_f: .non_f:
RDTSC ; RDTSC
push eax ; push eax
cmp [dr_flag],6 cmp [dr_flag],6
jne @f jne @f
call draw_dots call draw_dots
@ -799,6 +800,8 @@ init_envmap2: ; do env_map using many light sources
pop ebp pop ebp
ret ret
do_color_buffer: ; do color buffer for Gouraud, flat shading do_color_buffer: ; do color buffer for Gouraud, flat shading
;env_map 512 x 512 x 3 bytes ; many lights using ;env_map 512 x 512 x 3 bytes ; many lights using
.temp equ word [ebp-2] .temp equ word [ebp-2]

View File

@ -268,7 +268,7 @@ base_vector:
if Ext=SSE if Ext=SSE
db ' (SSE)' db ' (SSE)'
end if end if
db ' 0.055' db ' 0.057'
labellen: labellen:
STRdata db '-1 ' STRdata db '-1 '

View File

@ -1,8 +1,8 @@
View3ds 0.055 - tiny viewer to .3ds files. View3ds 0.057 - tiny viewer to .3ds files.
What's new? What's new?
1. SSE optimizations (file BUMP_TEX.INC). 1. By opening file bigger then ~18 KB, and choosing env mode program terminate.
3. Compiles correctly in newest FASM. I remove this bug
Buttons description: Buttons description:
1. rotary: choosing rotary axle: x, y, x+y. 1. rotary: choosing rotary axle: x, y, x+y.
@ -15,14 +15,14 @@ Buttons description:
3. speed: idle, full. 3. speed: idle, full.
4,5. zoom in, out: no comment. 4,5. zoom in, out: no comment.
6. catmull: on( use z buffer ( z coordinate interpolation), off( depth sorting, painters 6. catmull: on( use z buffer ( z coordinate interpolation), off( depth sorting, painters
alghoritm).Txgrd and 2tex models only with catmull = on. alghoritm).Txgrd, 2tex and bumptex models only with catmull = on.
7. culling: backface culling on/ off. 7. culling: backface culling on/ off.
8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination). 8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination).
9. Blur: blur N times; N=0,1,2,3,4,5 9. Blur: blur N times; N=0,1,2,3,4,5
10.11,12,13. loseless operations (rotary 90, 180 degrees). 10.11,12,13. loseless operations (rotary 90, 180 degrees).
12. emboss: Do emboss effect( flat bumps ), use blur to do edges more deep. 12. emboss: Do emboss effect( flat bumps ), use blur to do edges more deep.
carefull with emboss + fire - it looks annoying. carefull with emboss + fire - it looks annoying.
13. fire: do movement blur ( looks like fire ). 13. fire: do motion blur ( looks like fire ).
14. move: changes meaning x,y,z +/- buttons -> obj: moving object, camr: moving camera. 14. move: changes meaning x,y,z +/- buttons -> obj: moving object, camr: moving camera.
15. generate: Generates some objects: node, Thorn Crown, heart... 15. generate: Generates some objects: node, Thorn Crown, heart...
16. bumps: random, according to texture. 16. bumps: random, according to texture.
@ -30,4 +30,4 @@ Buttons description:
18. re-map tex -> re-map texture and bump map coordinates, to change spherical mapping 18. re-map tex -> re-map texture and bump map coordinates, to change spherical mapping
around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button. around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button.
Macgub Jan 2011 Macgub April 2011