2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2011 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:09:55 +00:00
|
|
|
// 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
|
|
|
|
{
|
2015-07-02 16:18:32 +00:00
|
|
|
FIELD_ODD = 0,
|
|
|
|
FIELD_EVEN = 1,
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
2015-06-03 21:21:46 +00:00
|
|
|
virtual int Video_Sync(int ticks) = 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
|
|
|
|
2015-06-03 21:21:46 +00:00
|
|
|
int Video_Sync(int ticks) 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();
|
2011-01-31 01:28:32 +00:00
|
|
|
};
|