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

View File

@ -34,22 +34,37 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc)
m_userhacks_skipdraw = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_SkipDraw", 0) : 0; 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_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; 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_width = theApp.GetConfig("resx", m_width);
m_height = theApp.GetConfig("resy", m_height); m_height = theApp.GetConfig("resy", m_height);
m_upscale_multiplier = theApp.GetConfig("upscale_multiplier", m_upscale_multiplier); 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 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_width = (m_buffer_size * 64) * m_upscale_multiplier;
m_height = 512 * m_upscale_multiplier; // 448 is also common, but this is not always detected right. m_height = m_width; //Keep it square
} }
} }
else else
@ -59,9 +74,15 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc)
if (m_upscale_multiplier == 1) { if (m_upscale_multiplier == 1) {
// No upscaling hack at native resolution // 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_round_sprite_offset = 0;
m_userhacks_align_sprite_X = 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() GSRendererHW::~GSRendererHW()
@ -74,11 +95,6 @@ void GSRendererHW::SetGameCRC(uint32 crc, int options)
GSRenderer::SetGameCRC(crc, options); GSRenderer::SetGameCRC(crc, options);
m_hacks.SetGameCRC(m_game); 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() bool GSRendererHW::CanUpscale()
@ -108,6 +124,9 @@ void GSRendererHW::Reset()
void GSRendererHW::VSync(int field) void GSRendererHW::VSync(int field)
{ {
//Check if the frame buffer width or display width has changed
SetScaling();
if(m_reset) if(m_reset)
{ {
m_tc->RemoveAll(); m_tc->RemoveAll();

View File

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

View File

@ -40,6 +40,18 @@ GSTextureCache::~GSTextureCache()
_aligned_free(m_temp); _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() void GSTextureCache::RemoveAll()
{ {
m_src.RemoveAll(); m_src.RemoveAll();

View File

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