swr/rast: Remove use of C++14 template variable
authorTim Rowley <timothy.o.rowley@intel.com>
Thu, 10 Aug 2017 21:11:35 +0000 (16:11 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 6 Sep 2017 16:02:29 +0000 (11:02 -0500)
SWR rasterizer must remain C++11 compliant.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/core/binner.cpp
src/gallium/drivers/swr/rasterizer/core/binner.h

index 832c47d6e4bd644d491f8d5a7977603cc3a7084b..01c2f8f7a33a0001edf7ef0c5143c3a445d47de8 100644 (file)
@@ -502,7 +502,7 @@ void SIMDCALL BinTrianglesImpl(
     }
 
     // Adjust for pixel center location
-    typename SIMD_T::Float offset = g_pixelOffsets<SIMD_T>[rastState.pixelLocation];
+    typename SIMD_T::Float offset = SwrPixelOffsets<SIMD_T>::GetOffset(rastState.pixelLocation);
 
     tri[0].x = SIMD_T::add_ps(tri[0].x, offset);
     tri[0].y = SIMD_T::add_ps(tri[0].y, offset);
@@ -1332,7 +1332,7 @@ void BinPointsImpl(
         }
     }
 
-    typename SIMD_T::Float offset = g_pixelOffsets<SIMD_T>[rastState.pixelLocation];
+    typename SIMD_T::Float offset = SwrPixelOffsets<SIMD_T>::GetOffset(rastState.pixelLocation);
 
     prim[0].x = SIMD_T::add_ps(prim[0].x, offset);
     prim[0].y = SIMD_T::add_ps(prim[0].y, offset);
@@ -1666,7 +1666,7 @@ void SIMDCALL BinLinesImpl(
     }
 
     // adjust for pixel center location
-    typename SIMD_T::Float offset = g_pixelOffsets<SIMD_T>[rastState.pixelLocation];
+    typename SIMD_T::Float offset = SwrPixelOffsets<SIMD_T>::GetOffset(rastState.pixelLocation);
 
     prim[0].x = SIMD_T::add_ps(prim[0].x, offset);
     prim[0].y = SIMD_T::add_ps(prim[0].y, offset);
index e842aa663b2a97bf590ce31b57ac29f4eabe1b6a..97e113f7f28a609464125e40020cbdfa0501789b 100644 (file)
 //////////////////////////////////////////////////////////////////////////
 /// @brief Offsets added to post-viewport vertex positions based on
 /// raster state.
+///
+/// Can't use templated variable because we must stick with C++11 features.
+/// Template variables were introduced with C++14
 template <typename SIMD_T>
-static const typename SIMD_T::Float g_pixelOffsets[SWR_PIXEL_LOCATION_UL + 1] =
+struct SwrPixelOffsets
 {
-    SIMD_T::set1_ps(0.0f),  // SWR_PIXEL_LOCATION_CENTER
-    SIMD_T::set1_ps(0.5f),  // SWR_PIXEL_LOCATION_UL
+public:
+    INLINE static typename SIMD_T::Float GetOffset(uint32_t loc)
+    {
+        SWR_ASSERT(loc <= 1);
+
+        return SIMD_T::set1_ps(loc ? 0.5f : 0.0f);
+    }
 };
 
 //////////////////////////////////////////////////////////////////////////