<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 Nov 9, 2016, at 11:50 AM, 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="">With ARB_clip_control, GL may also do 0..1 depth clipping, not just<br class="">
-1..1. This removes clip's reliance on driver type. DX users will need<br class="">
to be updated to set the new clipHalfZ flag to get proper clipping<br class="">
functionality.<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="">
<br class="">
v2 -> v3: drop the api-level setting of clipHalfZ for DX driverType.<br class="">
<br class="">
src/gallium/drivers/swr/rasterizer/core/clip.h | 13 ++++++-------<br class="">
src/gallium/drivers/swr/rasterizer/core/state.h | 1 +<br class="">
2 files changed, 7 insertions(+), 7 deletions(-)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/rasterizer/core/clip.h b/src/gallium/drivers/swr/rasterizer/core/clip.h<br class="">
index 43bc522..3d86b28 100644<br class="">
--- a/src/gallium/drivers/swr/rasterizer/core/clip.h<br class="">
+++ b/src/gallium/drivers/swr/rasterizer/core/clip.h<br class="">
@@ -63,7 +63,7 @@ void Clip(const float *pTriangle, const float *pAttribs, int numAttribs, float *<br class="">
int *numVerts, float *pOutAttribs);<br class="">
<br class="">
INLINE<br class="">
-void ComputeClipCodes(DRIVER_TYPE type, const API_STATE& state, const simdvector& vertex, simdscalar& clipCodes, simdscalari viewportIndexes)<br class="">
+void ComputeClipCodes(const API_STATE& state, const simdvector& vertex, simdscalar& clipCodes, simdscalari viewportIndexes)<br class="">
{<br class="">
clipCodes = _simd_setzero_ps();<br class="">
<br class="">
@@ -90,7 +90,7 @@ void ComputeClipCodes(DRIVER_TYPE type, const API_STATE& state, const simdvector<br class="">
{<br class="">
// FRUSTUM_NEAR<br class="">
// DX clips depth [0..w], GL clips [-w..w]<br class="">
- if (type == DX)<br class="">
+ if (state.rastState.clipHalfZ)<br class="">
{<br class="">
vRes = _simd_cmplt_ps(vertex.z, _simd_setzero_ps());<br class="">
}<br class="">
@@ -135,7 +135,7 @@ class Clipper<br class="">
{<br class="">
public:<br class="">
Clipper(uint32_t in_workerId, DRAW_CONTEXT* in_pDC) :<br class="">
- workerId(in_workerId), driverType(in_pDC->pContext->driverType), pDC(in_pDC), state(GetApiState(in_pDC))<br class="">
+ workerId(in_workerId), pDC(in_pDC), state(GetApiState(in_pDC))<br class="">
{<br class="">
static_assert(NumVertsPerPrim >= 1 && NumVertsPerPrim <= 3, "Invalid NumVertsPerPrim");<br class="">
}<br class="">
@@ -144,7 +144,7 @@ public:<br class="">
{<br class="">
for (uint32_t i = 0; i < NumVertsPerPrim; ++i)<br class="">
{<br class="">
- ::ComputeClipCodes(this->driverType, this->state, vertex[i], this->clipCodes[i], viewportIndexes);<br class="">
+ ::ComputeClipCodes(this->state, vertex[i], this->clipCodes[i], viewportIndexes);<br class="">
}<br class="">
}<br class="">
<br class="">
@@ -640,7 +640,7 @@ private:<br class="">
case FRUSTUM_BOTTOM: t = ComputeInterpFactor(_simd_sub_ps(v1[3], v1[1]), _simd_sub_ps(v2[3], v2[1])); break;<br class="">
case FRUSTUM_NEAR: <br class="">
// DX Znear plane is 0, GL is -w<br class="">
- if (this->driverType == DX)<br class="">
+ if (this->state.rastState.clipHalfZ)<br class="">
{<br class="">
t = ComputeInterpFactor(v1[2], v2[2]);<br class="">
}<br class="">
@@ -708,7 +708,7 @@ private:<br class="">
case FRUSTUM_RIGHT: return _simd_cmple_ps(v[0], v[3]);<br class="">
case FRUSTUM_TOP: return _simd_cmpge_ps(v[1], _simd_mul_ps(v[3], _simd_set1_ps(-1.0f)));<br class="">
case FRUSTUM_BOTTOM: return _simd_cmple_ps(v[1], v[3]);<br class="">
- case FRUSTUM_NEAR: return _simd_cmpge_ps(v[2], this->driverType == DX ? _simd_setzero_ps() : _simd_mul_ps(v[3], _simd_set1_ps(-1.0f)));<br class="">
+ case FRUSTUM_NEAR: return _simd_cmpge_ps(v[2], this->state.rastState.clipHalfZ ? _simd_setzero_ps() : _simd_mul_ps(v[3], _simd_set1_ps(-1.0f)));<br class="">
case FRUSTUM_FAR: return _simd_cmple_ps(v[2], v[3]);<br class="">
default:<br class="">
SWR_ASSERT(false, "invalid clipping plane: %d", ClippingPlane);<br class="">
@@ -942,7 +942,6 @@ private:<br class="">
}<br class="">
<br class="">
const uint32_t workerId{ 0 };<br class="">
- const DRIVER_TYPE driverType{ DX };<br class="">
DRAW_CONTEXT* pDC{ nullptr };<br class="">
const API_STATE& state;<br class="">
simdscalar clipCodes[NumVertsPerPrim];<br class="">
diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h b/src/gallium/drivers/swr/rasterizer/core/state.h<br class="">
index 93e4565..5ee12e8 100644<br class="">
--- a/src/gallium/drivers/swr/rasterizer/core/state.h<br class="">
+++ b/src/gallium/drivers/swr/rasterizer/core/state.h<br class="">
@@ -932,6 +932,7 @@ struct SWR_RASTSTATE<br class="">
uint32_t frontWinding : 1;<br class="">
uint32_t scissorEnable : 1;<br class="">
uint32_t depthClipEnable : 1;<br class="">
+ uint32_t clipHalfZ : 1;<br class="">
uint32_t pointParam : 1;<br class="">
uint32_t pointSpriteEnable : 1;<br class="">
uint32_t pointSpriteTopOrigin : 1;<br class="">
-- <br class="">
2.7.3<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>