104 static const int ByteSize = 2048;
105 char Memory[ByteSize];
113 , BytesLeft(ByteSize)
117 memcpy(MemCursor, &empty, CDListCmd::SizeOf<CEmptyListCmd>());
125 template <
class CmdType>
126 bool CanFit(CmdType cmd)
128 return (CDListCmd::SizeOf<CmdType>()
129 <= BytesLeft - CDListCmd::SizeOf<CNextBlockCmd>());
132 template <
class CmdType>
133 void operator+=(CmdType cmd)
135 memcpy(MemCursor, &cmd,
sizeof(CmdType));
136 MemCursor += CDListCmd::SizeOf<CmdType>();
137 BytesLeft -= CDListCmd::SizeOf<CmdType>();
157 static const int kBufferMaxQwordLength = 16 * 1024;
158 CDmaPacket *VertexBuf, *NormalBuf, *TexCoordBuf, *ColorBuf;
160 static const int kMaxNumRenderPackets = 512;
161 int NumRenderPackets;
162 CVifSCDmaPacket* RenderPackets[kMaxNumRenderPackets];
169 template <
class CmdType>
175 template <
class CmdType>
176 void operator+=(CmdType cmd)
178 if (!CurCmdBlock->CanFit(cmd)) {
182 CurCmdBlock->SetNextBlock(newBlock);
184 CurCmdBlock = newBlock;
191 CDListCmd* nextCmd = FirstCmdBlock->GetFirstCmd();
193 nextCmd = nextCmd->Play();
203 CDmaPacket& GetVertexBuf();
204 CDmaPacket& GetNormalBuf();
205 CDmaPacket& GetTexCoordBuf();
206 CDmaPacket& GetColorBuf();
208 void RegisterNewPacket(CVifSCDmaPacket* packet)
210 RenderPackets[NumRenderPackets++] = packet;
219 static const int kMaxListID = 4096;
221 CDList* Lists[kMaxListID];
222 unsigned int OpenListID;
225 bool ListsAreFree(
int firstListID,
int numLists);
227 static const int kMaxBuffersToBeFreed = 1024;
228 CDList* ListsToBeFreed[2][kMaxBuffersToBeFreed];
229 int NumListsToBeFreed[2];
232 inline void AddListToBeFreed(
CDList* dlist)
234 mAssert(NumListsToBeFreed[CurBuffer] < kMaxBuffersToBeFreed);
235 ListsToBeFreed[CurBuffer][NumListsToBeFreed[CurBuffer]++] = dlist;
245 for (
int i = 0; i < kMaxListID; i++)
247 NumListsToBeFreed[0] = NumListsToBeFreed[1] = 0;
251 for (
int i = 0; i < 10; i++)
258 unsigned int GenLists(
int numLists);
259 void DeleteLists(
unsigned int firstListID,
int numLists);
260 void NewList(
unsigned int listID, GLenum mode);
262 void CallList(
unsigned int listID);
264 CDList& GetOpenDList()
const {
return *OpenList; }