<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Tim Rowley <<a href="mailto:timothy.o.rowley@intel.com" class="">timothy.o.rowley@intel.com</a>>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Dec 8, 2016, at 8:21 PM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Clip distances need to be perspective-divided. This fixes all the<br class="">
interpolation-*-{distance,vertex} piglits.<br class="">
<br class="">
Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>><br class="">
---<br class="">
src/gallium/drivers/swr/rasterizer/core/binner.cpp | 14 ++++++++------<br class="">
1 file changed, 8 insertions(+), 6 deletions(-)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp<br class="">
index 6f9259f..1538020 100644<br class="">
--- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp<br class="">
+++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp<br class="">
@@ -383,7 +383,7 @@ PFN_PROCESS_ATTRIBUTES GetProcessAttributesFunc(uint32_t NumVerts, bool IsSwizzl<br class="">
/// @param clipDistMask - mask of enabled clip distances<br class="">
/// @param pUserClipBuffer - buffer to store results<br class="">
template<uint32_t NumVerts><br class="">
-void ProcessUserClipDist(PA_STATE& pa, uint32_t primIndex, uint8_t clipDistMask, float* pUserClipBuffer)<br class="">
+void ProcessUserClipDist(PA_STATE& pa, uint32_t primIndex, uint8_t clipDistMask, float *pRecipW, float* pUserClipBuffer)<br class="">
{<br class="">
DWORD clipDist;<br class="">
while (_BitScanForward(&clipDist, clipDistMask))<br class="">
@@ -407,11 +407,12 @@ void ProcessUserClipDist(PA_STATE& pa, uint32_t primIndex, uint8_t clipDistMask,<br class="">
<br class="">
// setup plane equations for barycentric interpolation in the backend<br class="">
float baryCoeff[NumVerts];<br class="">
+ float last = vertClipDist[NumVerts - 1] * pRecipW[NumVerts - 1];<br class="">
for (uint32_t e = 0; e < NumVerts - 1; ++e)<br class="">
{<br class="">
- baryCoeff[e] = vertClipDist[e] - vertClipDist[NumVerts - 1];<br class="">
+ baryCoeff[e] = vertClipDist[e] * pRecipW[e] - last;<br class="">
}<br class="">
- baryCoeff[NumVerts - 1] = vertClipDist[NumVerts - 1];<br class="">
+ baryCoeff[NumVerts - 1] = last;<br class="">
<br class="">
for (uint32_t e = 0; e < NumVerts; ++e)<br class="">
{<br class="">
@@ -834,7 +835,7 @@ endBinTriangles:<br class="">
{<br class="">
uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);<br class="">
desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 3 * sizeof(float));<br class="">
- ProcessUserClipDist<3>(pa, triIndex, rastState.clipDistanceMask, desc.pUserClipBuffer);<br class="">
+ ProcessUserClipDist<3>(pa, triIndex, rastState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);<br class="">
}<br class="">
<br class="">
for (uint32_t y = aMTTop[triIndex]; y <= aMTBottom[triIndex]; ++y)<br class="">
@@ -1184,8 +1185,9 @@ void BinPoints(<br class="">
if (rastState.clipDistanceMask)<br class="">
{<br class="">
uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);<br class="">
+ float one[2] = {1.0f, 1.0f};<br class="">
desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 2 * sizeof(float));<br class="">
- ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, desc.pUserClipBuffer);<br class="">
+ ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, one, desc.pUserClipBuffer);<br class="">
}<br class="">
<br class="">
MacroTileMgr *pTileMgr = pDC->pTileMgr;<br class="">
@@ -1396,7 +1398,7 @@ void BinPostSetupLines(<br class="">
{<br class="">
uint32_t numClipDist = _mm_popcnt_u32(rastState.clipDistanceMask);<br class="">
desc.pUserClipBuffer = (float*)pArena->Alloc(numClipDist * 2 * sizeof(float));<br class="">
- ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, desc.pUserClipBuffer);<br class="">
+ ProcessUserClipDist<2>(pa, primIndex, rastState.clipDistanceMask, &desc.pTriBuffer[12], desc.pUserClipBuffer);<br class="">
}<br class="">
<br class="">
MacroTileMgr *pTileMgr = pDC->pTileMgr;<br class="">
-- <br class="">
2.7.3<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>