GSdx-TC: Fix load size calculation in target update

Previously, the calculation for the size of data to be loaded was done
based on the rendering target buffer size and scaling multiplier, which
was totally wrong. This led to different resolutions having different
load sizes while the size of the real GS memory is common regardless of
the scaling variancies.

Hence use the default rendering target buffer size for the load size
independent of the scaling values. I've also removed a buffer height saturation
code which seemed unreliable.

Note: The accurate version of the code can be enabled using the macro
provided in config.h (which is more intensive on resources), the current
code goes along with the approach of maintaining a decent performance
level along with a formidable accuracy.
This commit is contained in:
Akash 2017-11-08 12:17:23 +05:30
parent 1cbd4c5387
commit b10c357065
5 changed files with 17 additions and 16 deletions

View File

@ -1449,3 +1449,9 @@ enum class CRCHackLevel : int8
Full,
Aggressive
};
#ifdef ENABLE_ACCURATE_BUFFER_EMULATION
const GSVector2i default_rt_size(2048, 2048);
#else
const GSVector2i default_rt_size(1280, 1024);
#endif

View File

@ -23,8 +23,8 @@
#include "GSRendererHW.h"
GSRendererHW::GSRendererHW(GSTextureCache* tc)
: m_width(native_buffer.x)
, m_height(native_buffer.y)
: m_width(default_rt_size.x)
, m_height(default_rt_size.y)
, m_custom_width(1024)
, m_custom_height(1024)
, m_reset(false)
@ -158,8 +158,8 @@ void GSRendererHW::CustomResolutionScaling()
return;
m_tc->RemovePartial();
m_width = std::max(m_width, native_buffer.x);
m_height = std::max(framebuffer_height[m_large_framebuffer], native_buffer.y);
m_width = std::max(m_width, default_rt_size.x);
m_height = std::max(framebuffer_height[m_large_framebuffer], default_rt_size.y);
std::string overhead = std::to_string(framebuffer_height[1] - framebuffer_height[0]);
std::string message = "(Custom resolution) Framebuffer size set to " + std::to_string(crtc_width) + "x" + std::to_string(crtc_height);

View File

@ -30,7 +30,6 @@
class GSRendererHW : public GSRenderer
{
private:
GSVector2i native_buffer = GSVector2i{1280, 1024};
int m_width;
int m_height;
int m_custom_width;

View File

@ -1847,18 +1847,13 @@ void GSTextureCache::Target::Update()
// Alternate
// 1/ uses multiple vertex rectangle
GSVector2i t_size = m_texture->GetSize();
GSVector2 t_scale = m_texture->GetScale();
GSVector2i t_size = default_rt_size;
//Avoids division by zero when calculating texture size.
t_scale = GSVector2(std::max(1.0f, t_scale.x), std::max(1.0f, t_scale.y));
t_size.x = lround(static_cast<float>(t_size.x) / t_scale.x);
t_size.y = lround(static_cast<float>(t_size.y) / t_scale.y);
// Don't load above the GS memory
int max_y_blocks = (MAX_BLOCKS - m_TEX0.TBP0) / std::max(1u, m_TEX0.TBW);
int max_y = (max_y_blocks >> 5) * GSLocalMemory::m_psm[m_TEX0.PSM].pgs.y;
t_size.y = std::min(t_size.y, max_y);
// Ensure buffer width is at least of the minimum required value.
// Probably not necessary but doesn't hurt to be on the safe side.
// I've seen some games use buffer sizes over 1024, which might bypass our default limit
int buffer_width = m_TEX0.TBW << 6;
t_size.x = std::max(buffer_width, t_size.x);
GSVector4i r = m_dirty.GetDirtyRectAndClear(m_TEX0, t_size);

View File

@ -23,6 +23,7 @@
//#define ENABLE_VTUNE
//#define ENABLE_PCRTC_DEBUG
//#define ENABLE_ACCURATE_BUFFER_EMULATION
#define ENABLE_JIT_RASTERIZER
#define EXTERNAL_SHADER_LOADING 1