From 0536ca20d757b5ca9fc9f989ba64a545ab8235d7 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 16 Mar 2020 22:49:39 -0700 Subject: [PATCH] swr/rasterizer: Use private functions for min/max to avoid namespace issues. This is a similiar fix as bb2287ccdf46 ("gallivm/tessellator: use private functions for min/max to avoid namespace issues"). Fixes: ab5570820071 ("swr/rasterizer: Add tessellator implementation to the rasterizer") Signed-off-by: Vinson Lee Reviewed-by: Jan Zielinski Tested-by: Jan Zielinski Part-of: --- .../swr/rasterizer/core/tessellator.cpp | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/tessellator.cpp b/src/gallium/drivers/swr/rasterizer/core/tessellator.cpp index 9a93b056bef..05a598b60a9 100644 --- a/src/gallium/drivers/swr/rasterizer/core/tessellator.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/tessellator.cpp @@ -35,7 +35,7 @@ //--------------------------------------------------------------------------------------------------------------------------------- // isNaN //--------------------------------------------------------------------------------------------------------------------------------- -bool isNaN( float a ) +static bool tess_isNaN( float a ) { static const int exponentMask = 0x7f800000; static const int mantissaMask = 0x007fffff; @@ -46,7 +46,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; @@ -63,11 +63,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; } @@ -81,12 +81,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; } @@ -566,10 +566,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) { @@ -598,8 +598,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 @@ -1084,9 +1084,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) { @@ -1110,7 +1110,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) @@ -1459,9 +1459,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; @@ -2265,10 +2265,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; @@ -2305,11 +2305,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 @@ -2327,12 +2327,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; @@ -2376,11 +2376,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 @@ -2396,11 +2396,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 @@ -2419,7 +2419,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 } } @@ -2501,10 +2501,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; @@ -2513,7 +2513,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 @@ -2536,11 +2536,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 @@ -2615,19 +2615,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) ); } } -- 2.30.2