flat assembler
Message board for the users of flat assembler.

Index > MenuetOS > Alpha blend 32

Author
Thread Post new topic Reply to topic
Bondy



Joined: 27 Nov 2005
Posts: 9
Bondy 29 Nov 2005, 03:26
Created a raw image with an Alpha channel i.e. 32bpp had to do this by hand unfortunately.

using the same equation subroutine this is the result

Corrected a mistake new source & binary sorry


Description:
Download
Filename: 32bit Alpha Blend.zip
Filesize: 40.93 KB
Downloaded: 944 Time(s)



Last edited by Bondy on 29 Nov 2005, 21:29; edited 2 times in total
Post 29 Nov 2005, 03:26
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 29 Nov 2005, 14:56
Sorry, I'm an optimizing guy so I couldn't resist Very Happy
Code:
AlphaBlendMMX:

  movd      mm0,eax                  ; 0RGB
  movd      mm1,ebx                  ; 0RGB
  movd      mm2,ecx                  ; 000A
  punpcklwd mm2,mm2                  ; 00000A0A
  punpckldq mm2,mm2                  ; 0A0A0A0A
  pxor      mm3,mm3                  ; 00000000

  movq      mm4,mm0                  ; 00000RGB
  movq      mm5,mm1                  ; 00000RGB

  punpcklbw mm4,mm3                  ; 000R0G0B
  punpcklbw mm5,mm3                  ; 000R0G0B
  psubw     mm4,mm5                  ; Fore-Back

  pmullw    mm4,mm2                  ; (Fore-Back)*A
  psrlw     mm4,8                    ; (Fore-Back)*A/256
  paddw     mm4,mm5                  ; (Fore-Back)*A/256+Back
                                     ; 000R0G0B
  packuswb  mm4,mm4                  ; 0RGB0RGB
  movd      eax,mm4

  ret
    
Post 29 Nov 2005, 14:56
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Bondy



Joined: 27 Nov 2005
Posts: 9
Bondy 29 Nov 2005, 21:36
Madis731

tried your code couldnt get it to work with any colour but blue dont know why but I did find a problem with my stuff while I was checking so Ive posted new code above.

hope you can see what the problem is
Post 29 Nov 2005, 21:36
View user's profile Send private message Reply with quote
Bondy



Joined: 27 Nov 2005
Posts: 9
Bondy 30 Nov 2005, 02:49
Madis731 sorry Dude fixed it myself and saved two movq's

Code:

AlphaBlendMMX:

  movd        mm0,eax                  ; 0RGB
  movd        mm1,ebx                  ; 0RGB
  movd        mm2,ecx                  ; 000A

  punpcklwd   mm2,mm2                  ; 00000A0A
  punpcklwd   mm2,mm2                  ; 0A0A0A0A
  pxor        mm3,mm3                  ; 00000000

  punpcklbw   mm0,mm3                  ; 000R0G0B
  punpcklbw   mm1,mm3                  ; 000R0G0B

  psubw       mm0,mm1                  ; Fore-Back
  pmullw      mm0,mm2                  ; (Fore-Back)*A
  psraw       mm0,8                    ; (Fore-Back)*A/256
  paddw       mm0,mm1                  ; (Fore-Back)*A/256+Back
                                       ; 000R0G0B
  packuswb    mm0,mm0                  ; 0RGB0RGB
  movd        eax,mm0                  ; 0RGB

  ret

    


See Attached I call it Alpha on the move Very Happy
Post 30 Nov 2005, 02:49
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 30 Nov 2005, 07:45
I'm glad to hear you got it working. I can't get the first one working under 64-bit version, but later I will test it on a 32-bit one. The second attachment is dead (I don't know why) Sad
Post 30 Nov 2005, 07:45
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Bondy



Joined: 27 Nov 2005
Posts: 9
Bondy 01 Dec 2005, 06:57
Here it is again


Description:
Download
Filename: Alpha Blend 2mmx.zip
Filesize: 25.51 KB
Downloaded: 941 Time(s)

Post 01 Dec 2005, 06:57
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 01 Dec 2005, 09:48
Nice implementation!
I love that it is about two times shorter (the blending code), but did it give any speed advantages? I'm sorry, but I still haven't reached testing it. Weekend is coming, though Very Happy

EDIT: Ok, hmm, seems rather optimal to me. 18MHz on a 3Gig machine, I saw from the code that the delay is 50ms so (20FPS) 1 pass takes about 900kHz (just under million clocks). I expect even lower values from Pentium III - I'll let you know.
Post 01 Dec 2005, 09:48
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Bondy



Joined: 27 Nov 2005
Posts: 9
Bondy 01 Dec 2005, 15:06
Sorry found another problem with MMX code because the maths is done in 16bpp it causes errors if you increase the alpha value above a certain point.

try an alpha value of 255 to see what I mean.

original code works but I agree it would be nice to have an optimized version.
Post 01 Dec 2005, 15:06
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.