From c09483cf0a21a68c00a8daf080a2e7de17ac3039 Mon Sep 17 00:00:00 2001 From: George Kyriazis Date: Fri, 9 Feb 2018 11:37:17 -0600 Subject: [PATCH] swr/rast: Convert C Sampler intrinsics Convert portions of the C sampler to the rasty SIMD lib. Also fix SRL call with a non-immediate. Don't count on the compiler automagically converting an srli call to srl if the shift count isn't an immediate. Reviewed-by: Bruce Cherniak --- .../drivers/swr/rasterizer/common/intrin.h | 3 +++ .../swr/rasterizer/common/simdlib_128_avx.inl | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/gallium/drivers/swr/rasterizer/common/intrin.h b/src/gallium/drivers/swr/rasterizer/common/intrin.h index 33d37e3cece..59d66bc60a8 100644 --- a/src/gallium/drivers/swr/rasterizer/common/intrin.h +++ b/src/gallium/drivers/swr/rasterizer/common/intrin.h @@ -26,7 +26,10 @@ #include "os.h" +#if !defined(SIMD_ARCH) #define SIMD_ARCH KNOB_ARCH +#endif + #include "simdlib_types.hpp" typedef SIMDImpl::SIMD128Impl::Float simd4scalar; diff --git a/src/gallium/drivers/swr/rasterizer/common/simdlib_128_avx.inl b/src/gallium/drivers/swr/rasterizer/common/simdlib_128_avx.inl index 72327918937..b1511c6c0e2 100644 --- a/src/gallium/drivers/swr/rasterizer/common/simdlib_128_avx.inl +++ b/src/gallium/drivers/swr/rasterizer/common/simdlib_128_avx.inl @@ -174,6 +174,7 @@ SIMD_IWRAPPER_2_(xor_si, _mm_xor_si128); // return a ^ b (int) // Shift operations //----------------------------------------------------------------------- SIMD_IWRAPPER_1I(slli_epi32); // return a << ImmT +SIMD_IWRAPPER_1I(slli_epi64); // return a << ImmT static SIMDINLINE Integer SIMDCALL sllv_epi32(Integer vA, Integer vB) // return a << b (uint32) { @@ -205,6 +206,11 @@ SIMD_IWRAPPER_1I(srai_epi32); // return a >> ImmT (int32) SIMD_IWRAPPER_1I(srli_epi32); // return a >> ImmT (uint32) SIMD_IWRAPPER_1I_(srli_si, _mm_srli_si128); // return a >> (ImmT*8) (uint) +static SIMDINLINE Integer SIMDCALL srl_epi64(Integer a, Integer n) +{ + return _mm_srl_epi64(a, n); +} + template // same as srli_si, but with Float cast to int static SIMDINLINE Float SIMDCALL srlisi_ps(Float a) { @@ -272,6 +278,16 @@ static SIMDINLINE Float SIMDCALL cvtepi32_ps(Integer a) // return (float)a (i return _mm_cvtepi32_ps(a); } +static SIMDINLINE int32_t SIMDCALL cvtsi128_si32(Integer a) // return a.v[0] +{ + return _mm_cvtsi128_si32(a); +} + +static SIMDINLINE Integer SIMDCALL cvtsi32_si128(int32_t n) // return a[0] = n, a[1]...a[3] = 0 +{ + return _mm_cvtsi32_si128(n); +} + SIMD_IWRAPPER_1(cvtepu8_epi16); // return (int16)a (uint8 --> int16) SIMD_IWRAPPER_1(cvtepu8_epi32); // return (int32)a (uint8 --> int32) SIMD_IWRAPPER_1(cvtepu16_epi32); // return (int32)a (uint16 --> int32) -- 2.30.2