GS/TC: Optimize block offset calculations in ComputeSurfaceOffset.

Same deal as before, swap the fast linear loops to be second since they will be faster.
This commit is contained in:
lightningterror
2025-10-03 16:59:24 +02:00
parent ddd33a0701
commit 96ac35a4bd

View File

@@ -8014,9 +8014,9 @@ GSTextureCache::SurfaceOffset GSTextureCache::ComputeSurfaceOffset(const Surface
if (a_el.bp >= b_el.bp)
{
// A starts after B, search <x,y> offset from B to A in B coords.
for (b2a_offset.x = b_rect.x; b2a_offset.x < b_rect.z; b2a_offset.x += dx)
for (b2a_offset.y = b_rect.y; b2a_offset.y < b_rect.w; b2a_offset.y += dy)
{
for (b2a_offset.y = b_rect.y; b2a_offset.y < b_rect.w; b2a_offset.y += dy)
for (b2a_offset.x = b_rect.x; b2a_offset.x < b_rect.z; b2a_offset.x += dx)
{
const u32 a_candidate_bp = b_psm_s.info.bn(b2a_offset.x, b2a_offset.y, b_el.bp, b_el.bw);
if (a_el.bp == a_candidate_bp)
@@ -8055,9 +8055,9 @@ GSTextureCache::SurfaceOffset GSTextureCache::ComputeSurfaceOffset(const Surface
{
// B ends after A, sweep search <z,w> offset in B coordinates.
so.is_valid = false;
for (b2a_offset.z = b2a_offset.x; b2a_offset.z <= b_rect.z; b2a_offset.z += dx)
for (b2a_offset.w = b2a_offset.y; b2a_offset.w <= b_rect.w; b2a_offset.w += dy)
{
for (b2a_offset.w = b2a_offset.y; b2a_offset.w <= b_rect.w; b2a_offset.w += dy)
for (b2a_offset.z = b2a_offset.x; b2a_offset.z <= b_rect.z; b2a_offset.z += dx)
{
const u32 a_candidate_bp_end = b_psm_s.info.bn(b2a_offset.z - 1, b2a_offset.w - 1, b_el.bp, b_el.bw);
if (a_bp_end == a_candidate_bp_end)