Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Sep 1, 2023
2 parents 265f26e + 17d2fb1 commit 0319f1d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 32 deletions.
6 changes: 0 additions & 6 deletions bin/resources/GameIndex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21301,7 +21301,6 @@ SLES-53974:
compat: 5
gsHWFixes:
autoFlush: 2 # Fixes missing bloom from surfaces like windows.
textureInsideRT: 1 # Fixes corruption.
# halfPixelOffset: 1 # Aligns shadows properly, but causes grid lines to appear in sea travel.
halfPixelOffset: 2 # Sharpens world in far distances, aligns some bloom better.
roundSprite: 1 # Fixes font artifacts.
Expand Down Expand Up @@ -31170,7 +31169,6 @@ SLPM-62490:
region: "NTSC-J"
gsHWFixes:
autoFlush: 2 # Fixes missing bloom from surfaces like windows.
textureInsideRT: 1 # Fixes corruption.
# halfPixelOffset: 1 # Aligns shadows properly, but causes grid lines to appear in sea travel.
halfPixelOffset: 2 # Sharpens world in far distances, aligns some bloom better.
roundSprite: 1 # Fixes font artifacts.
Expand Down Expand Up @@ -35446,7 +35444,6 @@ SLPM-65888:
compat: 5
gsHWFixes:
autoFlush: 2 # Fixes missing bloom from surfaces like windows.
textureInsideRT: 1 # Fixes corruption.
# halfPixelOffset: 1 # Aligns shadows properly, but causes grid lines to appear in sea travel.
halfPixelOffset: 2 # Sharpens world in far distances, aligns some bloom better.
roundSprite: 1 # Fixes font artifacts.
Expand Down Expand Up @@ -37904,7 +37901,6 @@ SLPM-66481:
region: "NTSC-J"
gsHWFixes:
autoFlush: 2 # Fixes missing bloom from surfaces like windows.
textureInsideRT: 1 # Fixes corruption.
# halfPixelOffset: 1 # Aligns shadows properly, but causes grid lines to appear in sea travel.
halfPixelOffset: 2 # Sharpens world in far distances, aligns some bloom better.
roundSprite: 1 # Fixes font artifacts.
Expand Down Expand Up @@ -52663,7 +52659,6 @@ SLUS-21207:
compat: 5
gsHWFixes:
autoFlush: 2 # Fixes missing bloom from surfaces like windows.
textureInsideRT: 1 # Fixes corruption.
# halfPixelOffset: 1 # Aligns shadows properly, but causes grid lines to appear in sea travel.
halfPixelOffset: 2 # Sharpens world in far distances, aligns some bloom better.
roundSprite: 1 # Fixes font artifacts.
Expand Down Expand Up @@ -57258,7 +57253,6 @@ SLUS-29157:
region: "NTSC-U"
gsHWFixes:
autoFlush: 2 # Fixes missing bloom from surfaces like windows.
textureInsideRT: 1 # Fixes corruption.
# halfPixelOffset: 1 # Aligns shadows properly, but causes grid lines to appear in sea travel.
halfPixelOffset: 2 # Sharpens world in far distances, aligns some bloom better.
roundSprite: 1 # Fixes font artifacts.
Expand Down
37 changes: 29 additions & 8 deletions pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5684,7 +5684,7 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds)
const u32 written_pages = w_pages * h_pages;

// If both buffers are side by side we can expect a fast clear in on-going
if (half != (base + written_pages))
if (half > (base + written_pages) || half <= base)
return false;

// Don't allow double half clear to go through when the number of bits written through FRAME and Z are different.
Expand Down Expand Up @@ -5729,10 +5729,18 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds)
base * BLOCKS_PER_PAGE, clear_depth ? m_cached_ctx.FRAME.PSM : m_cached_ctx.ZBUF.PSM);
}

u32 end_block = ((half + written_pages) * BLOCKS_PER_PAGE) - 1;

if (tgt)
{
// If the full size is an odd width and it's trying to do half (in the case of FF7 DoC it goes from 7 to 4), we need to recalculate our end check.
if ((m_cached_ctx.FRAME.FBW * 2) == (tgt->m_TEX0.TBW + 1))
end_block = GSLocalMemory::GetUnwrappedEndBlockAddress(tgt->m_TEX0.TBP0, tgt->m_TEX0.TBW + 1, tgt->m_TEX0.PSM, tgt->GetUnscaledRect());
else
end_block = GSLocalMemory::GetUnwrappedEndBlockAddress(tgt->m_TEX0.TBP0, tgt->m_TEX0.TBW, tgt->m_TEX0.PSM, tgt->GetUnscaledRect());
}
// Are we clearing over the middle of this target?
if (!tgt || (((half + written_pages) * BLOCKS_PER_PAGE) - 1) >
GSLocalMemory::GetUnwrappedEndBlockAddress(
tgt->m_TEX0.TBP0, tgt->m_TEX0.TBW, tgt->m_TEX0.PSM, tgt->GetUnscaledRect()))
if (!tgt || (((half + written_pages) * BLOCKS_PER_PAGE) - 1) > end_block)
{
return false;
}
Expand Down Expand Up @@ -6158,11 +6166,24 @@ bool GSRendererHW::PrimitiveCoversWithoutGaps()
u32 last_pX = v[1].XYZ.X;
for (u32 i = 2; i < m_vertex.next; i += 2)
{
const u32 dpX = v[i + 1].XYZ.X - v[i].XYZ.X;
if (dpX != first_dpX || v[i].XYZ.X != last_pX)
if (v[i].XYZ.X < v[i-2].XYZ.X)
{
m_primitive_covers_without_gaps = false;
return false;
const u32 dpX = v[i + 1].XYZ.X - v[i].XYZ.X;
const u32 prev_X = v[i - 2].XYZ.X - m_context->XYOFFSET.OFX;
if (dpX != prev_X || v[i].XYZ.X != m_context->XYOFFSET.OFX)
{
m_primitive_covers_without_gaps = false;
return false;
}
}
else
{
const u32 dpX = v[i + 1].XYZ.X - v[i].XYZ.X;
if (dpX != first_dpX || v[i].XYZ.X != last_pX)
{
m_primitive_covers_without_gaps = false;
return false;
}
}

last_pX = v[i + 1].XYZ.X;
Expand Down
12 changes: 11 additions & 1 deletion pcsx2/GS/Renderers/HW/GSTextureCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1493,13 +1493,19 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con

if (!found_t && !dst && !GSConfig.UserHacks_DisableDepthSupport)
{
GSVector4i new_rect = r;

// Just in case the TextureMinMax trolls us as it does, when checking if inside the target.
new_rect.z -= 2;
new_rect.w -= 2;

// Let's try a trick to avoid to use wrongly a depth buffer
// Unfortunately, I don't have any Arc the Lad testcase
//
// 1/ Check only current frame, I guess it is only used as a postprocessing effect
for (auto t : m_dst[DepthStencil])
{
if (t->m_age <= 1 && t->m_used && t->m_dirty.empty() && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM))
if (t->m_age <= 1 && t->m_used && t->m_dirty.empty() && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM) && t->Inside(bp, bw, psm, new_rect))
{
GL_INS("TC: Warning depth format read as color format. Pixels will be scrambled");
// Let's fetch a depth format texture. Rational, it will avoid the texture allocation and the
Expand Down Expand Up @@ -2023,6 +2029,9 @@ GSTextureCache::Target* GSTextureCache::CreateTarget(GIFRegTEX0 TEX0, const GSVe
GL_CACHE("TC: Lookup %s(Color) %dx%d FBMSK %08x, miss (0x%x, TBW %d, %s) draw %d", is_frame ? "Frame" : "Target",
size.x, size.y, fbmask, TEX0.TBP0, TEX0.TBW, psm_str(TEX0.PSM), g_gs_renderer->s_n);
}
// Avoid making garbage targets (usually PCRTC).
if (GSVector4i::loadh(size).rempty())
return nullptr;

Target* dst = Target::Create(TEX0, size.x, size.y, scale, type, true);

Expand Down Expand Up @@ -5286,6 +5295,7 @@ GSTextureCache::Target::Target(GIFRegTEX0 TEX0, int type, const GSVector2i& unsc
, m_valid(GSVector4i::zero())
{
m_TEX0 = TEX0;
m_end_block = m_TEX0.TBP0;
m_unscaled_size = unscaled_size;
m_scale = scale;
m_texture = texture;
Expand Down
34 changes: 17 additions & 17 deletions pcsx2/IPU/IPU_MultiISA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1007,13 +1007,6 @@ __ri static bool mpeg2sliceIDEC()
ipu_cmd.pos[0] = 2;
while (1)
{
if (ready_to_decode == true)
{
ready_to_decode = false;
CPU_INT(IPU_PROCESS, 64); // Should probably be much higher, but myst 3 doesn't like it right now.
ipu_cmd.pos[0] = 2;
return false;
}
// IPU0 isn't ready for data, so let's wait for it to be
if ((!ipu0ch.chcr.STR || ipuRegs.ctrl.OFC || ipu0ch.qwc == 0) && ipu_cmd.pos[1] <= 2)
{
Expand Down Expand Up @@ -1127,9 +1120,14 @@ __ri static bool mpeg2sliceIDEC()
[[fallthrough]];
case 2:
{

if (ready_to_decode == true)
{
ready_to_decode = false;
CPU_INT(IPU_PROCESS, 64); // Should probably be much higher, but myst 3 doesn't like it right now.
ipu_cmd.pos[1] = 2;
return false;
}
pxAssert(decoder.ipu0_data > 0);
ready_to_decode = true;
uint read = ipu_fifo.out.write((u32*)decoder.GetIpuDataPtr(), decoder.ipu0_data);
decoder.AdvanceIpuDataBy(read);

Expand All @@ -1150,6 +1148,7 @@ __ri static bool mpeg2sliceIDEC()
[[fallthrough]];

case 3:
ready_to_decode = true;
while (1)
{
if (!GETWORD())
Expand Down Expand Up @@ -1210,7 +1209,6 @@ __ri static bool mpeg2sliceIDEC()

ipu_cmd.pos[1] = 0;
ipu_cmd.pos[2] = 0;
ready_to_decode = true;
}

finish_idec:
Expand Down Expand Up @@ -1306,12 +1304,7 @@ __fi static bool mpeg2_slice()

case 2:
ipu_cmd.pos[0] = 2;
if (ready_to_decode == true)
{
ready_to_decode = false;
CPU_INT(IPU_PROCESS, 64); // Should probably be much higher, but myst 3 doesn't like it right now.
return false;
}

// IPU0 isn't ready for data, so let's wait for it to be
if ((!ipu0ch.chcr.STR || ipuRegs.ctrl.OFC || ipu0ch.qwc == 0) && ipu_cmd.pos[0] <= 3)
{
Expand Down Expand Up @@ -1517,8 +1510,15 @@ __fi static bool mpeg2_slice()
[[fallthrough]];
case 3:
{
if (ready_to_decode == true)
{
ipu_cmd.pos[0] = 3;
ready_to_decode = false;
CPU_INT(IPU_PROCESS, 64); // Should probably be much higher, but myst 3 doesn't like it right now.
return false;
}

pxAssert(decoder.ipu0_data > 0);
ready_to_decode = true;
uint read = ipu_fifo.out.write((u32*)decoder.GetIpuDataPtr(), decoder.ipu0_data);
decoder.AdvanceIpuDataBy(read);

Expand Down

0 comments on commit 0319f1d

Please sign in to comment.