diff options
author | Tim Rowley <[email protected]> | 2017-03-31 16:50:40 -0500 |
---|---|---|
committer | Tim Rowley <[email protected]> | 2017-04-11 18:01:03 -0500 |
commit | 4c093869db13fb59f5cf8b49fbbcb5deba7812a4 (patch) | |
tree | 472ebddc7dd37fba3a32072ffd11049cecbb2cdd /src/gallium/drivers | |
parent | 147e71242ce539ff28e282f009c332818c35f5ac (diff) |
swr: [rasterizer core] Reduce templates to speed compile
Quick patch to remove some unused template params to cut down
rasterizer compile time.
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/core/binner.cpp | 8 | ||||
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp | 6 | ||||
-rw-r--r-- | src/gallium/drivers/swr/rasterizer/core/rasterizer.h | 67 |
3 files changed, 71 insertions, 10 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp index 9ec5bea76ee..eb1f20b5a35 100644 --- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp @@ -795,7 +795,7 @@ void BinTriangles( { // degenerate triangles won't be sent to rasterizer; just enable all edges pfnWork = GetRasterizerFunc(rastState.sampleCount, rastState.bIsCenterPattern, (rastState.conservativeRast > 0), - (SWR_INPUT_COVERAGE)pDC->pState->state.psState.inputCoverage, ALL_EDGES_VALID, (state.scissorsTileAligned == false)); + (SWR_INPUT_COVERAGE)pDC->pState->state.psState.inputCoverage, EdgeValToEdgeState(ALL_EDGES_VALID), (state.scissorsTileAligned == false)); } if (!triMask) @@ -941,7 +941,7 @@ endBinTriangles: // only rasterize valid edges if we have a degenerate primitive int32_t triEdgeEnable = (edgeEnable >> (triIndex * 3)) & ALL_EDGES_VALID; work.pfnWork = GetRasterizerFunc(rastState.sampleCount, rastState.bIsCenterPattern, (rastState.conservativeRast > 0), - (SWR_INPUT_COVERAGE)pDC->pState->state.psState.inputCoverage, triEdgeEnable, (state.scissorsTileAligned == false)); + (SWR_INPUT_COVERAGE)pDC->pState->state.psState.inputCoverage, EdgeValToEdgeState(triEdgeEnable), (state.scissorsTileAligned == false)); // Degenerate triangles are required to be constant interpolated isDegenerate = (triEdgeEnable != ALL_EDGES_VALID) ? true : false; @@ -1236,7 +1236,7 @@ void BinTriangles_simd16( { // degenerate triangles won't be sent to rasterizer; just enable all edges pfnWork = GetRasterizerFunc(rastState.sampleCount, rastState.bIsCenterPattern, (rastState.conservativeRast > 0), - (SWR_INPUT_COVERAGE)pDC->pState->state.psState.inputCoverage, ALL_EDGES_VALID, (state.scissorsTileAligned == false)); + (SWR_INPUT_COVERAGE)pDC->pState->state.psState.inputCoverage, EdgeValToEdgeState(ALL_EDGES_VALID), (state.scissorsTileAligned == false)); } if (!triMask) @@ -1396,7 +1396,7 @@ endBinTriangles: // only rasterize valid edges if we have a degenerate primitive int32_t triEdgeEnable = (edgeEnable >> (triIndex * 3)) & ALL_EDGES_VALID; work.pfnWork = GetRasterizerFunc(rastState.sampleCount, rastState.bIsCenterPattern, (rastState.conservativeRast > 0), - (SWR_INPUT_COVERAGE)pDC->pState->state.psState.inputCoverage, triEdgeEnable, (state.scissorsTileAligned == false)); + (SWR_INPUT_COVERAGE)pDC->pState->state.psState.inputCoverage, EdgeValToEdgeState(triEdgeEnable), (state.scissorsTileAligned == false)); // Degenerate triangles are required to be constant interpolated isDegenerate = (triEdgeEnable != ALL_EDGES_VALID) ? true : false; diff --git a/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp b/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp index 0837841746e..af54779653e 100644 --- a/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/rasterizer.cpp @@ -1343,7 +1343,7 @@ void RasterizeTriPoint(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, PFN_WORK_FUNC pfnTriRast; // conservative rast not supported for points/lines pfnTriRast = GetRasterizerFunc(rastState.sampleCount, rastState.bIsCenterPattern, false, - SWR_INPUT_COVERAGE_NONE, ALL_EDGES_VALID, (pDC->pState->state.scissorsTileAligned == false)); + SWR_INPUT_COVERAGE_NONE, EdgeValToEdgeState(ALL_EDGES_VALID), (pDC->pState->state.scissorsTileAligned == false)); // overwrite texcoords for point sprites if (isPointSpriteTexCoordEnabled) @@ -1676,7 +1676,7 @@ void RasterizeLine(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, voi PFN_WORK_FUNC pfnTriRast; // conservative rast not supported for points/lines pfnTriRast = GetRasterizerFunc(rastState.sampleCount, rastState.bIsCenterPattern, false, - SWR_INPUT_COVERAGE_NONE, ALL_EDGES_VALID, (pDC->pState->state.scissorsTileAligned == false)); + SWR_INPUT_COVERAGE_NONE, EdgeValToEdgeState(ALL_EDGES_VALID), (pDC->pState->state.scissorsTileAligned == false)); // make sure this macrotile intersects the triangle __m128i vXai = fpToFixedPoint(vXa); @@ -1798,6 +1798,6 @@ PFN_WORK_FUNC GetRasterizerFunc( IsCenter, IsConservative, IntArg<SWR_INPUT_COVERAGE_NONE, SWR_INPUT_COVERAGE_COUNT-1>{InputCoverage}, - IntArg<0, VALID_TRI_EDGE_COUNT-1>{EdgeEnable}, + IntArg<0, STATE_VALID_TRI_EDGE_COUNT-1>{EdgeEnable}, RasterizeScissorEdges); } diff --git a/src/gallium/drivers/swr/rasterizer/core/rasterizer.h b/src/gallium/drivers/swr/rasterizer/core/rasterizer.h index f4aa6eb9f90..e99920aef2e 100644 --- a/src/gallium/drivers/swr/rasterizer/core/rasterizer.h +++ b/src/gallium/drivers/swr/rasterizer/core/rasterizer.h @@ -52,7 +52,17 @@ PFN_WORK_FUNC GetRasterizerFunc( uint32_t EdgeEnable, bool RasterizeScissorEdges); -enum ValidTriEdges +enum TriEdgesStates +{ + STATE_NO_VALID_EDGES = 0, + STATE_E0_E1_VALID, + STATE_E0_E2_VALID, + STATE_E1_E2_VALID, + STATE_ALL_EDGES_VALID, + STATE_VALID_TRI_EDGE_COUNT, +}; + +enum TriEdgesValues { NO_VALID_EDGES = 0, E0_E1_VALID = 0x3, @@ -71,6 +81,56 @@ typedef std::integral_constant<uint32_t, E0_E2_VALID> E0E2ValidT; typedef std::integral_constant<uint32_t, E1_E2_VALID> E1E2ValidT; typedef std::integral_constant<uint32_t, NO_VALID_EDGES> NoEdgesValidT; +typedef std::integral_constant<uint32_t, STATE_ALL_EDGES_VALID> StateAllEdgesValidT; +typedef std::integral_constant<uint32_t, STATE_E0_E1_VALID> StateE0E1ValidT; +typedef std::integral_constant<uint32_t, STATE_E0_E2_VALID> StateE0E2ValidT; +typedef std::integral_constant<uint32_t, STATE_E1_E2_VALID> StateE1E2ValidT; +typedef std::integral_constant<uint32_t, STATE_NO_VALID_EDGES> StateNoEdgesValidT; + +// some specializations to convert from edge state to edge bitmask values +template <typename EdgeMask> +struct EdgeMaskVal +{ + static_assert(EdgeMask::value > STATE_ALL_EDGES_VALID, "Primary EdgeMaskVal shouldn't be instantiated"); +}; + +template <> +struct EdgeMaskVal<StateAllEdgesValidT> +{ + typedef AllEdgesValidT T; +}; + +template <> +struct EdgeMaskVal<StateE0E1ValidT> +{ + typedef E0E1ValidT T; +}; + +template <> +struct EdgeMaskVal<StateE0E2ValidT> +{ + typedef E0E2ValidT T; +}; + +template <> +struct EdgeMaskVal<StateE1E2ValidT> +{ + typedef E1E2ValidT T; +}; + +template <> +struct EdgeMaskVal<StateNoEdgesValidT> +{ + typedef NoEdgesValidT T; +}; + +INLINE uint32_t EdgeValToEdgeState(uint32_t val) +{ + SWR_ASSERT(val < VALID_TRI_EDGE_COUNT, "Unexpected tri edge mask"); + static const uint32_t edgeValToEdgeState[VALID_TRI_EDGE_COUNT] = { 0, 0, 0, 1, 0, 2, 3, 4 }; + return edgeValToEdgeState[val]; +} + ////////////////////////////////////////////////////////////////////////// /// @struct RasterScissorEdgesT /// @brief Primary RasterScissorEdgesT templated struct that holds compile @@ -86,7 +146,8 @@ struct RasterEdgeTraits { typedef std::true_type RasterizeScissorEdgesT; typedef std::integral_constant<uint32_t, 7> NumEdgesT; - typedef std::integral_constant<uint32_t, EdgeMaskT::value> ValidEdgeMaskT; + //typedef std::integral_constant<uint32_t, EdgeMaskT::value> ValidEdgeMaskT; + typedef typename EdgeMaskVal<EdgeMaskT>::T ValidEdgeMaskT; }; ////////////////////////////////////////////////////////////////////////// @@ -113,7 +174,7 @@ struct RasterEdgeTraits<std::false_type, std::false_type, EdgeMaskT> /// @tparam RasterScissorEdgesT: do we need to rasterize with a scissor? template <typename NumSamplesT, typename CenterPatternT, typename ConservativeT, typename InputCoverageT, typename EdgeEnableT, typename RasterScissorEdgesT> struct RasterizerTraits final : public ConservativeRastBETraits<ConservativeT, InputCoverageT>, - public RasterEdgeTraits<RasterScissorEdgesT, ConservativeT, std::integral_constant<uint32_t, EdgeEnableT::value>> + public RasterEdgeTraits<RasterScissorEdgesT, ConservativeT, EdgeEnableT> { typedef MultisampleTraits<static_cast<SWR_MULTISAMPLE_COUNT>(NumSamplesT::value), CenterPatternT::value> MT; |