summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2017-03-09 21:06:50 +0100
committerGitHub <noreply@github.com>2017-03-09 21:06:50 +0100
commitef74c5eabd52a75eb42ecf9b36701dca11d3061f (patch)
tree2cc71d56b6b97b05e29666d169824aacffc0258b /Source/Core/VideoCommon
parentcf848b7c42071104c2ade3b1b8230e2233a40f11 (diff)
parent2cd240af0d261d4600e273badd912570a5a09a19 (diff)
Merge pull request #5051 from stenzek/renderer-fixes
VideoBackends: Fix crashes introduced by #4999
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/FramebufferManagerBase.cpp10
-rw-r--r--Source/Core/VideoCommon/FramebufferManagerBase.h4
-rw-r--r--Source/Core/VideoCommon/RenderBase.cpp12
-rw-r--r--Source/Core/VideoCommon/RenderBase.h5
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp2
-rw-r--r--Source/Core/VideoCommon/VideoConfig.cpp1
-rw-r--r--Source/Core/VideoCommon/VideoConfig.h2
7 files changed, 17 insertions, 19 deletions
diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.cpp b/Source/Core/VideoCommon/FramebufferManagerBase.cpp
index 0fc65a5443..dd2cc88735 100644
--- a/Source/Core/VideoCommon/FramebufferManagerBase.cpp
+++ b/Source/Core/VideoCommon/FramebufferManagerBase.cpp
@@ -248,20 +248,18 @@ void FramebufferManagerBase::ReplaceVirtualXFB()
}
}
-int FramebufferManagerBase::ScaleToVirtualXfbWidth(int x)
+int FramebufferManagerBase::ScaleToVirtualXfbWidth(int x, const TargetRectangle& target_rectangle)
{
if (g_ActiveConfig.RealXFBEnabled())
return x;
- return x * static_cast<int>(g_renderer->GetTargetRectangle().GetWidth()) /
- static_cast<int>(FramebufferManagerBase::LastXfbWidth());
+ return x * target_rectangle.GetWidth() / s_last_xfb_width;
}
-int FramebufferManagerBase::ScaleToVirtualXfbHeight(int y)
+int FramebufferManagerBase::ScaleToVirtualXfbHeight(int y, const TargetRectangle& target_rectangle)
{
if (g_ActiveConfig.RealXFBEnabled())
return y;
- return y * static_cast<int>(g_renderer->GetTargetRectangle().GetHeight()) /
- static_cast<int>(FramebufferManagerBase::LastXfbHeight());
+ return y * target_rectangle.GetHeight() / s_last_xfb_height;
}
diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.h b/Source/Core/VideoCommon/FramebufferManagerBase.h
index 47426b2e01..c780a3fa21 100644
--- a/Source/Core/VideoCommon/FramebufferManagerBase.h
+++ b/Source/Core/VideoCommon/FramebufferManagerBase.h
@@ -57,8 +57,8 @@ public:
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);
- static int ScaleToVirtualXfbHeight(int y);
+ static int ScaleToVirtualXfbWidth(int x, const TargetRectangle& target_rectangle);
+ static int ScaleToVirtualXfbHeight(int y, const TargetRectangle& target_rectangle);
static unsigned int GetEFBLayers() { return m_EFBLayers; }
virtual std::pair<u32, u32> GetTargetSize() const = 0;
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 7e598e2373..1c99e51950 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -84,8 +84,8 @@ Renderer::Renderer(int backbuffer_width, int backbuffer_height)
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
UpdateActiveConfig();
- CalculateTargetSize();
UpdateDrawRectangle();
+ CalculateTargetSize();
OSDChoice = 0;
OSDTime = 0;
@@ -127,7 +127,7 @@ int Renderer::EFBToScaledX(int x)
switch (g_ActiveConfig.iEFBScale)
{
case SCALE_AUTO: // fractional
- return FramebufferManagerBase::ScaleToVirtualXfbWidth(x);
+ return FramebufferManagerBase::ScaleToVirtualXfbWidth(x, m_target_rectangle);
default:
return x * (int)m_efb_scale_numeratorX / (int)m_efb_scale_denominatorX;
@@ -139,7 +139,7 @@ int Renderer::EFBToScaledY(int y)
switch (g_ActiveConfig.iEFBScale)
{
case SCALE_AUTO: // fractional
- return FramebufferManagerBase::ScaleToVirtualXfbHeight(y);
+ return FramebufferManagerBase::ScaleToVirtualXfbHeight(y, m_target_rectangle);
default:
return y * (int)m_efb_scale_numeratorY / (int)m_efb_scale_denominatorY;
@@ -173,8 +173,8 @@ bool Renderer::CalculateTargetSize()
{
case SCALE_AUTO:
case SCALE_AUTO_INTEGRAL:
- newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH);
- newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT);
+ newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, m_target_rectangle);
+ newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, m_target_rectangle);
if (m_last_efb_scale == SCALE_AUTO_INTEGRAL)
{
@@ -217,7 +217,7 @@ bool Renderer::CalculateTargetSize()
m_efb_scale_numeratorX = m_efb_scale_numeratorY = m_last_efb_scale - 3;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
- const u32 max_size = GetMaxTextureSize();
+ const u32 max_size = g_ActiveConfig.backend_info.MaxTextureSize;
if (max_size < EFB_WIDTH * m_efb_scale_numeratorX / m_efb_scale_denominatorX)
{
m_efb_scale_numeratorX = m_efb_scale_numeratorY = (max_size / EFB_WIDTH);
diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h
index 79c174e28c..b1291adf0d 100644
--- a/Source/Core/VideoCommon/RenderBase.h
+++ b/Source/Core/VideoCommon/RenderBase.h
@@ -137,9 +137,6 @@ public:
PEControl::PixelFormat GetPrevPixelFormat() { return m_prev_efb_format; }
void StorePixelFormat(PEControl::PixelFormat new_format) { m_prev_efb_format = new_format; }
PostProcessingShaderImplementation* GetPostProcessor() { return m_post_processor.get(); }
- // Max height/width
- virtual u32 GetMaxTextureSize() = 0;
-
// Final surface changing
// This is called when the surface is resized (WX) or the window changes (Android).
virtual void ChangeSurface(void* new_surface_handle) {}
@@ -168,7 +165,7 @@ protected:
int m_backbuffer_width = 0;
int m_backbuffer_height = 0;
int m_last_efb_scale = 0;
- TargetRectangle m_target_rectangle;
+ TargetRectangle m_target_rectangle = {};
bool m_xfb_written = false;
FPSCounter m_fps_counter;
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index b1dbee5407..2f9b374dd6 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -242,7 +242,7 @@ void TextureCacheBase::ScaleTextureCacheEntryTo(TextureCacheBase::TCacheEntryBas
return;
}
- u32 max = g_renderer->GetMaxTextureSize();
+ const u32 max = g_ActiveConfig.backend_info.MaxTextureSize;
if (max < new_width || max < new_height)
{
ERROR_LOG(VIDEO, "Texture too big, width = %d, height = %d", new_width, new_height);
diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp
index 1f3d3d10ea..2db2494a05 100644
--- a/Source/Core/VideoCommon/VideoConfig.cpp
+++ b/Source/Core/VideoCommon/VideoConfig.cpp
@@ -37,6 +37,7 @@ VideoConfig::VideoConfig()
// disable all features by default
backend_info.api_type = APIType::Nothing;
+ backend_info.MaxTextureSize = 16384;
backend_info.bSupportsExclusiveFullscreen = false;
backend_info.bSupportsMultithreading = false;
backend_info.bSupportsInternalResolutionFrameDumps = false;
diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h
index dfab8bbcc3..ec79e6de48 100644
--- a/Source/Core/VideoCommon/VideoConfig.h
+++ b/Source/Core/VideoCommon/VideoConfig.h
@@ -173,6 +173,8 @@ struct VideoConfig final
// TODO: merge AdapterName and Adapters array
std::string AdapterName; // for OpenGL
+ u32 MaxTextureSize;
+
bool bSupportsExclusiveFullscreen;
bool bSupportsDualSourceBlend;
bool bSupportsPrimitiveRestart;