111 tU32 RendererContextChanged, SavedRendererContextChanges;
112 tU32 GsContextChanged, SavedGsContextChanges;
113 tU32 RendererPropsChanged, SavedRendererPropsChanges;
114 bool StateChangesArePushed;
116 inline void PushStateChanges()
118 mErrorIf(StateChangesArePushed,
"Trying to push state changes when already pushed.");
119 SavedRendererContextChanges = RendererContextChanged;
120 SavedGsContextChanges = GsContextChanged;
121 SavedRendererPropsChanges = RendererPropsChanged;
122 StateChangesArePushed =
true;
124 inline void PopStateChanges()
126 mErrorIf(!StateChangesArePushed,
127 "Trying to pop state changes that haven't been pushed.");
128 RendererContextChanged = SavedRendererContextChanges;
129 GsContextChanged = SavedGsContextChanges;
130 RendererPropsChanged = SavedRendererPropsChanges;
131 StateChangesArePushed =
false;
136 bool IsCurrentFieldEven;
137 unsigned int CurrentFrameNumber;
140 static const int kDmaPacketMaxQwordLength = 65000;
141 static CVifSCDmaPacket *CurPacket, *LastPacket,
142 *Vif1Packet, *SavedVif1Packet,
151 static const int kMaxDrawEnvChanges = 100;
152 void* DrawEnvPtrs0[kMaxDrawEnvChanges];
153 void* DrawEnvPtrs1[kMaxDrawEnvChanges];
154 void **CurDrawEnvPtrs, **LastDrawEnvPtrs;
155 int NumCurDrawEnvPtrs, NumLastDrawEnvPtrs;
158 static const int kMaxBuffersToBeFreed = 1024;
160 void* BuffersToBeFreed[2][kMaxBuffersToBeFreed];
161 int NumBuffersToBeFreed[2];
165 static const tU64
Ps2glSignalId = 0xffffffff00000000 | (tU32)
'G' << 24 | (tU32)
'L' << 16;
170 static int GsIntHandler(
int cause);
172 void FreeWaitingBuffersAndSwap();
174 void EndVif1Packet(
unsigned short signalNum);
176 typedef void (*tRenderingFinishedCallback)(void);
177 static tRenderingFinishedCallback RenderingFinishedCallback;
180 CGLContext(
int immBufferQwordSize,
int immDrawBufferQwordSize);
183 void SetMatrixMode(GLenum mode);
184 inline CMatrixStack& GetCurMatrixStack() {
return *CurMatrixStack; }
185 inline CImmMatrixStack& GetModelViewStack() {
return *ModelViewMatStack; }
186 inline CImmMatrixStack& GetProjectionStack() {
return *ProjectionMatStack; }
188 inline CLighting& GetLighting() {
return *CurLighting; }
189 inline CImmLighting& GetImmLighting() {
return *ImmLighting; }
190 inline CDListLighting& GetDListLighting() {
return *DListLighting; }
192 inline CGeomManager& GetGeomManager() {
return *CurGManager; }
198 inline CDListManager& GetDListManager() {
return *DListManager; }
200 inline CTexManager& GetTexManager() {
return *TexManager; }
202 inline CDrawContext& GetDrawContext() {
return *CurDrawContext; }
203 inline CImmDrawContext& GetImmDrawContext() {
return *ImmDrawContext; }
206 inline CDisplayContext& GetDisplayContext() {
return *DisplayContext; }
208 inline bool InDListDef()
const {
return CurGManager != (
CGeomManager*)ImmGManager; }
209 void BeginDListDef(
unsigned int listID, GLenum mode);
212 void BeginImmediateGeometry();
213 void EndImmediateGeometry();
214 void RenderImmediateGeometry();
215 void FinishRenderingImmediateGeometry(
bool forceImmediateStop);
217 void BeginGeometry();
219 void RenderGeometry();
220 void FinishRenderingGeometry(
bool forceImmediateStop);
222 void AddingDrawEnvToPacket(
void* de)
224 mErrorIf(NumCurDrawEnvPtrs == kMaxDrawEnvChanges,
225 "Too many draw environment changes. Need to increase kMaxDrawEnvChanges");
226 CurDrawEnvPtrs[NumCurDrawEnvPtrs++] = de;
228 void** GetDrawEnvPtrs() {
return LastDrawEnvPtrs; }
229 int GetNumDrawEnvPtrs()
const {
return NumLastDrawEnvPtrs; }
231 bool GetCurrentFieldIsEven()
const {
return IsCurrentFieldEven; }
245 mAssert(NumBuffersToBeFreed[CurBuffer] < kMaxBuffersToBeFreed);
246 BuffersToBeFreed[CurBuffer][NumBuffersToBeFreed[CurBuffer]++] = buf;
249 inline static void SetRenderingFinishedCallback(tRenderingFinishedCallback cb)
251 RenderingFinishedCallback = cb;
256 inline void NumLightsChanged()
258 RendererContextChanged |= RendererCtxtFlags::NumLights;
259 RendererPropsChanged |= RendererPropFlags::NumLights;
261 inline void LightPropChanged()
263 RendererContextChanged |= RendererCtxtFlags::LightPropChanged;
265 inline void GlobalAmbChanged()
267 RendererContextChanged |= RendererCtxtFlags::GlobalAmb;
269 inline void CurMaterialChanged()
271 RendererContextChanged |= RendererCtxtFlags::CurMaterial;
273 inline void XformChanged()
275 RendererContextChanged |= RendererCtxtFlags::Xform;
277 inline void PrimChanged()
279 RendererContextChanged |= RendererCtxtFlags::Prim;
280 RendererPropsChanged |= RendererPropFlags::Prim;
282 inline void ShadingChanged()
284 RendererContextChanged |= RendererCtxtFlags::Shading;
286 inline void TexEnabledChanged()
288 RendererContextChanged |= RendererCtxtFlags::TexEnabled;
289 RendererPropsChanged |= RendererPropFlags::TexEnabled;
290 GsContextChanged |= GsCtxtFlags::Texture;
292 inline void LightingEnabledChanged()
294 RendererContextChanged |= RendererCtxtFlags::LightingEnabled;
295 RendererPropsChanged |= RendererPropFlags::LightingEnabled;
297 inline void BlendEnabledChanged()
299 RendererContextChanged |= RendererCtxtFlags::AlphaBlending;
301 inline void DrawEnvChanged()
303 GsContextChanged |= GsCtxtFlags::DrawEnv;
305 inline void AlphaTestEnabledChanged()
307 GsContextChanged |= GsCtxtFlags::DrawEnv;
309 inline void DepthTestEnabledChanged()
311 GsContextChanged |= GsCtxtFlags::DrawEnv;
313 inline void DrawInterlacedChanged()
315 GsContextChanged |= GsCtxtFlags::DrawEnv;
317 inline void AlphaTestFuncChanged()
319 GsContextChanged |= GsCtxtFlags::DrawEnv;
321 inline void DepthTestFuncChanged()
323 GsContextChanged |= GsCtxtFlags::DrawEnv;
325 inline void DepthWriteEnabledChanged()
327 GsContextChanged |= GsCtxtFlags::DrawEnv;
329 inline void FrameBufferDrawMaskChanged()
331 GsContextChanged |= GsCtxtFlags::DrawEnv;
333 inline void SpecularEnabledChanged()
335 RendererPropsChanged |= RendererPropFlags::SpecularEnabled;
337 inline void TextureChanged()
339 GsContextChanged |= GsCtxtFlags::Texture;
341 inline void BlendModeChanged()
343 GsContextChanged |= GsCtxtFlags::DrawEnv;
345 inline void DrawBufferChanged()
347 GsContextChanged |= GsCtxtFlags::DrawEnv;
349 inline void PerVtxMaterialChanged()
351 RendererPropsChanged |= RendererPropFlags::PerVtxMaterial;
353 inline void ClippingEnabledChanged()
355 RendererPropsChanged |= RendererPropFlags::ClippingEnabled;
356 RendererContextChanged |= RendererCtxtFlags::ClippingEnabled;
358 inline void CullFaceEnabledChanged()
360 RendererPropsChanged |= RendererPropFlags::CullFaceEnabled;
362 inline void CullFaceDirChanged()
364 RendererContextChanged |= RendererCtxtFlags::CullFaceDir;
366 inline void ArrayAccessChanged()
368 RendererPropsChanged |= RendererPropFlags::ArrayAccessType;
370 inline void PolyModeChanged()
372 RendererContextChanged |= RendererCtxtFlags::Prim;
377 inline tU32 GetRendererContextChanged()
const {
return RendererContextChanged; }
378 inline void SetRendererContextChanged(
bool changed)
380 RendererContextChanged = (changed) ? 0xff : 0;
383 inline tU32 GetGsContextChanged()
const {
return GsContextChanged; }
384 inline void SetGsContextChanged(
bool changed)
386 GsContextChanged = (changed) ? 0xff : 0;
389 inline tU32 GetRendererPropsChanged()
const {
return RendererPropsChanged; }
390 inline void SetRendererPropsChanged(
bool changed)
392 RendererPropsChanged = (changed) ? 0xff : 0;
395 inline void PushVif1Packet()
397 mAssert(SavedVif1Packet == NULL);
398 SavedVif1Packet = Vif1Packet;
400 inline void PopVif1Packet()
402 mAssert(SavedVif1Packet != NULL);
403 Vif1Packet = SavedVif1Packet;
404 SavedVif1Packet = NULL;
406 inline void SetVif1Packet(CVifSCDmaPacket& packet) { Vif1Packet = &packet; }
407 inline CVifSCDmaPacket& GetVif1Packet() {
return *Vif1Packet; }