2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
#ifndef VIDEO_BACKEND_H_
|
|
|
|
#define VIDEO_BACKEND_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "ChunkFile.h"
|
2013-03-01 00:14:10 +00:00
|
|
|
#include "../../VideoCommon/Src/PerfQueryBase.h"
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2011-03-16 22:48:17 +00:00
|
|
|
typedef void (*writeFn16)(const u16,const u32);
|
|
|
|
typedef void (*writeFn32)(const u32,const u32);
|
|
|
|
typedef void (*readFn16)(u16&, const u32);
|
|
|
|
|
|
|
|
|
2011-01-31 01:28:32 +00: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 15:08:37 +00:00
|
|
|
volatile u32 SafeCPReadPointer;
|
2011-01-31 01:28:32 +00: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-10 04:47:02 +00:00
|
|
|
volatile u32 bFF_GPLinkEnable;
|
2011-01-31 01:28:32 +00:00
|
|
|
volatile u32 bFF_GPReadEnable;
|
|
|
|
volatile u32 bFF_BPEnable;
|
|
|
|
volatile u32 bFF_BPInt;
|
|
|
|
volatile u32 bFF_Breakpoint;
|
|
|
|
|
|
|
|
volatile u32 CPCmdIdle;
|
|
|
|
volatile u32 CPReadIdle;
|
|
|
|
|
|
|
|
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-17 04:25:21 +00:00
|
|
|
volatile u32 isGpuReadingData;
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class VideoBackend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~VideoBackend() {}
|
|
|
|
|
2011-02-02 04:40:27 +00:00
|
|
|
virtual void EmuStateChange(EMUSTATE_CHANGE) = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
virtual void UpdateFPSDisplay(const char*) = 0;
|
|
|
|
|
|
|
|
virtual unsigned int PeekMessages() = 0;
|
|
|
|
|
2011-02-25 21:14:13 +00:00
|
|
|
virtual bool Initialize(void *&) = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
virtual void Shutdown() = 0;
|
2011-02-08 10:37:47 +00:00
|
|
|
virtual void RunLoop(bool enable) = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
virtual std::string GetName() = 0;
|
2013-03-20 23:14:14 +00:00
|
|
|
virtual std::string GetDisplayName() { return GetName(); }
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
virtual void ShowConfig(void*) {}
|
|
|
|
|
|
|
|
virtual void Video_Prepare() = 0;
|
|
|
|
virtual void Video_EnterLoop() = 0;
|
|
|
|
virtual void Video_ExitLoop() = 0;
|
2013-02-26 15:42:32 +00:00
|
|
|
virtual void Video_Cleanup() = 0; // called from gl/d3d thread
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2013-09-23 06:29:31 +00:00
|
|
|
virtual void Video_BeginField(u32, u32, u32) = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
virtual void Video_EndField() = 0;
|
|
|
|
|
|
|
|
virtual u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) = 0;
|
2013-02-16 23:50:40 +00:00
|
|
|
virtual u32 Video_GetQueryResult(PerfQueryType type) = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
virtual void Video_AddMessage(const char* pstr, unsigned int milliseconds) = 0;
|
2011-02-02 04:40:27 +00:00
|
|
|
virtual void Video_ClearMessages() = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
virtual bool Video_Screenshot(const char* filename) = 0;
|
|
|
|
|
|
|
|
virtual void Video_SetRendering(bool bEnabled) = 0;
|
|
|
|
|
2011-03-16 22:48:17 +00:00
|
|
|
virtual void Video_GatherPipeBursted() = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2011-02-10 04:47:02 +00:00
|
|
|
virtual bool Video_IsPossibleWaitingSetDrawDone() = 0;
|
2012-03-05 05:40:10 +00:00
|
|
|
virtual bool Video_IsHiWatermarkActive() = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
virtual void Video_AbortFrame() = 0;
|
|
|
|
|
2011-03-16 22:48:17 +00: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-31 01:28:32 +00:00
|
|
|
static void PopulateList();
|
|
|
|
static void ClearList();
|
|
|
|
static void ActivateBackend(const std::string& name);
|
2011-12-31 04:16:12 +00: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;
|
2012-12-23 12:32:23 +00:00
|
|
|
|
|
|
|
virtual void CheckInvalidState() = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern std::vector<VideoBackend*> g_available_video_backends;
|
|
|
|
extern VideoBackend* g_video_backend;
|
|
|
|
|
|
|
|
// inherited by dx9/dx11/ogl backends
|
2011-03-16 22:48:17 +00:00
|
|
|
class VideoBackendHardware : public VideoBackend
|
2011-01-31 01:28:32 +00:00
|
|
|
{
|
2011-02-08 10:37:47 +00:00
|
|
|
void RunLoop(bool enable);
|
2012-01-02 10:20:22 +00:00
|
|
|
bool Initialize(void *&) { InitializeShared(); return true; }
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2011-02-02 04:40:27 +00:00
|
|
|
void EmuStateChange(EMUSTATE_CHANGE);
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
void Video_EnterLoop();
|
|
|
|
void Video_ExitLoop();
|
2013-09-23 06:29:31 +00:00
|
|
|
void Video_BeginField(u32, u32, u32);
|
2011-01-31 01:28:32 +00:00
|
|
|
void Video_EndField();
|
|
|
|
|
2013-02-16 23:50:40 +00:00
|
|
|
u32 Video_AccessEFB(EFBAccessType, u32, u32, u32);
|
|
|
|
u32 Video_GetQueryResult(PerfQueryType type);
|
|
|
|
|
2011-01-31 01:28:32 +00:00
|
|
|
void Video_AddMessage(const char* pstr, unsigned int milliseconds);
|
2011-02-02 04:40:27 +00:00
|
|
|
void Video_ClearMessages();
|
2011-01-31 01:28:32 +00:00
|
|
|
bool Video_Screenshot(const char* filename);
|
|
|
|
|
|
|
|
void Video_SetRendering(bool bEnabled);
|
|
|
|
|
2011-03-16 22:48:17 +00:00
|
|
|
void Video_GatherPipeBursted();
|
|
|
|
|
2011-02-10 04:47:02 +00:00
|
|
|
bool Video_IsPossibleWaitingSetDrawDone();
|
2012-03-05 05:40:10 +00:00
|
|
|
bool Video_IsHiWatermarkActive();
|
2011-01-31 01:28:32 +00:00
|
|
|
void Video_AbortFrame();
|
|
|
|
|
2011-03-16 22:48:17 +00:00
|
|
|
readFn16 Video_CPRead16();
|
|
|
|
writeFn16 Video_CPWrite16();
|
|
|
|
readFn16 Video_PERead16();
|
|
|
|
writeFn16 Video_PEWrite16();
|
|
|
|
writeFn32 Video_PEWrite32();
|
2012-01-02 10:20:22 +00:00
|
|
|
|
2011-12-31 04:16:12 +00:00
|
|
|
void PauseAndLock(bool doLock, bool unpauseOnUnlock=true);
|
|
|
|
void DoState(PointerWrap &p);
|
2012-12-23 12:32:23 +00:00
|
|
|
|
|
|
|
bool m_invalid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void CheckInvalidState();
|
2011-12-31 04:16:12 +00:00
|
|
|
|
2012-01-02 10:20:22 +00:00
|
|
|
protected:
|
|
|
|
void InitializeShared();
|
2012-12-23 12:32:23 +00:00
|
|
|
void InvalidState();
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|