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()
const State::DirtyBits &dirtyBits = mState.getDirtyBits();
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, mAllDirtyBits));
mState.clearDirtyBits();
mState.clearExtendedDirtyBits();
return angle::Result::Continue;
}
......@@ -98,7 +97,6 @@ ANGLE_INLINE angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMas
const State::DirtyBits &dirtyBits = (mState.getDirtyBits() & bitMask);
ANGLE_TRY(mImplementation->syncState(this, dirtyBits, bitMask));
mState.clearDirtyBits(dirtyBits);
mState.clearExtendedDirtyBits();
return angle::Result::Continue;
}
......
......@@ -1176,6 +1176,7 @@ void State::setClipDistanceEnable(int idx, bool enable)
}
mDirtyBits.set(DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(EXTENDED_DIRTY_BIT_CLIP_DISTANCES);
}
void State::setEnableFeature(GLenum feature, bool enabled)
......@@ -1485,6 +1486,7 @@ void State::setGenerateMipmapHint(GLenum hint)
{
mGenerateMipmapHint = hint;
mDirtyBits.set(DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(EXTENDED_DIRTY_BIT_MIPMAP_GENERATION_HINT);
}
GLenum State::getGenerateMipmapHint() const
......@@ -1508,6 +1510,7 @@ void State::setFragmentShaderDerivativeHint(GLenum hint)
{
mFragmentShaderDerivativeHint = hint;
mDirtyBits.set(DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(EXTENDED_DIRTY_BIT_SHADER_DERIVATIVE_HINT);
// TODO: Propagate the hint to shader translator so we can write
// ddx, ddx_coarse, or ddx_fine depending on the hint.
// Ignore for now. It is valid for implementations to ignore hint.
......@@ -3626,6 +3629,13 @@ AttributesMask State::getAndResetDirtyCurrentValues() const
return retVal;
}
State::ExtendedDirtyBits State::getAndResetExtendedDirtyBits() const
{
ExtendedDirtyBits retVal = mExtendedDirtyBits;
mExtendedDirtyBits.reset();
return retVal;
}
constexpr State::DirtyObjectHandler State::kDirtyObjectHandlers[DIRTY_OBJECT_MAX];
} // namespace gl
......@@ -670,12 +670,15 @@ class State : angle::NonCopyable
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_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.
enum DirtyObjectType
......@@ -706,8 +709,10 @@ class State : angle::NonCopyable
mDirtyCurrentValues.set();
}
using ExtendedDirtyBits = angle::BitSet8<EXTENDED_DIRTY_BIT_MAX>;
using ExtendedDirtyBits = angle::BitSet32<EXTENDED_DIRTY_BIT_MAX>;
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(); }
using DirtyObjects = angle::BitSet<DIRTY_OBJECT_MAX>;
......@@ -1105,7 +1110,7 @@ class State : angle::NonCopyable
GLES1State mGLES1State;
DirtyBits mDirtyBits;
ExtendedDirtyBits mExtendedDirtyBits;
mutable ExtendedDirtyBits mExtendedDirtyBits;
DirtyObjects mDirtyObjects;
mutable AttributesMask mDirtyCurrentValues;
ActiveTextureMask mDirtyActiveTextures;
......
......@@ -3088,26 +3088,39 @@ angle::Result ContextVk::syncState(const gl::Context *context,
break;
case gl::State::DIRTY_BIT_EXTENDED:
{
// Handling clip distance enabled flags, mipmap generation hint & shader derivative
// hint.
invalidateGraphicsDriverUniforms();
// Handling clip space origin for EXT_clip_control.
if (glState.getExtendedDirtyBits().test(
gl::State::ExtendedDirtyBitType::EXTENDED_DIRTY_BIT_CLIP_CONTROL))
gl::State::ExtendedDirtyBits extendedDirtyBits =
glState.getAndResetExtendedDirtyBits();
for (size_t extendedDirtyBit : extendedDirtyBits)
{
updateViewport(vk::GetImpl(glState.getDrawFramebuffer()), glState.getViewport(),
glState.getNearPlane(), glState.getFarPlane(),
isViewportFlipEnabledForDrawFBO());
// Since we are flipping the y coordinate, update front face state
mGraphicsPipelineDesc->updateFrontFace(&mGraphicsPipelineTransition,
glState.getRasterizerState(),
isYFlipEnabledForDrawFBO());
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.
switch (extendedDirtyBit)
{
case gl::State::ExtendedDirtyBitType::EXTENDED_DIRTY_BIT_CLIP_CONTROL:
updateViewport(vk::GetImpl(glState.getDrawFramebuffer()),
glState.getViewport(), glState.getNearPlane(),
glState.getFarPlane(),
isViewportFlipEnabledForDrawFBO());
// Since we are flipping the y coordinate, update front face state
mGraphicsPipelineDesc->updateFrontFace(&mGraphicsPipelineTransition,
glState.getRasterizerState(),
isYFlipEnabledForDrawFBO());
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;
}
......
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