gsdx: detect RT size based on fb size and gs output configuration

* It is required for snowbling games
* Targets of Texture cache are dropped.
This commit is contained in:
refraction 2015-05-13 20:00:25 +02:00 committed by Gregory Hainaut
parent 02274601b3
commit 97b237712c
4 changed files with 46 additions and 10 deletions

@ -34,22 +34,37 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc)
m_userhacks_skipdraw = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_SkipDraw", 0) : 0;
m_userhacks_align_sprite_X = !!theApp.GetConfig("UserHacks_align_sprite_X", 0) && !!theApp.GetConfig("UserHacks", 0);
m_userhacks_round_sprite_offset = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_round_sprite_offset", 0) : 0;
}
if(!m_nativeres)
void GSRendererHW::SetScaling(){
int env = IsEnabled(1) ? 1 : 0;
m_buffer_size = max(m_context->FRAME.FBW, m_regs->DISP[env].DISPFB.FBW);
if (m_upscale_multiplier < 6 && (m_width / m_upscale_multiplier) != (m_buffer_size * 64)){
printf("Frame buffer width on vsync %d m_width %d\n", m_buffer_size, (m_width / m_upscale_multiplier));
m_tc->RemovePartial();
}
else {
return;
}
if (!m_nativeres)
{
m_width = theApp.GetConfig("resx", m_width);
m_height = theApp.GetConfig("resy", m_height);
m_upscale_multiplier = theApp.GetConfig("upscale_multiplier", m_upscale_multiplier);
if(m_upscale_multiplier > 6)
if (m_upscale_multiplier > 6)
{
m_upscale_multiplier = 1; // use the normal upscale math
}
else if(m_upscale_multiplier > 1)
else if (m_upscale_multiplier > 1)
{
m_width = 640 * m_upscale_multiplier; // 512 is also common, but this is not always detected right.
m_height = 512 * m_upscale_multiplier; // 448 is also common, but this is not always detected right.
m_width = (m_buffer_size * 64) * m_upscale_multiplier;
m_height = m_width; //Keep it square
}
}
else
@ -59,9 +74,15 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc)
if (m_upscale_multiplier == 1) {
// No upscaling hack at native resolution
if (m_nativeres) {
m_width = (m_buffer_size * 64) * m_upscale_multiplier;
m_height = m_width; //Keep it square
}
m_userhacks_round_sprite_offset = 0;
m_userhacks_align_sprite_X = 0;
}
printf("Frame buffer width %d m_width set to %d multiplier %d", m_buffer_size, m_width, m_upscale_multiplier);
}
GSRendererHW::~GSRendererHW()
@ -74,11 +95,6 @@ void GSRendererHW::SetGameCRC(uint32 crc, int options)
GSRenderer::SetGameCRC(crc, options);
m_hacks.SetGameCRC(m_game);
if(m_game.title == CRC::JackieChanAdv)
{
m_width = 1280; // TODO: uses a 1280px wide 16 bit render target, but this only fixes half of the problem
}
}
bool GSRendererHW::CanUpscale()
@ -108,6 +124,9 @@ void GSRendererHW::Reset()
void GSRendererHW::VSync(int field)
{
//Check if the frame buffer width or display width has changed
SetScaling();
if(m_reset)
{
m_tc->RemoveAll();

@ -25,6 +25,7 @@
#include "GSTextureCache.h"
#include "GSCrc.h"
#include "GSFunctionMap.h"
#include "GSState.h"
class GSRendererHW : public GSRenderer
{
@ -34,6 +35,7 @@ private:
int m_skip;
bool m_reset;
int m_upscale_multiplier;
int m_buffer_size;
int m_userhacks_skipdraw;
bool m_userhacks_align_sprite_X;
@ -151,6 +153,7 @@ public:
void SetGameCRC(uint32 crc, int options);
bool CanUpscale();
int GetUpscaleMultiplier();
void SetScaling();
void Reset();
void VSync(int field);

@ -40,6 +40,18 @@ GSTextureCache::~GSTextureCache()
_aligned_free(m_temp);
}
void GSTextureCache::RemovePartial()
{
//m_src.RemoveAll();
for (int type = 0; type < 2; type++)
{
for_each(m_dst[type].begin(), m_dst[type].end(), delete_object());
m_dst[type].clear();
}
}
void GSTextureCache::RemoveAll()
{
m_src.RemoveAll();

@ -99,6 +99,7 @@ public:
void Add(Source* s, const GIFRegTEX0& TEX0, const GSOffset* off);
void RemoveAll();
void RemovePartial();
void RemoveAt(Source* s);
};
@ -128,6 +129,7 @@ public:
virtual void Read(Target* t, const GSVector4i& r) = 0;
#endif
void RemoveAll();
void RemovePartial();
Source* LookupSource(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i& r);
Target* LookupTarget(const GIFRegTEX0& TEX0, int w, int h, int type, bool used);