forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Blitting 24 bit image data into 32 bit frame buffer...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
pailes



Joined: 16 Feb 2007
Posts: 16

PostPosted: Tue Feb 20, 2007 8:39 am    Post subject: Blitting 24 bit image data into 32 bit frame buffer... Reply with quote

Hi there,

I was wondering what would be the fastest way on MIPS to blit a 24 bit image (3 bytes per pixel) into the 32 bit frame buffer without causing alignment issues?
Right now I'm moving three single bytes which feels kinda slow. I could move from 24 bit image data to 32 bit image data and copy dwords but then I'd be wasting some memory I could use otherwise.
Any tips or hints?
Back to top
View user's profile Send private message Visit poster's website
crazyc



Joined: 17 Jun 2005
Posts: 410

PostPosted: Tue Feb 20, 2007 8:50 am    Post subject: Re: Blitting 24 bit image data into 32 bit frame buffer... Reply with quote

pailes wrote:
Hi there,

I was wondering what would be the fastest way on MIPS to blit a 24 bit image (3 bytes per pixel) into the 32 bit frame buffer without causing alignment issues?
Right now I'm moving three single bytes which feels kinda slow. I could move from 24 bit image data to 32 bit image data and copy dwords but then I'd be wasting some memory I could use otherwise.
Any tips or hints?


AFAIK, the fastest way would be to use lwl and lwr to load the data then mask off the top byte.
Back to top
View user's profile Send private message
StrmnNrmn



Joined: 14 Feb 2007
Posts: 46
Location: London, UK

PostPosted: Tue Feb 20, 2007 9:31 am    Post subject: Reply with quote

Can you load 4*3 bytes at a time (4 RGB pixels) and use a a few shifts and masks to forms 4*4 bytes to write out (4 RGBA pixels)? Something like:

Code:

lui t5, 0xff00    // assuming alpha is 255

loop:
lw  t0, 0(a0)
lw  t1, 4(a0)
lw  t2, 8(a0)
addiu a0, a0, 12

// Pixel 1
srl t3, t0, 8  // extract RGBx -> 0RGB
or  t3, t3, t5   // or in alpha
sw t3, 0(a1)

// Pixel 2
sll t3, t0, 16  // xxxR -> xR00
srl t4, t1, 16 // GBxx -> 00GB
or t3, t3, t4  // Combine
or t3, t3, t5  // Add alpha
sw t3, 4(a1)

// Pixel 3
sll t3, t1, 8    // xxRG -> xRGx
srl t4, t2, 24  // Bxxx -> 000B
or t3, t3, t4  // Combine
or t3, t3, t5  // Add alpha
sw t3, 8(a1)

// Pixel 4
// t2 is xRGB - just or in alpha
or t2, t2, t5
sw t2, 12(a1)
addiu a1, a1, 24

branch to loop while pixels remain


I'm assuming that there's quite a large penalty for lwl/lwr, otherwise you're probably not going to get anything for the extra effort.

The code above also assumes a certain ordering for the RGB elements, which I'm fairly sure is wrong...You also might get some mileage from using ext/ins?

-StrmnNrmn
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group