From 64074a44a659c2794f21a278a5f784fc32bca8b0 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 24 Feb 2025 23:58:33 +0100 Subject: [PATCH] [util] Add sfence helper --- src/util/util_bit.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/util/util_bit.h b/src/util/util_bit.h index 6f6727005..08ec6e4d9 100644 --- a/src/util/util_bit.h +++ b/src/util/util_bit.h @@ -632,4 +632,17 @@ namespace dxvk::bit { return float(n) / float(1u << F); } + + /** + * \brief Flush pending stores, if any + * + * Needed on x86 after writing to mapped memory or using non-temporal + * stores in order to flush write-combined buffers. + */ + inline void sfence() { + #if defined(DXVK_ARCH_X86) && (defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)) + _mm_sfence(); + #endif + } + }