From 0b4db4370544459fcd47499d9f8663e421fcae34 Mon Sep 17 00:00:00 2001 From: Alok Hota Date: Tue, 28 Aug 2018 12:23:31 -0500 Subject: swr/rast: FP consistency between POSH/RENDER pipes - Ensure all threads have optimal floating-point control state - Disable auto-generation of fused FP ops for VERTEX shader stage - Disable "fast" FP ops for VERTEX shader stage Reviewed-by: Bruce Cherniak --- src/gallium/drivers/swr/rasterizer/common/os.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/gallium/drivers/swr/rasterizer/common') diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h b/src/gallium/drivers/swr/rasterizer/common/os.h index 314d8184374..b00beeb36dd 100644 --- a/src/gallium/drivers/swr/rasterizer/common/os.h +++ b/src/gallium/drivers/swr/rasterizer/common/os.h @@ -294,4 +294,25 @@ int SWR_API std::string* pOptStdErr = nullptr, ///< (Optional Out) Standard Error text const std::string* pOptStdIn = nullptr); ///< (Optional In) Standard Input text + +/// Helper for setting up FP state +/// @returns old csr state +static INLINE uint32_t SetOptimalVectorCSR() +{ + uint32_t oldCSR = _mm_getcsr(); + + uint32_t newCSR = (oldCSR & ~(_MM_ROUND_MASK | _MM_DENORMALS_ZERO_MASK | _MM_FLUSH_ZERO_MASK)); + newCSR |= (_MM_ROUND_NEAREST | _MM_FLUSH_ZERO_ON | _MM_DENORMALS_ZERO_ON); + _mm_setcsr(newCSR); + + return oldCSR; +} + +/// Set Vector CSR state. +/// @param csrState - should be value returned from SetOptimalVectorCSR() +static INLINE void RestoreVectorCSR(uint32_t csrState) +{ + _mm_setcsr(csrState); +} + #endif //__SWR_OS_H__ -- cgit v1.2.3