Skip to content

Commit

Permalink
GPU: Approxiate texture cache reload time for P8/C16 sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Aug 11, 2024
1 parent db4e28f commit abbb21f
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/core/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,39 @@ class GPU

u32 ticks_per_row = drawn_width;
if (textured)
ticks_per_row += drawn_width;
{
switch (m_draw_mode.mode_reg.texture_mode)
{
case GPUTextureMode::Palette4Bit:
ticks_per_row += drawn_width;
break;

case GPUTextureMode::Palette8Bit:
{
// Texture cache reload every 2 pixels, reads in 8 bytes (assuming 4x2). Cache only reloads if the
// draw width is greater than 32, otherwise the cache hits between rows.
if (drawn_width >= 32)
ticks_per_row += (drawn_width / 4) * 8;
else
ticks_per_row += drawn_width;
}
break;

case GPUTextureMode::Direct16Bit:
case GPUTextureMode::Reserved_Direct16Bit:
{
// Same as above, except with 2x2 blocks instead of 4x2.
if (drawn_width >= 32)
ticks_per_row += (drawn_width / 2) * 8;
else
ticks_per_row += drawn_width;
}
break;

DefaultCaseIsUnreachable()
}
}

if (semitransparent || m_GPUSTAT.check_mask_before_draw)
ticks_per_row += (drawn_width + 1u) / 2u;
if (m_GPUSTAT.SkipDrawingToActiveField())
Expand Down

0 comments on commit abbb21f

Please sign in to comment.