PS2GL
OpenGL*-like API for the PS2
Loading...
Searching...
No Matches
gsmemory.cpp
Go to the documentation of this file.
1/* Copyright (C) 2000,2001,2002 Sony Computer Entertainment America
2
3 This file is subject to the terms and conditions of the GNU Lesser
4 General Public License Version 2.1. See the file "COPYING" in the
5 main directory of this archive for more details. */
6
7#include "GL/ps2gl.h"
8
9#include "ps2s/gsmem.h"
10
16static bool GsMemInitted = false;
17
23// gs mem
24
41{
42 GS::CMemManager& mm = GS::CMemArea::GetMemManager();
43 mm.PrintAllocation();
44}
45
51{
52 return GsMemInitted;
53}
54
55// slots
56
117pgl_slot_handle_t
118pglAddGsMemSlot(int startingPage, int pageLength, unsigned int pixelMode)
119{
120 GS::CMemManager& mm = GS::CMemArea::GetMemManager();
121 GS::CMemSlot* newSlot = mm.AddSlot(startingPage, pageLength, (GS::tPSM)pixelMode);
122
123 GsMemInitted = true;
124
125 return reinterpret_cast<pgl_slot_handle_t>(newSlot);
126}
127
132void pglLockGsMemSlot(pgl_slot_handle_t slot_handle)
133{
134 GS::CMemSlot* slot = reinterpret_cast<GS::CMemSlot*>(slot_handle);
135 slot->Lock();
136}
137
142void pglUnlockGsMemSlot(pgl_slot_handle_t slot_handle)
143{
144 GS::CMemSlot* slot = reinterpret_cast<GS::CMemSlot*>(slot_handle);
145 slot->Unlock();
146}
147
152{
153 GS::CMemManager& mm = GS::CMemArea::GetMemManager();
154 mm.RemoveAllSlots();
155}
156
// gs_mem_slots
158
159// mem area operations
160
184pgl_area_handle_t
185pglCreateGsMemArea(int width, int height, unsigned int pix_format)
186{
187 GS::CMemArea* newArea = new GS::CMemArea(width, height, (GS::tPSM)pix_format);
188 return reinterpret_cast<pgl_area_handle_t>(newArea);
189}
190
194void pglDestroyGsMemArea(pgl_area_handle_t mem_area)
195{
196 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
197 delete area;
198}
199
210void pglAllocGsMemArea(pgl_area_handle_t mem_area)
211{
212 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
213 area->Alloc();
214}
215
220void pglFreeGsMemArea(pgl_area_handle_t mem_area)
221{
222 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
223 area->Free();
224}
225
231void pglSetGsMemAreaWordAddr(pgl_area_handle_t mem_area, unsigned int addr)
232{
233 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
234 area->SetWordAddr(addr);
235}
236
241void pglBindGsMemAreaToSlot(pgl_area_handle_t mem_area, pgl_slot_handle_t mem_slot)
242{
243 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
244 GS::CMemSlot* slot = reinterpret_cast<GS::CMemSlot*>(mem_slot);
245 slot->Bind(*area, 0); // FIXME: current frame number
246}
247
251void pglUnbindGsMemArea(pgl_area_handle_t mem_area)
252{
253 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
254 area->Unbind();
255}
256
261void pglLockGsMemArea(pgl_area_handle_t mem_area)
262{
263 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
264 area->Lock();
265}
269void pglUnlockGsMemArea(pgl_area_handle_t mem_area)
270{
271 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
272 area->Unlock();
273}
277int pglGsMemAreaIsAllocated(pgl_area_handle_t mem_area)
278{
279 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
280 return (int)area->IsAllocated();
281}
285unsigned int
286pglGetGsMemAreaWordAddr(pgl_area_handle_t mem_area)
287{
288 GS::CMemArea* area = reinterpret_cast<GS::CMemArea*>(mem_area);
289 return area->GetWordAddr();
290}
291
// gs_mem_areas
293
// gs_mem
295
// pgl_api
void pglDestroyGsMemArea(pgl_area_handle_t mem_area)
Definition gsmemory.cpp:194
void pglSetGsMemAreaWordAddr(pgl_area_handle_t mem_area, unsigned int addr)
Definition gsmemory.cpp:231
void pglLockGsMemArea(pgl_area_handle_t mem_area)
Definition gsmemory.cpp:261
int pglGsMemAreaIsAllocated(pgl_area_handle_t mem_area)
Definition gsmemory.cpp:277
void pglBindGsMemAreaToSlot(pgl_area_handle_t mem_area, pgl_slot_handle_t mem_slot)
Definition gsmemory.cpp:241
void pglUnlockGsMemArea(pgl_area_handle_t mem_area)
Definition gsmemory.cpp:269
void pglFreeGsMemArea(pgl_area_handle_t mem_area)
Definition gsmemory.cpp:220
unsigned int pglGetGsMemAreaWordAddr(pgl_area_handle_t mem_area)
Definition gsmemory.cpp:286
void pglUnbindGsMemArea(pgl_area_handle_t mem_area)
Definition gsmemory.cpp:251
pgl_area_handle_t pglCreateGsMemArea(int width, int height, unsigned int pix_format)
Definition gsmemory.cpp:185
void pglAllocGsMemArea(pgl_area_handle_t mem_area)
Definition gsmemory.cpp:210
void pglRemoveAllGsMemSlots()
Definition gsmemory.cpp:151
pgl_slot_handle_t pglAddGsMemSlot(int startingPage, int pageLength, unsigned int pixelMode)
Definition gsmemory.cpp:118
void pglUnlockGsMemSlot(pgl_slot_handle_t slot_handle)
Definition gsmemory.cpp:142
void pglLockGsMemSlot(pgl_slot_handle_t slot_handle)
Definition gsmemory.cpp:132
int pglHasGsMemBeenInitted()
Definition gsmemory.cpp:50
void pglPrintGsMemAllocation()
Definition gsmemory.cpp:40