DMA: Memory wraparound is unlikely

This commit is contained in:
Stenzek 2023-12-20 22:44:50 +10:00
parent 48a1282a08
commit bbd021bd5f
No known key found for this signature in database
1 changed files with 4 additions and 4 deletions

View File

@ -688,7 +688,7 @@ TickCount DMA::TransferMemoryToDevice(u32 address, u32 increment, u32 word_count
const u32 mask = GetAddressMask(); const u32 mask = GetAddressMask();
if constexpr (channel != Channel::GPU) if constexpr (channel != Channel::GPU)
{ {
if (static_cast<s32>(increment) < 0 || ((address + (increment * word_count)) & mask) <= address) if (static_cast<s32>(increment) < 0 || ((address + (increment * word_count)) & mask) <= address) [[unlikely]]
{ {
// Use temp buffer if it's wrapping around // Use temp buffer if it's wrapping around
if (s_transfer_buffer.size() < word_count) if (s_transfer_buffer.size() < word_count)
@ -708,7 +708,7 @@ TickCount DMA::TransferMemoryToDevice(u32 address, u32 increment, u32 word_count
{ {
case Channel::GPU: case Channel::GPU:
{ {
if (g_gpu->BeginDMAWrite()) if (g_gpu->BeginDMAWrite()) [[likely]]
{ {
u8* ram_pointer = Bus::g_ram; u8* ram_pointer = Bus::g_ram;
for (u32 i = 0; i < word_count; i++) for (u32 i = 0; i < word_count; i++)
@ -765,7 +765,7 @@ TickCount DMA::TransferDeviceToMemory(u32 address, u32 increment, u32 word_count
} }
u32* dest_pointer = reinterpret_cast<u32*>(&Bus::g_ram[address]); u32* dest_pointer = reinterpret_cast<u32*>(&Bus::g_ram[address]);
if (static_cast<s32>(increment) < 0 || ((address + (increment * word_count)) & mask) <= address) if (static_cast<s32>(increment) < 0 || ((address + (increment * word_count)) & mask) <= address) [[unlikely]]
{ {
// Use temp buffer if it's wrapping around // Use temp buffer if it's wrapping around
if (s_transfer_buffer.size() < word_count) if (s_transfer_buffer.size() < word_count)
@ -798,7 +798,7 @@ TickCount DMA::TransferDeviceToMemory(u32 address, u32 increment, u32 word_count
break; break;
} }
if (dest_pointer == s_transfer_buffer.data()) if (dest_pointer == s_transfer_buffer.data()) [[unlikely]]
{ {
u8* ram_pointer = Bus::g_ram; u8* ram_pointer = Bus::g_ram;
for (u32 i = 0; i < word_count; i++) for (u32 i = 0; i < word_count; i++)