Mesa (main): mesa/streaming-memcpy: add memcpy fallback
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 7 03:57:39 UTC 2022
Module: Mesa
Branch: main
Commit: c370fa362b99ceaf2d4cd2b37f8d110e83b32b60
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c370fa362b99ceaf2d4cd2b37f8d110e83b32b60
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Jun 2 09:56:11 2022 -0400
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 <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16732>
---
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 <smmintrin.h>
+#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);
More information about the mesa-commit
mailing list