Commit 8b624c6d by Shahbaz Youssefi Committed by Commit Bot

Use constexpr initializer list for bitsets

Allows setting/resetting multiple bits to be coalesced into one operation. Bug: angleproject:5528 Change-Id: Ibf2dff8c81441a75c268d95066d23da1b2a3c810 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2678885 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent cf8c71de
......@@ -290,6 +290,14 @@ egl::ContextPriority GetContextPriority(const gl::State &state)
}
} // anonymous namespace
// Not necessary once upgraded to C++17.
constexpr ContextVk::DirtyBits ContextVk::kIndexAndVertexDirtyBits;
constexpr ContextVk::DirtyBits ContextVk::kPipelineDescAndBindingDirtyBits;
constexpr ContextVk::DirtyBits ContextVk::kTexturesAndDescSetDirtyBits;
constexpr ContextVk::DirtyBits ContextVk::kResourcesAndDescSetDirtyBits;
constexpr ContextVk::DirtyBits ContextVk::kXfbBuffersAndDescSetDirtyBits;
constexpr ContextVk::DirtyBits ContextVk::kDriverUniformsAndBindingDirtyBits;
ANGLE_INLINE void ContextVk::flushDescriptorSetUpdates()
{
if (mWriteDescriptorSets.empty())
......@@ -408,24 +416,18 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
// Note that currently these dirty bits are set every time a new render pass command buffer is
// begun. However, using ANGLE's SecondaryCommandBuffer, the Vulkan command buffer (which is
// the primary command buffer) is not ended, so technically we don't need to rebind these.
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_RENDER_PASS);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_PIPELINE_BINDING);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_TEXTURES);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_VERTEX_BUFFERS);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_INDEX_BUFFER);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_SHADER_RESOURCES);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS_BINDING);
mNewGraphicsCommandBufferDirtyBits = DirtyBits{
DIRTY_BIT_RENDER_PASS, DIRTY_BIT_PIPELINE_BINDING, DIRTY_BIT_TEXTURES,
DIRTY_BIT_VERTEX_BUFFERS, DIRTY_BIT_INDEX_BUFFER, DIRTY_BIT_SHADER_RESOURCES,
DIRTY_BIT_DESCRIPTOR_SETS, DIRTY_BIT_DRIVER_UNIFORMS_BINDING};
if (getFeatures().supportsTransformFeedbackExtension.enabled)
{
mNewGraphicsCommandBufferDirtyBits.set(DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS);
}
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_PIPELINE_BINDING);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_TEXTURES);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_SHADER_RESOURCES);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mNewComputeCommandBufferDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS_BINDING);
mNewComputeCommandBufferDirtyBits =
DirtyBits{DIRTY_BIT_PIPELINE_BINDING, DIRTY_BIT_TEXTURES, DIRTY_BIT_SHADER_RESOURCES,
DIRTY_BIT_DESCRIPTOR_SETS, DIRTY_BIT_DRIVER_UNIFORMS_BINDING};
mGraphicsDirtyBitHandlers[DIRTY_BIT_EVENT_LOG] = &ContextVk::handleDirtyGraphicsEventLog;
mGraphicsDirtyBitHandlers[DIRTY_BIT_DEFAULT_ATTRIBS] =
......@@ -3483,10 +3485,8 @@ angle::Result ContextVk::invalidateCurrentTextures(const gl::Context *context)
if (executable->hasTextures())
{
mGraphicsDirtyBits.set(DIRTY_BIT_TEXTURES);
mGraphicsDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mComputeDirtyBits.set(DIRTY_BIT_TEXTURES);
mComputeDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mGraphicsDirtyBits |= kTexturesAndDescSetDirtyBits;
mComputeDirtyBits |= kTexturesAndDescSetDirtyBits;
ANGLE_TRY(updateActiveTextures(context));
}
......@@ -3502,25 +3502,20 @@ void ContextVk::invalidateCurrentShaderResources()
if (executable->hasUniformBuffers() || executable->hasStorageBuffers() ||
executable->hasAtomicCounterBuffers() || executable->hasImages())
{
mGraphicsDirtyBits.set(DIRTY_BIT_SHADER_RESOURCES);
mGraphicsDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mComputeDirtyBits.set(DIRTY_BIT_SHADER_RESOURCES);
mComputeDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mGraphicsDirtyBits |= kResourcesAndDescSetDirtyBits;
mComputeDirtyBits |= kResourcesAndDescSetDirtyBits;
}
}
void ContextVk::invalidateGraphicsDriverUniforms()
{
mGraphicsDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS);
mGraphicsDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS_BINDING);
mGraphicsDirtyBits |= kDriverUniformsAndBindingDirtyBits;
}
void ContextVk::invalidateDriverUniforms()
{
mGraphicsDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS);
mGraphicsDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS_BINDING);
mComputeDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS);
mComputeDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS_BINDING);
mGraphicsDirtyBits |= kDriverUniformsAndBindingDirtyBits;
mComputeDirtyBits |= kDriverUniformsAndBindingDirtyBits;
}
void ContextVk::onFramebufferChange(FramebufferVk *framebufferVk)
......@@ -3563,8 +3558,7 @@ void ContextVk::invalidateCurrentTransformFeedbackBuffers()
}
else if (getFeatures().emulateTransformFeedback.enabled)
{
mGraphicsDirtyBits.set(DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS);
mGraphicsDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
mGraphicsDirtyBits |= kXfbBuffersAndDescSetDirtyBits;
}
}
......@@ -3572,8 +3566,8 @@ void ContextVk::onTransformFeedbackStateChanged()
{
if (getFeatures().supportsTransformFeedbackExtension.enabled)
{
mGraphicsDirtyBits.set(DIRTY_BIT_TRANSFORM_FEEDBACK_STATE);
mGraphicsDirtyBits.set(DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS);
mGraphicsDirtyBits |=
DirtyBits{DIRTY_BIT_TRANSFORM_FEEDBACK_STATE, DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS};
}
else if (getFeatures().emulateTransformFeedback.enabled)
{
......@@ -3840,8 +3834,7 @@ void ContextVk::writeAtomicCounterBufferDriverUniformOffsets(uint32_t *offsetsOu
void ContextVk::pauseTransformFeedbackIfStartedAndRebindBuffersOnResume()
{
DirtyBits rebindTransformFeedbackOnResume;
rebindTransformFeedbackOnResume.set(DIRTY_BIT_TRANSFORM_FEEDBACK_STATE);
DirtyBits rebindTransformFeedbackOnResume{DIRTY_BIT_TRANSFORM_FEEDBACK_STATE};
pauseTransformFeedbackIfStarted(rebindTransformFeedbackOnResume);
}
......
......@@ -301,8 +301,7 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
ANGLE_INLINE void invalidateVertexAndIndexBuffers()
{
mGraphicsDirtyBits.set(DIRTY_BIT_VERTEX_BUFFERS);
mGraphicsDirtyBits.set(DIRTY_BIT_INDEX_BUFFER);
mGraphicsDirtyBits |= kIndexAndVertexDirtyBits;
}
angle::Result onVertexBufferChange(const vk::BufferHelper *vertexBuffer);
......@@ -760,14 +759,13 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
ANGLE_INLINE void invalidateCurrentGraphicsPipeline()
{
// Note: DIRTY_BIT_PIPELINE_BIND will be automatically set if pipeline bind is necessary.
// Note: DIRTY_BIT_PIPELINE_BINDING will be automatically set if pipeline bind is necessary.
mGraphicsDirtyBits.set(DIRTY_BIT_PIPELINE_DESC);
}
ANGLE_INLINE void invalidateCurrentComputePipeline()
{
mComputeDirtyBits.set(DIRTY_BIT_PIPELINE_DESC);
mComputeDirtyBits.set(DIRTY_BIT_PIPELINE_BINDING);
mComputeDirtyBits |= kPipelineDescAndBindingDirtyBits;
mCurrentComputePipeline = nullptr;
}
......@@ -915,6 +913,18 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
DirtyBits mIndexedDirtyBitsMask;
DirtyBits mNewGraphicsCommandBufferDirtyBits;
DirtyBits mNewComputeCommandBufferDirtyBits;
static constexpr DirtyBits kIndexAndVertexDirtyBits{DIRTY_BIT_VERTEX_BUFFERS,
DIRTY_BIT_INDEX_BUFFER};
static constexpr DirtyBits kPipelineDescAndBindingDirtyBits{DIRTY_BIT_PIPELINE_DESC,
DIRTY_BIT_PIPELINE_BINDING};
static constexpr DirtyBits kTexturesAndDescSetDirtyBits{DIRTY_BIT_TEXTURES,
DIRTY_BIT_DESCRIPTOR_SETS};
static constexpr DirtyBits kResourcesAndDescSetDirtyBits{DIRTY_BIT_SHADER_RESOURCES,
DIRTY_BIT_DESCRIPTOR_SETS};
static constexpr DirtyBits kXfbBuffersAndDescSetDirtyBits{DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS,
DIRTY_BIT_DESCRIPTOR_SETS};
static constexpr DirtyBits kDriverUniformsAndBindingDirtyBits{
DIRTY_BIT_DRIVER_UNIFORMS, DIRTY_BIT_DRIVER_UNIFORMS_BINDING};
// Cached back-end objects.
VertexArrayVk *mVertexArray;
......
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