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 

From GBA to Ps2 - Any way to do similar per pixel blitting?

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



Joined: 26 Jun 2006
Posts: 275

PostPosted: Mon Jun 26, 2006 12:48 pm    Post subject: From GBA to Ps2 - Any way to do similar per pixel blitting? Reply with quote

My only console experience so far has been with The vba. And one feature I liked about it was it's mode 3 15bit mode, that let you write directly to the framebuffer,

Code:

videoBuffer[ y*width+x ] = rgb3( 31,31,31 );


It wasn't too fast, but coming from the amiga like I do I have a thing for per pixel blitting that cannot be explained by words.

So basically, can this be done in the ps2?

I realise you won't be able to poke directly into the GS as it's got to go through packets to the gif (or something to that effect), but can I do this?


Code:


   void * buffer = malloc ( 640*480*4 );
   
   MyPlot( 20,20,MyRgb(255,255,255) ,buffer)



Then do something like this with ps2's dma

Code:


  DMA_FASTCOPY( buffer, PSLIB_GETVIDEOBUFFER() );



So basically I'd work on a 'scratch' buffer in ram (Presumably high speed? bandwidth specs for ps2 look pretty good) then dma it across into the active screen buffer.

Or is it more abstracted in the ps2 and you have to rely on gif packets for everything?
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Mon Jun 26, 2006 1:09 pm    Post subject: Reply with quote

Yes, you can easily do that. You can either dma directly to the framebuffer (note that this still needs to be in a gif packed with giftags describing where to dump the image) and it will show.

Alternatively you can instead DMA the image to somewhere else in VRAM and then use it to tecture a full screen quad, wich can buy you nice things like scaling, alpha blending, etc.

Sources like gsKit show how to load & display a texture.. I guess there would't be much different to maintain an in-memory buffer instead of a bmp/png file...
_________________
Damn, I need a decent signature!
Back to top
View user's profile Send private message
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Mon Jun 26, 2006 1:14 pm    Post subject: Reply with quote

Cool, now I can get to work on my mega crap software 3d engine :)
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Mon Jun 26, 2006 1:18 pm    Post subject: Reply with quote

ohh, also you could use something pre-existing (again maybe gsKit) and simply use the pixel primitive to draw stuff. You would loose the ability to read stuff back (no biggie if you also keep a local cache) and performance would likey suck quite badly, but should be simple to get off the ground.
_________________
Damn, I need a decent signature!
Back to top
View user's profile Send private message
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Mon Jun 26, 2006 1:29 pm    Post subject: Reply with quote

Thanks for the idea but for now I'll go with the scratch ram to vram idea I think. Only cos I've been dreaming about doing ever since I found this page, I'm a man on a mission now :)
Back to top
View user's profile Send private message
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Fri Jun 30, 2006 3:27 pm    Post subject: Reply with quote

So I've got the gsKit installed and running and have got a simple demo running, but does anyone know how/if I can upload a memory bank(I.e a malloced pointer) to vram using gsKit? The demos only cover primitive drawing so far.

Or do I have to treat the buffer as a texture?
If so, what's the gsKit equilivent of glTexImage2D ?


Any examples please?
Back to top
View user's profile Send private message
SSpeare



Joined: 23 May 2006
Posts: 63

PostPosted: Sat Jul 01, 2006 12:11 am    Post subject: Reply with quote

You have two options, one is to upload the data to VRAM somewhere and then render it as a textured primitive. That would be slow, however, and pointless if you will be drawing the entire frame.

Better is to upload your image data to VRAM and point the destination address as the frame buffer. The function call in gsKit will probably have the word "texture" in it or image. I'm not familiar with gsKit. This is pretty straightforward to do and I'm sure gsKit can do it.

On the underneath side, you just build a GIF packet with the proper width/height and pixel format with the destination address on the GS as the location of the framebuffer. This is what the call to gsKit will do, so it's easier to just use gsKit and read the source if you want to know what it's doing.

You'll want to use double-buffering I'm pretty sure in this case.

Sorry, no samples from me! My dev machine is still down and I haven't looked at gsKit yet.
Back to top
View user's profile Send private message Visit poster's website
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Sat Jul 01, 2006 12:30 am    Post subject: Reply with quote

Sounds pretty straight forward, thanks for the info. I'll have a look through the gskit headers see if I find anything like that. Though I'd be very happy if someone here could save me potentially having to read something by telling me what function I need :)
Back to top
View user's profile Send private message
SSpeare



Joined: 23 May 2006
Posts: 63

PostPosted: Sat Jul 01, 2006 12:56 am    Post subject: Reply with quote

Check out the examples in gsKit. There are two texture examples there that should be a good guide.

EDIT:
Actually, current gsKit in SVN has several:
alpha
bigtex
linuz-texture
png-texture
textures

and fb looks good.


Last edited by SSpeare on Sat Jul 01, 2006 1:29 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Kojima



Joined: 26 Jun 2006
Posts: 275

PostPosted: Sat Jul 01, 2006 1:10 am    Post subject: Reply with quote

yeah the fb one appears to be what I need, i'll have a closer look after i've finished my pong game(Don't laugh, we all have to start somewhere :) )
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 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