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.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.
Fast 565 RGB->BGR Conversion Needed
- ChaosKnight
- Posts: 142
- Joined: Thu Apr 14, 2005 2:08 am
- Location: Florida, USA
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:
Which is incredibly slow. Any thoughts?
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: Select all
// Color correction LUT method
for (int i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++)
PspFrameBuffer2[i] = CLUT[PspFrameBuffer[i]];
w00t
- ChaosKnight
- Posts: 142
- Joined: Thu Apr 14, 2005 2:08 am
- Location: Florida, USA
I don't think so, that was pretty simple stuff:
Code: Select all
PspFrameBuffer = (FB_TYPE *)sceGeEdramGetAddr();
PspFrameBuffer2 = PspFrameBuffer + BII_FRAMEBUFFER_SIZE;
w00t
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.ChaosKnight wrote:I don't think so, that was pretty simple stuff:Code: Select all
PspFrameBuffer = (FB_TYPE *)sceGeEdramGetAddr(); PspFrameBuffer2 = PspFrameBuffer + BII_FRAMEBUFFER_SIZE;
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.
- ChaosKnight
- Posts: 142
- Joined: Thu Apr 14, 2005 2:08 am
- Location: Florida, USA
This may help:
Code: Select all
#define BII_FRAMEBUFFER_SIZE (PSP_LINE_SIZE * SCREEN_HEIGHT * PIXEL_SIZE)
w00t
- ChaosKnight
- Posts: 142
- Joined: Thu Apr 14, 2005 2:08 am
- Location: Florida, USA
The depth buffer is setup like this now:
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.
Code: Select all
#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);
w00t
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...
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...