Merge branch 'master' into windows-unicode

This commit is contained in:
Jordan Woyak
2013-03-02 15:33:32 -06:00
64 changed files with 1083 additions and 183 deletions

View File

@ -62,7 +62,7 @@
#define BPMEM_COPYFILTER1 0x54
#define BPMEM_CLEARBBOX1 0x55
#define BPMEM_CLEARBBOX2 0x56
#define BPMEM_UNKNOWN_57 0x57
#define BPMEM_CLEAR_PIXEL_PERF 0x57
#define BPMEM_REVBITS 0x58
#define BPMEM_SCISSOROFFSET 0x59
#define BPMEM_PRELOAD_ADDR 0x60

View File

@ -31,6 +31,7 @@
#include "VertexShaderManager.h"
#include "Thread.h"
#include "HW/Memmap.h"
#include "PerfQueryBase.h"
using namespace BPFunctions;
@ -62,7 +63,6 @@ void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xf
{
Renderer::RenderToXFB(xfbAddr, dstWidth, dstHeight, rc, gamma);
}
void BPWritten(const BPCmd& bp)
{
/*
@ -144,7 +144,8 @@ void BPWritten(const BPCmd& bp)
|| bp.address == BPMEM_LOADTLUT0
|| bp.address == BPMEM_LOADTLUT1
|| bp.address == BPMEM_TEXINVALIDATE
|| bp.address == BPMEM_PRELOAD_MODE))
|| bp.address == BPMEM_PRELOAD_MODE
|| bp.address == BPMEM_CLEAR_PIXEL_PERF))
{
return;
}
@ -484,9 +485,10 @@ void BPWritten(const BPCmd& bp)
case BPMEM_IND_IMASK: // Index Mask ?
case BPMEM_REVBITS: // Always set to 0x0F when GX_InitRevBits() is called.
break;
case BPMEM_UNKNOWN_57: // Sunshine alternates this register between values 0x000 and 0xAAA
DEBUG_LOG(VIDEO, "Unknown BP Reg 0x57: %08x", bp.newvalue);
case BPMEM_CLEAR_PIXEL_PERF:
// GXClearPixMetric writes 0xAAA here, Sunshine alternates this register between values 0x000 and 0xAAA
g_perf_query->ResetQuery();
break;
case BPMEM_PRELOAD_ADDR:

View File

@ -21,6 +21,10 @@ volatile u32 s_swapRequested = false;
u32 s_efbAccessRequested = false;
volatile u32 s_FifoShuttingDown = false;
std::condition_variable s_perf_query_cond;
std::mutex s_perf_query_lock;
static volatile bool s_perf_query_requested;
static volatile struct
{
u32 xfbAddr;
@ -169,6 +173,43 @@ u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32
return 0;
}
static bool QueryResultIsReady()
{
return !s_perf_query_requested || s_FifoShuttingDown;
}
void VideoFifo_CheckPerfQueryRequest()
{
if (s_perf_query_requested)
{
g_perf_query->FlushResults();
{
std::lock_guard<std::mutex> lk(s_perf_query_lock);
s_perf_query_requested = false;
}
s_perf_query_cond.notify_one();
}
}
u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type)
{
// TODO: Is this check sane?
if (!g_perf_query->IsFlushed())
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread)
{
s_perf_query_requested = true;
std::unique_lock<std::mutex> lk(s_perf_query_lock);
s_perf_query_cond.wait(lk, QueryResultIsReady);
}
else
g_perf_query->FlushResults();
}
return g_perf_query->GetQueryResult(type);
}
void VideoBackendHardware::InitializeShared()
{
@ -176,6 +217,7 @@ void VideoBackendHardware::InitializeShared()
s_swapRequested = 0;
s_efbAccessRequested = 0;
s_perf_query_requested = false;
s_FifoShuttingDown = 0;
memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs));
memset(&s_accessEFBArgs, 0, sizeof(s_accessEFBArgs));
@ -186,6 +228,11 @@ void VideoBackendHardware::InitializeShared()
// Run from the CPU thread
void VideoBackendHardware::DoState(PointerWrap& p)
{
bool software = false;
p.Do(software);
if (p.GetMode() == PointerWrap::MODE_READ && software == true)
// change mode to abort load of incompatible save state.
p.SetMode(PointerWrap::MODE_VERIFY);
VideoCommon_DoState(p);
p.DoMarker("VideoCommon");
@ -233,6 +280,7 @@ void VideoFifo_CheckAsyncRequest()
{
VideoFifo_CheckSwapRequest();
VideoFifo_CheckEFBAccess();
VideoFifo_CheckPerfQueryRequest();
}
void VideoBackendHardware::Video_GatherPipeBursted()

View File

@ -22,7 +22,7 @@ namespace OSD
{
// On-screen message display
void AddMessage(const char* str, u32 ms);
void AddMessage(const char* str, u32 ms = 2000);
void DrawMessages(); // draw the current messages on the screen. Only call once per frame.
void ClearMessages();

View File

@ -0,0 +1,3 @@
#include "PerfQueryBase.h"
PerfQueryBase* g_perf_query = 0;

View File

@ -0,0 +1,54 @@
#ifndef _PERFQUERY_BASE_H_
#define _PERFQUERY_BASE_H_
#include "CommonTypes.h"
enum PerfQueryType
{
PQ_ZCOMP_INPUT_ZCOMPLOC = 0,
PQ_ZCOMP_OUTPUT_ZCOMPLOC,
PQ_ZCOMP_INPUT,
PQ_ZCOMP_OUTPUT,
PQ_BLEND_INPUT,
PQ_EFB_COPY_CLOCKS,
PQ_NUM_MEMBERS
};
enum PerfQueryGroup
{
PQG_ZCOMP_ZCOMPLOC,
PQG_ZCOMP,
PQG_EFB_COPY_CLOCKS,
PQG_NUM_MEMBERS,
};
class PerfQueryBase
{
public:
PerfQueryBase() {};
virtual ~PerfQueryBase() {}
// Begin querying the specified value for the following host GPU commands
virtual void EnableQuery(PerfQueryGroup type) {}
// Stop querying the specified value for the following host GPU commands
virtual void DisableQuery(PerfQueryGroup type) {}
// Reset query counters to zero and drop any pending queries
virtual void ResetQuery() {}
// Return the measured value for the specified query type
// NOTE: Called from CPU thread
virtual u32 GetQueryResult(PerfQueryType type) { return 0; }
// Request the value of any pending queries - causes a pipeline flush and thus should be used carefully!
virtual void FlushResults() {}
// True if there are no further pending query results
// NOTE: Called from CPU thread
virtual bool IsFlushed() const { return true; }
};
extern PerfQueryBase* g_perf_query;
#endif // _PERFQUERY_H_

View File

@ -28,10 +28,13 @@
#include "ConfigManager.h"
#include "PixelEngine.h"
#include "RenderBase.h"
#include "CommandProcessor.h"
#include "HW/ProcessorInterface.h"
#include "DLCache.h"
#include "State.h"
#include "PerfQueryBase.h"
namespace PixelEngine
{
@ -255,23 +258,59 @@ void Read16(u16& _uReturnValue, const u32 _iAddress)
break;
}
case PE_PERF_0L:
case PE_PERF_0H:
case PE_PERF_1L:
case PE_PERF_1H:
case PE_PERF_2L:
case PE_PERF_2H:
case PE_PERF_3L:
case PE_PERF_3H:
case PE_PERF_4L:
case PE_PERF_4H:
case PE_PERF_5L:
case PE_PERF_5H:
INFO_LOG(PIXELENGINE, "(r16) perf counter @ %08x", _iAddress);
// git r90a2096a24f4 (svn r3663) added the PE_PERF cases, without setting
// _uReturnValue to anything, this reverts to the previous behaviour which allows
// The timer in SMS:Scrubbing Serena Beach to countdown correctly
_uReturnValue = 1;
// NOTE(neobrain): only PE_PERF_ZCOMP_OUTPUT is implemented in D3D11, but the other values shouldn't be contradictionary to the value of that register (i.e. INPUT registers should always be greater or equal to their corresponding OUTPUT registers).
case PE_PERF_ZCOMP_INPUT_ZCOMPLOC_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_INPUT_ZCOMPLOC) & 0xFFFF;
break;
case PE_PERF_ZCOMP_INPUT_ZCOMPLOC_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_INPUT_ZCOMPLOC) >> 16;
break;
case PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_OUTPUT_ZCOMPLOC) & 0xFFFF;
break;
case PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_OUTPUT_ZCOMPLOC) >> 16;
break;
case PE_PERF_ZCOMP_INPUT_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_INPUT) & 0xFFFF;
break;
case PE_PERF_ZCOMP_INPUT_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_INPUT) >> 16;
break;
case PE_PERF_ZCOMP_OUTPUT_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_OUTPUT) & 0xFFFF;
break;
case PE_PERF_ZCOMP_OUTPUT_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_ZCOMP_OUTPUT) >> 16;
break;
case PE_PERF_BLEND_INPUT_L:
// Super Mario Sunshine uses this register in episode 6 of Sirena Beach:
// The amount of remaining goop is determined by checking how many pixels reach the blending stage.
// Once this register falls below a particular value (around 0x90), the game regards the challenge finished.
// In very old builds, Dolphin only returned 0. That caused the challenge to be immediately finished without any goop being cleaned (the timer just didn't even start counting from 3:00:00).
// Later builds returned 1 for the high register. That caused the timer to actually count down, but made the challenge unbeatable because the game always thought you didn't clear any goop at all.
// Note that currently this functionality is only implemented in the D3D11 backend.
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_BLEND_INPUT) & 0xFFFF;
break;
case PE_PERF_BLEND_INPUT_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_BLEND_INPUT) >> 16;
break;
case PE_PERF_EFB_COPY_CLOCKS_L:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_EFB_COPY_CLOCKS) & 0xFFFF;
break;
case PE_PERF_EFB_COPY_CLOCKS_H:
_uReturnValue = g_video_backend->Video_GetQueryResult(PQ_EFB_COPY_CLOCKS) >> 16;
break;
default:

View File

@ -36,19 +36,20 @@ enum
PE_BBOX_TOP = 0x14, // Flip Top
PE_BBOX_BOTTOM = 0x16, // Flip Bottom
// These have not yet been RE:d. They are the perf counters.
PE_PERF_0L = 0x18,
PE_PERF_0H = 0x1a,
PE_PERF_1L = 0x1c,
PE_PERF_1H = 0x1e,
PE_PERF_2L = 0x20,
PE_PERF_2H = 0x22,
PE_PERF_3L = 0x24,
PE_PERF_3H = 0x26,
PE_PERF_4L = 0x28,
PE_PERF_4H = 0x2a,
PE_PERF_5L = 0x2c,
PE_PERF_5H = 0x2e,
// NOTE: Order not verified
// These indicate the number of quads that are being used as input/output for each particular stage
PE_PERF_ZCOMP_INPUT_ZCOMPLOC_L = 0x18,
PE_PERF_ZCOMP_INPUT_ZCOMPLOC_H = 0x1a,
PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_L = 0x1c,
PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_H = 0x1e,
PE_PERF_ZCOMP_INPUT_L = 0x20,
PE_PERF_ZCOMP_INPUT_H = 0x22,
PE_PERF_ZCOMP_OUTPUT_L = 0x24,
PE_PERF_ZCOMP_OUTPUT_H = 0x26,
PE_PERF_BLEND_INPUT_L = 0x28,
PE_PERF_BLEND_INPUT_H = 0x2a,
PE_PERF_EFB_COPY_CLOCKS_L = 0x2c,
PE_PERF_EFB_COPY_CLOCKS_H = 0x2e,
};
namespace PixelEngine

View File

@ -52,6 +52,15 @@ public:
Renderer();
virtual ~Renderer();
enum PixelPerfQuery {
PP_ZCOMP_INPUT_ZCOMPLOC,
PP_ZCOMP_OUTPUT_ZCOMPLOC,
PP_ZCOMP_INPUT,
PP_ZCOMP_OUTPUT,
PP_BLEND_INPUT,
PP_EFB_COPY_CLOCKS
};
virtual void SetColorMask() = 0;
virtual void SetBlendMode(bool forceUpdate) = 0;
virtual void SetScissorRect(const TargetRectangle& rc) = 0;

View File

@ -132,8 +132,7 @@ void TextureCache::Cleanup()
if ( frameCount > TEXTURE_KILL_THRESHOLD + iter->second->frameCount
// EFB copies living on the host GPU are unrecoverable and thus shouldn't be deleted
// TODO: encoding the texture back to RAM here might be a good idea
&& ! (g_ActiveConfig.bCopyEFBToTexture && iter->second->IsEfbCopy()) )
&& ! iter->second->IsEfbCopy() )
{
delete iter->second;
textures.erase(iter++);

View File

@ -257,7 +257,9 @@ void VertexManager::Flush()
//if (g_nativeVertexFmt)
g_nativeVertexFmt->SetupVertexPointers();
g_renderer->ResumePixelPerf(false);
g_vertex_manager->Draw(stride, false);
g_renderer->PausePixelPerf(false);
// run through vertex groups again to set alpha
if (false == g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)

View File

@ -115,7 +115,7 @@ struct VideoConfig
int iAnaglyphStereoSeparation;
int iAnaglyphFocalAngle;
bool b3DVision;
// Hacks
bool bEFBAccessEnable;
bool bDlistCachingEnable;