gallivm/tessellator: use private functions for min/max to avoid namespace issues
authorDave Airlie <airlied@redhat.com>
Mon, 2 Mar 2020 06:55:18 +0000 (16:55 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 2 Mar 2020 21:30:07 +0000 (07:30 +1000)
Different builds are failing because of namespace collisions here.

Just fix the MS code to avoid it.

Fixes: bd0188f9eab ("gallium/auxiliary: add the microsoft tessellator and a pipe wrapper.")
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2586
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4016>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4016>

src/gallium/auxiliary/tessellator/tessellator.cpp

index d3f3fc2cf76a72111a783b4073235f59bc33e81d..ac16aabd098d4991225f0a522bfa05e3bc4e8b21 100644 (file)
@@ -43,7 +43,7 @@ union fiu {
     int i;
 };
 
-bool isNaN( float a )
+static bool tess_isNaN( float a )
 {
     static const int exponentMask = 0x7f800000;
     static const int mantissaMask = 0x007fffff;
@@ -55,7 +55,7 @@ bool isNaN( float a )
 //---------------------------------------------------------------------------------------------------------------------------------
 // flush (denorm)
 //---------------------------------------------------------------------------------------------------------------------------------
-float flush( float a )
+static float tess_flush( float a )
 {
     static const int minNormalizedFloat = 0x00800000;
     static const int signBit = 0x80000000;
@@ -75,11 +75,11 @@ float flush( float a )
 //---------------------------------------------------------------------------------------------------------------------------------
 // IEEE754R min
 //---------------------------------------------------------------------------------------------------------------------------------
-float fmin( float a, float b )
+static float tess_fmin( float a, float b )
 {
-    float _a = flush( a );
-    float _b = flush( b );
-    if( isNaN( _b ) )
+    float _a = tess_flush( a );
+    float _b = tess_flush( b );
+    if( tess_isNaN( _b ) )
     {
         return a;
     }
@@ -95,12 +95,12 @@ float fmin( float a, float b )
 //---------------------------------------------------------------------------------------------------------------------------------
 // IEEE754R max
 //---------------------------------------------------------------------------------------------------------------------------------
-float fmax( float a, float b )
+static float tess_fmax( float a, float b )
 {
-    float _a = flush( a );
-    float _b = flush( b );
+    float _a = tess_flush( a );
+    float _b = tess_flush( b );
 
-    if( isNaN( _b ) )
+    if( tess_isNaN( _b ) )
     {
         return a;
     }
@@ -582,10 +582,10 @@ void CHWTessellator::QuadProcessTessFactors( float tessFactor_Ueq0, float tessFa
             break;
     }
 
-    tessFactor_Ueq0 = fmin( upperBound, fmax( lowerBound, tessFactor_Ueq0 ) );
-    tessFactor_Veq0 = fmin( upperBound, fmax( lowerBound, tessFactor_Veq0 ) );
-    tessFactor_Ueq1 = fmin( upperBound, fmax( lowerBound, tessFactor_Ueq1 ) );
-    tessFactor_Veq1 = fmin( upperBound, fmax( lowerBound, tessFactor_Veq1 ) );
+    tessFactor_Ueq0 = tess_fmin( upperBound, tess_fmax( lowerBound, tessFactor_Ueq0 ) );
+    tessFactor_Veq0 = tess_fmin( upperBound, tess_fmax( lowerBound, tessFactor_Veq0 ) );
+    tessFactor_Ueq1 = tess_fmin( upperBound, tess_fmax( lowerBound, tessFactor_Ueq1 ) );
+    tessFactor_Veq1 = tess_fmin( upperBound, tess_fmax( lowerBound, tessFactor_Veq1 ) );
 
     if( HWIntegerPartitioning()) // pow2 or integer, round to next int (hw doesn't care about pow2 distinction)
     {
@@ -614,8 +614,8 @@ void CHWTessellator::QuadProcessTessFactors( float tessFactor_Ueq0, float tessFa
         }
     }
 
-    insideTessFactor_U = fmin( upperBound, fmax( lowerBound, insideTessFactor_U ) );
-    insideTessFactor_V = fmin( upperBound, fmax( lowerBound, insideTessFactor_V ) );
+    insideTessFactor_U = tess_fmin( upperBound, tess_fmax( lowerBound, insideTessFactor_U ) );
+    insideTessFactor_V = tess_fmin( upperBound, tess_fmax( lowerBound, insideTessFactor_V ) );
     // Note the above clamps map NaN to lowerBound
 
 
@@ -1100,9 +1100,9 @@ void CHWTessellator::TriProcessTessFactors( float tessFactor_Ueq0, float tessFac
             break;
     }
 
-    tessFactor_Ueq0 = fmin( upperBound, fmax( lowerBound, tessFactor_Ueq0 ) );
-    tessFactor_Veq0 = fmin( upperBound, fmax( lowerBound, tessFactor_Veq0 ) );
-    tessFactor_Weq0 = fmin( upperBound, fmax( lowerBound, tessFactor_Weq0 ) );
+    tessFactor_Ueq0 = tess_fmin( upperBound, tess_fmax( lowerBound, tessFactor_Ueq0 ) );
+    tessFactor_Veq0 = tess_fmin( upperBound, tess_fmax( lowerBound, tessFactor_Veq0 ) );
+    tessFactor_Weq0 = tess_fmin( upperBound, tess_fmax( lowerBound, tessFactor_Weq0 ) );
 
     if( HWIntegerPartitioning()) // pow2 or integer, round to next int (hw doesn't care about pow2 distinction)
     {
@@ -1126,7 +1126,7 @@ void CHWTessellator::TriProcessTessFactors( float tessFactor_Ueq0, float tessFac
         }
     }
 
-    insideTessFactor = fmin( upperBound, fmax( lowerBound, insideTessFactor ) );
+    insideTessFactor = tess_fmin( upperBound, tess_fmax( lowerBound, insideTessFactor ) );
     // Note the above clamps map NaN to lowerBound
 
     if( HWIntegerPartitioning()) // pow2 or integer, round to next int (hw doesn't care about pow2 distinction)
@@ -1475,9 +1475,9 @@ void CHWTessellator::IsoLineProcessTessFactors( float TessFactor_V_LineDensity,
             break;
     }
 
-    TessFactor_V_LineDensity = fmin( D3D11_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR,
-                                    fmax( D3D11_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR, TessFactor_V_LineDensity ) );
-    TessFactor_U_LineDetail = fmin( upperBound, fmax( lowerBound, TessFactor_U_LineDetail ) );
+    TessFactor_V_LineDensity = tess_fmin( D3D11_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR,
+                                    tess_fmax( D3D11_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR, TessFactor_V_LineDensity ) );
+    TessFactor_U_LineDetail = tess_fmin( upperBound, tess_fmax( lowerBound, TessFactor_U_LineDetail ) );
 
     // Reset our vertex and index buffers.  We have enough storage for the max tessFactor.
     m_NumPoints = 0;
@@ -2281,10 +2281,10 @@ void CHLSLTessellator::QuadHLSLProcessTessFactors( float tessFactor_Ueq0, float
         switch( m_insideTessFactorReduction )
         {
         case D3D11_TESSELLATOR_REDUCTION_MIN:
-            insideTessFactor[U] = fmin(fmin(tessFactor_Veq0,tessFactor_Veq1),fmin(tessFactor_Ueq0,tessFactor_Ueq1));
+            insideTessFactor[U] = tess_fmin(tess_fmin(tessFactor_Veq0,tessFactor_Veq1),tess_fmin(tessFactor_Ueq0,tessFactor_Ueq1));
             break;
         case D3D11_TESSELLATOR_REDUCTION_MAX:
-            insideTessFactor[U] = fmax(fmax(tessFactor_Veq0,tessFactor_Veq1),fmax(tessFactor_Ueq0,tessFactor_Ueq1));
+            insideTessFactor[U] = tess_fmax(tess_fmax(tessFactor_Veq0,tessFactor_Veq1),tess_fmax(tessFactor_Ueq0,tessFactor_Ueq1));
             break;
         case D3D11_TESSELLATOR_REDUCTION_AVERAGE:
             insideTessFactor[U] = (tessFactor_Veq0 + tessFactor_Veq1 + tessFactor_Ueq0 + tessFactor_Ueq1) / 4;
@@ -2321,11 +2321,11 @@ void CHLSLTessellator::QuadHLSLProcessTessFactors( float tessFactor_Ueq0, float
         {
             if(D3D11_TESSELLATOR_REDUCTION_MAX == m_insideTessFactorReduction)
             {
-                insideTessFactor[U] = fmin(FLOAT_THREE,fmax(fmax(tessFactor_Veq0,tessFactor_Veq1),fmax(tessFactor_Ueq0,tessFactor_Ueq1)));
+                insideTessFactor[U] = tess_fmin(FLOAT_THREE,tess_fmax(tess_fmax(tessFactor_Veq0,tessFactor_Veq1),tess_fmax(tessFactor_Ueq0,tessFactor_Ueq1)));
             }
             else
             {
-                insideTessFactor[U] = fmin(FLOAT_THREE,(tessFactor_Veq0 + tessFactor_Veq1 + tessFactor_Ueq0 + tessFactor_Ueq1) / 4);
+                insideTessFactor[U] = tess_fmin(FLOAT_THREE,(tessFactor_Veq0 + tessFactor_Veq1 + tessFactor_Ueq0 + tessFactor_Ueq1) / 4);
             }
             ClampTessFactor(insideTessFactor[U]); // clamp reduction result that is based on unbounded user input
             m_LastUnRoundedComputedTessFactors[4] = m_LastUnRoundedComputedTessFactors[5] = insideTessFactor[U]; // Save off TessFactors so they can be returned to app
@@ -2343,12 +2343,12 @@ void CHLSLTessellator::QuadHLSLProcessTessFactors( float tessFactor_Ueq0, float
         switch( m_insideTessFactorReduction )
         {
         case D3D11_TESSELLATOR_REDUCTION_MIN:
-            insideTessFactor[U] = fmin(tessFactor_Veq0,tessFactor_Veq1);
-            insideTessFactor[V] = fmin(tessFactor_Ueq0,tessFactor_Ueq1);
+            insideTessFactor[U] = tess_fmin(tessFactor_Veq0,tessFactor_Veq1);
+            insideTessFactor[V] = tess_fmin(tessFactor_Ueq0,tessFactor_Ueq1);
             break;
         case D3D11_TESSELLATOR_REDUCTION_MAX:
-            insideTessFactor[U] = fmax(tessFactor_Veq0,tessFactor_Veq1);
-            insideTessFactor[V] = fmax(tessFactor_Ueq0,tessFactor_Ueq1);
+            insideTessFactor[U] = tess_fmax(tessFactor_Veq0,tessFactor_Veq1);
+            insideTessFactor[V] = tess_fmax(tessFactor_Ueq0,tessFactor_Ueq1);
             break;
         case D3D11_TESSELLATOR_REDUCTION_AVERAGE:
             insideTessFactor[U] = (tessFactor_Veq0 + tessFactor_Veq1) / 2;
@@ -2392,11 +2392,11 @@ void CHLSLTessellator::QuadHLSLProcessTessFactors( float tessFactor_Ueq0, float
         {
             if(D3D11_TESSELLATOR_REDUCTION_MAX == m_insideTessFactorReduction)
             {
-                insideTessFactor[U] = fmin(FLOAT_THREE,fmax(tessFactor_Veq0,tessFactor_Veq1));
+                insideTessFactor[U] = tess_fmin(FLOAT_THREE,tess_fmax(tessFactor_Veq0,tessFactor_Veq1));
             }
             else
             {
-                insideTessFactor[U] = fmin(FLOAT_THREE,(tessFactor_Veq0 + tessFactor_Veq1) / 2);
+                insideTessFactor[U] = tess_fmin(FLOAT_THREE,(tessFactor_Veq0 + tessFactor_Veq1) / 2);
             }
             ClampTessFactor(insideTessFactor[U]); // clamp reduction result that is based on unbounded user input
             m_LastUnRoundedComputedTessFactors[4] = insideTessFactor[U]; // Save off TessFactors so they can be returned to app
@@ -2412,11 +2412,11 @@ void CHLSLTessellator::QuadHLSLProcessTessFactors( float tessFactor_Ueq0, float
         {
             if(D3D11_TESSELLATOR_REDUCTION_MAX == m_insideTessFactorReduction)
             {
-                insideTessFactor[V] = fmin(FLOAT_THREE,fmax(tessFactor_Ueq0,tessFactor_Ueq1));
+                insideTessFactor[V] = tess_fmin(FLOAT_THREE,tess_fmax(tessFactor_Ueq0,tessFactor_Ueq1));
             }
             else
             {
-                insideTessFactor[V] = fmin(FLOAT_THREE,(tessFactor_Ueq0 + tessFactor_Ueq1) / 2);
+                insideTessFactor[V] = tess_fmin(FLOAT_THREE,(tessFactor_Ueq0 + tessFactor_Ueq1) / 2);
             }
             ClampTessFactor(insideTessFactor[V]);// clamp reduction result that is based on unbounded user input
             m_LastUnRoundedComputedTessFactors[5] = insideTessFactor[V]; // Save off TessFactors so they can be returned to app
@@ -2435,7 +2435,7 @@ void CHLSLTessellator::QuadHLSLProcessTessFactors( float tessFactor_Ueq0, float
                 // as much as the side with the minimum TessFactor.  Prevents snapping to edge.
                 if( (insideTessFactor[axis] < FLOAT_THREE) && (insideTessFactor[axis] < insideTessFactor[(axis+1)&0x1]))
                 {
-                    insideTessFactor[axis] = fmin(insideTessFactor[(axis+1)&0x1],FLOAT_THREE);
+                    insideTessFactor[axis] = tess_fmin(insideTessFactor[(axis+1)&0x1],FLOAT_THREE);
                     m_LastUnRoundedComputedTessFactors[4+axis] = insideTessFactor[axis]; // Save off TessFactors so they can be returned to app
                 }
             }
@@ -2517,10 +2517,10 @@ void CHLSLTessellator::TriHLSLProcessTessFactors( float tessFactor_Ueq0, float t
     switch( m_insideTessFactorReduction )
     {
     case D3D11_TESSELLATOR_REDUCTION_MIN:
-        insideTessFactor = fmin(fmin(tessFactor_Ueq0,tessFactor_Veq0),tessFactor_Weq0);
+        insideTessFactor = tess_fmin(tess_fmin(tessFactor_Ueq0,tessFactor_Veq0),tessFactor_Weq0);
         break;
     case D3D11_TESSELLATOR_REDUCTION_MAX:
-        insideTessFactor = fmax(fmax(tessFactor_Ueq0,tessFactor_Veq0),tessFactor_Weq0);
+        insideTessFactor = tess_fmax(tess_fmax(tessFactor_Ueq0,tessFactor_Veq0),tessFactor_Weq0);
         break;
     case D3D11_TESSELLATOR_REDUCTION_AVERAGE:
         insideTessFactor = (tessFactor_Ueq0 + tessFactor_Veq0 + tessFactor_Weq0) / 3;
@@ -2529,7 +2529,7 @@ void CHLSLTessellator::TriHLSLProcessTessFactors( float tessFactor_Ueq0, float t
 
     // Scale inside TessFactor based on user scale factor.
     ClampFloatTessFactorScale(insideTessFactorScale); // clamp scale value to [0..1], NaN->0
-    insideTessFactor = insideTessFactor*fmin(FLOAT_ONE,insideTessFactorScale);
+    insideTessFactor = insideTessFactor*tess_fmin(FLOAT_ONE,insideTessFactorScale);
 
     ClampTessFactor(insideTessFactor); // clamp reduction + scale result that is based on unbounded user input
     m_LastUnRoundedComputedTessFactors[3] = insideTessFactor;// Save off TessFactors so they can be returned to app
@@ -2552,11 +2552,11 @@ void CHLSLTessellator::TriHLSLProcessTessFactors( float tessFactor_Ueq0, float t
         // in using avg or max (and ignore inside TessFactor scaling) until it is at least 3.
         if(D3D11_TESSELLATOR_REDUCTION_MAX == m_insideTessFactorReduction)
         {
-            insideTessFactor = fmin(FLOAT_THREE,fmax(tessFactor_Ueq0,fmax(tessFactor_Veq0,tessFactor_Weq0)));
+            insideTessFactor = tess_fmin(FLOAT_THREE,tess_fmax(tessFactor_Ueq0,tess_fmax(tessFactor_Veq0,tessFactor_Weq0)));
         }
         else
         {
-            insideTessFactor = fmin(FLOAT_THREE,(tessFactor_Ueq0 + tessFactor_Veq0 + tessFactor_Weq0) / 3);
+            insideTessFactor = tess_fmin(FLOAT_THREE,(tessFactor_Ueq0 + tessFactor_Veq0 + tessFactor_Weq0) / 3);
         }
         ClampTessFactor(insideTessFactor); // clamp reduction result that is based on unbounded user input
         m_LastUnRoundedComputedTessFactors[3] = insideTessFactor;// Save off TessFactors so they can be returned to app
@@ -2631,19 +2631,19 @@ void CHLSLTessellator::ClampTessFactor(float& TessFactor)
 {
     if( Pow2Partitioning() )
     {
-        TessFactor = fmin( D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR, fmax( TessFactor, D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR) );
+        TessFactor = tess_fmin( D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR, tess_fmax( TessFactor, D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR) );
     }
     else if( IntegerPartitioning() )
     {
-        TessFactor = fmin( D3D11_TESSELLATOR_MAX_TESSELLATION_FACTOR, fmax( TessFactor, D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR) );
+        TessFactor = tess_fmin( D3D11_TESSELLATOR_MAX_TESSELLATION_FACTOR, tess_fmax( TessFactor, D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR) );
     }
     else if( Odd() )
     {
-        TessFactor = fmin( D3D11_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR, fmax( TessFactor, D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR) );
+        TessFactor = tess_fmin( D3D11_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR, tess_fmax( TessFactor, D3D11_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR) );
     }
     else // even
     {
-        TessFactor = fmin( D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR, fmax( TessFactor, D3D11_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR) );
+        TessFactor = tess_fmin( D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR, tess_fmax( TessFactor, D3D11_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR) );
     }
 }