From 87b3ad8a35cc7dd9207110e80fa436e6e4a47e99 Mon Sep 17 00:00:00 2001 From: jaromil Date: Sat, 12 Oct 2002 00:39:20 +0000 Subject: [PATCH] correct mmx blit algos for cropped layers git-svn-id: svn://dyne.org/rastasoft/freej/freej@49 383723c8-4afa-0310-b8a8-b1afb83214fc --- src/include/lubrify.h | 8 ++++---- src/layer.cpp | 12 ++++++++---- src/lubrify.c | 28 ++++++++++++++++------------ src/mmx_blit_add.asm | 27 +++++++++++++++++---------- src/mmx_blit_and.asm | 27 +++++++++++++++++---------- src/mmx_blit_or.asm | 27 +++++++++++++++++---------- src/mmx_blit_sub.asm | 27 +++++++++++++++++---------- 7 files changed, 96 insertions(+), 60 deletions(-) diff --git a/src/include/lubrify.h b/src/include/lubrify.h index 39a53bcb..b13d23cb 100644 --- a/src/include/lubrify.h +++ b/src/include/lubrify.h @@ -24,10 +24,10 @@ extern "C" { void mmxcopy(void *src1, void *dst, unsigned int size); void mmxblit(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch); - void mmxblit_add(void *src1, void *dst, unsigned int height, unsigned int pitch, unsigned int scr_pitch); - void mmxblit_sub(void *src1, void *dst, unsigned int height, unsigned int pitch, unsigned int scr_pitch); - void mmxblit_and(void *src1, void *dst, unsigned int height, unsigned int pitch, unsigned int scr_pitch); - void mmxblit_or(void *src1, void *dst, unsigned int height, unsigned int pitch, unsigned int scr_pitch); + void mmxblit_add(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch); + void mmxblit_sub(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch); + void mmxblit_and(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch); + void mmxblit_or(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch); void vline(void *scr, unsigned int height, unsigned int pitch, unsigned int bpp); void hline(void *scr, unsigned int width, unsigned int bpp); void mmxosd_clean(void *scr, double col); diff --git a/src/layer.cpp b/src/layer.cpp index 5932eb5f..b53da602 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -378,19 +378,23 @@ void Layer::blit(void *offset) { return; case 5: - mmxblit_add(offset,screen->coords(geo.x,geo.y),geo.h,geo.pitch,screen->pitch); + mmxblit_add((Uint8*)offset+blit_offset,screen->coords(blit_x,blit_y), + blit_width,blit_height,geo.pitch,screen->pitch); return; case 6: - mmxblit_sub(offset,screen->coords(geo.x,geo.y),geo.h,geo.pitch,screen->pitch); + mmxblit_sub((Uint8*)offset+blit_offset,screen->coords(blit_x,blit_y), + blit_width,blit_height,geo.pitch,screen->pitch); return; case 7: - mmxblit_and(offset,screen->coords(geo.x,geo.y),geo.h,geo.pitch,screen->pitch); + mmxblit_and((Uint8*)offset+blit_offset,screen->coords(blit_x,blit_y), + blit_width,blit_height,geo.pitch,screen->pitch); return; case 8: - mmxblit_or(offset,screen->coords(geo.x,geo.y),geo.h,geo.pitch,screen->pitch); + mmxblit_or((Uint8*)offset+blit_offset,screen->coords(blit_x,blit_y), + blit_width,blit_height,geo.pitch,screen->pitch); return; default: return; diff --git a/src/lubrify.c b/src/lubrify.c index 99b4f1d9..abbbbe79 100644 --- a/src/lubrify.c +++ b/src/lubrify.c @@ -59,42 +59,46 @@ void mmxblit(void *src1, void *dst, unsigned int width, unsigned int height, uns mmx_blit(); } -void mmxblit_add(void *src1, void *dst, unsigned int height, unsigned int pitch, unsigned int scr_pitch) { +void mmxblit_add(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch) { asmsrc1 = src1; asmdst = dst; asmnum1 = height; - asmnum2 = pitch; - asmnum3 = scr_pitch; + asmnum2 = width; + asmnum3 = pitch; + asmnum4 = scr_pitch; mmx_blit_add(); } -void mmxblit_sub(void *src1, void *dst, unsigned int height, unsigned int pitch, unsigned int scr_pitch) { +void mmxblit_sub(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch) { asmsrc1 = src1; asmdst = dst; asmnum1 = height; - asmnum2 = pitch; - asmnum3 = scr_pitch; + asmnum2 = width; + asmnum3 = pitch; + asmnum4 = scr_pitch; mmx_blit_sub(); } -void mmxblit_and(void *src1, void *dst, unsigned int height, unsigned int pitch, unsigned int scr_pitch) { +void mmxblit_and(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch) { asmsrc1 = src1; asmdst = dst; asmnum1 = height; - asmnum2 = pitch; - asmnum3 = scr_pitch; + asmnum2 = width; + asmnum3 = pitch; + asmnum4 = scr_pitch; mmx_blit_and(); } -void mmxblit_or(void *src1, void *dst, unsigned int height, unsigned int pitch, unsigned int scr_pitch) { +void mmxblit_or(void *src1, void *dst, unsigned int width, unsigned int height, unsigned int pitch, unsigned int scr_pitch) { asmsrc1 = src1; asmdst = dst; asmnum1 = height; - asmnum2 = pitch; - asmnum3 = scr_pitch; + asmnum2 = width; + asmnum3 = pitch; + asmnum4 = scr_pitch; mmx_blit_or(); } diff --git a/src/mmx_blit_add.asm b/src/mmx_blit_add.asm index 47142ae5..c0dd4b25 100644 --- a/src/mmx_blit_add.asm +++ b/src/mmx_blit_add.asm @@ -11,6 +11,7 @@ global mmx_blit_add extern asmnum1 extern asmnum2 extern asmnum3 + extern asmnum4 mmx_blit_add: ;; EAX source @@ -33,33 +34,39 @@ mmx_blit_add: push ebp ;; place data - mov eax,[asmsrc1] ; SRC mov edx,[asmdst] ; DST - mov ecx,[asmnum1] push edx ; puntatore a inizio linea dst - + mov eax,[asmsrc1] ; SRC + push eax ; puntatore a inizio linea src + mov ecx,[asmnum1] ; src height + .OuterLoop push ecx ; altezza - mov ecx,[asmnum2] ; src pitch - shr ecx,3 ; pitch=pitch/8 (il loop decrementa di 1) + mov ecx,[asmnum2] ; src width + shr ecx,1 ; we move 2 pixels at a time + .InnerLoop movq mm1,[eax] ; mette il src in mm1 (64bit) (MMX!) - movq mm2,[edx] - paddusb mm1,mm2 - movq [edx],mm1 ; mette mm1 in dst (64bit) (MMX!) add eax,8 ; incrementa il puntatore *src + movq mm2,[edx] ; mette il dst in mm2 (64bit) (MMX!) + paddusb mm1,mm2 ; PACKED ADD UNSIGNED BYTES (MMX!) + movq [edx],mm1 ; mette mm1 in dst (64bit) (MMX!) add edx,8 ; incrementa il puntatore *dst loop .InnerLoop ; se ha blittato tutta la linea va a capo .PitchReached ; ANDIAMO A CAPO pop ecx ; prende il contatore delle linee + pop eax ; prende l'inizio della linea di *src + add eax,[asmnum3] ; va a capo col *src pop edx ; prende l'inizio della linea di *dst - add edx,[asmnum3] ; va a capo col *dst + add edx,[asmnum4] ; va a capo col *dst push edx ; rimette tutto apposto nello stack + push eax loop .OuterLoop ; riluppa .TheEnd pop eax + pop edx emms ;; restore registers @@ -73,4 +80,4 @@ mmx_blit_add: leave ret -SEGMENT DATA \ No newline at end of file +SEGMENT DATA diff --git a/src/mmx_blit_and.asm b/src/mmx_blit_and.asm index 748d5e84..0b350a4d 100644 --- a/src/mmx_blit_and.asm +++ b/src/mmx_blit_and.asm @@ -11,6 +11,7 @@ global mmx_blit_and extern asmnum1 extern asmnum2 extern asmnum3 + extern asmnum4 mmx_blit_and: ;; EAX source @@ -33,33 +34,39 @@ mmx_blit_and: push ebp ;; place data - mov eax,[asmsrc1] ; SRC mov edx,[asmdst] ; DST - mov ecx,[asmnum1] push edx ; puntatore a inizio linea dst - + mov eax,[asmsrc1] ; SRC + push eax ; puntatore a inizio linea src + mov ecx,[asmnum1] ; src height + .OuterLoop push ecx ; altezza - mov ecx,[asmnum2] ; src pitch - shr ecx,3 ; pitch=pitch/8 (il loop decrementa di 1) + mov ecx,[asmnum2] ; src width + shr ecx,1 ; we move 2 pixels at a time + .InnerLoop movq mm1,[eax] ; mette il src in mm1 (64bit) (MMX!) - movq mm2,[edx] - pand mm1,mm2 - movq [edx],mm1 ; mette mm1 in dst (64bit) (MMX!) add eax,8 ; incrementa il puntatore *src + movq mm2,[edx] ; mette il dst in mm2 (64bit) (MMX!) + pand mm1,mm2 ; PACKED ADD UNSIGNED BYTES (MMX!) + movq [edx],mm1 ; mette mm1 in dst (64bit) (MMX!) add edx,8 ; incrementa il puntatore *dst loop .InnerLoop ; se ha blittato tutta la linea va a capo .PitchReached ; ANDIAMO A CAPO pop ecx ; prende il contatore delle linee + pop eax ; prende l'inizio della linea di *src + add eax,[asmnum3] ; va a capo col *src pop edx ; prende l'inizio della linea di *dst - add edx,[asmnum3] ; va a capo col *dst + add edx,[asmnum4] ; va a capo col *dst push edx ; rimette tutto apposto nello stack + push eax loop .OuterLoop ; riluppa .TheEnd pop eax + pop edx emms ;; restore registers @@ -73,4 +80,4 @@ mmx_blit_and: leave ret -SEGMENT DATA \ No newline at end of file +SEGMENT DATA diff --git a/src/mmx_blit_or.asm b/src/mmx_blit_or.asm index c4ce429a..3945cc61 100644 --- a/src/mmx_blit_or.asm +++ b/src/mmx_blit_or.asm @@ -11,6 +11,7 @@ global mmx_blit_or extern asmnum1 extern asmnum2 extern asmnum3 + extern asmnum4 mmx_blit_or: ;; EAX source @@ -33,33 +34,39 @@ mmx_blit_or: push ebp ;; place data - mov eax,[asmsrc1] ; SRC mov edx,[asmdst] ; DST - mov ecx,[asmnum1] push edx ; puntatore a inizio linea dst - + mov eax,[asmsrc1] ; SRC + push eax ; puntatore a inizio linea src + mov ecx,[asmnum1] ; src height + .OuterLoop push ecx ; altezza - mov ecx,[asmnum2] ; src pitch - shr ecx,3 ; pitch=pitch/8 (il loop decrementa di 1) + mov ecx,[asmnum2] ; src width + shr ecx,1 ; we move 2 pixels at a time + .InnerLoop movq mm1,[eax] ; mette il src in mm1 (64bit) (MMX!) - movq mm2,[edx] - por mm1,mm2 - movq [edx],mm1 ; mette mm1 in dst (64bit) (MMX!) add eax,8 ; incrementa il puntatore *src + movq mm2,[edx] ; mette il dst in mm2 (64bit) (MMX!) + por mm1,mm2 ; PACKED ADD UNSIGNED BYTES (MMX!) + movq [edx],mm1 ; mette mm1 in dst (64bit) (MMX!) add edx,8 ; incrementa il puntatore *dst loop .InnerLoop ; se ha blittato tutta la linea va a capo .PitchReached ; ANDIAMO A CAPO pop ecx ; prende il contatore delle linee + pop eax ; prende l'inizio della linea di *src + add eax,[asmnum3] ; va a capo col *src pop edx ; prende l'inizio della linea di *dst - add edx,[asmnum3] ; va a capo col *dst + add edx,[asmnum4] ; va a capo col *dst push edx ; rimette tutto apposto nello stack + push eax loop .OuterLoop ; riluppa .TheEnd pop eax + pop edx emms ;; restore registers @@ -73,4 +80,4 @@ mmx_blit_or: leave ret -SEGMENT DATA \ No newline at end of file +SEGMENT DATA diff --git a/src/mmx_blit_sub.asm b/src/mmx_blit_sub.asm index efe18be0..2ee77301 100644 --- a/src/mmx_blit_sub.asm +++ b/src/mmx_blit_sub.asm @@ -11,6 +11,7 @@ global mmx_blit_sub extern asmnum1 extern asmnum2 extern asmnum3 + extern asmnum4 mmx_blit_sub: ;; EAX source @@ -33,33 +34,39 @@ mmx_blit_sub: push ebp ;; place data - mov eax,[asmsrc1] ; SRC mov edx,[asmdst] ; DST - mov ecx,[asmnum1] push edx ; puntatore a inizio linea dst - + mov eax,[asmsrc1] ; SRC + push eax ; puntatore a inizio linea src + mov ecx,[asmnum1] ; src height + .OuterLoop push ecx ; altezza - mov ecx,[asmnum2] ; src pitch - shr ecx,3 ; pitch=pitch/8 (il loop decrementa di 1) + mov ecx,[asmnum2] ; src width + shr ecx,1 ; we move 2 pixels at a time + .InnerLoop movq mm1,[eax] ; mette il src in mm1 (64bit) (MMX!) - movq mm2,[edx] - psubusb mm1,mm2 - movq [edx],mm1 ; mette mm1 in dst (64bit) (MMX!) add eax,8 ; incrementa il puntatore *src + movq mm2,[edx] ; mette il dst in mm2 (64bit) (MMX!) + psubusb mm1,mm2 ; PACKED ADD UNSIGNED BYTES (MMX!) + movq [edx],mm1 ; mette mm1 in dst (64bit) (MMX!) add edx,8 ; incrementa il puntatore *dst loop .InnerLoop ; se ha blittato tutta la linea va a capo .PitchReached ; ANDIAMO A CAPO pop ecx ; prende il contatore delle linee + pop eax ; prende l'inizio della linea di *src + add eax,[asmnum3] ; va a capo col *src pop edx ; prende l'inizio della linea di *dst - add edx,[asmnum3] ; va a capo col *dst + add edx,[asmnum4] ; va a capo col *dst push edx ; rimette tutto apposto nello stack + push eax loop .OuterLoop ; riluppa .TheEnd pop eax + pop edx emms ;; restore registers @@ -73,4 +80,4 @@ mmx_blit_sub: leave ret -SEGMENT DATA \ No newline at end of file +SEGMENT DATA