Commit 89f50584 by Mohan Maiya Committed by Commit Bot

Vulkan: Add ExtendedDirtyBitType bitset

ExtendedDirtyBitType qualifies DIRTY_BIT_EXTENDED dirtybit. Clip control code path can now set the appropriate ExtendedDirtyBitType when there is a change in state. Also remove the ClipSpaceOrigin member in the Vulkan backend that cached front-end state. Bug: angleproject:5471 Tests: dEQP-GLES2.functional.clip_control.* Change-Id: I8dbb509ef940e7905439d32483fd67a8fc171a6e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2673062Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent 573d7f34
...@@ -89,6 +89,7 @@ ANGLE_INLINE angle::Result Context::syncDirtyBits() ...@@ -89,6 +89,7 @@ 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;
} }
...@@ -97,6 +98,7 @@ ANGLE_INLINE angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMas ...@@ -97,6 +98,7 @@ 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;
} }
......
...@@ -822,16 +822,23 @@ void State::setDepthRange(float zNear, float zFar) ...@@ -822,16 +822,23 @@ void State::setDepthRange(float zNear, float zFar)
void State::setClipControl(GLenum origin, GLenum depth) void State::setClipControl(GLenum origin, GLenum depth)
{ {
bool updated = false;
if (mClipControlOrigin != origin) if (mClipControlOrigin != origin)
{ {
mClipControlOrigin = origin; mClipControlOrigin = origin;
mDirtyBits.set(DIRTY_BIT_EXTENDED); updated = true;
} }
if (mClipControlDepth != depth) if (mClipControlDepth != depth)
{ {
mClipControlDepth = depth; mClipControlDepth = depth;
updated = true;
}
if (updated)
{
mDirtyBits.set(DIRTY_BIT_EXTENDED); mDirtyBits.set(DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(EXTENDED_DIRTY_BIT_CLIP_CONTROL);
} }
} }
......
...@@ -668,6 +668,15 @@ class State : angle::NonCopyable ...@@ -668,6 +668,15 @@ class State : angle::NonCopyable
static_assert(DIRTY_BIT_MAX <= 64, "State dirty bits must be capped at 64"); static_assert(DIRTY_BIT_MAX <= 64, "State dirty bits must be capped at 64");
enum ExtendedDirtyBitType
{
EXTENDED_DIRTY_BIT_CLIP_CONTROL, // EXT_clip_control
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");
// 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
{ {
...@@ -697,6 +706,10 @@ class State : angle::NonCopyable ...@@ -697,6 +706,10 @@ class State : angle::NonCopyable
mDirtyCurrentValues.set(); mDirtyCurrentValues.set();
} }
using ExtendedDirtyBits = angle::BitSet8<EXTENDED_DIRTY_BIT_MAX>;
const ExtendedDirtyBits &getExtendedDirtyBits() const { return mExtendedDirtyBits; }
void clearExtendedDirtyBits() { mExtendedDirtyBits.reset(); }
using DirtyObjects = angle::BitSet<DIRTY_OBJECT_MAX>; using DirtyObjects = angle::BitSet<DIRTY_OBJECT_MAX>;
void clearDirtyObjects() { mDirtyObjects.reset(); } void clearDirtyObjects() { mDirtyObjects.reset(); }
void setAllDirtyObjects() { mDirtyObjects.set(); } void setAllDirtyObjects() { mDirtyObjects.set(); }
...@@ -1092,6 +1105,7 @@ class State : angle::NonCopyable ...@@ -1092,6 +1105,7 @@ class State : angle::NonCopyable
GLES1State mGLES1State; GLES1State mGLES1State;
DirtyBits mDirtyBits; DirtyBits mDirtyBits;
ExtendedDirtyBits mExtendedDirtyBits;
DirtyObjects mDirtyObjects; DirtyObjects mDirtyObjects;
mutable AttributesMask mDirtyCurrentValues; mutable AttributesMask mDirtyCurrentValues;
ActiveTextureMask mDirtyActiveTextures; ActiveTextureMask mDirtyActiveTextures;
......
...@@ -376,7 +376,6 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk ...@@ -376,7 +376,6 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mFlipYForCurrentSurface(false), mFlipYForCurrentSurface(false),
mFlipViewportForDrawFramebuffer(false), mFlipViewportForDrawFramebuffer(false),
mFlipViewportForReadFramebuffer(false), mFlipViewportForReadFramebuffer(false),
mClipSpaceOrigin(gl::ClipSpaceOrigin::LowerLeft),
mIsAnyHostVisibleBufferWritten(false), mIsAnyHostVisibleBufferWritten(false),
mEmulateSeamfulCubeMapSampling(false), mEmulateSeamfulCubeMapSampling(false),
mOutsideRenderPassCommands(nullptr), mOutsideRenderPassCommands(nullptr),
...@@ -2655,7 +2654,7 @@ void ContextVk::updateViewport(FramebufferVk *framebufferVk, ...@@ -2655,7 +2654,7 @@ void ContextVk::updateViewport(FramebufferVk *framebufferVk,
rotatedRect, nearPlane, farPlane, invertViewport, rotatedRect, nearPlane, farPlane, invertViewport,
// If clip space origin is upper left, viewport origin's y value will be offset by the // If clip space origin is upper left, viewport origin's y value will be offset by the
// height of the viewport when clip space is mapped into screen space. // height of the viewport when clip space is mapped into screen space.
mClipSpaceOrigin == gl::ClipSpaceOrigin::UpperLeft, mState.getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft,
// If the surface is rotated 90/270 degrees, use the framebuffer's width instead of the // If the surface is rotated 90/270 degrees, use the framebuffer's width instead of the
// height for calculating the final viewport. // height for calculating the final viewport.
isRotatedAspectRatioForDrawFBO() ? fbDimensions.width : fbDimensions.height, &vkViewport); isRotatedAspectRatioForDrawFBO() ? fbDimensions.width : fbDimensions.height, &vkViewport);
...@@ -3099,9 +3098,9 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -3099,9 +3098,9 @@ angle::Result ContextVk::syncState(const gl::Context *context,
invalidateGraphicsDriverUniforms(); invalidateGraphicsDriverUniforms();
// Handling clip space origin for EXT_clip_control. // Handling clip space origin for EXT_clip_control.
if (glState.getClipSpaceOrigin() != getClipSpaceOrigin()) if (glState.getExtendedDirtyBits().test(
gl::State::ExtendedDirtyBitType::EXTENDED_DIRTY_BIT_CLIP_CONTROL))
{ {
updateClipSpaceOrigin(glState);
updateViewport(vk::GetImpl(glState.getDrawFramebuffer()), glState.getViewport(), updateViewport(vk::GetImpl(glState.getDrawFramebuffer()), glState.getViewport(),
glState.getNearPlane(), glState.getFarPlane(), glState.getNearPlane(), glState.getFarPlane(),
isViewportFlipEnabledForDrawFBO()); isViewportFlipEnabledForDrawFBO());
...@@ -3315,16 +3314,6 @@ void ContextVk::updateSurfaceRotationReadFramebuffer(const gl::State &glState) ...@@ -3315,16 +3314,6 @@ void ContextVk::updateSurfaceRotationReadFramebuffer(const gl::State &glState)
DetermineSurfaceRotation(readFramebuffer, mCurrentWindowSurface); DetermineSurfaceRotation(readFramebuffer, mCurrentWindowSurface);
} }
gl::ClipSpaceOrigin ContextVk::getClipSpaceOrigin() const
{
return mClipSpaceOrigin;
}
void ContextVk::updateClipSpaceOrigin(const gl::State &glState)
{
mClipSpaceOrigin = glState.getClipSpaceOrigin();
}
gl::Caps ContextVk::getNativeCaps() const gl::Caps ContextVk::getNativeCaps() const
{ {
return mRenderer->getNativeCaps(); return mRenderer->getNativeCaps();
......
...@@ -215,11 +215,10 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText ...@@ -215,11 +215,10 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
// isYFlipEnabledForDrawFBO indicates the rendered image is upside-down. // isYFlipEnabledForDrawFBO indicates the rendered image is upside-down.
ANGLE_INLINE bool isYFlipEnabledForDrawFBO() const ANGLE_INLINE bool isYFlipEnabledForDrawFBO() const
{ {
return mClipSpaceOrigin == gl::ClipSpaceOrigin::UpperLeft return mState.getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft
? !isViewportFlipEnabledForDrawFBO() ? !isViewportFlipEnabledForDrawFBO()
: isViewportFlipEnabledForDrawFBO(); : isViewportFlipEnabledForDrawFBO();
} }
gl::ClipSpaceOrigin getClipSpaceOrigin() const;
void invalidateProgramBindingHelper(const gl::State &glState); void invalidateProgramBindingHelper(const gl::State &glState);
angle::Result invalidateProgramExecutableHelper(const gl::Context *context); angle::Result invalidateProgramExecutableHelper(const gl::Context *context);
...@@ -749,8 +748,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText ...@@ -749,8 +748,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
void updateSurfaceRotationDrawFramebuffer(const gl::State &glState); void updateSurfaceRotationDrawFramebuffer(const gl::State &glState);
void updateSurfaceRotationReadFramebuffer(const gl::State &glState); void updateSurfaceRotationReadFramebuffer(const gl::State &glState);
void updateClipSpaceOrigin(const gl::State &glState);
angle::Result updateActiveTextures(const gl::Context *context); angle::Result updateActiveTextures(const gl::Context *context);
angle::Result updateActiveImages(const gl::Context *context, angle::Result updateActiveImages(const gl::Context *context,
vk::CommandBufferHelper *commandBufferHelper); vk::CommandBufferHelper *commandBufferHelper);
...@@ -957,9 +954,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText ...@@ -957,9 +954,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
bool mFlipViewportForDrawFramebuffer; bool mFlipViewportForDrawFramebuffer;
bool mFlipViewportForReadFramebuffer; bool mFlipViewportForReadFramebuffer;
// Cache clip origin state, needed for viewport calculation.
gl::ClipSpaceOrigin mClipSpaceOrigin;
// If any host-visible buffer is written by the GPU since last submission, a barrier is inserted // If any host-visible buffer is written by the GPU since last submission, a barrier is inserted
// at the end of the command buffer to make that write available to the host. // at the end of the command buffer to make that write available to the host.
bool mIsAnyHostVisibleBufferWritten; bool mIsAnyHostVisibleBufferWritten;
......
...@@ -1572,7 +1572,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk, ...@@ -1572,7 +1572,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk); gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk);
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO(); bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
bool clipSpaceOriginUpperLeft = bool clipSpaceOriginUpperLeft =
contextVk->getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft; contextVk->getState().getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft;
// Set depth range to clear value. If clearing depth, the vertex shader depth output is clamped // Set depth range to clear value. If clearing depth, the vertex shader depth output is clamped
// to this value, thus clearing the depth buffer to the desired clear value. // to this value, thus clearing the depth buffer to the desired clear value.
const float clearDepthValue = params.depthStencilClearValue.depth; const float clearDepthValue = params.depthStencilClearValue.depth;
...@@ -2694,7 +2694,7 @@ angle::Result UtilsVk::unresolve(ContextVk *contextVk, ...@@ -2694,7 +2694,7 @@ angle::Result UtilsVk::unresolve(ContextVk *contextVk,
gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk); gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk);
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO(); bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
bool clipSpaceOriginUpperLeft = bool clipSpaceOriginUpperLeft =
contextVk->getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft; contextVk->getState().getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft;
gl_vk::GetViewport(completeRenderArea, 0.0f, 1.0f, invertViewport, clipSpaceOriginUpperLeft, gl_vk::GetViewport(completeRenderArea, 0.0f, 1.0f, invertViewport, clipSpaceOriginUpperLeft,
completeRenderArea.height, &viewport); completeRenderArea.height, &viewport);
pipelineDesc.setViewport(viewport); pipelineDesc.setViewport(viewport);
......
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