GS/HW: Fix some format conversion scaling problems

This commit is contained in:
refractionpcsx2 2025-02-05 01:16:16 +00:00
parent 10297abb6c
commit 4ce1d57494
2 changed files with 16 additions and 14 deletions

View File

@ -2175,6 +2175,8 @@ void GSRendererHW::Draw()
m_conf.scissor.w = m_conf.scissor.y + (((num_skipped_channel_shuffle_draws + 1 + (m_channel_shuffle_width - 1)) / std::max(1U, m_channel_shuffle_width)) * 32) * m_conf.cb_ps.ScaleFactor.z;
if (width_pages)
m_conf.scissor.z = m_conf.scissor.x + (((num_skipped_channel_shuffle_draws + 1) % std::max(1U, m_channel_shuffle_width) % std::max(1U, m_channel_shuffle_width)) * 64) * m_conf.cb_ps.ScaleFactor.z;
m_last_rt->UpdateValidity(GSVector4i::loadh(m_last_rt->m_unscaled_size).rintersect(GSVector4i(GSVector4(m_conf.scissor) / m_conf.cb_ps.ScaleFactor.z)), true);
}
g_gs_device->RenderHW(m_conf);
@ -3638,13 +3640,13 @@ void GSRendererHW::Draw()
update_rect.z = buffer_width;
}
if (m_in_target_draw && src && m_channel_shuffle && src->m_from_target && src->m_from_target == rt && m_cached_ctx.TEX0.TBP0 == src->m_from_target->m_TEX0.TBP0)
/*if (m_in_target_draw && src && m_channel_shuffle && src->m_from_target && src->m_from_target == rt && m_cached_ctx.TEX0.TBP0 == src->m_from_target->m_TEX0.TBP0)
{
new_size.y = std::max(new_size.y, static_cast<int>((((m_cached_ctx.FRAME.Block() - rt->m_TEX0.TBP0) >> 5) / rt->m_TEX0.TBW) * frame_psm.pgs.y) * 2);
new_size.y = std::max(new_size.y, static_cast<int>((((m_cached_ctx.FRAME.Block() - rt->m_TEX0.TBP0) >> 5) / rt->m_TEX0.TBW) * frame_psm.pgs.y));
GSVector4i new_valid = rt->m_valid;
new_valid.w = new_size.y;
new_valid.w = std::max(new_valid.w, static_cast<int>((((m_cached_ctx.FRAME.Block() - rt->m_TEX0.TBP0) >> 5) / rt->m_TEX0.TBW) * frame_psm.pgs.y) + frame_psm.pgs.y);
rt->UpdateValidity(new_valid, true);
}
}*/
// We still need to make sure the dimensions of the targets match.
// Limit new size to 2048, the GS can't address more than this so may avoid some bugs/crashes.
@ -3979,8 +3981,8 @@ void GSRendererHW::Draw()
const GSVector4i dRect = GSVector4i(0, z_vertical_offset * ds->m_scale, ds->m_unscaled_size.x * ds->m_scale, std::min(z_vertical_offset + m_r.w + 1 - vertical_offset, ds->m_unscaled_size.y) * ds->m_scale);
GL_CACHE("RT in RT Z copy back draw %d z_vert_offset %d z_offset %d", s_n, z_vertical_offset, vertical_offset);
g_gs_device->StretchRect(g_texture_cache->GetTemporaryZ(), GSVector4(0.0f, vertical_offset / static_cast<float>(g_texture_cache->GetTemporaryZ()->GetHeight()), 1.0f,
std::min(real_rect.w + 1, ds->m_unscaled_size.y + vertical_offset) / static_cast<float>(g_texture_cache->GetTemporaryZ()->GetHeight())), ds->m_texture, GSVector4(dRect), ShaderConvert::DEPTH_COPY, false);
g_gs_device->StretchRect(g_texture_cache->GetTemporaryZ(), GSVector4(0.0f, (static_cast<float>(vertical_offset) * ds->m_scale) / static_cast<float>(g_texture_cache->GetTemporaryZ()->GetHeight()), 1.0f,
floor(static_cast<float>(std::min(real_rect.w + 1, ds->m_unscaled_size.y + vertical_offset)) * ds->m_scale) / static_cast<float>(g_texture_cache->GetTemporaryZ()->GetHeight())), ds->m_texture, GSVector4(dRect), ShaderConvert::DEPTH_COPY, false);
}
}
}

View File

@ -2362,15 +2362,14 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(GIFRegTEX0 TEX0, const GSVe
{
if (scale_down)
{
if ((new_size.y * 2) < 1024)
{
new_scaled_size.y *= 2;
new_size.y *= 2;
dst->m_valid.y *= 2;
dst->m_valid.w *= 2;
}
new_scaled_size.y *= 2;
dst->m_valid.y *= 2;
dst->m_valid.w *= 2;
dRect.y *= 2;
dRect.w *= 2;
new_size.y *= 2;
new_size.y = std::max(dst->m_valid.w, new_size.y);
}
else
{
@ -2380,6 +2379,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(GIFRegTEX0 TEX0, const GSVe
dRect.w /= 2;
dst->m_valid.y /= 2;
dst->m_valid.w /= 2;
new_size.y = std::max(dst->m_valid.w, new_size.y);
}
}
if (!is_shuffle)
@ -2620,7 +2620,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(GIFRegTEX0 TEX0, const GSVe
dst->m_valid = dst_match->m_valid;
dst->m_valid_alpha_low = dst_match->m_valid_alpha_low; //&& psm_s.trbpp != 24;
dst->m_valid_alpha_high = dst_match->m_valid_alpha_high; //&& psm_s.trbpp != 24;
dst->m_valid_rgb = dst_match->m_valid_rgb;
dst->m_valid_rgb = dst_match->m_valid_rgb && (dst->m_TEX0.TBW == TEX0.TBW || min_rect.w <= GSLocalMemory::m_psm[dst_match->m_TEX0.PSM].pgs.y);
dst->m_was_dst_matched = true;
dst_match->m_was_dst_matched = true;
dst_match->m_valid_rgb = preserve_rgb;