From 4c093869db13fb59f5cf8b49fbbcb5deba7812a4 Mon Sep 17 00:00:00 2001 From: Tim Rowley Date: Fri, 31 Mar 2017 16:50:40 -0500 Subject: [PATCH] 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 --- .../drivers/swr/rasterizer/core/binner.cpp | 8 +-- .../swr/rasterizer/core/rasterizer.cpp | 6 +- .../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{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 E0E2ValidT; typedef std::integral_constant E1E2ValidT; typedef std::integral_constant NoEdgesValidT; +typedef std::integral_constant StateAllEdgesValidT; +typedef std::integral_constant StateE0E1ValidT; +typedef std::integral_constant StateE0E2ValidT; +typedef std::integral_constant StateE1E2ValidT; +typedef std::integral_constant StateNoEdgesValidT; + +// some specializations to convert from edge state to edge bitmask values +template +struct EdgeMaskVal +{ + static_assert(EdgeMask::value > STATE_ALL_EDGES_VALID, "Primary EdgeMaskVal shouldn't be instantiated"); +}; + +template <> +struct EdgeMaskVal +{ + typedef AllEdgesValidT T; +}; + +template <> +struct EdgeMaskVal +{ + typedef E0E1ValidT T; +}; + +template <> +struct EdgeMaskVal +{ + typedef E0E2ValidT T; +}; + +template <> +struct EdgeMaskVal +{ + typedef E1E2ValidT T; +}; + +template <> +struct EdgeMaskVal +{ + 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 NumEdgesT; - typedef std::integral_constant ValidEdgeMaskT; + //typedef std::integral_constant ValidEdgeMaskT; + typedef typename EdgeMaskVal::T ValidEdgeMaskT; }; ////////////////////////////////////////////////////////////////////////// @@ -113,7 +174,7 @@ struct RasterEdgeTraits /// @tparam RasterScissorEdgesT: do we need to rasterize with a scissor? template struct RasterizerTraits final : public ConservativeRastBETraits, - public RasterEdgeTraits> + public RasterEdgeTraits { typedef MultisampleTraits(NumSamplesT::value), CenterPatternT::value> MT; -- 2.30.2