1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

only use __movsb if src and dst are aligned

This commit is contained in:
FunkyFr3sh 2022-09-25 11:26:31 +02:00
parent 620e700d72
commit c39280deb2

View File

@ -12,9 +12,9 @@ void blt_copy(
size_t size) size_t size)
{ {
#if defined(_MSC_VER) || defined(__AVX__) #if defined(_MSC_VER) || defined(__AVX__)
if (g_blt_use_avx && !((DWORD)dst % 32) && !((DWORD)src % 32)) if (!((DWORD)dst % 32) && !((DWORD)src % 32))
{ {
if (size >= 1024 * 4096) if (size >= 1024 * 4096 && g_blt_use_avx)
{ {
_mm_prefetch((const char*)(src), _MM_HINT_NTA); _mm_prefetch((const char*)(src), _MM_HINT_NTA);
@ -48,7 +48,7 @@ void blt_copy(
_mm_sfence(); _mm_sfence();
_mm256_zeroupper(); _mm256_zeroupper();
} }
else if (size < 1024 * 100) else if (size < 1024 * 100 && g_blt_use_avx)
{ {
while (size >= 128) while (size >= 128)
{ {
@ -69,16 +69,18 @@ void blt_copy(
_mm256_zeroupper(); _mm256_zeroupper();
} }
else if (size >= 1024 * 100)
{
__movsb(dst, src, size);
size = 0;
}
/* memcpy below handles the remainder */ /* memcpy below handles the remainder */
} }
#endif #endif
if (size >= 1024 * 100) if (size > 0)
{
__movsb(dst, src, size);
}
else
{ {
memcpy(dst, src, size); memcpy(dst, src, size);
} }