[Mesa-dev] [PATCH v2 1/2] swr: [rasterizer core] support polygonmode point

George Kyriazis george.kyriazis at intel.com
Wed Apr 26 18:22:41 UTC 2017


add support in the binner: Split BinPoints into BinPostSetupPoints,
so we can use it from BinTriangles, since setup is already done.

v2: remove cc stable
---
 src/gallium/drivers/swr/rasterizer/core/binner.cpp | 175 ++++++++++++++-------
 1 file changed, 117 insertions(+), 58 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp
index 9d36f21..f69db29 100644
--- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp
@@ -36,9 +36,11 @@
 
 // Function Prototype
 void BinPostSetupLines(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[3], simdscalar vRecipW[2], uint32_t primMask, simdscalari primID, simdscalari viewportIdx);
+void BinPostSetupPoints(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx);
 
 #if USE_SIMD16_FRONTEND
 void BinPostSetupLines_simd16(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simd16vector prims[3], simd16scalar vRecipW[2], uint32_t primMask, simd16scalari primID, simd16scalari viewportIdx);
+void BinPostSetupPoints_simd16(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx);
 #endif
 
 //////////////////////////////////////////////////////////////////////////
@@ -745,6 +747,14 @@ void BinTriangles(
 
         AR_END(FEBinTriangles, 1);
         return;
+    } else if (rastState.fillMode == SWR_FILLMODE_POINT)
+    {
+        // bin 3 points
+
+        BinPostSetupPoints(pDC, pa, workerId, &tri[0], triMask, primID, viewportIdx);
+        BinPostSetupPoints(pDC, pa, workerId, &tri[1], triMask, primID, viewportIdx);
+        BinPostSetupPoints(pDC, pa, workerId, &tri[2], triMask, primID, viewportIdx);
+        return;
     }
 
     /// Note: these variable initializations must stay above any 'goto endBenTriangles'
@@ -1494,18 +1504,11 @@ PFN_PROCESS_PRIMS_SIMD16 GetBinTrianglesFunc_simd16(bool IsConservative)
 
 #endif
 
-//////////////////////////////////////////////////////////////////////////
-/// @brief Bin SIMD points to the backend.  Only supports point size of 1
-/// @param pDC - pointer to draw context.
-/// @param pa - The primitive assembly object.
-/// @param workerId - thread's worker id. Even thread has a unique id.
-/// @param tri - Contains point position data for SIMDs worth of points.
-/// @param primID - Primitive ID for each point.
-void BinPoints(
+void BinPostSetupPoints(
     DRAW_CONTEXT *pDC,
     PA_STATE& pa,
     uint32_t workerId,
-    simdvector prim[3],
+    simdvector prim[],
     uint32_t primMask,
     simdscalari primID,
     simdscalari viewportIdx)
@@ -1517,7 +1520,6 @@ void BinPoints(
     simdvector& primVerts = prim[0];
 
     const API_STATE& state = GetApiState(pDC);
-    const SWR_FRONTEND_STATE& feState = state.frontendState;
     const SWR_GS_STATE& gsState = state.gsState;
     const SWR_RASTSTATE& rastState = state.rastState;
     const uint32_t *pViewportIndex = (uint32_t *)&viewportIdx;
@@ -1526,30 +1528,6 @@ void BinPoints(
     PFN_PROCESS_ATTRIBUTES pfnProcessAttribs = GetProcessAttributesFunc(1,
         state.backendState.swizzleEnable, state.backendState.constantInterpolationMask);
 
-    if (!feState.vpTransformDisable)
-    {
-        // perspective divide
-        simdscalar vRecipW0 = _simd_div_ps(_simd_set1_ps(1.0f), primVerts.w);
-        primVerts.x = _simd_mul_ps(primVerts.x, vRecipW0);
-        primVerts.y = _simd_mul_ps(primVerts.y, vRecipW0);
-        primVerts.z = _simd_mul_ps(primVerts.z, vRecipW0);
-
-        // viewport transform to screen coords
-        if (state.gsState.emitsViewportArrayIndex)
-        {
-            viewportTransform<1>(&primVerts, state.vpMatrices, viewportIdx);
-        }
-        else
-        {
-            viewportTransform<1>(&primVerts, state.vpMatrices);
-        }
-    }
-
-    // adjust for pixel center location
-    simdscalar offset = g_pixelOffsets[rastState.pixelLocation];
-    primVerts.x = _simd_add_ps(primVerts.x, offset);
-    primVerts.y = _simd_add_ps(primVerts.y, offset);
-
     // convert to fixed point
     simdscalari vXi, vYi;
     vXi = fpToFixedPointVertical(primVerts.x);
@@ -1837,40 +1815,35 @@ void BinPoints(
     AR_END(FEBinPoints, 1);
 }
 
-#if USE_SIMD16_FRONTEND
-void BinPoints_simd16(
+//////////////////////////////////////////////////////////////////////////
+/// @brief Bin SIMD points to the backend.  Only supports point size of 1
+/// @param pDC - pointer to draw context.
+/// @param pa - The primitive assembly object.
+/// @param workerId - thread's worker id. Even thread has a unique id.
+/// @param tri - Contains point position data for SIMDs worth of points.
+/// @param primID - Primitive ID for each point.
+void BinPoints(
     DRAW_CONTEXT *pDC,
     PA_STATE& pa,
     uint32_t workerId,
-    simd16vector prim[3],
+    simdvector prim[3],
     uint32_t primMask,
-    simd16scalari primID,
-    simd16scalari viewportIdx)
+    simdscalari primID,
+    simdscalari viewportIdx)
 {
-    SWR_CONTEXT *pContext = pDC->pContext;
-
-    AR_BEGIN(FEBinPoints, pDC->drawId);
-
-    simd16vector& primVerts = prim[0];
+    simdvector& primVerts = prim[0];
 
     const API_STATE& state = GetApiState(pDC);
     const SWR_FRONTEND_STATE& feState = state.frontendState;
-    const SWR_GS_STATE& gsState = state.gsState;
     const SWR_RASTSTATE& rastState = state.rastState;
-    const uint32_t *pViewportIndex = (uint32_t *)&viewportIdx;
-
-    // Select attribute processor
-    PFN_PROCESS_ATTRIBUTES pfnProcessAttribs = GetProcessAttributesFunc(1,
-        state.backendState.swizzleEnable, state.backendState.constantInterpolationMask);
 
     if (!feState.vpTransformDisable)
     {
         // perspective divide
-        simd16scalar vRecipW0 = _simd16_div_ps(_simd16_set1_ps(1.0f), primVerts.w);
-
-        primVerts.x = _simd16_mul_ps(primVerts.x, vRecipW0);
-        primVerts.y = _simd16_mul_ps(primVerts.y, vRecipW0);
-        primVerts.z = _simd16_mul_ps(primVerts.z, vRecipW0);
+        simdscalar vRecipW0 = _simd_div_ps(_simd_set1_ps(1.0f), primVerts.w);
+        primVerts.x = _simd_mul_ps(primVerts.x, vRecipW0);
+        primVerts.y = _simd_mul_ps(primVerts.y, vRecipW0);
+        primVerts.z = _simd_mul_ps(primVerts.z, vRecipW0);
 
         // viewport transform to screen coords
         if (state.gsState.emitsViewportArrayIndex)
@@ -1883,10 +1856,45 @@ void BinPoints_simd16(
         }
     }
 
-    const simd16scalar offset = g_pixelOffsets_simd16[rastState.pixelLocation];
+    // adjust for pixel center location
+    simdscalar offset = g_pixelOffsets[rastState.pixelLocation];
+    primVerts.x = _simd_add_ps(primVerts.x, offset);
+    primVerts.y = _simd_add_ps(primVerts.y, offset);
 
-    primVerts.x = _simd16_add_ps(primVerts.x, offset);
-    primVerts.y = _simd16_add_ps(primVerts.y, offset);
+    BinPostSetupPoints(
+        pDC,
+        pa,
+        workerId,
+        prim,
+        primMask,
+        primID,
+        viewportIdx);
+}
+
+#if USE_SIMD16_FRONTEND
+void BinPostSetupPoints_simd16(
+    DRAW_CONTEXT *pDC,
+    PA_STATE& pa,
+    uint32_t workerId,
+    simd16vector prim[],
+    uint32_t primMask,
+    simd16scalari primID,
+    simd16scalari viewportIdx)
+{
+    SWR_CONTEXT *pContext = pDC->pContext;
+
+    AR_BEGIN(FEBinPoints, pDC->drawId);
+
+    simd16vector& primVerts = prim[0];
+
+    const API_STATE& state = GetApiState(pDC);
+    const SWR_GS_STATE& gsState = state.gsState;
+    const SWR_RASTSTATE& rastState = state.rastState;
+    const uint32_t *pViewportIndex = (uint32_t *)&viewportIdx;
+
+    // Select attribute processor
+    PFN_PROCESS_ATTRIBUTES pfnProcessAttribs = GetProcessAttributesFunc(1,
+        state.backendState.swizzleEnable, state.backendState.constantInterpolationMask);
 
     // convert to fixed point
     simd16scalari vXi, vYi;
@@ -2184,6 +2192,57 @@ void BinPoints_simd16(
     AR_END(FEBinPoints, 1);
 }
 
+
+void BinPoints_simd16(
+    DRAW_CONTEXT *pDC,
+    PA_STATE& pa,
+    uint32_t workerId,
+    simd16vector prim[3],
+    uint32_t primMask,
+    simd16scalari primID,
+    simd16scalari viewportIdx)
+{
+    simd16vector& primVerts = prim[0];
+
+    const API_STATE& state = GetApiState(pDC);
+    const SWR_FRONTEND_STATE& feState = state.frontendState;
+    const SWR_RASTSTATE& rastState = state.rastState;
+
+    if (!feState.vpTransformDisable)
+    {
+        // perspective divide
+        simd16scalar vRecipW0 = _simd16_div_ps(_simd16_set1_ps(1.0f), primVerts.w);
+
+        primVerts.x = _simd16_mul_ps(primVerts.x, vRecipW0);
+        primVerts.y = _simd16_mul_ps(primVerts.y, vRecipW0);
+        primVerts.z = _simd16_mul_ps(primVerts.z, vRecipW0);
+
+        // viewport transform to screen coords
+        if (state.gsState.emitsViewportArrayIndex)
+        {
+            viewportTransform<1>(&primVerts, state.vpMatrices, viewportIdx);
+        }
+        else
+        {
+            viewportTransform<1>(&primVerts, state.vpMatrices);
+        }
+    }
+
+    const simd16scalar offset = g_pixelOffsets_simd16[rastState.pixelLocation];
+
+    primVerts.x = _simd16_add_ps(primVerts.x, offset);
+    primVerts.y = _simd16_add_ps(primVerts.y, offset);
+
+    BinPostSetupPoints_simd16(
+        pDC,
+        pa,
+        workerId,
+        prim,
+        primMask,
+        primID,
+        viewportIdx);
+}
+
 #endif
 //////////////////////////////////////////////////////////////////////////
 /// @brief Bin SIMD lines to the backend.
-- 
2.7.4



More information about the mesa-dev mailing list