summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorTony Wasserka <neobrainx@gmail.com>2014-02-16 22:08:28 +0100
committerTony Wasserka <neobrainx@gmail.com>2014-02-16 22:08:28 +0100
commitde5bfd0bced8b12811d461b8e6683effa6b672fb (patch)
treedc1209fbb812f995c831583c314a01506a099a89 /Source/Core/VideoCommon
parent2a7a94387ca0e096f698c0468307bfe6b1d365d7 (diff)
parent647aad0a19acc2a7bcb637160bb43d794771ed41 (diff)
Merge pull request #37 from degasus/VideoCommonApiFixes
VideoCommon API cleanups
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/BPFunctions.cpp3
-rw-r--r--Source/Core/VideoCommon/BPStructs.cpp3
-rw-r--r--Source/Core/VideoCommon/MainBase.cpp2
-rw-r--r--Source/Core/VideoCommon/PerfQueryBase.cpp2
-rw-r--r--Source/Core/VideoCommon/PerfQueryBase.h2
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp22
-rw-r--r--Source/Core/VideoCommon/RenderBase.h9
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp14
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.h2
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp5
10 files changed, 43 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp
index 43623a94a8..3cc1764f3b 100644
--- a/Source/Core/VideoCommon/BPFunctions.cpp
+++ b/Source/Core/VideoCommon/BPFunctions.cpp
@@ -47,8 +47,7 @@ void SetScissor()
if (rc.left > rc.right) rc.right = rc.left;
if (rc.top > rc.bottom) rc.bottom = rc.top;
- TargetRectangle trc = g_renderer->ConvertEFBRectangle(rc);
- g_renderer->SetScissorRect(trc);
+ g_renderer->SetScissorRect(rc);
}
void SetLineWidth()
diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp
index 5482dae102..2434d347fa 100644
--- a/Source/Core/VideoCommon/BPStructs.cpp
+++ b/Source/Core/VideoCommon/BPStructs.cpp
@@ -423,7 +423,8 @@ void BPWritten(const BPCmd& bp)
case BPMEM_CLEAR_PIXEL_PERF:
// GXClearPixMetric writes 0xAAA here, Sunshine alternates this register between values 0x000 and 0xAAA
- g_perf_query->ResetQuery();
+ if(PerfQueryBase::ShouldEmulate())
+ g_perf_query->ResetQuery();
break;
case BPMEM_PRELOAD_ADDR:
diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp
index 649f8974b3..43c0d7a140 100644
--- a/Source/Core/VideoCommon/MainBase.cpp
+++ b/Source/Core/VideoCommon/MainBase.cpp
@@ -72,7 +72,7 @@ void VideoFifo_CheckSwapRequest()
if (Common::AtomicLoadAcquire(s_swapRequested))
{
EFBRectangle rc;
- g_renderer->Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight,rc);
+ Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight,rc);
Common::AtomicStoreRelease(s_swapRequested, false);
}
}
diff --git a/Source/Core/VideoCommon/PerfQueryBase.cpp b/Source/Core/VideoCommon/PerfQueryBase.cpp
index af8bfa72e5..ada539c05e 100644
--- a/Source/Core/VideoCommon/PerfQueryBase.cpp
+++ b/Source/Core/VideoCommon/PerfQueryBase.cpp
@@ -3,7 +3,7 @@
PerfQueryBase* g_perf_query = 0;
-bool PerfQueryBase::ShouldEmulate() const
+bool PerfQueryBase::ShouldEmulate()
{
return g_ActiveConfig.bPerfQueriesEnable;
}
diff --git a/Source/Core/VideoCommon/PerfQueryBase.h b/Source/Core/VideoCommon/PerfQueryBase.h
index 64a22c2712..ad112ede9d 100644
--- a/Source/Core/VideoCommon/PerfQueryBase.h
+++ b/Source/Core/VideoCommon/PerfQueryBase.h
@@ -29,7 +29,7 @@ public:
// Checks if performance queries are enabled in the gameini configuration.
// NOTE: Called from CPU+GPU thread
- bool ShouldEmulate() const;
+ static bool ShouldEmulate();
// Begin querying the specified value for the following host GPU commands
virtual void EnableQuery(PerfQueryGroup type) {}
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 7f046e53a3..45bd870670 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -30,6 +30,9 @@
#include "XFMemory.h"
#include "FifoPlayer/FifoRecorder.h"
#include "AVIDump.h"
+#include "Debugger.h"
+#include "Statistics.h"
+#include "Core.h"
#include <cmath>
#include <string>
@@ -117,7 +120,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
}
else
{
- g_renderer->Swap(xfbAddr, fbWidth, fbHeight,sourceRc,Gamma);
+ Swap(xfbAddr, fbWidth, fbHeight,sourceRc,Gamma);
Common::AtomicStoreRelease(s_swapRequested, false);
}
}
@@ -509,8 +512,19 @@ void Renderer::RecordVideoMemory()
FifoRecorder::GetInstance().SetVideoMemory(bpMem, cpMem, xfMem, xfRegs, sizeof(XFRegisters) / 4);
}
-void UpdateViewport()
+void Renderer::Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc, float Gamma)
{
- if (xfregs.viewport.wd != 0 && xfregs.viewport.ht != 0)
- g_renderer->UpdateViewport();
+ // TODO: merge more generic parts into VideoCommon
+ g_renderer->SwapImpl(xfbAddr, fbWidth, fbHeight, rc, Gamma);
+
+ frameCount++;
+ GFX_DEBUGGER_PAUSE_AT(NEXT_FRAME, true);
+
+ // Begin new frame
+ // Set default viewport and scissor, for the clear to work correctly
+ // New frame
+ stats.ResetFrame();
+
+ Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB));
+ XFBWrited = false;
}
diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h
index 81ca9f75fd..fb99362a2a 100644
--- a/Source/Core/VideoCommon/RenderBase.h
+++ b/Source/Core/VideoCommon/RenderBase.h
@@ -49,7 +49,7 @@ public:
virtual void SetColorMask() = 0;
virtual void SetBlendMode(bool forceUpdate) = 0;
- virtual void SetScissorRect(const TargetRectangle& rc) = 0;
+ virtual void SetScissorRect(const EFBRectangle& rc) = 0;
virtual void SetGenerationMode() = 0;
virtual void SetDepthMode() = 0;
virtual void SetLogicOpMode() = 0;
@@ -57,6 +57,7 @@ public:
virtual void SetLineWidth() = 0;
virtual void SetSamplerState(int stage,int texindex) = 0;
virtual void SetInterlacingMode() = 0;
+ virtual void SetViewport() = 0;
virtual void ApplyState(bool bUseDstAlpha) = 0;
virtual void RestoreState() = 0;
@@ -105,9 +106,8 @@ public:
virtual void RestoreAPIState() = 0;
// Finish up the current frame, print some stats
- virtual void Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma = 1.0f) = 0;
-
- virtual void UpdateViewport() = 0;
+ static void Swap(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma = 1.0f);
+ virtual void SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& rc,float Gamma = 1.0f) = 0;
virtual bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc) = 0;
@@ -160,4 +160,3 @@ private:
extern Renderer *g_renderer;
-void UpdateViewport();
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index c4980ae190..0ea44d9a57 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -11,6 +11,8 @@
#include "RenderBase.h"
#include "BPStructs.h"
#include "XFMemory.h"
+#include "Debugger.h"
+#include "PerfQueryBase.h"
#include "VertexManagerBase.h"
#include "MainBase.h"
@@ -216,8 +218,16 @@ void VertexManager::Flush()
VertexShaderManager::SetConstants();
PixelShaderManager::SetConstants();
- // TODO: need to merge more stuff into VideoCommon
- g_vertex_manager->vFlush();
+ bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate
+ && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
+
+ if(PerfQueryBase::ShouldEmulate())
+ g_perf_query->EnableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP);
+ g_vertex_manager->vFlush(useDstAlpha);
+ if(PerfQueryBase::ShouldEmulate())
+ g_perf_query->DisableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP);
+
+ GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);
IsFlushed = true;
}
diff --git a/Source/Core/VideoCommon/VertexManagerBase.h b/Source/Core/VideoCommon/VertexManagerBase.h
index 6854bc5b73..997cf308d1 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.h
+++ b/Source/Core/VideoCommon/VertexManagerBase.h
@@ -58,7 +58,7 @@ private:
//virtual void Draw(u32 stride, bool alphapass) = 0;
// temp
- virtual void vFlush() = 0;
+ virtual void vFlush(bool useDstAlpha) = 0;
};
extern VertexManager *g_vertex_manager;
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index 4632d098c4..f39bd6231f 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -18,6 +18,7 @@
#include "XFMemory.h"
#include "VideoCommon.h"
#include "VertexManagerBase.h"
+#include "RenderBase.h"
#include "RenderBase.h"
float GC_ALIGNED16(g_fProjectionMatrix[16]);
@@ -173,8 +174,6 @@ static void ViewportCorrectionMatrix(Matrix44& result)
result.data[4*1+3] = (-intendedHt + 2.f * (Y - intendedY)) / Ht + 1.f;
}
-void UpdateViewport();
-
void VertexShaderManager::Init()
{
Dirty();
@@ -373,7 +372,7 @@ void VertexShaderManager::SetConstants()
constants.depthparams[1] = xfregs.viewport.zRange / 16777216.0f;
dirty = true;
// This is so implementation-dependent that we can't have it here.
- UpdateViewport();
+ g_renderer->SetViewport();
// Update projection if the viewport isn't 1:1 useable
if(!g_ActiveConfig.backend_info.bSupportsOversizedViewports)