gallium/swr: fix gcc warnings
authorKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Wed, 29 Jan 2020 15:46:04 +0000 (16:46 +0100)
committerKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Fri, 31 Jan 2020 09:52:27 +0000 (09:52 +0000)
Few changes to make gcc happy.

Reviewed-by: Jan Zielinski <jan.zielinski@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3629>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3629>

src/gallium/drivers/swr/meson.build
src/gallium/drivers/swr/rasterizer/core/format_conversion.h
src/gallium/drivers/swr/rasterizer/core/frontend.cpp
src/gallium/drivers/swr/rasterizer/core/tessellator.cpp
src/gallium/drivers/swr/rasterizer/core/tessellator.hpp
src/gallium/drivers/swr/rasterizer/jitter/functionpasses/lower_x86.cpp
src/gallium/drivers/swr/swr_screen.h
src/gallium/drivers/swr/swr_shader.cpp

index 11ea7d3f43ed3c9247a26d423e72e34b3f827b05..6b6ec3652ec2763289d4bf27a3a78d9b9e06a7e7 100644 (file)
@@ -191,6 +191,10 @@ swr_cpp_args = [cpp_vis_args]
 if cpp.has_argument('-fno-strict-aliasing')
   swr_cpp_args += '-fno-strict-aliasing'
 endif
+if cpp.has_argument('-Wno-aligned-new')
+  swr_cpp_args += '-Wno-aligned-new'
+endif
+
 
 swr_arch_libs = []
 swr_defines = []
index 247ba0b0dcd90f44bc2fdf703e159652873f1491..f1ea06c4978e551c94386546dd7cb20318711d57 100644 (file)
@@ -100,6 +100,12 @@ template <typename SIMD_T, SWR_FORMAT Format>
 INLINE Float<SIMD_T> SIMDCALL Clamp(Float<SIMD_T> const& v, uint32_t Component)
 {
     Float<SIMD_T> vComp = v;
+    if (Component >= 4 || Component < 0)
+    {
+       // Component shouldn't out of <0;3> range
+       assert(false);
+       return vComp;
+    }
     if (FormatTraits<Format>::isNormalized(Component))
     {
         if (FormatTraits<Format>::GetType(Component) == SWR_TYPE_UNORM)
index 97d435394eddfe95b6eaa3e21dbd6eb45353760a..63beac180d9fe62a548d6292a5ca8c9069ebca8d 100644 (file)
@@ -704,7 +704,6 @@ void ProcessStreamIdBuffer(uint32_t stream,
 {
     SWR_ASSERT(stream < MAX_SO_STREAMS);
 
-    uint32_t numInputBytes  = AlignUp(numEmittedVerts * 2, 8) / 8;
     uint32_t numOutputBytes = AlignUp(numEmittedVerts, 8) / 8;
 
     for (uint32_t b = 0; b < numOutputBytes; ++b)
@@ -1553,7 +1552,7 @@ static void TessellationStages(DRAW_CONTEXT* pDC,
                     // Gather data from the SVG if provided.
                     simd16scalari vViewportIdx = SIMD16::setzero_si();
                     simd16scalari vRtIdx       = SIMD16::setzero_si();
-                    SIMD16::Vec4  svgAttrib[4];
+                    SIMD16::Vec4 svgAttrib[4] = {SIMD16::setzero_ps()};
 
                     if (state.backendState.readViewportArrayIndex ||
                         state.backendState.readRenderTargetArrayIndex)
index e0464c360fa3459cb379c228c11d55b120e987af..9a93b056bef8be5fd73262411d55f4e73536bc12 100644 (file)
@@ -179,7 +179,9 @@ INT32 floatToIDotF( const float& input )
         if (iShift >= 0)
         {
 //            assert( iShift < 32 );
+#if defined(_WIN32) || defined(_WIN64)
 #pragma warning( suppress : 4293 )
+#endif
             _fxpMaxPosValueFloat -= INT32( 1 ) << iShift;
         }
 
@@ -199,7 +201,9 @@ INT32 floatToIDotF( const float& input )
         if (iShift >= 0)
         {
 //            assert( iShift < 32 );
+#if defined(_WIN32) || defined(_WIN64)
 #pragma warning( suppress : 4293 )
+#endif
             _fxpMaxPosValueFloat -= INT32( 1 ) << iShift;
         }
 
@@ -542,7 +546,7 @@ void CHWTessellator::QuadProcessTessFactors( float tessFactor_Ueq0, float tessFa
     }
 
     // Clamp edge TessFactors
-    float lowerBound, upperBound;
+    float lowerBound = 0.0, upperBound = 0.0;
     switch(m_originalPartitioning)
     {
         case D3D11_TESSELLATOR_PARTITIONING_INTEGER:
@@ -1060,7 +1064,7 @@ void CHWTessellator::TriProcessTessFactors( float tessFactor_Ueq0, float tessFac
     }
 
     // Clamp edge TessFactors
-    float lowerBound, upperBound;
+    float lowerBound = 0.0, upperBound = 0.0;
     switch(m_originalPartitioning)
     {
         case D3D11_TESSELLATOR_PARTITIONING_INTEGER:
@@ -1435,7 +1439,7 @@ void CHWTessellator::IsoLineProcessTessFactors( float TessFactor_V_LineDensity,
     }
 
     // Clamp edge TessFactors
-    float lowerBound, upperBound;
+    float lowerBound = 0.0, upperBound = 0.0;
     switch(m_originalPartitioning)
     {
         case D3D11_TESSELLATOR_PARTITIONING_INTEGER:
@@ -2236,15 +2240,13 @@ void CHLSLTessellator::QuadHLSLProcessTessFactors( float tessFactor_Ueq0, float
     // Process outside tessFactors
     float outsideTessFactor[QUAD_EDGES] = {tessFactor_Ueq0, tessFactor_Veq0, tessFactor_Ueq1, tessFactor_Veq1};
     int edge, axis;
-    TESSELLATOR_PARITY insideTessFactorParity[QUAD_AXES], outsideTessFactorParity[QUAD_EDGES];
+    TESSELLATOR_PARITY insideTessFactorParity[QUAD_AXES];
     if( Pow2Partitioning() || IntegerPartitioning() )
     {
         for( edge = 0; edge < QUAD_EDGES; edge++ )
         {
             RoundUpTessFactor(outsideTessFactor[edge]);
             ClampTessFactor(outsideTessFactor[edge]); // clamp unbounded user input based on tessellation mode
-            int edgeEven = isEven(outsideTessFactor[edge]);
-            outsideTessFactorParity[edge] = edgeEven ? TESSELLATOR_PARITY_EVEN : TESSELLATOR_PARITY_ODD;
         }
     }
     else
@@ -2253,7 +2255,6 @@ void CHLSLTessellator::QuadHLSLProcessTessFactors( float tessFactor_Ueq0, float
         for( edge = 0; edge < QUAD_EDGES; edge++ )
         {
             ClampTessFactor(outsideTessFactor[edge]); // clamp unbounded user input based on tessellation mode
-            outsideTessFactorParity[edge] = m_originalParity;
         }
     }
 
@@ -2588,18 +2589,10 @@ void CHLSLTessellator::IsoLineHLSLProcessTessFactors( float TessFactor_V_LineDen
 
     m_LastUnRoundedComputedTessFactors[1] = TessFactor_U_LineDetail;    // Save off TessFactors so they can be returned to app
 
-    TESSELLATOR_PARITY parity;
     if(Pow2Partitioning()||IntegerPartitioning())
     {
         RoundUpTessFactor(TessFactor_U_LineDetail);
-        parity = isEven(TessFactor_U_LineDetail) ? TESSELLATOR_PARITY_EVEN : TESSELLATOR_PARITY_ODD;
     }
-    else
-    {
-        parity = m_originalParity;
-    }
-
-    FXP fxpTessFactor_U_LineDetail = floatToFixed(TessFactor_U_LineDetail);
 
     OverridePartitioning(D3D11_TESSELLATOR_PARTITIONING_INTEGER);
 
index 77a228d8b27f3c1d0045fc3a0c373bbba9ca1df8..459c1093d2e3706538dfbc84454b7d243ec97bfa 100644 (file)
@@ -74,7 +74,7 @@
 //=================================================================================================================================
 // Data types for the caller
 //=================================================================================================================================
-typedef enum D3D11_TESSELLATOR_PARTITIONING
+enum D3D11_TESSELLATOR_PARTITIONING
 {
     D3D11_TESSELLATOR_PARTITIONING_INTEGER,
     D3D11_TESSELLATOR_PARTITIONING_POW2,
@@ -82,20 +82,20 @@ typedef enum D3D11_TESSELLATOR_PARTITIONING
     D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN
 };
 
-typedef enum D3D11_TESSELLATOR_REDUCTION
+enum D3D11_TESSELLATOR_REDUCTION
 {
     D3D11_TESSELLATOR_REDUCTION_MIN,
     D3D11_TESSELLATOR_REDUCTION_MAX,
     D3D11_TESSELLATOR_REDUCTION_AVERAGE
 };
 
-typedef enum D3D11_TESSELLATOR_QUAD_REDUCTION_AXIS
+enum D3D11_TESSELLATOR_QUAD_REDUCTION_AXIS
 {
     D3D11_TESSELLATOR_QUAD_REDUCTION_1_AXIS,
     D3D11_TESSELLATOR_QUAD_REDUCTION_2_AXIS
 };
 
-typedef enum D3D11_TESSELLATOR_OUTPUT_PRIMITIVE
+enum D3D11_TESSELLATOR_OUTPUT_PRIMITIVE
 {
     D3D11_TESSELLATOR_OUTPUT_POINT,
     D3D11_TESSELLATOR_OUTPUT_LINE,
@@ -177,7 +177,7 @@ public:
     static const int TRI_EDGES = 3;
     //=============================================================================================================================
 
-    typedef enum TESSELLATOR_PARITY // derived from D3D11_TESSELLATOR_PARTITIONING
+    enum TESSELLATOR_PARITY // derived from D3D11_TESSELLATOR_PARTITIONING
     {                               // (note: for integer tessellation, both parities are used)
         TESSELLATOR_PARITY_EVEN,
         TESSELLATOR_PARITY_ODD
@@ -310,7 +310,7 @@ private:
                                                int outsideEdgePointBaseOffset, int outsideNumHalfTessFactorPoints,
                                                TESSELLATOR_PARITY outsideEdgeTessFactorParity );
     // The interior can just use a simpler stitch.
-    typedef enum DIAGONALS
+    enum DIAGONALS
     {
         DIAGONALS_INSIDE_TO_OUTSIDE,
         DIAGONALS_INSIDE_TO_OUTSIDE_EXCEPT_MIDDLE,
index d00a8963d3853610688f01e5fe2e31466b0f2d1a..2fadca340dbe06aa9c67b31eb5eb61183190e6b3 100644 (file)
@@ -507,7 +507,7 @@ namespace SwrJit
         uint32_t numElem  = vSrc->getType()->getVectorNumElements();
         auto     i32Scale = B->Z_EXT(i8Scale, B->mInt32Ty);
         auto     srcTy    = vSrc->getType()->getVectorElementType();
-        Value*   v32Gather;
+        Value*   v32Gather = nullptr;
         if (arch == AVX)
         {
             // Full emulation for AVX
@@ -536,7 +536,7 @@ namespace SwrJit
         }
         else if (arch == AVX2 || (arch == AVX512 && width == W256))
         {
-            Function* pX86IntrinFunc;
+            Function* pX86IntrinFunc = nullptr;
             if (srcTy == B->mFP32Ty)
             {
                 pX86IntrinFunc = Intrinsic::getDeclaration(B->JM()->mpCurrentModule,
@@ -627,8 +627,8 @@ namespace SwrJit
         }
         else if (arch == AVX512)
         {
-            Value*    iMask;
-            Function* pX86IntrinFunc;
+            Value*    iMask = nullptr;
+            Function* pX86IntrinFunc = nullptr;
             if (srcTy == B->mFP32Ty)
             {
                 pX86IntrinFunc = Intrinsic::getDeclaration(B->JM()->mpCurrentModule,
index 8c79acfea4cb019c384e63cc3ec0d3309a6741bd..e66f5443357b40f75220ba96244754d557d2bac3 100644 (file)
@@ -72,7 +72,7 @@ swr_screen(struct pipe_screen *pipe)
 SWR_FORMAT
 mesa_to_swr_format(enum pipe_format format);
 
-static void swr_print_info(const char *format, ...)
+INLINE void swr_print_info(const char *format, ...)
 {
    static bool print_info = debug_get_bool_option("SWR_PRINT_INFO", false);
    if(print_info) {
index 028ebb7d7b63bbf70cecb52f6d4b60ac44061af1..558cf5fe4bc7fcb29c9a3e77246b7b0bcccaade5 100644 (file)
@@ -1623,10 +1623,10 @@ BuilderSWR::CompileTES(struct swr_context *ctx, swr_jit_tes_key &key)
    unsigned tes_spacing = info->properties[TGSI_PROPERTY_TES_SPACING];
    bool tes_vertex_order_cw = info->properties[TGSI_PROPERTY_TES_VERTEX_ORDER_CW];
    bool tes_point_mode = info->properties[TGSI_PROPERTY_TES_POINT_MODE];
-   SWR_TS_DOMAIN type;
-   SWR_TS_PARTITIONING partitioning;
-   SWR_TS_OUTPUT_TOPOLOGY topology;
-   PRIMITIVE_TOPOLOGY postDSTopology;
+   SWR_TS_DOMAIN type = SWR_TS_ISOLINE;
+   SWR_TS_PARTITIONING partitioning = SWR_TS_EVEN_FRACTIONAL;
+   SWR_TS_OUTPUT_TOPOLOGY topology = SWR_TS_OUTPUT_POINT;
+   PRIMITIVE_TOPOLOGY postDSTopology = TOP_POINT_LIST;
 
    // TESS_TODO: move this to helper functions to improve readability
    switch (tes_prim_mode) {