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 

Fast 565 RGB->BGR Conversion Needed
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
holger



Joined: 18 Aug 2005
Posts: 204

PostPosted: Thu Oct 13, 2005 7:21 pm    Post subject: Reply with quote

ChaosKnight wrote:
How do I get a block of memory on VRAM? do I just have to point to a certain address? If so what is that address and how much space am I allowed to use within it. It seems i'm only using ~265K for a buffer, so it's pretty small yet, but I wish to experiment with larger resolutions and scaling.


Unless you want to do dynamic memory allocation just pass a pointer to a (yet unused) VRAM area behind your frame buffers. sceGeEdramGetSize() returns the size of VRAM, sceGeEdramGetAddr() the start address. The size of your frame buffer you need to calculate manually.
Back to top
View user's profile Send private message
ChaosKnight



Joined: 14 Apr 2005
Posts: 142
Location: Florida, USA

PostPosted: Thu Oct 13, 2005 11:43 pm    Post subject: Reply with quote

Okay, doing the VRAM thing led to textures that were really fun but not quite right. Flushing the cache and forcing a writeback was also fun and made the texture even crazier. So I went back to sane RAM until I get get VRAM figured out.

I did my own CLUT which is basically the same as before except instead of telling the hardware to do it I do this:
Code:
   // Color correction LUT method
   for (int i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++)
      PspFrameBuffer2[i] = CLUT[PspFrameBuffer[i]];

Which is incredibly slow. Any thoughts?
_________________
w00t
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Arwin



Joined: 12 Jul 2005
Posts: 426

PostPosted: Fri Oct 14, 2005 12:23 am    Post subject: Reply with quote

ChaosKnight wrote:
Any thoughts?


What did you do with this suggestion from Holger?:

Quote:
The size of your frame buffer you need to calculate manually.


Maybe something went wrong there?
Back to top
View user's profile Send private message
ChaosKnight



Joined: 14 Apr 2005
Posts: 142
Location: Florida, USA

PostPosted: Fri Oct 14, 2005 12:38 am    Post subject: Reply with quote

I don't think so, that was pretty simple stuff:
Code:
PspFrameBuffer = (FB_TYPE *)sceGeEdramGetAddr();
PspFrameBuffer2 = PspFrameBuffer + BII_FRAMEBUFFER_SIZE;

_________________
w00t
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Arwin



Joined: 12 Jul 2005
Posts: 426

PostPosted: Fri Oct 14, 2005 1:49 am    Post subject: Reply with quote

ChaosKnight wrote:
I don't think so, that was pretty simple stuff:
Code:
PspFrameBuffer = (FB_TYPE *)sceGeEdramGetAddr();
PspFrameBuffer2 = PspFrameBuffer + BII_FRAMEBUFFER_SIZE;


And how does that calculate the framebuffer size? I feel like an idiot, but I don't get it. I see that a syscall gets an address, and I see that address being added to a constant/variable which seemingly comes out of nowhere.

Anyway, I don't know anything about this at all so I'm just being stupid. I think I'll go brush up on this stuff a bit later on. I need to learn a lot ... maybe find a good book on basic low-level graphics.
Back to top
View user's profile Send private message
ChaosKnight



Joined: 14 Apr 2005
Posts: 142
Location: Florida, USA

PostPosted: Fri Oct 14, 2005 2:30 am    Post subject: Reply with quote

This may help:
Code:
#define BII_FRAMEBUFFER_SIZE        (PSP_LINE_SIZE * SCREEN_HEIGHT * PIXEL_SIZE)

_________________
w00t
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
holger



Joined: 18 Aug 2005
Posts: 204

PostPosted: Fri Oct 14, 2005 4:07 am    Post subject: Reply with quote

sceGuDepthBuffer((void*) 0x110000, PSP_LINE_SIZE); is probably at the same address as your LUT. So writes to the depth buffer overwrite the CLUT.
Back to top
View user's profile Send private message
holger



Joined: 18 Aug 2005
Posts: 204

PostPosted: Fri Oct 14, 2005 4:19 am    Post subject: Reply with quote

another check: do you set up the CLUT pixel format correctly to BGR565 ?
Back to top
View user's profile Send private message
ChaosKnight



Joined: 14 Apr 2005
Posts: 142
Location: Florida, USA

PostPosted: Fri Oct 14, 2005 4:33 am    Post subject: Reply with quote

The depth buffer is setup like this now:
Code:

#define SCREEN_HEIGHT           272
#define PSP_LINE_SIZE           512
#define BII_PIXEL_SIZE          2
#define PSP_FRAMEBUFFER_SIZE    (PSP_LINE_SIZE * SCREEN_HEIGHT * PSP_PIXEL_SIZE)
sceGuDepthBuffer((void*)(PSP_FRAMEBUFFER_SIZE * 2), PSP_LINE_SIZE);

I really wish I had a memory map... I feel like some ancient explorer who didn't feel like making a map and so sailed in circles until his death.
_________________
w00t
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
holger



Joined: 18 Aug 2005
Posts: 204

PostPosted: Fri Oct 14, 2005 5:12 am    Post subject: Reply with quote

Should work ok for your usecase, but the macros will fail as soon you change to framebuffer color format - depth size is always 2, color pixel size can be 2 or 4, depending on the format.

Maybe you want to consider to port your graphics backend to OpenGL (the API is not far from libgu anyways). Jeremy's pspgl tree supports indexed textures as you need and you don't need to worry about cache and VRAM management, this complexity is transparently handled.

For free you get portability to desktop and other console systems. And all the work you do on the input system (in glut.c? I'd like to see some mouse/keyboard emulation there, the effort to incorporate this is the same as you need to do anyways - ), is reusable by other projects. Maybe you want to take a closer look...
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 -> PSP Development All times are GMT + 10 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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