Merge pull request #5051 from stenzek/renderer-fixes

VideoBackends: Fix crashes introduced by #4999
This commit is contained in:
Markus Wick
2017-03-09 21:06:50 +01:00
committed by GitHub
26 changed files with 91 additions and 97 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;