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/+/2673062
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
This commit is contained in:
Mohan Maiya 2021-02-03 08:51:04 -08:00 коммит произвёл Commit Bot
Родитель 573d7f34a4
Коммит 89f505844c
6 изменённых файлов: 30 добавлений и 24 удалений

Просмотреть файл

@ -89,6 +89,7 @@ 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;
}
@ -97,6 +98,7 @@ 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;
}

Просмотреть файл

@ -822,16 +822,23 @@ void State::setDepthRange(float zNear, float zFar)
void State::setClipControl(GLenum origin, GLenum depth)
{
bool updated = false;
if (mClipControlOrigin != origin)
{
mClipControlOrigin = origin;
mDirtyBits.set(DIRTY_BIT_EXTENDED);
updated = true;
}
if (mClipControlDepth != depth)
{
mClipControlDepth = depth;
updated = true;
}
if (updated)
{
mDirtyBits.set(DIRTY_BIT_EXTENDED);
mExtendedDirtyBits.set(EXTENDED_DIRTY_BIT_CLIP_CONTROL);
}
}

Просмотреть файл

@ -668,6 +668,15 @@ class State : angle::NonCopyable
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.
enum DirtyObjectType
{
@ -697,6 +706,10 @@ class State : angle::NonCopyable
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>;
void clearDirtyObjects() { mDirtyObjects.reset(); }
void setAllDirtyObjects() { mDirtyObjects.set(); }
@ -1092,6 +1105,7 @@ class State : angle::NonCopyable
GLES1State mGLES1State;
DirtyBits mDirtyBits;
ExtendedDirtyBits mExtendedDirtyBits;
DirtyObjects mDirtyObjects;
mutable AttributesMask mDirtyCurrentValues;
ActiveTextureMask mDirtyActiveTextures;

Просмотреть файл

@ -376,7 +376,6 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mFlipYForCurrentSurface(false),
mFlipViewportForDrawFramebuffer(false),
mFlipViewportForReadFramebuffer(false),
mClipSpaceOrigin(gl::ClipSpaceOrigin::LowerLeft),
mIsAnyHostVisibleBufferWritten(false),
mEmulateSeamfulCubeMapSampling(false),
mOutsideRenderPassCommands(nullptr),
@ -2655,7 +2654,7 @@ void ContextVk::updateViewport(FramebufferVk *framebufferVk,
rotatedRect, nearPlane, farPlane, invertViewport,
// 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.
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
// height for calculating the final viewport.
isRotatedAspectRatioForDrawFBO() ? fbDimensions.width : fbDimensions.height, &vkViewport);
@ -3099,9 +3098,9 @@ angle::Result ContextVk::syncState(const gl::Context *context,
invalidateGraphicsDriverUniforms();
// 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(),
glState.getNearPlane(), glState.getFarPlane(),
isViewportFlipEnabledForDrawFBO());
@ -3315,16 +3314,6 @@ void ContextVk::updateSurfaceRotationReadFramebuffer(const gl::State &glState)
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
{
return mRenderer->getNativeCaps();

Просмотреть файл

@ -215,11 +215,10 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
// isYFlipEnabledForDrawFBO indicates the rendered image is upside-down.
ANGLE_INLINE bool isYFlipEnabledForDrawFBO() const
{
return mClipSpaceOrigin == gl::ClipSpaceOrigin::UpperLeft
return mState.getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft
? !isViewportFlipEnabledForDrawFBO()
: isViewportFlipEnabledForDrawFBO();
}
gl::ClipSpaceOrigin getClipSpaceOrigin() const;
void invalidateProgramBindingHelper(const gl::State &glState);
angle::Result invalidateProgramExecutableHelper(const gl::Context *context);
@ -749,8 +748,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
void updateSurfaceRotationDrawFramebuffer(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 updateActiveImages(const gl::Context *context,
vk::CommandBufferHelper *commandBufferHelper);
@ -957,9 +954,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
bool mFlipViewportForDrawFramebuffer;
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
// at the end of the command buffer to make that write available to the host.
bool mIsAnyHostVisibleBufferWritten;

Просмотреть файл

@ -1572,7 +1572,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk);
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
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
// to this value, thus clearing the depth buffer to the desired clear value.
const float clearDepthValue = params.depthStencilClearValue.depth;
@ -2694,7 +2694,7 @@ angle::Result UtilsVk::unresolve(ContextVk *contextVk,
gl::Rectangle completeRenderArea = framebuffer->getRotatedCompleteRenderArea(contextVk);
bool invertViewport = contextVk->isViewportFlipEnabledForDrawFBO();
bool clipSpaceOriginUpperLeft =
contextVk->getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft;
contextVk->getState().getClipSpaceOrigin() == gl::ClipSpaceOrigin::UpperLeft;
gl_vk::GetViewport(completeRenderArea, 0.0f, 1.0f, invertViewport, clipSpaceOriginUpperLeft,
completeRenderArea.height, &viewport);
pipelineDesc.setViewport(viewport);