Fix D3D11 errors where the application passes in QNAN to glPolygonOffset or for…

Fix D3D11 errors where the application passes in QNAN to glPolygonOffset or for the viewport bounds. TRAC #22565 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1924 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ce3128ad
......@@ -480,8 +480,9 @@ bool Context::isPolygonOffsetFillEnabled() const
void Context::setPolygonOffsetParams(GLfloat factor, GLfloat units)
{
mState.rasterizer.polygonOffsetFactor = factor;
mState.rasterizer.polygonOffsetUnits = units;
// An application can pass NaN values here, so handle this gracefully
mState.rasterizer.polygonOffsetFactor = factor != factor ? 0.0f : factor;
mState.rasterizer.polygonOffsetUnits = units != units ? 0.0f : units;
}
void Context::setSampleAlphaToCoverage(bool enabled)
......
......@@ -56,7 +56,8 @@ inline unsigned int ceilPow2(unsigned int x)
template<typename T, typename MIN, typename MAX>
inline T clamp(T x, MIN min, MAX max)
{
return x < min ? min : (x > max ? max : x);
// Since NaNs fail all comparison tests, a NaN value will default to min
return x > min ? (x > max ? max : x) : min;
}
inline float clamp01(float x)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment