Commit 7a5f35c4 by Jiacheng Lu Committed by Commit Bot

Filter out redundant glDepthRange calls

1. Compare depth range with active config in frontend when glDepthRange is called. It avoids triggering unnecessary backend update. Also remove depth range checking in D3D and GL backends as they are now done in frontend. 2. Change the clamp on far and near plane to ASSERT statement in vulkan backend, as clamp already been applied in frontend. Bug: angleproject:3696 Change-Id: I52ad420dc446d685b98d53690637a19553372873 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1702284Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 950e1a4d
...@@ -665,9 +665,12 @@ void State::setDepthFunc(GLenum depthFunc) ...@@ -665,9 +665,12 @@ void State::setDepthFunc(GLenum depthFunc)
void State::setDepthRange(float zNear, float zFar) void State::setDepthRange(float zNear, float zFar)
{ {
mNearZ = zNear; if (mNearZ != zNear || mFarZ != zFar)
mFarZ = zFar; {
mDirtyBits.set(DIRTY_BIT_DEPTH_RANGE); mNearZ = zNear;
mFarZ = zFar;
mDirtyBits.set(DIRTY_BIT_DEPTH_RANGE);
}
} }
void State::setBlend(bool enabled) void State::setBlend(bool enabled)
......
...@@ -1163,10 +1163,7 @@ void StateManager11::syncState(const gl::Context *context, const gl::State::Dirt ...@@ -1163,10 +1163,7 @@ void StateManager11::syncState(const gl::Context *context, const gl::State::Dirt
} }
break; break;
case gl::State::DIRTY_BIT_DEPTH_RANGE: case gl::State::DIRTY_BIT_DEPTH_RANGE:
if (state.getNearPlane() != mCurNear || state.getFarPlane() != mCurFar) invalidateViewport(context);
{
invalidateViewport(context);
}
break; break;
case gl::State::DIRTY_BIT_VIEWPORT: case gl::State::DIRTY_BIT_VIEWPORT:
if (state.getViewport() != mCurViewport) if (state.getViewport() != mCurViewport)
......
...@@ -358,10 +358,7 @@ void StateManager9::syncState(const gl::State &state, const gl::State::DirtyBits ...@@ -358,10 +358,7 @@ void StateManager9::syncState(const gl::State &state, const gl::State::DirtyBits
} }
break; break;
case gl::State::DIRTY_BIT_DEPTH_RANGE: case gl::State::DIRTY_BIT_DEPTH_RANGE:
if (state.getNearPlane() != mCurNear || state.getFarPlane() != mCurFar) mDirtyBits.set(DIRTY_BIT_VIEWPORT);
{
mDirtyBits.set(DIRTY_BIT_VIEWPORT);
}
break; break;
case gl::State::DIRTY_BIT_VIEWPORT: case gl::State::DIRTY_BIT_VIEWPORT:
if (state.getViewport() != mCurViewport) if (state.getViewport() != mCurViewport)
......
...@@ -1018,25 +1018,22 @@ void StateManagerGL::setViewport(const gl::Rectangle &viewport) ...@@ -1018,25 +1018,22 @@ void StateManagerGL::setViewport(const gl::Rectangle &viewport)
void StateManagerGL::setDepthRange(float near, float far) void StateManagerGL::setDepthRange(float near, float far)
{ {
if (mNear != near || mFar != far) mNear = near;
{ mFar = far;
mNear = near;
mFar = far;
// The glDepthRangef function isn't available until OpenGL 4.1. Prefer it when it is // The glDepthRangef function isn't available until OpenGL 4.1. Prefer it when it is
// available because OpenGL ES only works in floats. // available because OpenGL ES only works in floats.
if (mFunctions->depthRangef) if (mFunctions->depthRangef)
{ {
mFunctions->depthRangef(mNear, mFar); mFunctions->depthRangef(mNear, mFar);
} }
else else
{ {
ASSERT(mFunctions->depthRange); ASSERT(mFunctions->depthRange);
mFunctions->depthRange(mNear, mFar); mFunctions->depthRange(mNear, mFar);
}
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_RANGE);
} }
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_RANGE);
} }
void StateManagerGL::setBlendEnabled(bool enabled) void StateManagerGL::setBlendEnabled(bool enabled)
......
...@@ -1260,8 +1260,10 @@ void GraphicsPipelineDesc::updateDepthRange(GraphicsPipelineTransitionBits *tran ...@@ -1260,8 +1260,10 @@ void GraphicsPipelineDesc::updateDepthRange(GraphicsPipelineTransitionBits *tran
{ {
// GLES2.0 Section 2.12.1: Each of n and f are clamped to lie within [0, 1], as are all // GLES2.0 Section 2.12.1: Each of n and f are clamped to lie within [0, 1], as are all
// arguments of type clampf. // arguments of type clampf.
mViewport.minDepth = gl::clamp01(nearPlane); ASSERT(nearPlane >= 0.0f && nearPlane <= 1.0f);
mViewport.maxDepth = gl::clamp01(farPlane); ASSERT(farPlane >= 0.0f && farPlane <= 1.0f);
mViewport.minDepth = nearPlane;
mViewport.maxDepth = farPlane;
transition->set(ANGLE_GET_TRANSITION_BIT(mViewport, minDepth)); transition->set(ANGLE_GET_TRANSITION_BIT(mViewport, minDepth));
transition->set(ANGLE_GET_TRANSITION_BIT(mViewport, maxDepth)); transition->set(ANGLE_GET_TRANSITION_BIT(mViewport, maxDepth));
} }
......
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