summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2012-12-27 10:36:54 +0100
committerdegasus <wickmarkus@web.de>2012-12-27 10:36:54 +0100
commit316a33d1e68ab47b2870345a04bb9dfd4f383f28 (patch)
tree03b40807def9787df30976ecb53f09d6c6084c13 /Source/Core/VideoCommon
parent53398ca5d8bc6e73a726c9d803db5a956c22cf6a (diff)
parent94116bf89c917309b7e7b2a2b46bf2f43f3219db (diff)
Merge branch 'master' into GLSL-master
Conflicts: Source/Core/DolphinWX/Src/VideoConfigDiag.h Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h Source/Plugins/Plugin_VideoOGL/Src/Render.cpp Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/BPFunctions.cpp2
-rw-r--r--Source/Core/VideoCommon/Src/BPStructs.cpp9
-rw-r--r--Source/Core/VideoCommon/Src/DLCache.cpp8
-rw-r--r--Source/Core/VideoCommon/Src/Debugger.h12
-rw-r--r--Source/Core/VideoCommon/Src/Fifo.cpp1
-rw-r--r--Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp31
-rw-r--r--Source/Core/VideoCommon/Src/FramebufferManagerBase.h11
-rw-r--r--Source/Core/VideoCommon/Src/MainBase.cpp14
-rw-r--r--Source/Core/VideoCommon/Src/OnScreenDisplay.cpp3
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.cpp19
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderManager.cpp1
-rw-r--r--Source/Core/VideoCommon/Src/RenderBase.cpp240
-rw-r--r--Source/Core/VideoCommon/Src/RenderBase.h27
-rw-r--r--Source/Core/VideoCommon/Src/TextureCacheBase.cpp26
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader.cpp10
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoaderManager.cpp19
-rw-r--r--Source/Core/VideoCommon/Src/VertexManagerBase.cpp4
-rw-r--r--Source/Core/VideoCommon/Src/VertexManagerBase.h5
-rw-r--r--Source/Core/VideoCommon/Src/VertexShaderManager.cpp2
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.cpp122
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.h8
-rw-r--r--Source/Core/VideoCommon/Src/XFStructs.cpp67
-rw-r--r--Source/Core/VideoCommon/VideoCommon.vcxproj8
23 files changed, 363 insertions, 286 deletions
diff --git a/Source/Core/VideoCommon/Src/BPFunctions.cpp b/Source/Core/VideoCommon/Src/BPFunctions.cpp
index cddeae3000..b9a76ba7b6 100644
--- a/Source/Core/VideoCommon/Src/BPFunctions.cpp
+++ b/Source/Core/VideoCommon/Src/BPFunctions.cpp
@@ -236,7 +236,7 @@ bool GetConfig(const int &type)
case CONFIG_DISABLEFOG:
return g_ActiveConfig.bDisableFog;
case CONFIG_SHOWEFBREGIONS:
- return false;
+ return g_ActiveConfig.bShowEFBCopyRegions;
default:
PanicAlert("GetConfig Error: Unknown Config Type!");
return false;
diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp
index 179196e412..0bde9cc613 100644
--- a/Source/Core/VideoCommon/Src/BPStructs.cpp
+++ b/Source/Core/VideoCommon/Src/BPStructs.cpp
@@ -34,9 +34,9 @@
using namespace BPFunctions;
-u32 mapTexAddress;
-bool mapTexFound;
-int numWrites;
+static u32 mapTexAddress;
+static bool mapTexFound;
+static int numWrites;
extern volatile bool g_bSkipCurrentFrame;
@@ -81,6 +81,9 @@ void BPWritten(const BPCmd& bp)
just stuff geometry in them and don't put state changes there
----------------------------------------------------------------------------------------------------------------
*/
+
+ // check for invalid state, else unneeded configuration are built
+ g_video_backend->CheckInvalidState();
// Debugging only, this lets you skip a bp update
//static int times = 0;
diff --git a/Source/Core/VideoCommon/Src/DLCache.cpp b/Source/Core/VideoCommon/Src/DLCache.cpp
index 5499fa26f1..c828ea3a03 100644
--- a/Source/Core/VideoCommon/Src/DLCache.cpp
+++ b/Source/Core/VideoCommon/Src/DLCache.cpp
@@ -361,9 +361,9 @@ u32 AnalyzeAndRunDisplayList(u32 address, u32 size, CachedDisplayList *dl)
(cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT,
numVertices);
num_draw_call++;
- const int tc[12] = {
+ const u32 tc[12] = {
g_VtxDesc.Position, g_VtxDesc.Normal, g_VtxDesc.Color0, g_VtxDesc.Color1, g_VtxDesc.Tex0Coord, g_VtxDesc.Tex1Coord,
- g_VtxDesc.Tex2Coord, g_VtxDesc.Tex3Coord, g_VtxDesc.Tex4Coord, g_VtxDesc.Tex5Coord, g_VtxDesc.Tex6Coord, (const int)((g_VtxDesc.Hex >> 31) & 3)
+ g_VtxDesc.Tex2Coord, g_VtxDesc.Tex3Coord, g_VtxDesc.Tex4Coord, g_VtxDesc.Tex5Coord, g_VtxDesc.Tex6Coord, (const u32)((g_VtxDesc.Hex >> 31) & 3)
};
for(int i = 0; i < 12; i++)
{
@@ -563,9 +563,9 @@ void CompileAndRunDisplayList(u32 address, u32 size, CachedDisplayList *dl)
dl->InsertRegion(NewRegion);
memcpy(NewRegion->start_address, StartAddress, Vdatasize);
emitter.ABI_CallFunctionCCCP((void *)&VertexLoaderManager::RunCompiledVertices, cmd_byte & GX_VAT_MASK, (cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT, numVertices, NewRegion->start_address);
- const int tc[12] = {
+ const u32 tc[12] = {
g_VtxDesc.Position, g_VtxDesc.Normal, g_VtxDesc.Color0, g_VtxDesc.Color1, g_VtxDesc.Tex0Coord, g_VtxDesc.Tex1Coord,
- g_VtxDesc.Tex2Coord, g_VtxDesc.Tex3Coord, g_VtxDesc.Tex4Coord, g_VtxDesc.Tex5Coord, g_VtxDesc.Tex6Coord, (const int)((g_VtxDesc.Hex >> 31) & 3)
+ g_VtxDesc.Tex2Coord, g_VtxDesc.Tex3Coord, g_VtxDesc.Tex4Coord, g_VtxDesc.Tex5Coord, g_VtxDesc.Tex6Coord, (const u32)((g_VtxDesc.Hex >> 31) & 3)
};
for(int i = 0; i < 12; i++)
{
diff --git a/Source/Core/VideoCommon/Src/Debugger.h b/Source/Core/VideoCommon/Src/Debugger.h
index bcce50f223..fde31e4268 100644
--- a/Source/Core/VideoCommon/Src/Debugger.h
+++ b/Source/Core/VideoCommon/Src/Debugger.h
@@ -72,21 +72,9 @@ void GFXDebuggerCheckAndPause(bool update);
void GFXDebuggerToPause(bool update);
void GFXDebuggerUpdateScreen();
-#undef ENABLE_GFX_DEBUGGER
-#if defined(_DEBUG) || defined(DEBUGFAST)
-#define ENABLE_GFX_DEBUGGER
-#endif
-
-#ifdef ENABLE_GFX_DEBUGGER
#define GFX_DEBUGGER_PAUSE_AT(event,update) {if (((GFXDebuggerToPauseAtNext & event) && --GFXDebuggerEventToPauseCount<=0) || GFXDebuggerPauseFlag) GFXDebuggerToPause(update);}
#define GFX_DEBUGGER_PAUSE_LOG_AT(event,update,dumpfunc) {if (((GFXDebuggerToPauseAtNext & event) && --GFXDebuggerEventToPauseCount<=0) || GFXDebuggerPauseFlag) {{dumpfunc};GFXDebuggerToPause(update);}}
#define GFX_DEBUGGER_LOG_AT(event,dumpfunc) {if (( GFXDebuggerToPauseAtNext & event ) ) {{dumpfunc};}}
-#else
-// Disable debugging calls in Release build
-#define GFX_DEBUGGER_PAUSE_AT(event,update)
-#define GFX_DEBUGGER_PAUSE_LOG_AT(event,update,dumpfunc)
-#define GFX_DEBUGGER_LOG_AT(event,dumpfunc)
-#endif // ENABLE_GFX_DEBUGGER
#endif // _GFX_DEBUGGER_H_
diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp
index 565684297a..50aa21ebbf 100644
--- a/Source/Core/VideoCommon/Src/Fifo.cpp
+++ b/Source/Core/VideoCommon/Src/Fifo.cpp
@@ -16,7 +16,6 @@
// http://code.google.com/p/dolphin-emu/
#include "VideoConfig.h"
-#include "Setup.h"
#include "MemoryUtil.h"
#include "Thread.h"
#include "Atomic.h"
diff --git a/Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp b/Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp
index b234a7c865..c883714daf 100644
--- a/Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp
+++ b/Source/Core/VideoCommon/Src/FramebufferManagerBase.cpp
@@ -10,6 +10,9 @@ XFBSourceBase *FramebufferManagerBase::m_realXFBSource; // Only used in Real XFB
FramebufferManagerBase::VirtualXFBListType FramebufferManagerBase::m_virtualXFBList; // Only used in Virtual XFB mode
const XFBSourceBase* FramebufferManagerBase::m_overlappingXFBArray[MAX_VIRTUAL_XFB];
+unsigned int FramebufferManagerBase::s_last_xfb_width = 1;
+unsigned int FramebufferManagerBase::s_last_xfb_height = 1;
+
FramebufferManagerBase::FramebufferManagerBase()
{
m_realXFBSource = NULL;
@@ -226,3 +229,31 @@ void FramebufferManagerBase::ReplaceVirtualXFB()
}
}
}
+
+int FramebufferManagerBase::ScaleToVirtualXfbWidth(int x, unsigned int backbuffer_width)
+{
+ if (g_ActiveConfig.RealXFBEnabled())
+ return x;
+
+ if (g_ActiveConfig.b3DVision)
+ {
+ // This works, yet the version in the else doesn't. No idea why.
+ return x * (int)backbuffer_width / (int)FramebufferManagerBase::LastXfbWidth();
+ }
+ else
+ return x * (int)Renderer::GetTargetRectangle().GetWidth() / (int)FramebufferManagerBase::LastXfbWidth();
+}
+
+int FramebufferManagerBase::ScaleToVirtualXfbHeight(int y, unsigned int backbuffer_height)
+{
+ if (g_ActiveConfig.RealXFBEnabled())
+ return y;
+
+ if (g_ActiveConfig.b3DVision)
+ {
+ // This works, yet the version in the else doesn't. No idea why.
+ return y * (int)backbuffer_height / (int)FramebufferManagerBase::LastXfbHeight();
+ }
+ else
+ return y * (int)Renderer::GetTargetRectangle().GetHeight() / (int)FramebufferManagerBase::LastXfbHeight();
+}
diff --git a/Source/Core/VideoCommon/Src/FramebufferManagerBase.h b/Source/Core/VideoCommon/Src/FramebufferManagerBase.h
index 26d360647d..e529bb1a39 100644
--- a/Source/Core/VideoCommon/Src/FramebufferManagerBase.h
+++ b/Source/Core/VideoCommon/Src/FramebufferManagerBase.h
@@ -50,6 +50,14 @@ public:
static void CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma);
static const XFBSourceBase* const* GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount);
+ static void SetLastXfbWidth(unsigned int width) { s_last_xfb_width = width; }
+ static void SetLastXfbHeight(unsigned int height) { s_last_xfb_height = height; }
+ static unsigned int LastXfbWidth() { return s_last_xfb_width; }
+ static unsigned int LastXfbHeight() { return s_last_xfb_height; }
+
+ static int ScaleToVirtualXfbWidth(int x, unsigned int backbuffer_width);
+ static int ScaleToVirtualXfbHeight(int y, unsigned int backbuffer_height);
+
protected:
struct VirtualXFB
{
@@ -85,6 +93,9 @@ private:
static VirtualXFBListType m_virtualXFBList; // Only used in Virtual XFB mode
static const XFBSourceBase* m_overlappingXFBArray[MAX_VIRTUAL_XFB];
+
+ static unsigned int s_last_xfb_width;
+ static unsigned int s_last_xfb_height;
};
extern FramebufferManagerBase *g_framebuffer_manager;
diff --git a/Source/Core/VideoCommon/Src/MainBase.cpp b/Source/Core/VideoCommon/Src/MainBase.cpp
index cb6dc7ae5b..726ef71b38 100644
--- a/Source/Core/VideoCommon/Src/MainBase.cpp
+++ b/Source/Core/VideoCommon/Src/MainBase.cpp
@@ -180,6 +180,7 @@ void VideoBackendHardware::InitializeShared()
memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs));
memset(&s_accessEFBArgs, 0, sizeof(s_accessEFBArgs));
s_AccessEFBResult = 0;
+ m_invalid = false;
}
// Run from the CPU thread
@@ -198,16 +199,25 @@ void VideoBackendHardware::DoState(PointerWrap& p)
// Refresh state.
if (p.GetMode() == PointerWrap::MODE_READ)
{
- BPReload();
+ m_invalid = true;
RecomputeCachedArraybases();
// Clear all caches that touch RAM
// (? these don't appear to touch any emulation state that gets saved. moved to on load only.)
- TextureCache::Invalidate();
VertexLoaderManager::MarkAllDirty();
}
}
+void VideoBackendHardware::CheckInvalidState() {
+ if (m_invalid)
+ {
+ m_invalid = false;
+
+ BPReload();
+ TextureCache::Invalidate();
+ }
+}
+
void VideoBackendHardware::PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
Fifo_PauseAndLock(doLock, unpauseOnUnlock);
diff --git a/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp b/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp
index f24bfc31b3..10cf5b84af 100644
--- a/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp
+++ b/Source/Core/VideoCommon/Src/OnScreenDisplay.cpp
@@ -19,6 +19,7 @@
#include "Common.h"
+#include "ConfigManager.h"
#include "OnScreenDisplay.h"
#include "RenderBase.h"
#include "Timer.h"
@@ -47,6 +48,8 @@ void AddMessage(const char* pstr, u32 ms)
void DrawMessages()
{
+ if(!SConfig::GetInstance().m_LocalCoreStartupParameter.bOnScreenDisplayMessages) return;
+
if (s_listMsgs.size() > 0)
{
int left = 25, top = 15;
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
index b2bada299f..52c4633ced 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
@@ -129,15 +129,11 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 compo
return;
}
+ // numtexgens should be <= 8
for (unsigned int i = 0; i < bpmem.genMode.numtexgens; ++i)
- {
- if (18+i < 32)
- uid->values[0] |= xfregs.texMtxInfo[i].projection << (18+i); // 1
- else
- uid->values[1] |= xfregs.texMtxInfo[i].projection << (i - 14); // 1
- }
+ uid->values[0] |= xfregs.texMtxInfo[i].projection << (18+i); // 1
- uid->values[1] = bpmem.genMode.numindstages << 2; // 3
+ uid->values[1] = bpmem.genMode.numindstages; // 3
u32 indirectStagesUsed = 0;
for (unsigned int i = 0; i < bpmem.genMode.numindstages; ++i)
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages)
@@ -145,20 +141,20 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 compo
assert(indirectStagesUsed == (indirectStagesUsed & 0xF));
- uid->values[1] |= indirectStagesUsed << 5; // 4;
+ uid->values[1] |= indirectStagesUsed << 3; // 4;
for (unsigned int i = 0; i < bpmem.genMode.numindstages; ++i)
{
if (indirectStagesUsed & (1 << i))
{
- uid->values[1] |= (bpmem.tevindref.getTexCoord(i) < bpmem.genMode.numtexgens) << (9 + 3*i); // 1
+ uid->values[1] |= (bpmem.tevindref.getTexCoord(i) < bpmem.genMode.numtexgens) << (7 + 3*i); // 1
if (bpmem.tevindref.getTexCoord(i) < bpmem.genMode.numtexgens)
- uid->values[1] |= bpmem.tevindref.getTexCoord(i) << (10 + 3*i); // 2
+ uid->values[1] |= bpmem.tevindref.getTexCoord(i) << (8 + 3*i); // 2
}
}
u32* ptr = &uid->values[2];
- for (unsigned int i = 0; i < bpmem.genMode.numtevstages+1; ++i)
+ for (int i = 0; i < bpmem.genMode.numtevstages+1; ++i)
{
StageHash(i, ptr);
ptr += 4; // max: ptr = &uid->values[66]
@@ -780,7 +776,6 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
WRITE(p, "void main()\n{\n");
}
- char* pmainstart = p;
int Pretest = AlphaPreTest();
if(Pretest >= 0 && !DepthTextureEnable)
{
diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp
index e7086da7b3..e56f646c15 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp
@@ -304,6 +304,7 @@ void PixelShaderManager::SetConstants()
float GC_ALIGNED16(material[4]);
float NormalizationCoef = 1 / 255.0f;
+ // TODO: This code is wrong. i goes out of range for xfregs.ambColor.
for (int i = 0; i < 4; ++i)
{
if (nMaterialsChanged & (1 << i))
diff --git a/Source/Core/VideoCommon/Src/RenderBase.cpp b/Source/Core/VideoCommon/Src/RenderBase.cpp
index 0bd1c89118..577570c568 100644
--- a/Source/Core/VideoCommon/Src/RenderBase.cpp
+++ b/Source/Core/VideoCommon/Src/RenderBase.cpp
@@ -67,12 +67,7 @@ int Renderer::s_target_height;
int Renderer::s_backbuffer_width;
int Renderer::s_backbuffer_height;
-// ratio of backbuffer size and render area size
-float Renderer::xScale;
-float Renderer::yScale;
-
-unsigned int Renderer::s_XFB_width;
-unsigned int Renderer::s_XFB_height;
+TargetRectangle Renderer::target_rc;
int Renderer::s_LastEFBScale;
@@ -81,6 +76,11 @@ bool Renderer::XFBWrited;
bool Renderer::s_EnableDLCachingAfterRecording;
unsigned int Renderer::prev_efb_format = (unsigned int)-1;
+unsigned int Renderer::efb_scale_numeratorX = 1;
+unsigned int Renderer::efb_scale_numeratorY = 1;
+unsigned int Renderer::efb_scale_denominatorX = 1;
+unsigned int Renderer::efb_scale_denominatorY = 1;
+unsigned int Renderer::ssaa_multiplier = 1;
Renderer::Renderer() : frame_data(NULL), bLastFrameDumped(false)
@@ -98,6 +98,8 @@ Renderer::~Renderer()
// invalidate previous efb format
prev_efb_format = (unsigned int)-1;
+ efb_scale_numeratorX = efb_scale_numeratorY = efb_scale_denominatorX = efb_scale_denominatorY = ssaa_multiplier = 1;
+
#if defined _WIN32 || defined HAVE_LIBAV
if (g_ActiveConfig.bDumpFrames && bLastFrameDumped && bAVIDumping)
AVIDump::Stop();
@@ -121,64 +123,117 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
XFBWrited = true;
- // XXX: Without the VI, how would we know what kind of field this is? So
- // just use progressive.
if (g_ActiveConfig.bUseXFB)
{
FramebufferManagerBase::CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc,Gamma);
}
else
{
+ // XXX: Without the VI, how would we know what kind of field this is? So
+ // just use progressive.
g_renderer->Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight,sourceRc,Gamma);
Common::AtomicStoreRelease(s_swapRequested, false);
}
}
-void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY)
+int Renderer::EFBToScaledX(int x)
{
switch (g_ActiveConfig.iEFBScale)
{
+ case 0: // fractional
+ return (int)ssaa_multiplier * FramebufferManagerBase::ScaleToVirtualXfbWidth(x, s_backbuffer_width);
+
+ default:
+ return x * (int)ssaa_multiplier * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX;
+ };
+}
+
+int Renderer::EFBToScaledY(int y)
+{
+ switch (g_ActiveConfig.iEFBScale)
+ {
+ case 0: // fractional
+ return (int)ssaa_multiplier * FramebufferManagerBase::ScaleToVirtualXfbHeight(y, s_backbuffer_height);
+
+ default:
+ return y * (int)ssaa_multiplier * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY;
+ };
+}
+
+void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY)
+{
+ if (g_ActiveConfig.iEFBScale == 0 || g_ActiveConfig.iEFBScale == 1)
+ {
+ scaledX = x;
+ scaledY = y;
+ }
+ else
+ {
+ scaledX = x * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX;
+ scaledY = y * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY;
+ }
+}
+
+// return true if target size changed
+bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier)
+{
+ int newEFBWidth, newEFBHeight;
+
+ // TODO: Ugly. Clean up
+ switch (s_LastEFBScale)
+ {
+ case 2: // 1x
+ efb_scale_numeratorX = efb_scale_numeratorY = 1;
+ efb_scale_denominatorX = efb_scale_denominatorY = 1;
+ break;
+
case 3: // 1.5x
- scaledX = (x / 2) * 3;
- scaledY = (y / 2) * 3;
+ efb_scale_numeratorX = efb_scale_numeratorY = 3;
+ efb_scale_denominatorX = efb_scale_denominatorY = 2;
break;
+
case 4: // 2x
- scaledX = x * 2;
- scaledY = y * 2;
+ efb_scale_numeratorX = efb_scale_numeratorY = 2;
+ efb_scale_denominatorX = efb_scale_denominatorY = 1;
break;
+
case 5: // 2.5x
- scaledX = (x / 2) * 5;
- scaledY = (y / 2) * 5;
+ efb_scale_numeratorX = efb_scale_numeratorY = 5;
+ efb_scale_denominatorX = efb_scale_denominatorY = 2;
break;
+
case 6: // 3x
- scaledX = x * 3;
- scaledY = y * 3;
+ efb_scale_numeratorX = efb_scale_numeratorY = 3;
+ efb_scale_denominatorX = efb_scale_denominatorY = 1;
break;
+
case 7: // 4x
- scaledX = x * 4;
- scaledY = y * 4;
+ efb_scale_numeratorX = efb_scale_numeratorY = 4;
+ efb_scale_denominatorX = efb_scale_denominatorY = 1;
break;
- default:
- scaledX = x;
- scaledY = y;
+
+ default: // fractional & integral handled later
break;
- };
-}
+ }
-// return true if target size changed
-bool Renderer::CalculateTargetSize(int multiplier)
-{
- int newEFBWidth, newEFBHeight;
switch (s_LastEFBScale)
{
case 0: // fractional
- newEFBWidth = (int)(EFB_WIDTH * xScale);
- newEFBHeight = (int)(EFB_HEIGHT * yScale);
- break;
case 1: // integral
- newEFBWidth = EFB_WIDTH * (int)ceilf(xScale);
- newEFBHeight = EFB_HEIGHT * (int)ceilf(yScale);
+ newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, framebuffer_width);
+ newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, framebuffer_height);
+
+ if (s_LastEFBScale == 1)
+ {
+ newEFBWidth = ((newEFBWidth-1) / EFB_WIDTH + 1) * EFB_WIDTH;
+ newEFBHeight = ((newEFBHeight-1) / EFB_HEIGHT + 1) * EFB_HEIGHT;
+ }
+ efb_scale_numeratorX = newEFBWidth;
+ efb_scale_denominatorX = EFB_WIDTH;
+ efb_scale_numeratorY = newEFBHeight;
+ efb_scale_denominatorY = EFB_HEIGHT;
break;
+
default:
CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, newEFBWidth, newEFBHeight);
break;
@@ -186,6 +241,7 @@ bool Renderer::CalculateTargetSize(int multiplier)
newEFBWidth *= multiplier;
newEFBHeight *= multiplier;
+ ssaa_multiplier = multiplier;
if (newEFBWidth != s_target_width || newEFBHeight != s_target_height)
{
@@ -311,27 +367,125 @@ void Renderer::DrawDebugText()
}
}
-void Renderer::CalculateXYScale(const TargetRectangle& dst_rect)
+// TODO: remove
+extern bool g_aspect_wide;
+
+void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height)
{
- if (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)
+ float FloatGLWidth = (float)backbuffer_width;
+ float FloatGLHeight = (float)backbuffer_height;
+ float FloatXOffset = 0;
+ float FloatYOffset = 0;
+
+ // The rendering window size
+ const float WinWidth = FloatGLWidth;
+ const float WinHeight = FloatGLHeight;
+
+ // Handle aspect ratio.
+ // Default to auto.
+ bool use16_9 = g_aspect_wide;
+
+ // Update aspect ratio hack values
+ // Won't take effect until next frame
+ // Don't know if there is a better place for this code so there isn't a 1 frame delay
+ if ( g_ActiveConfig.bWidescreenHack )
{
- xScale = 1.0f;
- yScale = 1.0f;
+ float source_aspect = use16_9 ? (16.0f / 9.0f) : (4.0f / 3.0f);
+ float target_aspect;
+
+ switch ( g_ActiveConfig.iAspectRatio )
+ {
+ case ASPECT_FORCE_16_9 :
+ target_aspect = 16.0f / 9.0f;
+ break;
+ case ASPECT_FORCE_4_3 :
+ target_aspect = 4.0f / 3.0f;
+ break;
+ case ASPECT_STRETCH :
+ target_aspect = WinWidth / WinHeight;
+ break;
+ default :
+ // ASPECT_AUTO == no hacking
+ target_aspect = source_aspect;
+ break;
+ }
+
+ float adjust = source_aspect / target_aspect;
+ if ( adjust > 1 )
+ {
+ // Vert+
+ g_Config.fAspectRatioHackW = 1;
+ g_Config.fAspectRatioHackH = 1/adjust;
+ }
+ else
+ {
+ // Hor+
+ g_Config.fAspectRatioHackW = adjust;
+ g_Config.fAspectRatioHackH = 1;
+ }
}
else
{
- if (g_ActiveConfig.b3DVision)
+ // Hack is disabled
+ g_Config.fAspectRatioHackW = 1;
+ g_Config.fAspectRatioHackH = 1;
+ }
+
+ // Check for force-settings and override.
+ if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9)
+ use16_9 = true;
+ else if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_4_3)
+ use16_9 = false;
+
+ if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH)
+ {
+ // The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
+ float Ratio = (WinWidth / WinHeight) / (!use16_9 ? (4.0f / 3.0f) : (16.0f / 9.0f));
+ // Check if height or width is the limiting factor. If ratio > 1 the picture is too wide and have to limit the width.
+ if (Ratio > 1.0f)
{
- // This works, yet the version in the else doesn't. No idea why.
- xScale = (float)(s_backbuffer_width-1) / (float)(s_XFB_width-1);
- yScale = (float)(s_backbuffer_height-1) / (float)(s_XFB_height-1);
+ // Scale down and center in the X direction.
+ FloatGLWidth /= Ratio;
+ FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f;
}
+ // The window is too high, we have to limit the height
else
{
- xScale = (float)(dst_rect.right - dst_rect.left - 1) / (float)(s_XFB_width-1);
- yScale = (float)(dst_rect.bottom - dst_rect.top - 1) / (float)(s_XFB_height-1);
+ // Scale down and center in the Y direction.
+ FloatGLHeight *= Ratio;
+ FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f;
}
}
+
+ // -----------------------------------------------------------------------
+ // Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
+ // Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
+ // ------------------
+ if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH && g_ActiveConfig.bCrop)
+ {
+ float Ratio = !use16_9 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f)));
+ // The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
+ float IncreasedWidth = (Ratio - 1.0f) * FloatGLWidth;
+ float IncreasedHeight = (Ratio - 1.0f) * FloatGLHeight;
+ // The new width and height
+ FloatGLWidth = FloatGLWidth * Ratio;
+ FloatGLHeight = FloatGLHeight * Ratio;
+ // Adjust the X and Y offset
+ FloatXOffset = FloatXOffset - (IncreasedWidth * 0.5f);
+ FloatYOffset = FloatYOffset - (IncreasedHeight * 0.5f);
+ }
+
+ int XOffset = (int)(FloatXOffset + 0.5f);
+ int YOffset = (int)(FloatYOffset + 0.5f);
+ int iWhidth = (int)ceil(FloatGLWidth);
+ int iHeight = (int)ceil(FloatGLHeight);
+ iWhidth -= iWhidth % 4; // ensure divisibility by 4 to make it compatible with all the video encoders
+ iHeight -= iHeight % 4;
+
+ target_rc.left = XOffset;
+ target_rc.top = YOffset;
+ target_rc.right = XOffset + iWhidth;
+ target_rc.bottom = YOffset + iHeight;
}
void Renderer::SetWindowSize(int width, int height)
diff --git a/Source/Core/VideoCommon/Src/RenderBase.h b/Source/Core/VideoCommon/Src/RenderBase.h
index e8d4c55a20..4da80c9752 100644
--- a/Source/Core/VideoCommon/Src/RenderBase.h
+++ b/Source/Core/VideoCommon/Src/RenderBase.h
@@ -74,10 +74,6 @@ public:
static int GetBackbufferWidth() { return s_backbuffer_width; }
static int GetBackbufferHeight() { return s_backbuffer_height; }
- // XFB scale - TODO: Remove this and add two XFBToScaled functions instead
- static float GetXFBScaleX() { return xScale; }
- static float GetXFBScaleY() { return yScale; }
-
static void SetWindowSize(int width, int height);
// EFB coordinate conversion functions
@@ -85,9 +81,13 @@ public:
// Use this to convert a whole native EFB rect to backbuffer coordinates
virtual TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) = 0;
+ static const TargetRectangle& GetTargetRectangle() { return target_rc; }
+ static void UpdateDrawRectangle(int backbuffer_width, int backbuffer_height);
+
+
// Use this to upscale native EFB coordinates to IDEAL internal resolution
- static unsigned int EFBToScaledX(int x) { return x * GetTargetWidth() / EFB_WIDTH; }
- static unsigned int EFBToScaledY(int y) { return y * GetTargetHeight() / EFB_HEIGHT; }
+ static int EFBToScaledX(int x);
+ static int EFBToScaledY(int y);
// Floating point versions of the above - only use them if really necessary
static float EFBToScaledXf(float x) { return x * ((float)GetTargetWidth() / (float)EFB_WIDTH); }
@@ -133,8 +133,7 @@ public:
protected:
static void CalculateTargetScale(int x, int y, int &scaledX, int &scaledY);
- static bool CalculateTargetSize(int multiplier = 1);
- static void CalculateXYScale(const TargetRectangle& dst_rect);
+ static bool CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier = 1);
static void CheckFifoRecording();
static void RecordVideoMemory();
@@ -159,12 +158,7 @@ protected:
static int s_backbuffer_width;
static int s_backbuffer_height;
- // ratio of backbuffer size and render area size - TODO: Remove these!
- static float xScale;
- static float yScale;
-
- static unsigned int s_XFB_width;
- static unsigned int s_XFB_height;
+ static TargetRectangle target_rc;
// can probably eliminate this static var
static int s_LastEFBScale;
@@ -176,6 +170,11 @@ protected:
private:
static unsigned int prev_efb_format;
+ static unsigned int efb_scale_numeratorX;
+ static unsigned int efb_scale_numeratorY;
+ static unsigned int efb_scale_denominatorX;
+ static unsigned int efb_scale_denominatorY;
+ static unsigned int ssaa_multiplier;
};
extern Renderer *g_renderer;
diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp
index a5c390df3d..9fc18ef1bd 100644
--- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp
@@ -205,8 +205,11 @@ void TextureCache::ClearRenderTargets()
tcend = textures.end();
for (; iter!=tcend; ++iter)
- if (iter->second->type != TCET_EC_DYNAMIC)
- iter->second->type = TCET_NORMAL;
+ if (iter->second->type == TCET_EC_VRAM)
+ {
+ delete iter->second;
+ textures.erase(iter++);
+ }
}
bool TextureCache::CheckForCustomTextureLODs(u64 tex_hash, int texformat, unsigned int levels)
@@ -374,7 +377,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
//
// TODO: Don't we need to force texture decoding to RGBA8 for dynamic EFB copies?
// TODO: Actually, it should be enough if the internal texture format matches...
- if ((entry->type == TCET_NORMAL && width == entry->native_width && height == entry->native_height && full_format == entry->format && entry->num_mipmaps == maxlevel)
+ if ((entry->type == TCET_NORMAL && width == entry->virtual_width && height == entry->virtual_height && full_format == entry->format && entry->num_mipmaps == maxlevel)
|| (entry->type == TCET_EC_DYNAMIC && entry->native_width == width && entry->native_height == height))
{
// reuse the texture
@@ -393,14 +396,21 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
pcfmt = LoadCustomTexture(tex_hash, texformat, 0, width, height);
if (pcfmt != PC_TEX_FMT_NONE)
{
- expandedWidth = width;
- expandedHeight = height;
+ if (expandedWidth != width || expandedHeight != height)
+ {
+ expandedWidth = width;
+ expandedHeight = height;
+
+ // If we thought we could reuse the texture before, make sure to delete it now!
+ delete entry;
+ entry = NULL;
+ }
using_custom_texture = true;
}
}
- // TODO: RGBA8 textures are stored non-continuously in tmem, that might cause problems when preloading is enabled
- if (pcfmt == PC_TEX_FMT_NONE)
+ // TODO: RGBA8 textures are stored non-continuously in tmem, that might cause problems here when preloading is enabled
+ if (!using_custom_texture)
pcfmt = TexDecoder_Decode(temp, src_data, expandedWidth,
expandedHeight, texformat, tlutaddr, tlutfmt, g_ActiveConfig.backend_info.bUseRGBATextures);
@@ -782,7 +792,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
textures[dstAddr] = entry = g_texture_cache->CreateRenderTargetTexture(scaled_tex_w, scaled_tex_h);
// TODO: Using the wrong dstFormat, dumb...
- entry->SetGeneralParameters(dstAddr, 0, dstFormat, 0);
+ entry->SetGeneralParameters(dstAddr, 0, dstFormat, 1);
entry->SetDimensions(tex_w, tex_h, scaled_tex_w, scaled_tex_h);
entry->SetHashes(TEXHASH_INVALID);
entry->type = TCET_EC_VRAM;
diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp
index fb34ce1bc1..5bffab8ee7 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp
@@ -224,14 +224,14 @@ void VertexLoader::CompileVertexTranslator()
#endif
// Colors
- const int col[2] = {m_VtxDesc.Color0, m_VtxDesc.Color1};
+ const u32 col[2] = {m_VtxDesc.Color0, m_VtxDesc.Color1};
// TextureCoord
// Since m_VtxDesc.Text7Coord is broken across a 32 bit word boundary, retrieve its value manually.
// If we didn't do this, the vertex format would be read as one bit offset from where it should be, making
// 01 become 00, and 10/11 become 01
- const int tc[8] = {
+ const u32 tc[8] = {
m_VtxDesc.Tex0Coord, m_VtxDesc.Tex1Coord, m_VtxDesc.Tex2Coord, m_VtxDesc.Tex3Coord,
- m_VtxDesc.Tex4Coord, m_VtxDesc.Tex5Coord, m_VtxDesc.Tex6Coord, (const int)((m_VtxDesc.Hex >> 31) & 3)
+ m_VtxDesc.Tex4Coord, m_VtxDesc.Tex5Coord, m_VtxDesc.Tex6Coord, (const u32)((m_VtxDesc.Hex >> 31) & 3)
};
// Reset pipeline
@@ -770,7 +770,7 @@ void VertexLoader::AppendToString(std::string *dest) const
dest->append(StringFromFormat("Nrm: %i %s-%s ",
m_VtxAttr.NormalElements, posMode[m_VtxDesc.Normal], posFormats[m_VtxAttr.NormalFormat]));
}
- int color_mode[2] = {m_VtxDesc.Color0, m_VtxDesc.Color1};
+ u32 color_mode[2] = {m_VtxDesc.Color0, m_VtxDesc.Color1};
for (int i = 0; i < 2; i++)
{
if (color_mode[i])
@@ -778,7 +778,7 @@ void VertexLoader::AppendToString(std::string *dest) const
dest->append(StringFromFormat("C%i: %i %s-%s ", i, m_VtxAttr.color[i].Elements, posMode[color_mode[i]], colorFormat[m_VtxAttr.color[i].Comp]));
}
}
- int tex_mode[8] = {
+ u32 tex_mode[8] = {
m_VtxDesc.Tex0Coord, m_VtxDesc.Tex1Coord, m_VtxDesc.Tex2Coord, m_VtxDesc.Tex3Coord,
m_VtxDesc.Tex4Coord, m_VtxDesc.Tex5Coord, m_VtxDesc.Tex6Coord, m_VtxDesc.Tex7Coord
};
diff --git a/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp b/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp
index 316941a639..153e69a8c3 100644
--- a/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp
@@ -19,9 +19,12 @@
#ifdef _MSC_VER
#include <hash_map>
using stdext::hash_map;
-#else
+#elif defined __APPLE__
#include <ext/hash_map>
using __gnu_cxx::hash_map;
+#else
+#include <unordered_map>
+using std::unordered_map;
#endif
#include <map>
#include <vector>
@@ -45,7 +48,12 @@ namespace stdext {
}
}
#else
-namespace __gnu_cxx {
+#ifdef __APPLE__
+namespace __gnu_cxx
+#else
+namespace std
+#endif
+{
template<> struct hash<VertexLoaderUID> {
size_t operator()(const VertexLoaderUID& uid) const {
return uid.GetHash();
@@ -54,10 +62,15 @@ namespace __gnu_cxx {
}
#endif
+#if defined _MSC_VER || defined __APPLE__
+typedef hash_map<VertexLoaderUID, VertexLoader*> VertexLoaderMap;
+#else
+typedef unordered_map<VertexLoaderUID, VertexLoader*> VertexLoaderMap;
+#endif
+
namespace VertexLoaderManager
{
-typedef hash_map<VertexLoaderUID, VertexLoader*> VertexLoaderMap;
static VertexLoaderMap g_VertexLoaderMap;
// TODO - change into array of pointers. Keep a map of all seen so far.
diff --git a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
index 4118e3dcbd..5be72e4fcf 100644
--- a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp
@@ -9,6 +9,7 @@
#include "NativeVertexFormat.h"
#include "TextureCacheBase.h"
#include "RenderBase.h"
+#include "BPStructs.h"
#include "VertexManagerBase.h"
#include "VideoConfig.h"
@@ -159,6 +160,9 @@ void VertexManager::AddVertices(int primitive, int numVertices)
void VertexManager::Flush()
{
+ // loading a state will invalidate BP, so check for it
+ g_video_backend->CheckInvalidState();
+
g_vertex_manager->vFlush();
}
diff --git a/Source/Core/VideoCommon/Src/VertexManagerBase.h b/Source/Core/VideoCommon/Src/VertexManagerBase.h
index bc30fa3fba..f3a4aa72e3 100644
--- a/Source/Core/VideoCommon/Src/VertexManagerBase.h
+++ b/Source/Core/VideoCommon/Src/VertexManagerBase.h
@@ -21,7 +21,7 @@ public:
// values from DX11 backend
MAXVBUFFERSIZE = 0x50000,
- MAXIBUFFERSIZE = 0x10000,
+ MAXIBUFFERSIZE = 0xFFFF,
};
VertexManager();
@@ -46,7 +46,8 @@ public:
static u8* GetVertexBuffer() { return LocalVBuffer; }
static void DoState(PointerWrap& p);
-
+ virtual void CreateDeviceObjects(){};
+ virtual void DestroyDeviceObjects(){};
protected:
// TODO: make private after Flush() is merged
static void ResetBuffer();
diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp
index fbd5d9e779..5beaefb631 100644
--- a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp
@@ -209,6 +209,7 @@ void VertexShaderManager::SetConstants()
int endn = (nPostTransformMatricesChanged[1] + 3 ) / 4;
const float* pstart = (const float*)&xfmem[XFMEM_POSTMATRICES + startn * 4];
SetMultiVSConstant4fv(C_POSTTRANSFORMMATRICES + startn, endn - startn, pstart);
+ nPostTransformMatricesChanged[0] = nPostTransformMatricesChanged[1] = -1;
}
if (nLightsChanged[0] >= 0)
@@ -252,6 +253,7 @@ void VertexShaderManager::SetConstants()
float GC_ALIGNED16(material[4]);
float NormalizationCoef = 1 / 255.0f;
+ // TODO: This code is wrong. i goes out of range for xfregs.ambColor.
for (int i = 0; i < 4; ++i)
{
if (nMaterialsChanged & (1 << i))
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp
index c4aa1cc2b0..128a05177c 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp
@@ -293,125 +293,3 @@ void VideoConfig::GameIniSave(const char* default_ini, const char* game_ini)
iniFile.Save(game_ini);
}
-
-
-// TODO: remove
-extern bool g_aspect_wide;
-
-// TODO: Figure out a better place for this function.
-void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc)
-{
- float FloatGLWidth = (float)backbuffer_width;
- float FloatGLHeight = (float)backbuffer_height;
- float FloatXOffset = 0;
- float FloatYOffset = 0;
-
- // The rendering window size
- const float WinWidth = FloatGLWidth;
- const float WinHeight = FloatGLHeight;
-
- // Handle aspect ratio.
- // Default to auto.
- bool use16_9 = g_aspect_wide;
-
- // Update aspect ratio hack values
- // Won't take effect until next frame
- // Don't know if there is a better place for this code so there isn't a 1 frame delay
- if ( g_ActiveConfig.bWidescreenHack )
- {
- float source_aspect = use16_9 ? (16.0f / 9.0f) : (4.0f / 3.0f);
- float target_aspect;
-
- switch ( g_ActiveConfig.iAspectRatio )
- {
- case ASPECT_FORCE_16_9 :
- target_aspect = 16.0f / 9.0f;
- break;
- case ASPECT_FORCE_4_3 :
- target_aspect = 4.0f / 3.0f;
- break;
- case ASPECT_STRETCH :
- target_aspect = WinWidth / WinHeight;
- break;
- default :
- // ASPECT_AUTO == no hacking
- target_aspect = source_aspect;
- break;
- }
-
- float adjust = source_aspect / target_aspect;
- if ( adjust > 1 )
- {
- // Vert+
- g_Config.fAspectRatioHackW = 1;
- g_Config.fAspectRatioHackH = 1/adjust;
- }
- else
- {
- // Hor+
- g_Config.fAspectRatioHackW = adjust;
- g_Config.fAspectRatioHackH = 1;
- }
- }
- else
- {
- // Hack is disabled
- g_Config.fAspectRatioHackW = 1;
- g_Config.fAspectRatioHackH = 1;
- }
-
- // Check for force-settings and override.
- if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9)
- use16_9 = true;
- else if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_4_3)
- use16_9 = false;
-
- if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH)
- {
- // The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
- float Ratio = (WinWidth / WinHeight) / (!use16_9 ? (4.0f / 3.0f) : (16.0f / 9.0f));
- // Check if height or width is the limiting factor. If ratio > 1 the picture is too wide and have to limit the width.
- if (Ratio > 1.0f)
- {
- // Scale down and center in the X direction.
- FloatGLWidth /= Ratio;
- FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f;
- }
- // The window is too high, we have to limit the height
- else
- {
- // Scale down and center in the Y direction.
- FloatGLHeight *= Ratio;
- FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f;
- }
- }
-
- // -----------------------------------------------------------------------
- // Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
- // Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
- // ------------------
- if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH && g_ActiveConfig.bCrop)
- {
- float Ratio = !use16_9 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f)));
- // The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
- float IncreasedWidth = (Ratio - 1.0f) * FloatGLWidth;
- float IncreasedHeight = (Ratio - 1.0f) * FloatGLHeight;
- // The new width and height
- FloatGLWidth = FloatGLWidth * Ratio;
- FloatGLHeight = FloatGLHeight * Ratio;
- // Adjust the X and Y offset
- FloatXOffset = FloatXOffset - (IncreasedWidth * 0.5f);
- FloatYOffset = FloatYOffset - (IncreasedHeight * 0.5f);
- }
-
- int XOffset = (int)(FloatXOffset + 0.5f);
- int YOffset = (int)(FloatYOffset + 0.5f);
- int iWhidth = (int)ceil(FloatGLWidth);
- int iHeight = (int)ceil(FloatGLHeight);
- iWhidth -= iWhidth % 4; // ensure divisibility by 4 to make it compatible with all the video encoders
- iHeight -= iHeight % 4;
- rc->left = XOffset;
- rc->top = flip ? (int)(YOffset + iHeight) : YOffset;
- rc->right = XOffset + iWhidth;
- rc->bottom = flip ? YOffset : (int)(YOffset + iHeight);
-}
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h
index 064f8278a7..8972d60bcb 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.h
+++ b/Source/Core/VideoCommon/Src/VideoConfig.h
@@ -170,6 +170,12 @@ struct VideoConfig
bool bSupportsGLSLATTRBind;
bool bSupportsGLSLCache;
} backend_info;
+
+ // Utility
+ bool RealXFBEnabled() const { return bUseXFB && bUseRealXFB; }
+ bool VirtualXFBEnabled() const { return bUseXFB && !bUseRealXFB; }
+ bool EFBCopiesToTextureEnabled() const { return bEFBCopyEnable && bCopyEFBToTexture; }
+ bool EFBCopiesToRamEnabled() const { return bEFBCopyEnable && !bCopyEFBToTexture; }
};
extern VideoConfig g_Config;
@@ -178,6 +184,4 @@ extern VideoConfig g_ActiveConfig;
// Called every frame.
void UpdateActiveConfig();
-void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc);
-
#endif // _VIDEO_CONFIG_H_
diff --git a/Source/Core/VideoCommon/Src/XFStructs.cpp b/Source/Core/VideoCommon/Src/XFStructs.cpp
index f8330604ad..9f395bfecf 100644
--- a/Source/Core/VideoCommon/Src/XFStructs.cpp
+++ b/Source/Core/VideoCommon/Src/XFStructs.cpp
@@ -121,18 +121,12 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
case XFMEM_SETVIEWPORT+3:
case XFMEM_SETVIEWPORT+4:
case XFMEM_SETVIEWPORT+5:
- {
- u8 size = std::min(transferSize * 4, 6 * 4);
- if (memcmp((u32*)&xfregs + (address - 0x1000), pData + dataIndex, size))
- {
- VertexManager::Flush();
- VertexShaderManager::SetViewportChanged();
- PixelShaderManager::SetViewportChanged();
- }
+ VertexManager::Flush();
+ VertexShaderManager::SetViewportChanged();
+ PixelShaderManager::SetViewportChanged();
- nextAddress = XFMEM_SETVIEWPORT + 6;
- break;
- }
+ nextAddress = XFMEM_SETVIEWPORT + 6;
+ break;
case XFMEM_SETPROJECTION:
case XFMEM_SETPROJECTION+1:
@@ -141,21 +135,15 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
case XFMEM_SETPROJECTION+4:
case XFMEM_SETPROJECTION+5:
case XFMEM_SETPROJECTION+6:
- {
- u8 size = std::min(transferSize * 4, 7 * 4);
- if (memcmp((u32*)&xfregs + (address - 0x1000), pData + dataIndex, size))
- {
- VertexManager::Flush();
- VertexShaderManager::SetProjectionChanged();
- }
+ VertexManager::Flush();
+ VertexShaderManager::SetProjectionChanged();
- nextAddress = XFMEM_SETPROJECTION + 7;
- break;
- }
+ nextAddress = XFMEM_SETPROJECTION + 7;
+ break;
case XFMEM_SETNUMTEXGENS: // GXSetNumTexGens
if (xfregs.numTexGen.numTexGens != (newValue & 15))
- VertexManager::Flush();
+ VertexManager::Flush();
break;
case XFMEM_SETTEXMTXINFO:
@@ -166,16 +154,10 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
case XFMEM_SETTEXMTXINFO+5:
case XFMEM_SETTEXMTXINFO+6:
case XFMEM_SETTEXMTXINFO+7:
- {
- u8 size = std::min(transferSize * 4, 8 * 4);
- if (memcmp((u32*)&xfregs + (address - 0x1000), pData + dataIndex, size))
- {
- VertexManager::Flush();
- }
+ VertexManager::Flush();
- nextAddress = XFMEM_SETTEXMTXINFO + 8;
- break;
- }
+ nextAddress = XFMEM_SETTEXMTXINFO + 8;
+ break;
case XFMEM_SETPOSMTXINFO:
case XFMEM_SETPOSMTXINFO+1:
@@ -185,16 +167,10 @@ void XFRegWritten(int transferSize, u32 baseAddress, u32 *pData)
case XFMEM_SETPOSMTXINFO+5:
case XFMEM_SETPOSMTXINFO+6:
case XFMEM_SETPOSMTXINFO+7:
- {
- u8 size = std::min(transferSize * 4, 8 * 4);
- if (memcmp((u32*)&xfregs + (address - 0x1000), pData + dataIndex, size))
- {
- VertexManager::Flush();
- }
+ VertexManager::Flush();
- nextAddress = XFMEM_SETPOSMTXINFO + 8;
- break;
- }
+ nextAddress = XFMEM_SETPOSMTXINFO + 8;
+ break;
// --------------
// Unknown Regs
@@ -264,15 +240,8 @@ void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
transferSize = 0;
}
- for (u32 i = 0; i < xfMemTransferSize; ++i)
- {
- if (((u32*)&xfmem[xfMemBase])[i] != pData[i])
- {
- XFMemWritten(xfMemTransferSize, xfMemBase);
- memcpy_gc(&xfmem[xfMemBase], pData, xfMemTransferSize * 4);
- break;
- }
- }
+ XFMemWritten(xfMemTransferSize, xfMemBase);
+ memcpy_gc(&xfmem[xfMemBase], pData, xfMemTransferSize * 4);
pData += xfMemTransferSize;
}
diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj b/Source/Core/VideoCommon/VideoCommon.vcxproj
index 0869f33ff4..bf9122e6b5 100644
--- a/Source/Core/VideoCommon/VideoCommon.vcxproj
+++ b/Source/Core/VideoCommon/VideoCommon.vcxproj
@@ -111,7 +111,8 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\Common\Src;..\Core\Src;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
+ <OpenMPSupport>false</OpenMPSupport>
+ </ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
@@ -129,7 +130,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\Common\Src;..\Core\Src;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <OpenMPSupport>true</OpenMPSupport>
+ <OpenMPSupport>false</OpenMPSupport>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -141,7 +142,8 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\Common\Src;..\Core\Src;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
+ <OpenMPSupport>false</OpenMPSupport>
+ </ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>