Commit a7e03ed7 by Ian Elliott Committed by Commit Bot

Vulkan: Further refine invalidate for depth/stencil

Bug: angleproject:5079 Change-Id: Idc732b1e6729b2776d66c63c3ae2bd94e11bdbb5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2422684Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent edc0d2ee
......@@ -703,7 +703,7 @@ class SecondaryCommandBuffer final : angle::NonCopyable
static bool CanKnowIfEmpty() { return true; }
bool empty() const { return mCommands.size() == 0 || mCommands[0]->id == CommandID::Invalid; }
// The following is used to give the size of the command buffer in bytes
uint32_t getCommandBufferSize() const
uint32_t getCommandSize() const
{
ASSERT(mCommands.size() > 0 || mCurrentBytesRemaining == 0);
uint32_t rtn =
......
......@@ -794,7 +794,7 @@ bool CommandBufferHelper::onDepthStencilAccess(ResourceAccess access,
else
{
// Drawing to this attachment is being disabled.
if (isNoLongerInvalidated(*cmdCountInvalidated, *cmdCountDisabled))
if (hasWriteAfterInvalidate(*cmdCountInvalidated, *cmdCountDisabled))
{
// The attachment was previously drawn while enabled, and so is no longer invalidated.
*cmdCountInvalidated = kInfiniteCmdSize;
......@@ -808,7 +808,7 @@ bool CommandBufferHelper::onDepthStencilAccess(ResourceAccess access,
// Get the latest CmdSize at the start of being disabled. At the end of the render
// pass, cmdCountDisabled is <= the actual command buffer size, and so it's compared
// with cmdCountInvalidated. If the same, the attachment is still invalidated.
*cmdCountDisabled = mCommandBuffer.getCommandBufferSize();
*cmdCountDisabled = mCommandBuffer.getCommandSize();
return false;
}
}
......
......@@ -902,7 +902,7 @@ class PackedClearValuesArray final
// The following are used to help track the state of an invalidated attachment.
// This value indicates an "infinite" CmdSize that is not valid for comparing
constexpr uint32_t kInfiniteCmdSize = 0xffffffff;
constexpr uint32_t kInfiniteCmdSize = 0xFFFFFFFF;
// CommandBufferHelper (CBH) class wraps ANGLE's custom command buffer
// class, SecondaryCommandBuffer. This provides a way to temporarily
......@@ -996,7 +996,7 @@ class CommandBufferHelper : angle::NonCopyable
ASSERT(mIsRenderPassCommandBuffer);
// Keep track of the size of commands in the command buffer. If the size grows in the
// future, that implies that drawing occured since invalidated.
mDepthCmdSizeInvalidated = mCommandBuffer.getCommandBufferSize();
mDepthCmdSizeInvalidated = mCommandBuffer.getCommandSize();
// Also track the size if the attachment is currently disabled.
mDepthCmdSizeDisabled =
(dsState.depthTest && dsState.depthMask) ? kInfiniteCmdSize : mDepthCmdSizeInvalidated;
......@@ -1007,26 +1007,24 @@ class CommandBufferHelper : angle::NonCopyable
ASSERT(mIsRenderPassCommandBuffer);
// Keep track of the size of commands in the command buffer. If the size grows in the
// future, that implies that drawing occured since invalidated.
mStencilCmdSizeInvalidated = mCommandBuffer.getCommandBufferSize();
mStencilCmdSizeInvalidated = mCommandBuffer.getCommandSize();
// Also track the size if the attachment is currently disabled.
mStencilCmdSizeDisabled =
dsState.stencilTest ? kInfiniteCmdSize : mStencilCmdSizeInvalidated;
}
bool isNoLongerInvalidated(uint32_t cmdCountInvalidated, uint32_t cmdCountDisabled)
bool hasWriteAfterInvalidate(uint32_t cmdCountInvalidated, uint32_t cmdCountDisabled)
{
ASSERT(mIsRenderPassCommandBuffer);
return (cmdCountInvalidated != kInfiniteCmdSize &&
std::min(cmdCountDisabled, mCommandBuffer.getCommandBufferSize()) !=
cmdCountInvalidated);
std::min(cmdCountDisabled, mCommandBuffer.getCommandSize()) != cmdCountInvalidated);
}
bool isInvalidated(uint32_t cmdCountInvalidated, uint32_t cmdCountDisabled)
{
ASSERT(mIsRenderPassCommandBuffer);
return cmdCountInvalidated != kInfiniteCmdSize &&
std::min(cmdCountDisabled, mCommandBuffer.getCommandBufferSize()) ==
cmdCountInvalidated;
std::min(cmdCountDisabled, mCommandBuffer.getCommandSize()) == cmdCountInvalidated;
}
void updateRenderPassAttachmentFinalLayout(PackedAttachmentIndex attachmentIndex,
......
......@@ -709,7 +709,10 @@ TEST_P(VulkanPerformanceCounterTest, InvalidateDraw)
// Draw (since enabled, should result: in storeOp = STORE; mContentDefined = true)
drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f);
ASSERT_GL_NO_ERROR();
// TODO(ianelliott): have mContentDefined set at endRP(), so that it's correct
// TODO: Fix ANGLE to correct set mContentDefined for this scenario. At this point,
// mContentDefined will remain false since we don't do record anything at draw-time, and since
// we don't set mContentDefined at endRP().
// https://issuetracker.google.com/issues/167275320
// Ensure that the render pass wasn't broken
EXPECT_EQ(expected.renderPasses, counters.renderPasses);
......@@ -723,11 +726,8 @@ TEST_P(VulkanPerformanceCounterTest, InvalidateDraw)
drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f);
ASSERT_GL_NO_ERROR();
swapBuffers();
// TODO(ianelliott): have mContentDefined set at endRP(), so that it's correct; then uncomment:
// TODO: After fixing ANGLE per https://issuetracker.google.com/issues/167275320, uncomment:
// compareLoadCountersForInvalidateTest(counters, expected);
//
// TODO(ianelliott): have mContentDefined set at endRP(), so that it's correct; then uncomment:
// TEST_FUTURE_RP_LOADOP(1, 1);
}
// Tests that another case does not break render pass, and that counts are correct:
......
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