From 192317dfeb8c9223b702196e0c8e8c555c24b844 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Thu, 24 Nov 2016 13:27:48 -0500 Subject: swr: [rasterizer core] perform perspective division on clip distances Clip distances need to be perspective-divided. This fixes all the interpolation-*-{distance,vertex} piglits. Signed-off-by: Ilia Mirkin Reviewed-by: Tim Rowley --- src/gallium/drivers/swr/rasterizer/core/binner.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/gallium/drivers/swr') diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp index 6f9259fcf66..1538020a518 100644 --- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp @@ -383,7 +383,7 @@ PFN_PROCESS_ATTRIBUTES GetProcessAttributesFunc(uint32_t NumVerts, bool IsSwizzl /// @param clipDistMask - mask of enabled clip distances /// @param pUserClipBuffer - buffer to store results template -void ProcessUserClipDist(PA_STATE& pa, uint32_t primIndex, uint8_t clipDistMask, float* pUserClipBuffer) +void ProcessUserClipDist(PA_STATE& pa, uint32_t primIndex, uint8_t clipDistMask, float *pRecipW, float* pUserClipBuffer) { DWORD clipDist; while (_BitScanForward(&clipDist, clipDistMask)) @@ -407,11 +407,12 @@ void ProcessUserClipDist(PA_STATE& pa, uint32_t primIndex, uint8_t clipDistMask, // setup plane equations for barycentric interpolation in the backend float baryCoeff[NumVerts]; + float last = vertClipDist[NumVerts - 1] * pRecipW[NumVerts - 1]; for (uint32_t e = 0; e < NumVerts - 1; ++e) { - baryCoeff[e] = vertClipDist[e] - vertClipDist[NumVerts - 1]; + baryCoeff[e] = vertClipDist[e] * pRecipW[e] - last; } - baryCoeff[NumVerts - 1] = vertClipDist[NumVerts - 1]; + baryCoeff[NumVerts - 1] = last; for (uint32_t e = 0; e < NumVerts; ++e) { @@ -834,7 +835,7 @@ endBinTriangles: { uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask); desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 3 * sizeof(float)); - ProcessUserClipDist<3>(pa, triIndex, rastState.clipDistanceMask, desc.pUserClipBuffer); + ProcessUserClipDist<3>(pa, triIndex, rastState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer); } for (uint32_t y = aMTTop[triIndex]; y <= aMTBottom[triIndex]; ++y) @@ -1184,8 +1185,9 @@ void BinPoints( if (rastState.clipDistanceMask) { uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask); + float one[2] = {1.0f, 1.0f}; desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 2 * sizeof(float)); - ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, desc.pUserClipBuffer); + ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, one, desc.pUserClipBuffer); } MacroTileMgr *pTileMgr = pDC->pTileMgr; @@ -1396,7 +1398,7 @@ void BinPostSetupLines( { uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask); desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 2 * sizeof(float)); - ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, desc.pUserClipBuffer); + ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer); } MacroTileMgr *pTileMgr = pDC->pTileMgr; -- cgit v1.2.3