Skip to content

Commit

Permalink
GSdx-hw: Add automatic detection of half_height
Browse files Browse the repository at this point in the history
  • Loading branch information
tadanokojin committed Apr 22, 2019
1 parent 8f5faa0 commit fd0a7d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
36 changes: 19 additions & 17 deletions plugins/GSdx/Renderers/HW/GSRendererHW.cpp
Expand Up @@ -35,6 +35,7 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc)
, m_userhacks_tcoffset_y(0)
, m_channel_shuffle(false)
, m_lod(GSVector2i(0,0))
, m_src(nullptr)
{
m_mipmap = theApp.GetConfigI("mipmap_hw");
m_upscale_multiplier = theApp.GetConfigI("upscale_multiplier");
Expand Down Expand Up @@ -447,7 +448,8 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
tex_pos &= 0xFF;
read_ba = (tex_pos > 112 && tex_pos < 144);

bool half_height = false;
bool half_bottom = m_src->m_valid_rect == m_r;

if (PRIM->FST) {
GL_INS("First vertex is P: %d => %d T: %d => %d", v[0].XYZ.X, v[1].XYZ.X, v[0].U, v[1].U);

Expand All @@ -462,7 +464,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
else
v[i+1].U += 128u;

if (half_height){
if (!half_bottom){
// Height is too big (2x).
int tex_offset = v[i].V & 0xF;
GSVector4i offset(o.OFY, tex_offset, o.OFY, tex_offset);
Expand Down Expand Up @@ -491,7 +493,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
else
v[i+1].ST.S += offset_8pix;

if (half_height) {
if (!half_bottom) {
// Height is too big (2x).
GSVector4i offset(o.OFY, o.OFY);

Expand All @@ -513,7 +515,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
else
m_vt.m_max.p.x += 8.0f;

if (half_height) {
if (!half_bottom) {
float delta_Y = m_vt.m_max.p.y - m_vt.m_min.p.y;
m_vt.m_max.p.y -= delta_Y / 2.0f;
}
Expand All @@ -523,7 +525,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)
else
m_vt.m_max.t.x += 8.0f;

if (half_height) {
if (!half_bottom) {
float delta_T = m_vt.m_max.t.y - m_vt.m_min.t.y;
m_vt.m_max.t.y -= delta_T / 2.0f;
}
Expand Down Expand Up @@ -888,7 +890,7 @@ void GSRendererHW::Draw()
ds_tex = ds->m_texture;
}

GSTextureCache::Source* tex = NULL;
m_src = nullptr;
m_texture_shuffle = false;

if(PRIM->TME)
Expand Down Expand Up @@ -968,7 +970,7 @@ void GSRendererHW::Draw()

GetTextureMinMax(r, TEX0, MIP_CLAMP, m_vt.IsLinear());

tex = tex_psm.depth ? m_tc->LookupDepthSource(TEX0, env.TEXA, r) : m_tc->LookupSource(TEX0, env.TEXA, r);
m_src = tex_psm.depth ? m_tc->LookupDepthSource(TEX0, env.TEXA, r) : m_tc->LookupSource(TEX0, env.TEXA, r);

// Round 2
if (IsMipMapActive() && m_mipmap == 2 && !tex_psm.depth) {
Expand All @@ -991,7 +993,7 @@ void GSRendererHW::Draw()

GetTextureMinMax(r, MIP_TEX0, MIP_CLAMP, m_vt.IsLinear());

tex->UpdateLayer(MIP_TEX0, r, layer - m_lod.x);
m_src->UpdateLayer(MIP_TEX0, r, layer - m_lod.x);
}

m_vt.m_min.t = tmin;
Expand All @@ -1003,7 +1005,7 @@ void GSRendererHW::Draw()
//
// Both input and output are 16 bits and texture was initially 32 bits!
m_texture_shuffle = (GSLocalMemory::m_psm[context->FRAME.PSM].bpp == 16) && (tex_psm.bpp == 16)
&& draw_sprite_tex && tex->m_32_bits_fmt;
&& draw_sprite_tex && m_src->m_32_bits_fmt;

// Shadow_of_memories_Shadow_Flickering (Okami mustn't call this code)
if (m_texture_shuffle && m_vertex.next < 3 && PRIM->FST && (m_context->FRAME.FBMSK == 0)) {
Expand All @@ -1024,7 +1026,7 @@ void GSRendererHW::Draw()
// Texture shuffle is not yet supported with strange clamp mode
ASSERT(!m_texture_shuffle || (context->CLAMP.WMS < 3 && context->CLAMP.WMT < 3));

if (tex->m_target && m_context->TEX0.PSM == PSM_PSMT8 && single_page && draw_sprite_tex) {
if (m_src->m_target && m_context->TEX0.PSM == PSM_PSMT8 && single_page && draw_sprite_tex) {
GL_INS("Channel shuffle effect detected (2nd shot)");
m_channel_shuffle = true;
} else {
Expand Down Expand Up @@ -1052,21 +1054,21 @@ void GSRendererHW::Draw()
m_context->Dump(m_dump_root+s);
}

if(s_savet && s_n >= s_saven && tex)
if(s_savet && s_n >= s_saven && m_src)
{
s = format("%05d_f%lld_itex_%05x_%s_%d%d_%02x_%02x_%02x_%02x.dds",
s_n, frame, (int)context->TEX0.TBP0, psm_str(context->TEX0.PSM),
(int)context->CLAMP.WMS, (int)context->CLAMP.WMT,
(int)context->CLAMP.MINU, (int)context->CLAMP.MAXU,
(int)context->CLAMP.MINV, (int)context->CLAMP.MAXV);

tex->m_texture->Save(m_dump_root+s);
m_src->m_texture->Save(m_dump_root+s);

if(tex->m_palette)
if(m_src->m_palette)
{
s = format("%05d_f%lld_itpx_%05x_%s.dds", s_n, frame, context->TEX0.CBP, psm_str(context->TEX0.CPSM));

tex->m_palette->Save(m_dump_root+s);
m_src->m_palette->Save(m_dump_root+s);
}
}

Expand All @@ -1091,13 +1093,13 @@ void GSRendererHW::Draw()
// The rectangle of the draw
m_r = GSVector4i(m_vt.m_min.p.xyxy(m_vt.m_max.p)).rintersect(GSVector4i(context->scissor.in));

if(m_hacks.m_oi && !(this->*m_hacks.m_oi)(rt_tex, ds_tex, tex))
if(m_hacks.m_oi && !(this->*m_hacks.m_oi)(rt_tex, ds_tex, m_src))
{
GL_INS("Warning skipping a draw call (%d)", s_n);
return;
}

if (!OI_BlitFMV(rt, tex, m_r)) {
if (!OI_BlitFMV(rt, m_src, m_r)) {
GL_INS("Warning skipping a draw call (%d)", s_n);
return;
}
Expand Down Expand Up @@ -1161,7 +1163,7 @@ void GSRendererHW::Draw()

//

DrawPrims(rt_tex, ds_tex, tex);
DrawPrims(rt_tex, ds_tex, m_src);

//

Expand Down
1 change: 1 addition & 0 deletions plugins/GSdx/Renderers/HW/GSRendererHW.h
Expand Up @@ -41,6 +41,7 @@ class GSRendererHW : public GSRenderer
bool m_userHacks_merge_sprite;

GSVector4i m_r;
GSTextureCache::Source* m_src;

#pragma region hacks

Expand Down

0 comments on commit fd0a7d3

Please sign in to comment.