2012-12-28 20:58:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
2013-08-08 06:27:29 +00:00
|
|
|
#include "native/base/mutex.h"
|
|
|
|
#include "GPU/GPUInterface.h"
|
2013-08-08 06:59:32 +00:00
|
|
|
#include <deque>
|
2012-12-28 20:58:00 +00:00
|
|
|
|
|
|
|
class GPUCommon : public GPUInterface
|
|
|
|
{
|
|
|
|
public:
|
2013-04-05 06:19:28 +00:00
|
|
|
GPUCommon();
|
|
|
|
virtual ~GPUCommon() {}
|
2012-12-29 01:10:29 +00:00
|
|
|
|
2013-08-08 06:59:32 +00:00
|
|
|
virtual void RunEventsUntil(u64 globalticks);
|
|
|
|
|
2013-04-06 15:19:54 +00:00
|
|
|
virtual void InterruptStart(int listid);
|
|
|
|
virtual void InterruptEnd(int listid);
|
2013-04-07 19:45:42 +00:00
|
|
|
virtual void SyncEnd(WaitType waitType, int listid, bool wokeThreads);
|
2013-04-01 06:02:46 +00:00
|
|
|
virtual void EnableInterrupts(bool enable) {
|
|
|
|
interruptsEnabled_ = enable;
|
|
|
|
}
|
2013-02-03 23:41:16 +00:00
|
|
|
|
2013-04-01 06:02:46 +00:00
|
|
|
virtual void ExecuteOp(u32 op, u32 diff);
|
2012-12-29 01:10:29 +00:00
|
|
|
virtual void PreExecuteOp(u32 op, u32 diff);
|
|
|
|
virtual bool InterpretList(DisplayList &list);
|
|
|
|
virtual bool ProcessDLQueue();
|
2013-04-01 06:23:03 +00:00
|
|
|
virtual u32 UpdateStall(int listid, u32 newstall);
|
2012-12-22 06:50:35 +00:00
|
|
|
virtual u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, bool head);
|
2013-04-01 06:23:03 +00:00
|
|
|
virtual u32 DequeueList(int listid);
|
|
|
|
virtual int ListSync(int listid, int mode);
|
|
|
|
virtual u32 DrawSync(int mode);
|
2012-12-29 19:41:33 +00:00
|
|
|
virtual void DoState(PointerWrap &p);
|
2013-03-03 12:00:21 +00:00
|
|
|
virtual bool FramebufferDirty() { return true; }
|
2013-04-01 06:23:03 +00:00
|
|
|
virtual u32 Continue();
|
|
|
|
virtual u32 Break(int mode);
|
2013-08-04 22:15:50 +00:00
|
|
|
virtual void ReapplyGfxState();
|
2013-08-08 07:10:30 +00:00
|
|
|
virtual void SyncThread();
|
2012-12-28 20:58:00 +00:00
|
|
|
|
|
|
|
protected:
|
2013-04-28 21:23:30 +00:00
|
|
|
// To avoid virtual calls to PreExecuteOp().
|
|
|
|
virtual void FastRunLoop(DisplayList &list) = 0;
|
|
|
|
void SlowRunLoop(DisplayList &list);
|
2013-04-28 20:34:29 +00:00
|
|
|
void UpdatePC(u32 currentPC, u32 newPC = 0);
|
|
|
|
void UpdateState(GPUState state);
|
2013-04-05 06:19:28 +00:00
|
|
|
void PopDLQueue();
|
|
|
|
void CheckDrawSync();
|
2013-08-04 23:31:11 +00:00
|
|
|
int GetNextListIndex();
|
2013-08-08 06:59:32 +00:00
|
|
|
GPUEvent GetNextEvent();
|
2013-08-08 07:10:30 +00:00
|
|
|
bool HasEvents();
|
2013-08-08 06:59:32 +00:00
|
|
|
void ScheduleEvent(GPUEvent ev);
|
|
|
|
void ProcessDLQueueInternal();
|
|
|
|
void ReapplyGfxStateInternal();
|
|
|
|
virtual void ProcessEvent(GPUEvent ev) = 0;
|
2013-04-03 15:10:35 +00:00
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
typedef std::list<int> DisplayListQueue;
|
2012-12-29 01:10:29 +00:00
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
DisplayList dls[DisplayListMaxCount];
|
2012-12-28 20:58:00 +00:00
|
|
|
DisplayList *currentList;
|
|
|
|
DisplayListQueue dlQueue;
|
2013-08-08 06:27:29 +00:00
|
|
|
recursive_mutex listLock;
|
2012-12-29 01:10:29 +00:00
|
|
|
|
2013-08-08 06:59:32 +00:00
|
|
|
std::deque<GPUEvent> events;
|
|
|
|
recursive_mutex eventsLock;
|
2013-08-09 06:22:05 +00:00
|
|
|
recursive_mutex eventsWaitLock;
|
|
|
|
recursive_mutex eventsDrainLock;
|
|
|
|
condition_variable eventsWait;
|
|
|
|
condition_variable eventsDrain;
|
2013-08-08 06:59:32 +00:00
|
|
|
|
2013-02-03 23:41:16 +00:00
|
|
|
bool interruptRunning;
|
2013-04-04 08:07:30 +00:00
|
|
|
GPUState gpuState;
|
2013-04-04 07:35:38 +00:00
|
|
|
bool isbreak;
|
2013-04-07 19:45:42 +00:00
|
|
|
u64 drawCompleteTicks;
|
2013-04-09 07:56:04 +00:00
|
|
|
u64 busyTicks;
|
2012-12-29 01:10:29 +00:00
|
|
|
|
2013-04-28 21:23:30 +00:00
|
|
|
int downcount;
|
2013-04-03 15:10:35 +00:00
|
|
|
u64 startingTicks;
|
|
|
|
u32 cycleLastPC;
|
|
|
|
int cyclesExecuted;
|
|
|
|
|
2012-12-29 01:10:29 +00:00
|
|
|
bool dumpNextFrame_;
|
|
|
|
bool dumpThisFrame_;
|
2013-04-01 06:02:46 +00:00
|
|
|
bool interruptsEnabled_;
|
2013-02-03 23:41:16 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual DisplayList* getList(int listid)
|
|
|
|
{
|
2013-04-05 06:19:28 +00:00
|
|
|
return &dls[listid];
|
2013-02-03 23:41:16 +00:00
|
|
|
}
|
2013-02-10 15:36:06 +00:00
|
|
|
|
2013-04-05 06:19:28 +00:00
|
|
|
const std::list<int>& GetDisplayLists()
|
2013-02-10 15:36:06 +00:00
|
|
|
{
|
|
|
|
return dlQueue;
|
|
|
|
}
|
|
|
|
DisplayList* GetCurrentDisplayList()
|
|
|
|
{
|
|
|
|
return currentList;
|
|
|
|
}
|
2013-02-17 00:06:06 +00:00
|
|
|
virtual bool DecodeTexture(u8* dest, GPUgstate state)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
std::vector<FramebufferInfo> GetFramebufferList()
|
|
|
|
{
|
|
|
|
return std::vector<FramebufferInfo>();
|
|
|
|
}
|
|
|
|
|
2013-02-03 23:41:16 +00:00
|
|
|
};
|