PS2GL
OpenGL*-like API for the PS2
Loading...
Searching...
No Matches
GS memory 'slots'
+ Collaboration diagram for GS memory 'slots':

Functions

pgl_slot_handle_t pglAddGsMemSlot (int startingPage, int pageLength, unsigned int pixelMode)
 
void pglLockGsMemSlot (pgl_slot_handle_t slot_handle)
 
void pglUnlockGsMemSlot (pgl_slot_handle_t slot_handle)
 
void pglRemoveAllGsMemSlots ()
 

Detailed Description

API for managing the "slots" that partition GS memory in ps2gl. As mentioned in the documentation for "GS memory management," ps2gl asks the user to partition GS memory into slots. A slot is defined by a starting page number in GS ram, a page length, and a preferred pixel format.

Note that the pixel format of a slot is its preferred format. If there are no slots of the requested pixel type large enough, ps2gl will try to find a big enough slot of a "higher" pixel type. For example, a 64x64, 32-bit slot (2 pages) might be allocated to hold a 128x128, 8-bit image if there were no 8-bit slots large enough.

The idea is that if a level has a lot of 64x64, 8-bit textures, you would allocate a lot of 64x64, 8-bit slots.

For example, say that our app uses a 640x448 interlaced display with a 24-bit depth buffer. We would create 3 slots, one for the depth buffer and two for a double-buffered frame buffer.

First, we need the size and starting address of each slot. The size is calculated from the dimensions of a page for the pixel format in question. Here are the dimensions of one GS "page" for the various pixel formats (from section 8.3 of the GS manual):

Each frame buffer is 640x224 (interlaced) at 32-bits. This means we need a slot 10 pages by 7 pages = 70 pages. The 24-bit depth buffer pages are the same size, so we need another 70 pages for the depth buffer.

Now that we have the sizes of each slot (70 pages), we just need the starting addresses. It doesn't really matter much where they begin, except of course when existing code assumes to find them in certain places. So let's make them contiguous starting at page 0:

pglAddGsMemSlot( 0, 70, SCE_GS_PSMCT32 );
pglAddGsMemSlot( 70, 70, SCE_GS_PSMCT32 );
pglAddGsMemSlot( 140, 70, SCE_GS_PSMZ32 );

Take a look at ps2glut.cpp for a more complete example (a better tutorial is on the way).

Function Documentation

◆ pglAddGsMemSlot()

pgl_slot_handle_t pglAddGsMemSlot ( int  startingPage,
int  pageLength,
unsigned int  pixelMode 
)

#include <src/gsmemory.cpp>

Adds a memory slot to the list of free slots.

Parameters
startingPagethe first page this slot occupies
pageLengththe number of pages this slot occupies (NOT the last page)
pixelModethe preferred pixel format of this slot
Returns
a handle to the new slot

Definition at line 118 of file gsmemory.cpp.

◆ pglLockGsMemSlot()

void pglLockGsMemSlot ( pgl_slot_handle_t  slot_handle)

#include <src/gsmemory.cpp>

Prevents a slot from being allocated or freed automatically. The slot can still be bound to an area by the user.

Definition at line 132 of file gsmemory.cpp.

◆ pglUnlockGsMemSlot()

void pglUnlockGsMemSlot ( pgl_slot_handle_t  slot_handle)

#include <src/gsmemory.cpp>

Lets the memory manager automatically allocate/free a slot that was previously locked.

Definition at line 142 of file gsmemory.cpp.

◆ pglRemoveAllGsMemSlots()

void pglRemoveAllGsMemSlots ( )

#include <src/gsmemory.cpp>

Removes all gs memory slots.

Definition at line 151 of file gsmemory.cpp.