diff --git a/programs/demos/3DS/BUMP_CAT.INC b/programs/demos/3DS/BUMP_CAT.INC index 0ab609f52e..bae911c2b4 100644 --- a/programs/demos/3DS/BUMP_CAT.INC +++ b/programs/demos/3DS/BUMP_CAT.INC @@ -687,10 +687,10 @@ ret 34 push .t_bmap push dword .cey2 push .cex2 - push dword .cey1 - push .cex1 push dword .cby2 push .cbx2 + push dword .cey1 + push .cex1 push dword .cby1 push .cbx1 push ecx @@ -712,10 +712,10 @@ bump_line_z: .y equ dword [ebp+4] .bx1 equ [ebp+8] ; --- .by1 equ dword [ebp+12] ; | -.bx2 equ [ebp+16] ; | -.by2 equ dword [ebp+20] ; |> bump and env coords -.ex1 equ [ebp+24] ; |> shifted shl ROUND -.ey1 equ dword [ebp+28] ; | +.ex1 equ [ebp+16] ; | +.ey1 equ dword [ebp+20] ; |> bump and env coords +.bx2 equ [ebp+24] ; |> shifted shl ROUND +.by2 equ dword [ebp+28] ; | .ex2 equ [ebp+32] ; | .ey2 equ dword [ebp+36] ; --- .bmap equ dword [ebp+40] @@ -770,8 +770,8 @@ if Ext=NON mov edx,.ey1 xchg edx,.ey2 mov .ey1,edx -else - +end if +if Ext = MMX movq mm0,.bx1 movq mm1,.ex1 movq mm2,.bx2 @@ -780,7 +780,12 @@ else movq .ex2,mm1 movq .bx1,mm2 movq .ex1,mm3 - +end if +if Ext >= SSE + movups xmm0,.bx1 + movups xmm1,.bx2 + movups .bx2,xmm0 + movups .bx1,xmm1 end if mov edx,.z1 diff --git a/programs/demos/3DS/B_PROCS.INC b/programs/demos/3DS/B_PROCS.INC index 9bc0e8d83d..ed265575e5 100644 --- a/programs/demos/3DS/B_PROCS.INC +++ b/programs/demos/3DS/B_PROCS.INC @@ -636,6 +636,8 @@ make_random_lights: .temp2 equ ebp-8 ; - light vector generate variables .temp3 equ ebp-12 .max equ 800 + RDTSC + mov [rand_seed],ax push ebp mov ebp,esp sub esp,12 diff --git a/programs/demos/3DS/History.txt b/programs/demos/3DS/History.txt index 37ab363865..44a10ac418 100644 --- a/programs/demos/3DS/History.txt +++ b/programs/demos/3DS/History.txt @@ -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. 1. SSE optimizations (file BUMP_TEX.INC). 2. Compiles correctly in newest FASM. diff --git a/programs/demos/3DS/TWO_TEX.INC b/programs/demos/3DS/TWO_TEX.INC index f78ef719ca..c2f38fa130 100644 --- a/programs/demos/3DS/TWO_TEX.INC +++ b/programs/demos/3DS/TWO_TEX.INC @@ -716,8 +716,8 @@ ret 34 push .cz1 push .cz2 push .z_buff - push .t_emap push .t_bmap + push .t_emap push dword .cey2 push .cex2 push dword .cey1 @@ -743,39 +743,31 @@ two_tex_line_z: ;-------------- edi - pointer to screen buffer ;stack - another parameters : .y equ dword [ebp+4] -.bx1q equ [ebp+8] -.bx1 equ dword [ebp+8] ; --- -.by1 equ dword [ebp+12] ; | -.bx2q equ [ebp+16] -.bx2 equ dword [ebp+16] ; | -.by2 equ dword [ebp+20] ; |> b. texture and e. texture coords -.ex1q equ [ebp+24] -.ex1 equ dword [ebp+24] ; |> shifted shl ROUND -.ey1 equ dword [ebp+28] ; | -.ex2q equ [ebp+32] -.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 +.bx1 equ [ebp+8] ; --- +.by1 equ [ebp+12] ; | +.bx2 equ [ebp+16] ; | +.by2 equ [ebp+20] ; |> b. texture and e. texture coords +.ex1 equ [ebp+24] ; |> shifted shl ROUND +.ey1 equ [ebp+28] ; | +.ex2 equ [ebp+32] ; | +.ey2 equ [ebp+36] ; --- +.emap equ [ebp+40] ; b texture offset +.bmap equ [ebp+44] ; e texture offset .z_buff equ dword [ebp+48] .z2 equ dword [ebp+52] ; -- |> z coords shifted .z1 equ dword [ebp+56] ; -- shl CATMULL_SHIFT .x1 equ dword [ebp-4] .x2 equ dword [ebp-8] -.dbx equ dword [ebp-12] -.dby equ dword [ebp-16] -.dbyq equ qword [ebp-16] ; - new -.dex equ dword [ebp-20] -.dey equ dword [ebp-24] -.deyq equ qword [ebp-24] ; - new +.dbx equ [ebp-12] +.dex equ [ebp-16] +.dby equ [ebp-20] +.dey equ [ebp-24] .dz equ dword [ebp-28] -.cbx equ dword [ebp-32] -.cby equ dword [ebp-36] -.cbyq equ qword [ebp-36] ; - new -.cex equ dword [ebp-40] -.cey equ dword [ebp-44] -.ceyq equ qword [ebp-44] ; - new +.cbx equ [ebp-32] +.cex equ [ebp-36] +.cby equ [ebp-40] +.cey equ [ebp-44] .cz equ dword [ebp-48] .czbuff equ dword [ebp-52] @@ -807,14 +799,14 @@ if Ext=NON xchg edx,.ey2 mov .ey1,edx else - movq mm0,.bx1q - movq mm1,.ex1q - movq mm2,.bx2q - movq mm3,.ex2q - movq .bx2q,mm0 - movq .ex2q,mm1 - movq .bx1q,mm2 - movq .ex1q,mm3 + movq mm0,.bx1 + movq mm1,.ex1 + movq mm2,.bx2 + movq mm3,.ex2 + movq .bx2,mm0 + movq .ex2,mm1 + movq .bx1,mm2 + movq .ex1,mm3 end if mov edx,.z1 xchg edx,.z2 @@ -831,7 +823,7 @@ end if mov ebx,.x2 sub ebx,.x1 -if Ext=SSE +if Ext>=SSE sub esp,16 cvtsi2ss xmm3,ebx ;rcps @@ -847,22 +839,22 @@ if Ext=SSE ; movlhps xmm1,xmm1 ; cvtpi2ps xmm1,mm3 - cvtpi2ps xmm0,.bx1q ;mm0 + cvtpi2ps xmm0,.bx1 ;mm0 ; bx1; by1 movlhps xmm0,xmm0 - cvtpi2ps xmm0,.ex1q ;mm2 - cvtpi2ps xmm1,.bx2q ;mm1 + cvtpi2ps xmm0,.ex1 ;mm2 ; ex1; ey1 + cvtpi2ps xmm1,.bx2 ;mm1 ; bx2; by2 movlhps xmm1,xmm1 - cvtpi2ps xmm1,.ex2q ;mm3 + cvtpi2ps xmm1,.ex2 ;mm3 ; ex2; ey2 subps xmm1,xmm0 + ; hi lo + divps xmm1,xmm3 ; xmm1 -> dby; dbx; dey; dex - divps xmm1,xmm3 - - shufps xmm1,xmm1,10110001b + shufps xmm1,xmm1,11011000b cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords movhlps xmm1,xmm1 cvtps2pi mm1,xmm1 - movq .deyq,mm0 - movq .dbyq,mm1 + movq .dex,mm0 ; hi - lo -> dbx, dex + movq .dey,mm1 ; hi - lo -> dby, dey else @@ -872,14 +864,14 @@ else idiv ebx push eax - mov eax,.by2 ; calc .dby - sub eax,.by1 + mov eax,.ex2 ; calc .dby + sub eax,.ex1 cdq idiv ebx push eax - mov eax,.ex2 ; calc .dex - sub eax,.ex1 + mov eax,.by2 ; calc .dex + sub eax,.by1 cdq idiv ebx push eax @@ -942,18 +934,18 @@ end if mov ecx,.x2 sub ecx,.x1 ; init current variables - push .bx1 .by1 .ex1 .ey1 .z1 esi -; push .by1 -; push .ex1 -; push .ey1 + push dword .bx1 ;.by1 .ex1 .ey1 .z1 esi + push dword .ex1 + push dword .by1 + push dword .ey1 -; push .z1 ; current z shl CATMULL_SHIFT -; push esi + push .z1 ; current z shl CATMULL_SHIFT + push esi if Ext >= MMX pxor mm0,mm0 - movq mm3,.ceyq - movq mm4,.cbyq + movq mm3,.cex ; hi - lo -> cbx; cex + movq mm4,.cey ; hi - lo -> cby; cey ; movq mm5,mm3 ; movq mm6,mm4 ; psrad mm5,ROUND @@ -976,35 +968,42 @@ else end if jge .skip -;if Ext=NON +if Ext=NON mov eax,.cby mov esi,.cbx sar eax,ROUND sar esi,ROUND -;else -; movd eax,mm6 -; psrlq mm6,32 -; movd esi,mm6 -;end if shl eax,TEX_SHIFT ;- add esi,eax lea esi,[esi*3] ;- ; esi - current b. texture addres add esi,.bmap -;if Ext=NON mov ebx,.cex ;.cex - current env map X mov eax,.cey ;.cey - current env map y sar ebx,ROUND sar eax,ROUND -;else -; movd eax,mm5 -; psrlq mm5,32 -; movd ebx,mm5 -;end if + shl eax,TEX_SHIFT add ebx,eax lea ebx,[ebx*3] 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 movd mm1,[esi] movd mm2,[ebx] @@ -1056,14 +1055,14 @@ end if add .cey,eax else add edx,4 - paddd mm3,.deyq - paddd mm4,.dbyq + paddd mm3,.dex + paddd mm4,.dey ; movq mm5,mm3 ; movq mm6,mm4 ; psrad mm5,ROUND ; psrad mm6,ROUND - movq .ceyq,mm3 - movq .cbyq,mm4 + movq .cex,mm3 + movq .cey,mm4 end if mov eax,.dz add .cz,eax diff --git a/programs/demos/3DS/VIEW3DS.ASM b/programs/demos/3DS/VIEW3DS.ASM index e8d5503dd0..ea0d1ffb7d 100644 --- a/programs/demos/3DS/VIEW3DS.ASM +++ b/programs/demos/3DS/VIEW3DS.ASM @@ -1,5 +1,5 @@ -; application : View3ds ver. 0.055 - tiny .3ds files viewer. +; application : View3ds ver. 0.057 - tiny .3ds files viewer. ; compiler : FASM ; system : KolibriOS ; author : Macgub aka Maciej Guba @@ -81,7 +81,7 @@ START: ; start of execution call normalize_all_light_vectors call init_triangles_normals2 call init_point_normals - ; call init_envmap2 + call init_envmap2 call init_envmap_cub call generate_texture2 call init_sincos_tab @@ -141,7 +141,8 @@ still: jne .next_m6 cmp [dr_flag],2 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 @@: cmp [dr_flag],4 @@ -174,15 +175,15 @@ still: call make_random_lights ; 'env ' 2 call normalize_all_light_vectors ; 'bump' 3 call do_color_buffer ; intit color_map ; 'tex ' 4 - cmp [emboss_flag],1 ; 'pos ' 5 - je @f ; 'dots' 6 - cmp [dr_flag],8 - jge @f - cmp [dr_flag],2 ; 'txgr' 7 - jl .next_m5 ; '2tex' 8 - cmp [dr_flag],3 ; 'btex' 9 - jg .next_m5 - @@: + ; cmp [emboss_flag],1 ; 'pos ' 5 + ; je @f ; 'dots' 6 + ; cmp [dr_flag],8 + ; jge @f + ; cmp [dr_flag],2 ; 'txgr' 7 + ; jl .next_m5 ; '2tex' 8 + ; cmp [dr_flag],3 ; 'btex' 9 + ; jg .next_m5 + ; @@: call init_envmap2 ; update env map if shading model = environment or bump .next_m5: cmp ah,11 @@ -376,8 +377,8 @@ still: mov esi,angle_x mov edi,matrix call make_rotation_matrix -; RDTSC -; push eax + RDTSC + push eax mov esi,[points_normals_ptr] mov edi,[points_normals_rot_ptr] mov ebx,matrix @@ -425,8 +426,8 @@ still: @@: call fill_Z_buffer ; make background .non_f: - RDTSC - push eax +; RDTSC +; push eax cmp [dr_flag],6 jne @f call draw_dots @@ -799,6 +800,8 @@ init_envmap2: ; do env_map using many light sources pop ebp ret + + do_color_buffer: ; do color buffer for Gouraud, flat shading ;env_map 512 x 512 x 3 bytes ; many lights using .temp equ word [ebp-2] diff --git a/programs/demos/3DS/data.inc b/programs/demos/3DS/data.inc index 54e25ef510..f1cedd29dc 100644 --- a/programs/demos/3DS/data.inc +++ b/programs/demos/3DS/data.inc @@ -268,7 +268,7 @@ base_vector: if Ext=SSE db ' (SSE)' end if - db ' 0.055' + db ' 0.057' labellen: STRdata db '-1 ' diff --git a/programs/demos/3DS/readme.txt b/programs/demos/3DS/readme.txt index 2686d01fab..7f9305a1c5 100644 --- a/programs/demos/3DS/readme.txt +++ b/programs/demos/3DS/readme.txt @@ -1,8 +1,8 @@ -View3ds 0.055 - tiny viewer to .3ds files. +View3ds 0.057 - tiny viewer to .3ds files. What's new? -1. SSE optimizations (file BUMP_TEX.INC). -3. Compiles correctly in newest FASM. +1. By opening file bigger then ~18 KB, and choosing env mode program terminate. + I remove this bug Buttons description: 1. rotary: choosing rotary axle: x, y, x+y. @@ -15,14 +15,14 @@ Buttons description: 3. speed: idle, full. 4,5. zoom in, out: no comment. 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. 8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination). 9. Blur: blur N times; N=0,1,2,3,4,5 10.11,12,13. loseless operations (rotary 90, 180 degrees). 12. emboss: Do emboss effect( flat bumps ), use blur to do edges more deep. 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. 15. generate: Generates some objects: node, Thorn Crown, heart... 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 around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button. - Macgub Jan 2011 + Macgub April 2011 \ No newline at end of file