From c370fa362b99ceaf2d4cd2b37f8d110e83b32b60 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 2 Jun 2022 09:56:11 -0400 Subject: [PATCH] mesa/streaming-memcpy: add memcpy fallback this makes it more compatible and able to be used from the caller without ifdefs Reviewed-by: Emma Anholt Part-of: --- src/mesa/main/streaming-load-memcpy.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/streaming-load-memcpy.c b/src/mesa/main/streaming-load-memcpy.c index 32854b60eb2..376bfd87c4f 100644 --- a/src/mesa/main/streaming-load-memcpy.c +++ b/src/mesa/main/streaming-load-memcpy.c @@ -28,7 +28,10 @@ #include "main/macros.h" #include "main/streaming-load-memcpy.h" +#include "x86/common_x86_asm.h" +#ifdef USE_SSE41 #include +#endif /* Copies memory from src to dst, using SSE 4.1's MOVNTDQA to get streaming * read performance from uncached memory. @@ -39,8 +42,9 @@ _mesa_streaming_load_memcpy(void *restrict dst, void *restrict src, size_t len) char *restrict d = dst; char *restrict s = src; - /* If dst and src are not co-aligned, fallback to memcpy(). */ - if (((uintptr_t)d & 15) != ((uintptr_t)s & 15)) { +#ifdef USE_SSE41 + /* If dst and src are not co-aligned, or if SSE4.1 is not present, fallback to memcpy(). */ + if (((uintptr_t)d & 15) != ((uintptr_t)s & 15) || !cpu_has_sse4_1) { memcpy(d, s, len); return; } @@ -80,7 +84,7 @@ _mesa_streaming_load_memcpy(void *restrict dst, void *restrict src, size_t len) s += 64; len -= 64; } - +#endif /* memcpy() the tail. */ if (len) { memcpy(d, s, len);