Merge branch 'master' of https://code.google.com/p/dolphin-emu into dx9-ssaa-fix

This commit is contained in:
Rodolfo Bogado
2013-08-15 00:21:28 -03:00
43 changed files with 434 additions and 239 deletions

View File

@ -153,7 +153,10 @@ void BPWritten(const BPCmd& bp)
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans,
bpmem.genMode.multisampling, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode,
bpmem.genMode.numindstages, bpmem.genMode.zfreeze);
SetGenerationMode();
// Only call SetGenerationMode when cull mode changes.
if (bp.changes & 0xC000)
SetGenerationMode();
break;
}
case BPMEM_IND_MTXA: // Index Matrix Changed

View File

@ -1,3 +1,9 @@
#include "PerfQueryBase.h"
#include "VideoConfig.h"
PerfQueryBase* g_perf_query = 0;
bool PerfQueryBase::ShouldEmulate() const
{
return g_ActiveConfig.bPerfQueriesEnable;
}

View File

@ -25,9 +25,12 @@ enum PerfQueryGroup
class PerfQueryBase
{
public:
PerfQueryBase() {};
PerfQueryBase() {}
virtual ~PerfQueryBase() {}
// Checks if performance queries are enabled in the gameini configuration.
bool ShouldEmulate() const;
// Begin querying the specified value for the following host GPU commands
virtual void EnableQuery(PerfQueryGroup type) {}

View File

@ -92,8 +92,6 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
_assert_(bpmem.genMode.numtexgens == xfregs.numTexGen.numTexGens);
_assert_(bpmem.genMode.numcolchans == xfregs.numChan.numColorChans);
bool is_d3d = (api_type & API_D3D9 || api_type == API_D3D11);
// uniforms
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
out.Write("layout(std140) uniform VSBlock {\n");
@ -177,19 +175,9 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
if (components & VB_HAS_NRM0)
out.Write(" float3 rawnorm0 : NORMAL0,\n");
if (components & VB_HAS_NRM1)
{
if (is_d3d)
out.Write(" float3 rawnorm1 : NORMAL1,\n");
else
out.Write(" float3 rawnorm1 : ATTR%d,\n", SHADER_NORM1_ATTRIB);
}
out.Write(" float3 rawnorm1 : NORMAL1,\n");
if (components & VB_HAS_NRM2)
{
if (is_d3d)
out.Write(" float3 rawnorm2 : NORMAL2,\n");
else
out.Write(" float3 rawnorm2 : ATTR%d,\n", SHADER_NORM2_ATTRIB);
}
out.Write(" float3 rawnorm2 : NORMAL2,\n");
if (components & VB_HAS_COL0)
out.Write(" float4 color0 : COLOR0,\n");
if (components & VB_HAS_COL1)
@ -201,12 +189,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
out.Write(" float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i);
}
if (components & VB_HAS_POSMTXIDX)
{
if (is_d3d)
out.Write(" float4 blend_indices : BLENDINDICES,\n");
else
out.Write(" float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
}
out.Write(" float4 blend_indices : BLENDINDICES,\n");
out.Write(" float4 rawpos : POSITION) {\n");
}
out.Write("VS_OUTPUT o;\n");
@ -471,7 +454,7 @@ static inline void GenerateVertexShader(T& out, u32 components, API_TYPE api_typ
//write the true depth value, if the game uses depth textures pixel shaders will override with the correct values
//if not early z culling will improve speed
if (is_d3d)
if (api_type & API_D3D9 || api_type == API_D3D11)
{
out.Write("o.pos.z = " I_DEPTHPARAMS".x * o.pos.w + o.pos.z * " I_DEPTHPARAMS".y;\n");
}

View File

@ -0,0 +1,82 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "VideoBackendBase.h"
// TODO: ugly
#ifdef _WIN32
#include "../../../Plugins/Plugin_VideoDX9/Src/VideoBackend.h"
#include "../../../Plugins/Plugin_VideoDX11/Src/VideoBackend.h"
#endif
#if !defined(USE_GLES) || USE_GLES3
#include "../../../Plugins/Plugin_VideoOGL/Src/VideoBackend.h"
#endif
#include "../../../Plugins/Plugin_VideoSoftware/Src/VideoBackend.h"
std::vector<VideoBackend*> g_available_video_backends;
VideoBackend* g_video_backend = NULL;
static VideoBackend* s_default_backend = NULL;
#ifdef _WIN32
#include <windows.h>
// http://msdn.microsoft.com/en-us/library/ms725491.aspx
static bool IsGteVista()
{
OSVERSIONINFOEX osvi;
DWORDLONG dwlConditionMask = 0;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
osvi.dwMajorVersion = 6;
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
return VerifyVersionInfo(&osvi, VER_MAJORVERSION, dwlConditionMask) != FALSE;
}
#endif
void VideoBackend::PopulateList()
{
VideoBackend* backends[4] = { NULL };
// D3D11 > OGL > D3D9 > SW
#ifdef _WIN32
g_available_video_backends.push_back(backends[2] = new DX9::VideoBackend);
if (IsGteVista())
g_available_video_backends.push_back(backends[0] = new DX11::VideoBackend);
#endif
#if !defined(USE_GLES) || USE_GLES3
g_available_video_backends.push_back(backends[1] = new OGL::VideoBackend);
#endif
g_available_video_backends.push_back(backends[3] = new SW::VideoSoftware);
for (int i = 0; i < 4; ++i)
{
if (backends[i])
{
s_default_backend = g_video_backend = backends[i];
break;
}
}
}
void VideoBackend::ClearList()
{
while (!g_available_video_backends.empty())
{
delete g_available_video_backends.back();
g_available_video_backends.pop_back();
}
}
void VideoBackend::ActivateBackend(const std::string& name)
{
if (name.length() == 0) // If NULL, set it to the default backend (expected behavior)
g_video_backend = s_default_backend;
for (std::vector<VideoBackend*>::const_iterator it = g_available_video_backends.begin(); it != g_available_video_backends.end(); ++it)
if (name == (*it)->GetName())
g_video_backend = *it;
}

View File

@ -0,0 +1,185 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#ifndef VIDEO_BACKEND_H_
#define VIDEO_BACKEND_H_
#include <string>
#include <vector>
#include "ChunkFile.h"
#include "../../VideoCommon/Src/PerfQueryBase.h"
typedef void (*writeFn16)(const u16,const u32);
typedef void (*writeFn32)(const u32,const u32);
typedef void (*readFn16)(u16&, const u32);
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;
volatile u32 SafeCPReadPointer;
// 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;
volatile u32 bFF_GPLinkEnable;
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
volatile u32 isGpuReadingData;
};
class VideoBackend
{
public:
virtual ~VideoBackend() {}
virtual void EmuStateChange(EMUSTATE_CHANGE) = 0;
virtual void UpdateFPSDisplay(const char*) = 0;
virtual unsigned int PeekMessages() = 0;
virtual bool Initialize(void *&) = 0;
virtual void Shutdown() = 0;
virtual void RunLoop(bool enable) = 0;
virtual std::string GetName() = 0;
virtual std::string GetDisplayName() { return GetName(); }
virtual void ShowConfig(void*) {}
virtual void Video_Prepare() = 0;
virtual void Video_EnterLoop() = 0;
virtual void Video_ExitLoop() = 0;
virtual void Video_Cleanup() = 0; // called from gl/d3d thread
virtual void Video_BeginField(u32, FieldType, u32, u32) = 0;
virtual void Video_EndField() = 0;
virtual u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) = 0;
virtual u32 Video_GetQueryResult(PerfQueryType type) = 0;
virtual void Video_AddMessage(const char* pstr, unsigned int milliseconds) = 0;
virtual void Video_ClearMessages() = 0;
virtual bool Video_Screenshot(const char* filename) = 0;
virtual void Video_SetRendering(bool bEnabled) = 0;
virtual void Video_GatherPipeBursted() = 0;
virtual bool Video_IsPossibleWaitingSetDrawDone() = 0;
virtual bool Video_IsHiWatermarkActive() = 0;
virtual void Video_AbortFrame() = 0;
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;
static void PopulateList();
static void ClearList();
static void ActivateBackend(const std::string& name);
// 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;
virtual void CheckInvalidState() = 0;
};
extern std::vector<VideoBackend*> g_available_video_backends;
extern VideoBackend* g_video_backend;
// inherited by dx9/dx11/ogl backends
class VideoBackendHardware : public VideoBackend
{
void RunLoop(bool enable);
bool Initialize(void *&) { InitializeShared(); return true; }
void EmuStateChange(EMUSTATE_CHANGE);
void Video_EnterLoop();
void Video_ExitLoop();
void Video_BeginField(u32, FieldType, u32, u32);
void Video_EndField();
u32 Video_AccessEFB(EFBAccessType, u32, u32, u32);
u32 Video_GetQueryResult(PerfQueryType type);
void Video_AddMessage(const char* pstr, unsigned int milliseconds);
void Video_ClearMessages();
bool Video_Screenshot(const char* filename);
void Video_SetRendering(bool bEnabled);
void Video_GatherPipeBursted();
bool Video_IsPossibleWaitingSetDrawDone();
bool Video_IsHiWatermarkActive();
void Video_AbortFrame();
readFn16 Video_CPRead16();
writeFn16 Video_CPWrite16();
readFn16 Video_PERead16();
writeFn16 Video_PEWrite16();
writeFn32 Video_PEWrite32();
void PauseAndLock(bool doLock, bool unpauseOnUnlock=true);
void DoState(PointerWrap &p);
bool m_invalid;
public:
void CheckInvalidState();
protected:
void InitializeShared();
void InvalidState();
};
#endif

View File

@ -182,6 +182,7 @@ void VideoConfig::GameIniLoad(const char *ini_file)
iniFile.GetIfExists("Video", "PH_ZFar", &sPhackvalue[1]);
iniFile.GetIfExists("Video", "ZTPSpeedupHack", &bZTPSpeedHack);
iniFile.GetIfExists("Video", "UseBBox", &bUseBBox);
iniFile.GetIfExists("Video", "PerfQueriesEnable", &bPerfQueriesEnable);
}
void VideoConfig::VerifyValidity()

View File

@ -108,6 +108,7 @@ struct VideoConfig
// Hacks
bool bEFBAccessEnable;
bool bDlistCachingEnable;
bool bPerfQueriesEnable;
bool bEFBCopyEnable;
bool bEFBCopyCacheEnable;