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
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/ChunkFile.h"
|
|
|
|
#include "VideoCommon/PerfQueryBase.h"
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-02-02 13:16:43 +00:00
|
|
|
namespace MMIO { class Mapping; }
|
|
|
|
|
2011-03-16 22:48:17 +00:00
|
|
|
|
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 bFF_LoWatermarkInt;
|
|
|
|
volatile u32 bFF_HiWatermarkInt;
|
|
|
|
|
|
|
|
volatile u32 bFF_LoWatermark;
|
|
|
|
volatile u32 bFF_HiWatermark;
|
|
|
|
|
|
|
|
// for GP watchdog hack
|
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 unsigned int PeekMessages() = 0;
|
|
|
|
|
2014-08-06 04:44:21 +00:00
|
|
|
virtual bool Initialize(void *window_handle) = 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
|
|
|
|
2014-03-11 05:55:00 +00:00
|
|
|
virtual std::string GetName() const = 0;
|
|
|
|
virtual std::string GetDisplayName() const { return GetName(); }
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-06-16 21:03:29 +00:00
|
|
|
virtual void ShowConfig(void*) = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2014-05-02 07:08:44 +00:00
|
|
|
virtual void Video_BeginField(u32, 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;
|
2014-11-13 22:26:49 +00:00
|
|
|
virtual u16 Video_GetBoundingBox(int index) = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
virtual void Video_AddMessage(const std::string& msg, unsigned int milliseconds) = 0;
|
2011-02-02 04:40:27 +00:00
|
|
|
virtual void Video_ClearMessages() = 0;
|
2014-03-12 19:33:41 +00:00
|
|
|
virtual bool Video_Screenshot(const std::string& filename) = 0;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
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;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-02-02 13:16:43 +00:00
|
|
|
// Registers MMIO handlers for the CommandProcessor registers.
|
|
|
|
virtual void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) = 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).
|
2015-02-15 19:43:31 +00:00
|
|
|
virtual void PauseAndLock(bool doLock, bool unpauseOnUnlock = true) = 0;
|
2011-12-31 04:16:12 +00:00
|
|
|
|
|
|
|
// 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 16:09:39 +00:00
|
|
|
|
2012-12-23 12:32:23 +00:00
|
|
|
virtual void CheckInvalidState() = 0;
|
2014-09-06 21:26:40 +00:00
|
|
|
|
|
|
|
virtual void UpdateWantDeterminism(bool want) {}
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern std::vector<VideoBackend*> g_available_video_backends;
|
|
|
|
extern VideoBackend* g_video_backend;
|
|
|
|
|
2013-09-22 16:09:39 +00:00
|
|
|
// inherited by D3D/OGL backends
|
2011-03-16 22:48:17 +00:00
|
|
|
class VideoBackendHardware : public VideoBackend
|
2011-01-31 01:28:32 +00:00
|
|
|
{
|
2014-03-08 00:54:44 +00:00
|
|
|
void RunLoop(bool enable) override;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-03-08 00:54:44 +00:00
|
|
|
void EmuStateChange(EMUSTATE_CHANGE) override;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-03-08 00:54:44 +00:00
|
|
|
void Video_EnterLoop() override;
|
|
|
|
void Video_ExitLoop() override;
|
2014-05-02 07:08:44 +00:00
|
|
|
void Video_BeginField(u32, u32, u32, u32) override;
|
2014-03-08 00:54:44 +00:00
|
|
|
void Video_EndField() override;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-03-08 00:54:44 +00:00
|
|
|
u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) override;
|
|
|
|
u32 Video_GetQueryResult(PerfQueryType type) override;
|
2014-11-13 22:26:49 +00:00
|
|
|
u16 Video_GetBoundingBox(int index) override;
|
2013-09-22 16:09:39 +00:00
|
|
|
|
2014-03-12 19:33:41 +00:00
|
|
|
void Video_AddMessage(const std::string& pstr, unsigned int milliseconds) override;
|
2014-03-08 00:54:44 +00:00
|
|
|
void Video_ClearMessages() override;
|
2014-03-12 19:33:41 +00:00
|
|
|
bool Video_Screenshot(const std::string& filename) override;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-03-08 00:54:44 +00:00
|
|
|
void Video_SetRendering(bool bEnabled) override;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-03-08 00:54:44 +00:00
|
|
|
void Video_GatherPipeBursted() override;
|
2011-03-16 22:48:17 +00:00
|
|
|
|
2014-03-08 00:54:44 +00:00
|
|
|
bool Video_IsPossibleWaitingSetDrawDone() override;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2014-02-02 13:16:43 +00:00
|
|
|
void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) override;
|
|
|
|
|
2015-02-15 19:43:31 +00:00
|
|
|
void PauseAndLock(bool doLock, bool unpauseOnUnlock = true) override;
|
2014-03-08 00:54:44 +00:00
|
|
|
void DoState(PointerWrap &p) override;
|
2013-09-22 16:09:39 +00:00
|
|
|
|
2014-09-06 21:26:40 +00:00
|
|
|
void UpdateWantDeterminism(bool want) override;
|
|
|
|
|
2012-12-23 12:32:23 +00:00
|
|
|
bool m_invalid;
|
2013-09-22 16:09:39 +00:00
|
|
|
|
2012-12-23 12:32:23 +00:00
|
|
|
public:
|
2015-02-15 19:43:31 +00:00
|
|
|
void CheckInvalidState() override;
|
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
|
|
|
};
|