Commit 54242b8f by Mohan Maiya Committed by Commit Bot

Vulkan: Leverage ExtendedDirtyBitType

Expand ExtendedDirtyBitType to include bit for clip distance, mipmap generation hint and shader derivative hint. Handle these dirty bits in ContextVk::syncState Bug: angleproject:5611 Change-Id: If8d1646334e737f81ac72cdddb8fe3ba613b4b94 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2676173 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent 38916bcc
...@@ -89,7 +89,6 @@ ANGLE_INLINE angle::Result Context::syncDirtyBits() ...@@ -89,7 +89,6 @@ ANGLE_INLINE angle::Result Context::syncDirtyBits()
const State::DirtyBits &dirtyBits = mState.getDirtyBits(); const State::DirtyBits &dirtyBits = mState.getDirtyBits();
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, mAllDirtyBits)); ANGLE_TRY(mImplementation->syncState(this, dirtyBits, mAllDirtyBits));
mState.clearDirtyBits(); mState.clearDirtyBits();
mState.clearExtendedDirtyBits();
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -98,7 +97,6 @@ ANGLE_INLINE angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMas ...@@ -98,7 +97,6 @@ ANGLE_INLINE angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMas
const State::DirtyBits &dirtyBits = (mState.getDirtyBits() & bitMask); const State::DirtyBits &dirtyBits = (mState.getDirtyBits() & bitMask);
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, bitMask)); ANGLE_TRY(mImplementation->syncState(this, dirtyBits, bitMask));
mState.clearDirtyBits(dirtyBits); mState.clearDirtyBits(dirtyBits);
mState.clearExtendedDirtyBits();
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -1176,6 +1176,7 @@ void State::setClipDistanceEnable(int idx, bool enable) ...@@ -1176,6 +1176,7 @@ void State::setClipDistanceEnable(int idx, bool enable)
} }
mDirtyBits.set(DIRTY_BIT_EXTENDED); mDirtyBits.set(DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(EXTENDED_DIRTY_BIT_CLIP_DISTANCES);
} }
void State::setEnableFeature(GLenum feature, bool enabled) void State::setEnableFeature(GLenum feature, bool enabled)
...@@ -1485,6 +1486,7 @@ void State::setGenerateMipmapHint(GLenum hint) ...@@ -1485,6 +1486,7 @@ void State::setGenerateMipmapHint(GLenum hint)
{ {
mGenerateMipmapHint = hint; mGenerateMipmapHint = hint;
mDirtyBits.set(DIRTY_BIT_EXTENDED); mDirtyBits.set(DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(EXTENDED_DIRTY_BIT_MIPMAP_GENERATION_HINT);
} }
GLenum State::getGenerateMipmapHint() const GLenum State::getGenerateMipmapHint() const
...@@ -1508,6 +1510,7 @@ void State::setFragmentShaderDerivativeHint(GLenum hint) ...@@ -1508,6 +1510,7 @@ void State::setFragmentShaderDerivativeHint(GLenum hint)
{ {
mFragmentShaderDerivativeHint = hint; mFragmentShaderDerivativeHint = hint;
mDirtyBits.set(DIRTY_BIT_EXTENDED); mDirtyBits.set(DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(EXTENDED_DIRTY_BIT_SHADER_DERIVATIVE_HINT);
// TODO: Propagate the hint to shader translator so we can write // TODO: Propagate the hint to shader translator so we can write
// ddx, ddx_coarse, or ddx_fine depending on the hint. // ddx, ddx_coarse, or ddx_fine depending on the hint.
// Ignore for now. It is valid for implementations to ignore hint. // Ignore for now. It is valid for implementations to ignore hint.
...@@ -3626,6 +3629,13 @@ AttributesMask State::getAndResetDirtyCurrentValues() const ...@@ -3626,6 +3629,13 @@ AttributesMask State::getAndResetDirtyCurrentValues() const
return retVal; return retVal;
} }
State::ExtendedDirtyBits State::getAndResetExtendedDirtyBits() const
{
ExtendedDirtyBits retVal = mExtendedDirtyBits;
mExtendedDirtyBits.reset();
return retVal;
}
constexpr State::DirtyObjectHandler State::kDirtyObjectHandlers[DIRTY_OBJECT_MAX]; constexpr State::DirtyObjectHandler State::kDirtyObjectHandlers[DIRTY_OBJECT_MAX];
} // namespace gl } // namespace gl
...@@ -670,12 +670,15 @@ class State : angle::NonCopyable ...@@ -670,12 +670,15 @@ class State : angle::NonCopyable
enum ExtendedDirtyBitType enum ExtendedDirtyBitType
{ {
EXTENDED_DIRTY_BIT_CLIP_CONTROL, // EXT_clip_control EXTENDED_DIRTY_BIT_CLIP_CONTROL, // EXT_clip_control
EXTENDED_DIRTY_BIT_CLIP_DISTANCES, // clip distances
EXTENDED_DIRTY_BIT_MIPMAP_GENERATION_HINT, // mipmap generation hint
EXTENDED_DIRTY_BIT_SHADER_DERIVATIVE_HINT, // shader derivative hint
EXTENDED_DIRTY_BIT_INVALID, EXTENDED_DIRTY_BIT_INVALID,
EXTENDED_DIRTY_BIT_MAX = EXTENDED_DIRTY_BIT_INVALID, EXTENDED_DIRTY_BIT_MAX = EXTENDED_DIRTY_BIT_INVALID,
}; };
static_assert(EXTENDED_DIRTY_BIT_MAX <= 8, "State extended dirty bits must be capped at 8"); static_assert(EXTENDED_DIRTY_BIT_MAX <= 32, "State extended dirty bits must be capped at 32");
// TODO(jmadill): Consider storing dirty objects in a list instead of by binding. // TODO(jmadill): Consider storing dirty objects in a list instead of by binding.
enum DirtyObjectType enum DirtyObjectType
...@@ -706,8 +709,10 @@ class State : angle::NonCopyable ...@@ -706,8 +709,10 @@ class State : angle::NonCopyable
mDirtyCurrentValues.set(); mDirtyCurrentValues.set();
} }
using ExtendedDirtyBits = angle::BitSet8<EXTENDED_DIRTY_BIT_MAX>; using ExtendedDirtyBits = angle::BitSet32<EXTENDED_DIRTY_BIT_MAX>;
const ExtendedDirtyBits &getExtendedDirtyBits() const { return mExtendedDirtyBits; } const ExtendedDirtyBits &getExtendedDirtyBits() const { return mExtendedDirtyBits; }
// TODO(https://anglebug.com/5631): Handle extended dirty bits on non-vulkan backends
ExtendedDirtyBits getAndResetExtendedDirtyBits() const;
void clearExtendedDirtyBits() { mExtendedDirtyBits.reset(); } void clearExtendedDirtyBits() { mExtendedDirtyBits.reset(); }
using DirtyObjects = angle::BitSet<DIRTY_OBJECT_MAX>; using DirtyObjects = angle::BitSet<DIRTY_OBJECT_MAX>;
...@@ -1105,7 +1110,7 @@ class State : angle::NonCopyable ...@@ -1105,7 +1110,7 @@ class State : angle::NonCopyable
GLES1State mGLES1State; GLES1State mGLES1State;
DirtyBits mDirtyBits; DirtyBits mDirtyBits;
ExtendedDirtyBits mExtendedDirtyBits; mutable ExtendedDirtyBits mExtendedDirtyBits;
DirtyObjects mDirtyObjects; DirtyObjects mDirtyObjects;
mutable AttributesMask mDirtyCurrentValues; mutable AttributesMask mDirtyCurrentValues;
ActiveTextureMask mDirtyActiveTextures; ActiveTextureMask mDirtyActiveTextures;
......
...@@ -3088,26 +3088,39 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -3088,26 +3088,39 @@ angle::Result ContextVk::syncState(const gl::Context *context,
break; break;
case gl::State::DIRTY_BIT_EXTENDED: case gl::State::DIRTY_BIT_EXTENDED:
{ {
// Handling clip distance enabled flags, mipmap generation hint & shader derivative gl::State::ExtendedDirtyBits extendedDirtyBits =
// hint. glState.getAndResetExtendedDirtyBits();
invalidateGraphicsDriverUniforms(); for (size_t extendedDirtyBit : extendedDirtyBits)
// Handling clip space origin for EXT_clip_control.
if (glState.getExtendedDirtyBits().test(
gl::State::ExtendedDirtyBitType::EXTENDED_DIRTY_BIT_CLIP_CONTROL))
{ {
updateViewport(vk::GetImpl(glState.getDrawFramebuffer()), glState.getViewport(), switch (extendedDirtyBit)
glState.getNearPlane(), glState.getFarPlane(), {
isViewportFlipEnabledForDrawFBO()); case gl::State::ExtendedDirtyBitType::EXTENDED_DIRTY_BIT_CLIP_CONTROL:
// Since we are flipping the y coordinate, update front face state updateViewport(vk::GetImpl(glState.getDrawFramebuffer()),
mGraphicsPipelineDesc->updateFrontFace(&mGraphicsPipelineTransition, glState.getViewport(), glState.getNearPlane(),
glState.getRasterizerState(), glState.getFarPlane(),
isYFlipEnabledForDrawFBO()); isViewportFlipEnabledForDrawFBO());
updateScissor(glState); // Since we are flipping the y coordinate, update front face state
mGraphicsPipelineDesc->updateFrontFace(&mGraphicsPipelineTransition,
// Nothing is needed for depth correction for EXT_clip_control. glState.getRasterizerState(),
// glState will be used to toggle control path of depth correction code in isYFlipEnabledForDrawFBO());
// SPIR-V tranform options. updateScissor(glState);
// Nothing is needed for depth correction for EXT_clip_control.
// glState will be used to toggle control path of depth correction code
// in SPIR-V tranform options.
break;
case gl::State::ExtendedDirtyBitType::EXTENDED_DIRTY_BIT_CLIP_DISTANCES:
invalidateGraphicsDriverUniforms();
break;
case gl::State::ExtendedDirtyBitType::
EXTENDED_DIRTY_BIT_MIPMAP_GENERATION_HINT:
break;
case gl::State::ExtendedDirtyBitType::
EXTENDED_DIRTY_BIT_SHADER_DERIVATIVE_HINT:
break;
default:
UNREACHABLE();
}
} }
break; break;
} }
......
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