swr/rast: Move clip/cull enables in API
authorTim Rowley <timothy.o.rowley@intel.com>
Mon, 21 Aug 2017 22:11:34 +0000 (17:11 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 13 Sep 2017 15:09:04 +0000 (10:09 -0500)
Moved from from SWR_RASTSTATE to SWR_BACKEND_STATE.

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

index 363349f6c83a103d2bda9404c4ef1b7fb9bcc5f6..6282e87f31896d6369d14d3b5102163d5369d1bf 100644 (file)
@@ -272,9 +272,9 @@ void BackendNullPS(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_t y,
                     AR_END(BEBarycentric, 0);
 
                     // interpolate user clip distance if available
-                    if (state.rastState.clipDistanceMask)
+                    if (state.backendState.clipDistanceMask)
                     {
-                        coverageMask &= ~ComputeUserClipMask(state.rastState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.sample, psContext.vJ.sample);
+                        coverageMask &= ~ComputeUserClipMask(state.backendState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.sample, psContext.vJ.sample);
                     }
 
                     simdscalar vCoverageMask = _simd_vmask_ps(coverageMask);
index 0f430ef3abcd94351161a298b4afaac8c1e388a1..593082bd7de073da66e2bfadf7fe34db30ff7423 100644 (file)
@@ -886,7 +886,7 @@ void BackendPixelRate(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_t
 
     AR_END(BESetup, 0);
 
-    PixelRateZTestLoop<T> PixelRateZTest(pDC, workerId, work, coeffs, state, pDepthBuffer, pStencilBuffer, state.rastState.clipDistanceMask);
+    PixelRateZTestLoop<T> PixelRateZTest(pDC, workerId, work, coeffs, state, pDepthBuffer, pStencilBuffer, state.backendState.clipDistanceMask);
 
     psContext.vY.UL     = _simd_add_ps(vULOffsetsY,     _simd_set1_ps(static_cast<float>(y)));
     psContext.vY.center = _simd_add_ps(vCenterOffsetsY, _simd_set1_ps(static_cast<float>(y)));
index bb2e9a9f631604c3a4b44e2911dd3ac1a09afcb9..04e34aa264f9424d54164fe3bba2c4515f5f7891 100644 (file)
@@ -128,9 +128,9 @@ void BackendSampleRate(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint32_
                     AR_END(BEBarycentric, 0);
 
                     // interpolate user clip distance if available
-                    if (state.rastState.clipDistanceMask)
+                    if (state.backendState.clipDistanceMask)
                     {
-                        coverageMask &= ~ComputeUserClipMask(state.rastState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.sample, psContext.vJ.sample);
+                        coverageMask &= ~ComputeUserClipMask(state.backendState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.sample, psContext.vJ.sample);
                     }
 
                     simdscalar vCoverageMask = _simd_vmask_ps(coverageMask);
index 18f4299f51408a3d8302ee095571bad09f89b94e..686b97912cc9f1eab11dedb04571ed5ea455bedb 100644 (file)
@@ -112,9 +112,9 @@ void BackendSingleSample(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint3
                 AR_END(BEBarycentric, 1);
 
                 // interpolate user clip distance if available
-                if (state.rastState.clipDistanceMask)
+                if (state.backendState.clipDistanceMask)
                 {
-                    coverageMask &= ~ComputeUserClipMask(state.rastState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.center, psContext.vJ.center);
+                    coverageMask &= ~ComputeUserClipMask(state.backendState.clipDistanceMask, work.pUserClipBuffer, psContext.vI.center, psContext.vJ.center);
                 }
 
                 simdscalar vCoverageMask = _simd_vmask_ps(coverageMask);
index 01c2f8f7a33a0001edf7ef0c5143c3a445d47de8..19afd1f292d8a16f1d37b5e80dfeb5688a1c95f5 100644 (file)
@@ -868,11 +868,11 @@ endBinTriangles:
         SIMD128::store_ps(&desc.pTriBuffer[12], vHorizW[triIndex]);
 
         // store user clip distances
-        if (rastState.clipDistanceMask)
+        if (state.backendState.clipDistanceMask)
         {
-            uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);
+            uint32_t numClipDist = _mm_popcnt_u32(state.backendState.clipDistanceMask);
             desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 3 * sizeof(float));
-            ProcessUserClipDist<3>(pa, triIndex, rastState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
+            ProcessUserClipDist<3>(pa, triIndex, state.backendState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
         }
 
         for (uint32_t y = aMTTop[triIndex]; y <= aMTBottom[triIndex]; ++y)
@@ -1242,13 +1242,13 @@ void BinPostSetupPointsImpl(
             *pTriBuffer = aPrimVertsZ[primIndex];
 
             // store user clip distances
-            if (rastState.clipDistanceMask)
+            if (backendState.clipDistanceMask)
             {
-                uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);
+                uint32_t numClipDist = _mm_popcnt_u32(backendState.clipDistanceMask);
                 desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 3 * sizeof(float));
                 float dists[8];
                 float one = 1.0f;
-                ProcessUserClipDist<1>(pa, primIndex, rastState.clipDistanceMask, &one, dists);
+                ProcessUserClipDist<1>(pa, primIndex, backendState.clipDistanceMask, &one, dists);
                 for (uint32_t i = 0; i < numClipDist; i++) {
                     desc.pUserClipBuffer[3 * i + 0] = 0.0f;
                     desc.pUserClipBuffer[3 * i + 1] = 0.0f;
@@ -1573,11 +1573,11 @@ void BinPostSetupLinesImpl(
         _mm_store_ps(&desc.pTriBuffer[12], vHorizW[primIndex]);
 
         // store user clip distances
-        if (rastState.clipDistanceMask)
+        if (state.backendState.clipDistanceMask)
         {
-            uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);
+            uint32_t numClipDist = _mm_popcnt_u32(state.backendState.clipDistanceMask);
             desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 2 * sizeof(float));
-            ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
+            ProcessUserClipDist<2>(pa, primIndex, state.backendState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);
         }
 
         MacroTileMgr *pTileMgr = pDC->pTileMgr;
index d7b559bc01cb4e429d3bec6ed4cf744d3a92bbb1..e0aaf815417a4c1b9b9b5c4e200ec0cf938d16f1 100644 (file)
@@ -371,7 +371,7 @@ public:
 
     int ComputeUserClipCullMask(PA_STATE &pa, typename SIMD_T::Vec4 prim[])
     {
-        uint8_t cullMask = state.rastState.cullDistanceMask;
+        uint8_t cullMask = state.backendState.cullDistanceMask;
         typename SIMD_T::Float vClipCullMask = SIMD_T::setzero_ps();
 
         typename SIMD_T::Vec4 vClipCullDistLo[3];
@@ -408,7 +408,7 @@ public:
         }
 
         // clipper should also discard any primitive with NAN clip distance
-        uint8_t clipMask = state.rastState.clipDistanceMask;
+        uint8_t clipMask = state.backendState.clipDistanceMask;
         while (_BitScanForward(&index, clipMask))
         {
             clipMask &= ~(1 << index);
@@ -488,7 +488,7 @@ public:
         }
 
         // assemble user clip distances if enabled
-        if (state.rastState.clipDistanceMask & 0xf)
+        if (state.backendState.clipDistanceMask & 0xf)
         {
             pa.Assemble(VERTEX_CLIPCULL_DIST_LO_SLOT, tmpVector);
             for (uint32_t i = 0; i < NumVertsPerPrim; ++i)
@@ -497,7 +497,7 @@ public:
             }
         }
 
-        if (state.rastState.clipDistanceMask & 0xf0)
+        if (state.backendState.clipDistanceMask & 0xf0)
         {
             pa.Assemble(VERTEX_CLIPCULL_DIST_HI_SLOT, tmpVector);
             for (uint32_t i = 0; i < NumVertsPerPrim; ++i)
@@ -613,7 +613,7 @@ public:
             }
 
             // transpose user clip distances if enabled
-            if (state.rastState.clipDistanceMask & 0x0f)
+            if (state.backendState.clipDistanceMask & 0x0f)
             {
                 pBase = reinterpret_cast<uint8_t *>(&vertices[0].attrib[VERTEX_CLIPCULL_DIST_LO_SLOT]) + sizeof(float) * inputPrim;
 
@@ -625,7 +625,7 @@ public:
                 }
             }
 
-            if (state.rastState.clipDistanceMask & 0xf0)
+            if (state.backendState.clipDistanceMask & 0xf0)
             {
                 pBase = reinterpret_cast<uint8_t *>(&vertices[0].attrib[VERTEX_CLIPCULL_DIST_HI_SLOT]) + sizeof(float) * inputPrim;
 
@@ -703,7 +703,7 @@ public:
         primMask &= ~ComputeNaNMask(prim);
 
         // user cull distance cull 
-        if (this->state.rastState.cullDistanceMask)
+        if (state.backendState.cullDistanceMask)
         {
             primMask &= ~ComputeUserClipCullMask(pa, prim);
         }
@@ -867,7 +867,7 @@ private:
         }
 
         // interpolate clip distance if enabled
-        if (this->state.rastState.clipDistanceMask & 0xf)
+        if (this->state.backendState.clipDistanceMask & 0xf)
         {
             uint32_t attribSlot = VERTEX_CLIPCULL_DIST_LO_SLOT;
             for (uint32_t c = 0; c < 4; ++c)
@@ -879,7 +879,7 @@ private:
             }
         }
 
-        if (this->state.rastState.clipDistanceMask & 0xf0)
+        if (this->state.backendState.clipDistanceMask & 0xf0)
         {
             uint32_t attribSlot = VERTEX_CLIPCULL_DIST_HI_SLOT;
             for (uint32_t c = 0; c < 4; ++c)
@@ -963,7 +963,7 @@ private:
                 }
 
                 // store clip distance if enabled
-                if (this->state.rastState.clipDistanceMask & 0xf)
+                if (this->state.backendState.clipDistanceMask & 0xf)
                 {
                     uint32_t attribSlot = VERTEX_CLIPCULL_DIST_LO_SLOT;
                     for (uint32_t c = 0; c < 4; ++c)
@@ -973,7 +973,7 @@ private:
                     }
                 }
 
-                if (this->state.rastState.clipDistanceMask & 0xf0)
+                if (this->state.backendState.clipDistanceMask & 0xf0)
                 {
                     uint32_t attribSlot = VERTEX_CLIPCULL_DIST_HI_SLOT;
                     for (uint32_t c = 0; c < 4; ++c)
index a3ff557bd8c457d74dea57578ecab14912b74046..ae1e9c779baa1048dcc1626edc3d3f47ee282614 100644 (file)
@@ -125,7 +125,7 @@ void RasterizeLine(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t macroTile, voi
 
     // Store user clip distances for triangle 0
     float newClipBuffer[3 * 8];
-    uint32_t numClipDist = _mm_popcnt_u32(state.rastState.clipDistanceMask);
+    uint32_t numClipDist = _mm_popcnt_u32(state.backendState.clipDistanceMask);
     if (numClipDist)
     {
         newWorkDesc.pUserClipBuffer = newClipBuffer;
index ed49134364eab77bdbe11d8081fa6664b4e97ddd..284c523eba8605174ce3e63c9f5ca8acdee982a5 100644 (file)
@@ -1035,10 +1035,6 @@ struct SWR_RASTSTATE
     uint32_t pixelLocation;     // UL or Center
     SWR_MULTISAMPLE_POS samplePositions;    // @llvm_struct
     bool bIsCenterPattern;   // @llvm_enum
-
-    // user clip/cull distance enables
-    uint8_t cullDistanceMask;
-    uint8_t clipDistanceMask;
 };
 
 
@@ -1074,6 +1070,10 @@ 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
+    uint8_t cullDistanceMask;
+    uint8_t clipDistanceMask;
+
        // Offset to the start of the attributes of the input vertices, in simdvector units
     uint32_t vertexAttribOffset;
 };
index 47ab4453898bdb0dbe0f8041ea8d1be7f3eccdb5..d5b553b21ab71aeec54ea132cd878502b0324a7c 100644 (file)
@@ -1158,14 +1158,6 @@ swr_update_derived(struct pipe_context *pipe,
       rastState->depthClipEnable = rasterizer->depth_clip;
       rastState->clipHalfZ = rasterizer->clip_halfz;
 
-      rastState->clipDistanceMask =
-         ctx->vs->info.base.num_written_clipdistance ?
-         ctx->vs->info.base.clipdist_writemask & rasterizer->clip_plane_enable :
-         rasterizer->clip_plane_enable;
-
-      rastState->cullDistanceMask =
-         ctx->vs->info.base.culldist_writemask << ctx->vs->info.base.num_written_clipdistance;
-
       ctx->api.pfnSwrSetRastState(ctx->swrContext, rastState);
    }
 
@@ -1766,6 +1758,14 @@ swr_update_derived(struct pipe_context *pipe,
    backendState.readViewportArrayIndex = pLastFE->writes_viewport_index;
    backendState.vertexAttribOffset = VERTEX_ATTRIB_START_SLOT; // TODO: optimize
 
+   backendState.clipDistanceMask =
+      ctx->vs->info.base.num_written_clipdistance ?
+      ctx->vs->info.base.clipdist_writemask & ctx->rasterizer->clip_plane_enable :
+      ctx->rasterizer->clip_plane_enable;
+
+   backendState.cullDistanceMask =
+      ctx->vs->info.base.culldist_writemask << ctx->vs->info.base.num_written_clipdistance;
+
    ctx->api.pfnSwrSetBackendState(ctx->swrContext, &backendState);
 
    /* Ensure that any in-progress attachment change StoreTiles finish */