aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShahbaz Youssefi <syoussefi@chromium.org>2024-04-17 10:06:45 -0400
committerAngle LUCI CQ <angle-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-04-18 19:36:13 +0000
commit80c8b6f05034b346541788d9e6de17f5d22cc854 (patch)
tree0c26452e9fbbe61a3dccb0f98e5ed50dc81251ed
parentd0b01c813df0c5cf1153489ff5cdf447e99258f9 (diff)
downloadangle-80c8b6f05034b346541788d9e6de17f5d22cc854.tar.gz
Revert "Vulkan: Only enable DS dynamic state if there is DS attachment."
This reverts commit 471b50407d7d1c22491d066df77060cb8b9b2f89. The reverted change does not correctly handle UtilsVk functions, leading to validation failures. UtilsVk could be made to not set dynamic state when the depth/stencil attachments are missing, but instead the change is reverted because: - The original issue that prompted this is easily fixable (and fixed in this change) - Disabling depth/stencil dynamic state is not necessarily a performance improvement; every time a pipeline in such a render pass is bound, the driver would have to make sure to no-op the relevant state change if static, which is also costly. Instead, dynamic state may need to be set only once in the entire render pass. Bug: b/223456677 Bug: b/315353258 Bug: angleproject:8242 Change-Id: I8282b87857d6b9285dbcf307c3c6ecf69df5fadb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5462079 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Yuxin Hu <yuxinhu@google.com>
-rw-r--r--src/libANGLE/renderer/vulkan/ContextVk.cpp10
-rw-r--r--src/libANGLE/renderer/vulkan/ContextVk.h8
-rw-r--r--src/libANGLE/renderer/vulkan/UtilsVk.cpp36
-rw-r--r--src/libANGLE/renderer/vulkan/vk_cache_utils.cpp79
-rw-r--r--src/libANGLE/renderer/vulkan/vk_cache_utils.h2
-rw-r--r--src/libANGLE/renderer/vulkan/vk_helpers.cpp1
-rw-r--r--src/libANGLE/renderer/vulkan/vk_renderer.cpp3
7 files changed, 59 insertions, 80 deletions
diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp
index 5612e35395..e8cd9d6590 100644
--- a/src/libANGLE/renderer/vulkan/ContextVk.cpp
+++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp
@@ -1571,16 +1571,6 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
invalidateGraphicsDriverUniforms();
}
- // Process depth stencil dynamic state only if there is there depth stencil attachment
- if (!mGraphicsPipelineDesc->getRenderPassDesc().hasDepthAttachment())
- {
- dirtyBitMask = dirtyBitMask & ~kDepthDynamicStateDirtyBits;
- }
- if (!mGraphicsPipelineDesc->getRenderPassDesc().hasStencilAttachment())
- {
- dirtyBitMask = dirtyBitMask & ~kStencilDynamicStateDirtyBits;
- }
-
DirtyBits dirtyBits = mGraphicsDirtyBits & dirtyBitMask;
if (dirtyBits.any())
diff --git a/src/libANGLE/renderer/vulkan/ContextVk.h b/src/libANGLE/renderer/vulkan/ContextVk.h
index c238f77168..b11ffb46ae 100644
--- a/src/libANGLE/renderer/vulkan/ContextVk.h
+++ b/src/libANGLE/renderer/vulkan/ContextVk.h
@@ -1491,14 +1491,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
DIRTY_BIT_DESCRIPTOR_SETS};
static constexpr DirtyBits kXfbBuffersAndDescSetDirtyBits{DIRTY_BIT_TRANSFORM_FEEDBACK_BUFFERS,
DIRTY_BIT_DESCRIPTOR_SETS};
- static constexpr DirtyBits kDepthDynamicStateDirtyBits =
- DirtyBits{DIRTY_BIT_DYNAMIC_DEPTH_BIAS, DIRTY_BIT_DYNAMIC_DEPTH_TEST_ENABLE,
- DIRTY_BIT_DYNAMIC_DEPTH_WRITE_ENABLE, DIRTY_BIT_DYNAMIC_DEPTH_COMPARE_OP,
- DIRTY_BIT_DYNAMIC_DEPTH_BIAS_ENABLE};
- static constexpr DirtyBits kStencilDynamicStateDirtyBits =
- DirtyBits{DIRTY_BIT_DYNAMIC_STENCIL_COMPARE_MASK, DIRTY_BIT_DYNAMIC_STENCIL_WRITE_MASK,
- DIRTY_BIT_DYNAMIC_STENCIL_REFERENCE, DIRTY_BIT_DYNAMIC_STENCIL_TEST_ENABLE,
- DIRTY_BIT_DYNAMIC_STENCIL_OP};
// The offset we had the last time we bound the index buffer.
const GLvoid *mLastIndexBufferOffset;
diff --git a/src/libANGLE/renderer/vulkan/UtilsVk.cpp b/src/libANGLE/renderer/vulkan/UtilsVk.cpp
index 6a954fa1ed..0c53c7bb00 100644
--- a/src/libANGLE/renderer/vulkan/UtilsVk.cpp
+++ b/src/libANGLE/renderer/vulkan/UtilsVk.cpp
@@ -2547,11 +2547,11 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
commandBuffer->setStencilWriteMask(params.stencilMask, params.stencilMask);
commandBuffer->setStencilReference(clearStencilValue, clearStencilValue);
- SetStencilDynamicStateForWrite(contextVk->getRenderer(), commandBuffer);
+ SetStencilDynamicStateForWrite(renderer, commandBuffer);
}
else
{
- SetStencilDynamicStateForUnused(contextVk->getRenderer(), commandBuffer);
+ SetStencilDynamicStateForUnused(renderer, commandBuffer);
}
ASSERT(contextVk->hasStartedRenderPassWithQueueSerial(
@@ -2577,6 +2577,8 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk,
vk::ImageHelper *dst,
const ClearImageParameters &params)
{
+ vk::Renderer *renderer = contextVk->getRenderer();
+
ANGLE_TRY(ensureImageClearResourcesInitialized(contextVk));
const angle::Format &dstActualFormat = dst->getActualFormat();
@@ -2596,8 +2598,7 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk,
// format is renderable.
//
// http://anglebug.com/6151
- if (!vk::FormatHasNecessaryFeature(contextVk->getRenderer(), dstActualFormat.id,
- dst->getTilingMode(),
+ if (!vk::FormatHasNecessaryFeature(renderer, dstActualFormat.id, dst->getTilingMode(),
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
{
UNIMPLEMENTED();
@@ -2659,6 +2660,9 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk,
VkRect2D scissor = gl_vk::GetRect(renderArea);
commandBuffer->setScissor(0, 1, &scissor);
+ SetDepthDynamicStateForUnused(renderer, commandBuffer);
+ SetStencilDynamicStateForUnused(renderer, commandBuffer);
+
// Note: this utility creates its own framebuffer, thus bypassing ContextVk::startRenderPass.
// As such, occlusion queries are not enabled.
commandBuffer->draw(3, 0);
@@ -2998,6 +3002,8 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
const vk::ImageView *srcStencilView,
const BlitResolveParameters &params)
{
+ vk::Renderer *renderer = contextVk->getRenderer();
+
// When VK_EXT_shader_stencil_export is not available, stencil is blitted/resolved into a
// temporary buffer which is then copied into the stencil aspect of the image.
ANGLE_TRY(ensureBlitResolveStencilNoExportResourcesInitialized(contextVk));
@@ -3005,14 +3011,14 @@ angle::Result UtilsVk::stencilBlitResolveNoShaderExport(ContextVk *contextVk,
bool isResolve = src->getSamples() > 1;
// Create a temporary buffer to blit/resolve stencil into.
- vk::RendererScoped<vk::BufferHelper> blitBuffer(contextVk->getRenderer());
+ vk::RendererScoped<vk::BufferHelper> blitBuffer(renderer);
uint32_t bufferRowLengthInUints = UnsignedCeilDivide(params.blitArea.width, sizeof(uint32_t));
VkDeviceSize bufferSize = bufferRowLengthInUints * sizeof(uint32_t) * params.blitArea.height;
ANGLE_TRY(contextVk->initBufferAllocation(
- &blitBuffer.get(), contextVk->getRenderer()->getDeviceLocalMemoryTypeIndex(),
- static_cast<size_t>(bufferSize), contextVk->getRenderer()->getDefaultBufferAlignment(),
+ &blitBuffer.get(), renderer->getDeviceLocalMemoryTypeIndex(),
+ static_cast<size_t>(bufferSize), renderer->getDefaultBufferAlignment(),
BufferUsageType::Static));
BlitResolveStencilNoExportShaderParams shaderParams;
@@ -3183,6 +3189,8 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
const vk::ImageView *srcView,
const CopyImageParameters &params)
{
+ vk::Renderer *renderer = contextVk->getRenderer();
+
// The views passed to this function are already retained, so a render pass cannot be already
// open. Otherwise, this function closes the render pass, which may incur a vkQueueSubmit and
// then the views are used in a new command buffer without having been retained for it.
@@ -3389,6 +3397,9 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
VkRect2D scissor = gl_vk::GetRect(renderArea);
commandBuffer->setScissor(0, 1, &scissor);
+ SetDepthDynamicStateForUnused(renderer, commandBuffer);
+ SetStencilDynamicStateForUnused(renderer, commandBuffer);
+
// Note: this utility creates its own framebuffer, thus bypassing ContextVk::startRenderPass.
// As such, occlusion queries are not enabled.
commandBuffer->draw(3, 0);
@@ -3402,6 +3413,8 @@ angle::Result UtilsVk::copyImageBits(ContextVk *contextVk,
vk::ImageHelper *src,
const CopyImageBitsParameters &params)
{
+ vk::Renderer *renderer = contextVk->getRenderer();
+
// This function is used to copy the bit representation of an image to another, and is used to
// support EXT_copy_image when a format is emulated. Currently, only RGB->RGBA emulation is
// possible, and so this function is tailored to this specific kind of emulation.
@@ -3433,8 +3446,8 @@ angle::Result UtilsVk::copyImageBits(ContextVk *contextVk,
const angle::Format &dstImageFormat = dst->getActualFormat();
// Create temporary buffers.
- vk::RendererScoped<vk::BufferHelper> srcBuffer(contextVk->getRenderer());
- vk::RendererScoped<vk::BufferHelper> dstBuffer(contextVk->getRenderer());
+ vk::RendererScoped<vk::BufferHelper> srcBuffer(renderer);
+ vk::RendererScoped<vk::BufferHelper> dstBuffer(renderer);
const uint32_t srcPixelBytes = srcImageFormat.pixelBytes;
const uint32_t dstPixelBytes = dstImageFormat.pixelBytes;
@@ -4309,6 +4322,8 @@ angle::Result UtilsVk::drawOverlay(ContextVk *contextVk,
const vk::ImageView *destView,
const OverlayDrawParameters &params)
{
+ vk::Renderer *renderer = contextVk->getRenderer();
+
ANGLE_TRY(ensureOverlayDrawResourcesInitialized(contextVk));
OverlayDrawShaderParams shaderParams;
@@ -4417,6 +4432,9 @@ angle::Result UtilsVk::drawOverlay(ContextVk *contextVk,
VkRect2D scissor = gl_vk::GetRect(renderArea);
commandBuffer->setScissor(0, 1, &scissor);
+ SetDepthDynamicStateForUnused(renderer, commandBuffer);
+ SetStencilDynamicStateForUnused(renderer, commandBuffer);
+
// Draw all the graph widgets.
if (params.graphWidgetCount > 0)
{
diff --git a/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp b/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp
index ff2e4259f8..74a3c87798 100644
--- a/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_cache_utils.cpp
@@ -2586,18 +2586,6 @@ bool RenderPassDesc::hasDepthStencilAttachment() const
return formatID != angle::FormatID::NONE;
}
-bool RenderPassDesc::hasDepthAttachment() const
-{
- angle::FormatID formatID = operator[](depthStencilAttachmentIndex());
- return formatID != angle::FormatID::NONE && angle::Format::Get(formatID).depthBits > 0;
-}
-
-bool RenderPassDesc::hasStencilAttachment() const
-{
- angle::FormatID formatID = operator[](depthStencilAttachmentIndex());
- return formatID != angle::FormatID::NONE && angle::Format::Get(formatID).stencilBits > 0;
-}
-
size_t RenderPassDesc::clearableAttachmentCount() const
{
size_t colorAttachmentCount = 0;
@@ -3410,47 +3398,14 @@ void GraphicsPipelineDesc::initializePipelineShadersState(
}
// Dynamic state
- // Enable depth/stencil only if there is depth stencil attachment. This allows ContextVk/UtilsVk
- // to skip update these state if there is no attachment.
- const vk::RenderPassDesc renderPassDesc = getRenderPassDesc();
- if (renderPassDesc.hasDepthAttachment())
- {
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_BIAS);
- if (context->getRenderer()->useDepthTestEnableDynamicState())
- {
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE);
- }
- if (context->getRenderer()->useDepthWriteEnableDynamicState())
- {
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE);
- }
- if (context->getRenderer()->useDepthCompareOpDynamicState())
- {
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_COMPARE_OP);
- }
- if (context->getRenderer()->useDepthBiasEnableDynamicState())
- {
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE);
- }
- }
- if (renderPassDesc.hasStencilAttachment())
- {
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK);
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK);
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_REFERENCE);
- if (context->getRenderer()->useStencilTestEnableDynamicState())
- {
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE);
- }
- if (context->getRenderer()->useStencilOpDynamicState())
- {
- dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_OP);
- }
- }
-
dynamicStateListOut->push_back(VK_DYNAMIC_STATE_VIEWPORT);
dynamicStateListOut->push_back(VK_DYNAMIC_STATE_SCISSOR);
dynamicStateListOut->push_back(VK_DYNAMIC_STATE_LINE_WIDTH);
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_BIAS);
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_BOUNDS);
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK);
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK);
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_REFERENCE);
if (context->getRenderer()->useCullModeDynamicState())
{
dynamicStateListOut->push_back(VK_DYNAMIC_STATE_CULL_MODE_EXT);
@@ -3459,10 +3414,34 @@ void GraphicsPipelineDesc::initializePipelineShadersState(
{
dynamicStateListOut->push_back(VK_DYNAMIC_STATE_FRONT_FACE_EXT);
}
+ if (context->getRenderer()->useDepthTestEnableDynamicState())
+ {
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE);
+ }
+ if (context->getRenderer()->useDepthWriteEnableDynamicState())
+ {
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE);
+ }
+ if (context->getRenderer()->useDepthCompareOpDynamicState())
+ {
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_COMPARE_OP);
+ }
+ if (context->getRenderer()->useStencilTestEnableDynamicState())
+ {
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE);
+ }
+ if (context->getRenderer()->useStencilOpDynamicState())
+ {
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_STENCIL_OP);
+ }
if (context->getRenderer()->useRasterizerDiscardEnableDynamicState())
{
dynamicStateListOut->push_back(VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE);
}
+ if (context->getRenderer()->useDepthBiasEnableDynamicState())
+ {
+ dynamicStateListOut->push_back(VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE);
+ }
if (context->getFeatures().supportsFragmentShadingRate.enabled)
{
dynamicStateListOut->push_back(VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR);
diff --git a/src/libANGLE/renderer/vulkan/vk_cache_utils.h b/src/libANGLE/renderer/vulkan/vk_cache_utils.h
index 056d350503..8ca6de50e6 100644
--- a/src/libANGLE/renderer/vulkan/vk_cache_utils.h
+++ b/src/libANGLE/renderer/vulkan/vk_cache_utils.h
@@ -177,8 +177,6 @@ class alignas(4) RenderPassDesc final
bool isColorAttachmentEnabled(size_t colorIndexGL) const;
bool hasYUVResolveAttachment() const { return mIsYUVResolve; }
bool hasDepthStencilAttachment() const;
- bool hasDepthAttachment() const;
- bool hasStencilAttachment() const;
gl::DrawBufferMask getColorResolveAttachmentMask() const { return mColorResolveAttachmentMask; }
bool hasColorResolveAttachment(size_t colorIndexGL) const
{
diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.cpp b/src/libANGLE/renderer/vulkan/vk_helpers.cpp
index c463367fd1..0ccbd0b11c 100644
--- a/src/libANGLE/renderer/vulkan/vk_helpers.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_helpers.cpp
@@ -10515,7 +10515,6 @@ angle::Result ImageHelper::readPixelsImpl(ContextVk *contextVk,
ANGLE_VK_PERF_WARNING(contextVk, GL_DEBUG_SEVERITY_HIGH, "GPU stall due to ReadPixels");
// Triggers a full finish.
- // TODO(jmadill): Don't block on asynchronous readback.
ANGLE_TRY(contextVk->finishImpl(RenderPassClosureReason::GLReadPixels));
return packReadPixelBuffer(contextVk, area, packPixelsParams, getActualFormat(), *readFormat,
diff --git a/src/libANGLE/renderer/vulkan/vk_renderer.cpp b/src/libANGLE/renderer/vulkan/vk_renderer.cpp
index 8f21b1c44f..47f0b3c626 100644
--- a/src/libANGLE/renderer/vulkan/vk_renderer.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_renderer.cpp
@@ -247,8 +247,11 @@ constexpr const char *kSkippedMessages[] = {
// https://anglebug.com/7291
"VUID-vkCmdBlitImage-srcImage-00240",
// https://anglebug.com/8242
+ // VVL bug: https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/7858
"VUID-vkCmdDraw-None-08608",
"VUID-vkCmdDrawIndexed-None-08608",
+ // https://anglebug.com/8242
+ // Invalid feedback loop caused by the application
"VUID-vkCmdDraw-None-09000",
"VUID-vkCmdDrawIndexed-None-09000",
"VUID-vkCmdDraw-None-09002",