swr/rast: Start to remove hardcoded clipcull_dist vertex attrib slot
authorTim Rowley <timothy.o.rowley@intel.com>
Tue, 22 Aug 2017 21:42:57 +0000 (16:42 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 13 Sep 2017 15:09:11 +0000 (10:09 -0500)
Add new field in SWR_BACKEND_STATE::vertexClipCullOffset to specify the
start of the clip/cull section of the vertex header.  Removed use of
hardcoded slot from binner.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/core/binner.cpp
src/gallium/drivers/swr/rasterizer/core/state.h
src/gallium/drivers/swr/swr_state.cpp

index 19afd1f292d8a16f1d37b5e80dfeb5688a1c95f5..a6713e8c5d2801a712fbf5f0ce87d5fcab0d3f9c 100644 (file)
@@ -366,16 +366,17 @@ PFN_PROCESS_ATTRIBUTES GetProcessAttributesFunc(uint32_t NumVerts, bool IsSwizzl
 /// @param clipDistMask - mask of enabled clip distances
 /// @param pUserClipBuffer - buffer to store results
 template<uint32_t NumVerts>
-void ProcessUserClipDist(PA_STATE& pa, uint32_t primIndex, uint8_t clipDistMask, float *pRecipW, float* pUserClipBuffer)
+void ProcessUserClipDist(const SWR_BACKEND_STATE& state, PA_STATE& pa, uint32_t primIndex, float *pRecipW, float* pUserClipBuffer)
 {
     DWORD clipDist;
+    uint32_t clipDistMask = state.clipDistanceMask;
     while (_BitScanForward(&clipDist, clipDistMask))
     {
         clipDistMask &= ~(1 << clipDist);
         uint32_t clipSlot = clipDist >> 2;
         uint32_t clipComp = clipDist & 0x3;
         uint32_t clipAttribSlot = clipSlot == 0 ?
-            VERTEX_CLIPCULL_DIST_LO_SLOT : VERTEX_CLIPCULL_DIST_HI_SLOT;
+            state.vertexClipCullOffset : state.vertexClipCullOffset + 1;
 
         simd4scalar primClipDist[3];
         pa.AssembleSingle(clipAttribSlot, primIndex, primClipDist);
@@ -872,7 +873,7 @@ endBinTriangles:
         {
             uint32_t numClipDist = _mm_popcnt_u32(state.backendState.clipDistanceMask);
             desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 3 * sizeof(float));
-            ProcessUserClipDist<3>(pa, triIndex, state.backendState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
+            ProcessUserClipDist<3>(state.backendState, pa, triIndex, &desc.pTriBuffer[12], desc.pUserClipBuffer);
         }
 
         for (uint32_t y = aMTTop[triIndex]; y <= aMTBottom[triIndex]; ++y)
@@ -1248,7 +1249,7 @@ void BinPostSetupPointsImpl(
                 desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 3 * sizeof(float));
                 float dists[8];
                 float one = 1.0f;
-                ProcessUserClipDist<1>(pa, primIndex, backendState.clipDistanceMask, &one, dists);
+                ProcessUserClipDist<1>(backendState, pa, primIndex, &one, dists);
                 for (uint32_t i = 0; i < numClipDist; i++) {
                     desc.pUserClipBuffer[3 * i + 0] = 0.0f;
                     desc.pUserClipBuffer[3 * i + 1] = 0.0f;
@@ -1577,7 +1578,7 @@ void BinPostSetupLinesImpl(
         {
             uint32_t numClipDist = _mm_popcnt_u32(state.backendState.clipDistanceMask);
             desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 2 * sizeof(float));
-            ProcessUserClipDist<2>(pa, primIndex, state.backendState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
+            ProcessUserClipDist<2>(state.backendState, pa, primIndex, &desc.pTriBuffer[12], desc.pUserClipBuffer);
         }
 
         MacroTileMgr *pTileMgr = pDC->pTileMgr;
index 284c523eba8605174ce3e63c9f5ca8acdee982a5..b0af663d50ec3abbb2e14743a5e438ce5c65617a 100644 (file)
@@ -1070,12 +1070,15 @@ struct SWR_BACKEND_STATE
     bool readRenderTargetArrayIndex;    // Forward render target array index from last FE stage to the backend
     bool readViewportArrayIndex;        // Read viewport array index from last FE stage during binning
     
-    // user clip/cull distance enables
+       // Offset to the start of the attributes of the input vertices, in simdvector units
+    uint32_t vertexAttribOffset;
+
+    // User clip/cull distance enables
     uint8_t cullDistanceMask;
     uint8_t clipDistanceMask;
 
-       // Offset to the start of the attributes of the input vertices, in simdvector units
-    uint32_t vertexAttribOffset;
+    // Offset to clip/cull attrib section of the vertex, in simdvector units
+    uint32_t vertexClipCullOffset;
 };
 
 
index d5b553b21ab71aeec54ea132cd878502b0324a7c..69a447334fe0040017cafe01bbddda3c83f7911f 100644 (file)
@@ -1766,6 +1766,9 @@ swr_update_derived(struct pipe_context *pipe,
    backendState.cullDistanceMask =
       ctx->vs->info.base.culldist_writemask << ctx->vs->info.base.num_written_clipdistance;
 
+   // Assume old layout of SGV, POSITION, CLIPCULL, ATTRIB
+   backendState.vertexClipCullOffset = backendState.vertexAttribOffset - 2;
+
    ctx->api.pfnSwrSetBackendState(ctx->swrContext, &backendState);
 
    /* Ensure that any in-progress attachment change StoreTiles finish */