GPU: Precompute texture window expression [SAVEVERSION+]

This commit is contained in:
Connor McLaughlin
2020-09-20 21:28:45 +10:00
parent f761f1550f
commit cacf7a7cc9
8 changed files with 35 additions and 34 deletions

View File

@ -95,6 +95,7 @@ void GPU::SoftReset()
m_fifo.Clear();
m_blit_buffer.clear();
m_blit_remaining_words = 0;
m_draw_mode.texture_window_value = 0xFFFFFFFFu;
SetDrawMode(0);
SetTexturePalette(0);
SetTextureWindow(0);
@ -121,10 +122,10 @@ bool GPU::DoState(StateWrapper& sw)
sw.Do(&m_draw_mode.texture_page_y);
sw.Do(&m_draw_mode.texture_palette_x);
sw.Do(&m_draw_mode.texture_palette_y);
sw.Do(&m_draw_mode.texture_window_mask_x);
sw.Do(&m_draw_mode.texture_window_mask_y);
sw.Do(&m_draw_mode.texture_window_offset_x);
sw.Do(&m_draw_mode.texture_window_offset_y);
sw.Do(&m_draw_mode.texture_window_and_x);
sw.Do(&m_draw_mode.texture_window_and_y);
sw.Do(&m_draw_mode.texture_window_or_x);
sw.Do(&m_draw_mode.texture_window_or_y);
sw.Do(&m_draw_mode.texture_x_flip);
sw.Do(&m_draw_mode.texture_y_flip);
@ -1316,10 +1317,16 @@ void GPU::SetTextureWindow(u32 value)
FlushRender();
m_draw_mode.texture_window_mask_x = value & UINT32_C(0x1F);
m_draw_mode.texture_window_mask_y = (value >> 5) & UINT32_C(0x1F);
m_draw_mode.texture_window_offset_x = (value >> 10) & UINT32_C(0x1F);
m_draw_mode.texture_window_offset_y = (value >> 15) & UINT32_C(0x1F);
const u8 mask_x = Truncate8(value & UINT32_C(0x1F));
const u8 mask_y = Truncate8((value >> 5) & UINT32_C(0x1F));
const u8 offset_x = Truncate8((value >> 10) & UINT32_C(0x1F));
const u8 offset_y = Truncate8((value >> 15) & UINT32_C(0x1F));
Log_DebugPrintf("Set texture window %02X %02X %02X %02X", mask_x, mask_y, offset_x, offset_y);
m_draw_mode.texture_window_and_x = ~(mask_x * 8);
m_draw_mode.texture_window_and_y = ~(mask_y * 8);
m_draw_mode.texture_window_or_x = (offset_x & mask_x) * 8u;
m_draw_mode.texture_window_or_y = (offset_y & mask_y) * 8u;
m_draw_mode.texture_window_value = value;
m_draw_mode.texture_window_changed = true;
}