2013-04-17 21:09:55 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2011-01-30 18:28:32 -07:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2011-01-30 18:28:32 -07:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "ChunkFile.h"
|
2013-12-07 13:14:29 -07:00
|
|
|
#include "../VideoCommon/PerfQueryBase.h"
|
2011-01-30 18:28:32 -07:00
|
|
|
|
2011-03-16 16:48:17 -06:00
|
|
|
typedef void (*writeFn16)(const u16,const u32);
|
|
|
|
typedef void (*writeFn32)(const u32,const u32);
|
|
|
|
typedef void (*readFn16)(u16&, const u32);
|
|
|
|
|
|
|
|
|
2011-01-30 18:28:32 -07:00
|
|
|
enum FieldType
|
|
|
|
{
|
|
|
|
FIELD_PROGRESSIVE = 0,
|
|
|
|
FIELD_UPPER,
|
|
|
|
FIELD_LOWER
|
|
|
|
};
|
|
|
|
|
|
|
|
enum EFBAccessType
|
|
|
|
{
|
|
|
|
PEEK_Z = 0,
|
|
|
|
POKE_Z,
|
|
|
|
PEEK_COLOR,
|
|
|
|
POKE_COLOR
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCPFifoStruct
|
|
|
|
{
|
|
|
|
// fifo registers
|
|
|
|
volatile u32 CPBase;
|
|
|
|
volatile u32 CPEnd;
|
|
|
|
u32 CPHiWatermark;
|
|
|
|
u32 CPLoWatermark;
|
|
|
|
volatile u32 CPReadWriteDistance;
|
|
|
|
volatile u32 CPWritePointer;
|
|
|
|
volatile u32 CPReadPointer;
|
|
|
|
volatile u32 CPBreakpoint;
|
2011-02-13 08:08:37 -07:00
|
|
|
volatile u32 SafeCPReadPointer;
|
2011-01-30 18:28:32 -07:00
|
|
|
// Super Monkey Ball Adventure require this.
|
|
|
|
// Because the read&check-PEToken-loop stays in its JITed block I suppose.
|
|
|
|
// So no possiblity to ack the Token irq by the scheduler until some sort of PPC watchdog do its mess.
|
|
|
|
volatile u16 PEToken;
|
|
|
|
|
2011-02-09 21:47:02 -07:00
|
|
|
volatile u32 bFF_GPLinkEnable;
|
2011-01-30 18:28:32 -07:00
|
|
|
volatile u32 bFF_GPReadEnable;
|
|
|
|
volatile u32 bFF_BPEnable;
|
|
|
|
volatile u32 bFF_BPInt;
|
|
|
|
volatile u32 bFF_Breakpoint;
|
|
|
|
|
|
|
|
volatile u32 CPCmdIdle;
|
2013-10-28 23:23:17 -06:00
|
|
|
volatile u32 CPReadIdle;
|
2011-01-30 18:28:32 -07:00
|
|
|
|
|
|
|
volatile u32 bFF_LoWatermarkInt;
|
|
|
|
volatile u32 bFF_HiWatermarkInt;
|
|
|
|
|
|
|
|
volatile u32 bFF_LoWatermark;
|
|
|
|
volatile u32 bFF_HiWatermark;
|
|
|
|
|
|
|
|
// for GP watchdog hack
|
|
|
|
volatile u32 Fake_GPWDToken; // cicular incrementer
|
Big Fifo Commit Part2: Now the fifo is more stable than my first commit, so is time...
- ReImplementing Single Core Mode like Dual Core Mode Style.
- Stage 1: My goal is, we have the Fifo, CommandProccessor code the more clear, maintenible and documented possible. When I quit dolphin I want any developer can continue with the work only reading the code.
* Big Refactoring: A lot of functions was changed the names, and modularized.
Now the FifoLoop and CatchUpGPU does not exist, was replaced by RunGpu() and RunGpuLoop().
The general idea is modeling the code like the real HW. The fifo is only a buffer where the Write Gather Pipe write the commands and from the Graphic Processor read these.
* Big Clean UP a lot of obsolete code and comments was deleted, like DcFakeWachDog, "Fifo very soon hack", etc.
In the stage 2, I will refactoring more code doing emphasis in the division of CommandProcessor, Fifo, Gpu Emulation. Beside I will comment all functions and variables in the code (Don't worry I will ask for English help for this part ;) )
Please test a lot SC mode and DC mode :)
Thank you so much for testing always and the patience. I don't like broke your favorite game but... you must believe me this part is very sensible, I only try to contribute for have a better and stable dolphin emulator.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7185 8ced0084-cf51-0410-be5f-012b33b47a6e
2011-02-16 21:25:21 -07:00
|
|
|
volatile u32 isGpuReadingData;
|
2011-01-30 18:28:32 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class VideoBackend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~VideoBackend() {}
|
|
|
|
|
2011-02-01 21:40:27 -07:00
|
|
|
virtual void EmuStateChange(EMUSTATE_CHANGE) = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
|
|
|
|
virtual void UpdateFPSDisplay(const char*) = 0;
|
|
|
|
|
|
|
|
virtual unsigned int PeekMessages() = 0;
|
|
|
|
|
2011-02-25 14:14:13 -07:00
|
|
|
virtual bool Initialize(void *&) = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
virtual void Shutdown() = 0;
|
2011-02-08 03:37:47 -07:00
|
|
|
virtual void RunLoop(bool enable) = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
|
|
|
|
virtual std::string GetName() = 0;
|
2013-03-20 17:14:14 -06:00
|
|
|
virtual std::string GetDisplayName() { return GetName(); }
|
2011-01-30 18:28:32 -07:00
|
|
|
|
|
|
|
virtual void ShowConfig(void*) {}
|
|
|
|
|
|
|
|
virtual void Video_Prepare() = 0;
|
|
|
|
virtual void Video_EnterLoop() = 0;
|
|
|
|
virtual void Video_ExitLoop() = 0;
|
2013-02-26 08:42:32 -07:00
|
|
|
virtual void Video_Cleanup() = 0; // called from gl/d3d thread
|
2011-01-30 18:28:32 -07:00
|
|
|
|
2013-09-23 00:29:31 -06:00
|
|
|
virtual void Video_BeginField(u32, u32, u32) = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
virtual void Video_EndField() = 0;
|
|
|
|
|
|
|
|
virtual u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) = 0;
|
2013-02-16 16:50:40 -07:00
|
|
|
virtual u32 Video_GetQueryResult(PerfQueryType type) = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
|
|
|
|
virtual void Video_AddMessage(const char* pstr, unsigned int milliseconds) = 0;
|
2011-02-01 21:40:27 -07:00
|
|
|
virtual void Video_ClearMessages() = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
virtual bool Video_Screenshot(const char* filename) = 0;
|
|
|
|
|
|
|
|
virtual void Video_SetRendering(bool bEnabled) = 0;
|
|
|
|
|
2011-03-16 16:48:17 -06:00
|
|
|
virtual void Video_GatherPipeBursted() = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
|
2011-02-09 21:47:02 -07:00
|
|
|
virtual bool Video_IsPossibleWaitingSetDrawDone() = 0;
|
2012-03-04 22:40:10 -07:00
|
|
|
virtual bool Video_IsHiWatermarkActive() = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
virtual void Video_AbortFrame() = 0;
|
|
|
|
|
2011-03-16 16:48:17 -06:00
|
|
|
virtual readFn16 Video_CPRead16() = 0;
|
|
|
|
virtual writeFn16 Video_CPWrite16() = 0;
|
|
|
|
virtual readFn16 Video_PERead16() = 0;
|
|
|
|
virtual writeFn16 Video_PEWrite16() = 0;
|
|
|
|
virtual writeFn32 Video_PEWrite32() = 0;
|
|
|
|
|
2011-01-30 18:28:32 -07:00
|
|
|
static void PopulateList();
|
|
|
|
static void ClearList();
|
|
|
|
static void ActivateBackend(const std::string& name);
|
2011-12-30 21:16:12 -07:00
|
|
|
|
|
|
|
// waits until is paused and fully idle, and acquires a lock on that state.
|
|
|
|
// or, if doLock is false, releases a lock on that state and optionally unpauses.
|
|
|
|
// calls must be balanced and non-recursive (once with doLock true, then once with doLock false).
|
|
|
|
virtual void PauseAndLock(bool doLock, bool unpauseOnUnlock=true) = 0;
|
|
|
|
|
|
|
|
// the implementation needs not do synchronization logic, because calls to it are surrounded by PauseAndLock now
|
|
|
|
virtual void DoState(PointerWrap &p) = 0;
|
2013-09-22 10:09:39 -06:00
|
|
|
|
2012-12-23 05:32:23 -07:00
|
|
|
virtual void CheckInvalidState() = 0;
|
2011-01-30 18:28:32 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
extern std::vector<VideoBackend*> g_available_video_backends;
|
|
|
|
extern VideoBackend* g_video_backend;
|
|
|
|
|
2013-09-22 10:09:39 -06:00
|
|
|
// inherited by D3D/OGL backends
|
2011-03-16 16:48:17 -06:00
|
|
|
class VideoBackendHardware : public VideoBackend
|
2011-01-30 18:28:32 -07:00
|
|
|
{
|
2011-02-08 03:37:47 -07:00
|
|
|
void RunLoop(bool enable);
|
2012-01-02 03:20:22 -07:00
|
|
|
bool Initialize(void *&) { InitializeShared(); return true; }
|
2011-01-30 18:28:32 -07:00
|
|
|
|
2011-02-01 21:40:27 -07:00
|
|
|
void EmuStateChange(EMUSTATE_CHANGE);
|
2011-01-30 18:28:32 -07:00
|
|
|
|
|
|
|
void Video_EnterLoop();
|
|
|
|
void Video_ExitLoop();
|
2013-09-23 00:29:31 -06:00
|
|
|
void Video_BeginField(u32, u32, u32);
|
2011-01-30 18:28:32 -07:00
|
|
|
void Video_EndField();
|
|
|
|
|
2013-02-16 16:50:40 -07:00
|
|
|
u32 Video_AccessEFB(EFBAccessType, u32, u32, u32);
|
|
|
|
u32 Video_GetQueryResult(PerfQueryType type);
|
2013-09-22 10:09:39 -06:00
|
|
|
|
2011-01-30 18:28:32 -07:00
|
|
|
void Video_AddMessage(const char* pstr, unsigned int milliseconds);
|
2011-02-01 21:40:27 -07:00
|
|
|
void Video_ClearMessages();
|
2011-01-30 18:28:32 -07:00
|
|
|
bool Video_Screenshot(const char* filename);
|
|
|
|
|
|
|
|
void Video_SetRendering(bool bEnabled);
|
|
|
|
|
2011-03-16 16:48:17 -06:00
|
|
|
void Video_GatherPipeBursted();
|
|
|
|
|
2011-02-09 21:47:02 -07:00
|
|
|
bool Video_IsPossibleWaitingSetDrawDone();
|
2012-03-04 22:40:10 -07:00
|
|
|
bool Video_IsHiWatermarkActive();
|
2011-01-30 18:28:32 -07:00
|
|
|
void Video_AbortFrame();
|
|
|
|
|
2011-03-16 16:48:17 -06:00
|
|
|
readFn16 Video_CPRead16();
|
|
|
|
writeFn16 Video_CPWrite16();
|
|
|
|
readFn16 Video_PERead16();
|
|
|
|
writeFn16 Video_PEWrite16();
|
|
|
|
writeFn32 Video_PEWrite32();
|
2012-01-02 03:20:22 -07:00
|
|
|
|
2011-12-30 21:16:12 -07:00
|
|
|
void PauseAndLock(bool doLock, bool unpauseOnUnlock=true);
|
|
|
|
void DoState(PointerWrap &p);
|
2013-09-22 10:09:39 -06:00
|
|
|
|
2012-12-23 05:32:23 -07:00
|
|
|
bool m_invalid;
|
2013-09-22 10:09:39 -06:00
|
|
|
|
2012-12-23 05:32:23 -07:00
|
|
|
public:
|
|
|
|
void CheckInvalidState();
|
2011-12-30 21:16:12 -07:00
|
|
|
|
2012-01-02 03:20:22 -07:00
|
|
|
protected:
|
|
|
|
void InitializeShared();
|
2012-12-23 05:32:23 -07:00
|
|
|
void InvalidState();
|
2011-01-30 18:28:32 -07:00
|
|
|
};
|