Commit ebf75698 by Ian Elliott Committed by Angle LUCI CQ

Vulkan: Fix AGI clear hierarchy bug for clear commands

This approach properly handles outside-render-pass clears. Bug: b/190622922 Change-Id: Ia4a9d6ec13d7da8c4a445af1127e82c03f37e8b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2951960Reviewed-by: 's avatarMark Lobodzinski <mark@lunarg.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent bc913c70
......@@ -440,7 +440,7 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mEmulateSeamfulCubeMapSampling(false),
mOutsideRenderPassCommands(nullptr),
mRenderPassCommands(nullptr),
mQueryEventType(QueryEventCmdBuf::NotInQueryCmd),
mQueryEventType(GraphicsEventCmdBuf::NotInQueryCmd),
mGpuEventsEnabled(false),
mEGLSyncObjectPendingFlush(false),
mHasDeferredFlush(false),
......@@ -3040,10 +3040,10 @@ void ContextVk::endEventLog(angle::EntryPoint entryPoint, PipelineType pipelineT
mOutsideRenderPassCommands->getCommandBuffer().endDebugUtilsLabelEXT();
}
}
void ContextVk::endEventLogForQuery()
void ContextVk::endEventLogForClearOrQuery()
{
ASSERT(mQueryEventType == QueryEventCmdBuf::InOutsideCmdBufQueryCmd ||
mQueryEventType == QueryEventCmdBuf::InRenderPassCmdBufQueryCmd);
ASSERT(mQueryEventType == GraphicsEventCmdBuf::InOutsideCmdBufQueryCmd ||
mQueryEventType == GraphicsEventCmdBuf::InRenderPassCmdBufQueryCmd);
if (!mRenderer->angleDebuggerMode())
{
return;
......@@ -3052,11 +3052,11 @@ void ContextVk::endEventLogForQuery()
vk::CommandBuffer *commandBuffer = nullptr;
switch (mQueryEventType)
{
case QueryEventCmdBuf::InOutsideCmdBufQueryCmd:
case GraphicsEventCmdBuf::InOutsideCmdBufQueryCmd:
ASSERT(mOutsideRenderPassCommands);
commandBuffer = &mOutsideRenderPassCommands->getCommandBuffer();
break;
case QueryEventCmdBuf::InRenderPassCmdBufQueryCmd:
case GraphicsEventCmdBuf::InRenderPassCmdBufQueryCmd:
ASSERT(mRenderPassCommands);
commandBuffer = &mRenderPassCommands->getCommandBuffer();
break;
......@@ -3065,7 +3065,7 @@ void ContextVk::endEventLogForQuery()
}
commandBuffer->endDebugUtilsLabelEXT();
mQueryEventType = QueryEventCmdBuf::NotInQueryCmd;
mQueryEventType = GraphicsEventCmdBuf::NotInQueryCmd;
}
angle::Result ContextVk::handleNoopDrawEvent()
......@@ -3074,14 +3074,9 @@ angle::Result ContextVk::handleNoopDrawEvent()
return handleDirtyEventLogImpl(mRenderPassCommandBuffer);
}
angle::Result ContextVk::handleMidRenderPassClearEvent()
angle::Result ContextVk::handleGraphicsEventLog(GraphicsEventCmdBuf queryEventType)
{
return handleDirtyEventLogImpl(mRenderPassCommandBuffer);
}
angle::Result ContextVk::handleQueryEvent(QueryEventCmdBuf queryEventType)
{
ASSERT(mQueryEventType == QueryEventCmdBuf::NotInQueryCmd);
ASSERT(mQueryEventType == GraphicsEventCmdBuf::NotInQueryCmd);
if (!mRenderer->angleDebuggerMode())
{
return angle::Result::Continue;
......@@ -3092,11 +3087,11 @@ angle::Result ContextVk::handleQueryEvent(QueryEventCmdBuf queryEventType)
vk::CommandBuffer *commandBuffer = nullptr;
switch (mQueryEventType)
{
case QueryEventCmdBuf::InOutsideCmdBufQueryCmd:
case GraphicsEventCmdBuf::InOutsideCmdBufQueryCmd:
ASSERT(mOutsideRenderPassCommands);
commandBuffer = &mOutsideRenderPassCommands->getCommandBuffer();
break;
case QueryEventCmdBuf::InRenderPassCmdBufQueryCmd:
case GraphicsEventCmdBuf::InRenderPassCmdBufQueryCmd:
ASSERT(mRenderPassCommands);
commandBuffer = &mRenderPassCommands->getCommandBuffer();
break;
......@@ -5698,7 +5693,7 @@ angle::Result ContextVk::flushOutsideRenderPassCommands()
angle::Result ContextVk::beginRenderPassQuery(QueryVk *queryVk)
{
// Emit debug-util markers before calling the query command.
ANGLE_TRY(handleQueryEvent(rx::QueryEventCmdBuf::InRenderPassCmdBufQueryCmd));
ANGLE_TRY(handleGraphicsEventLog(rx::GraphicsEventCmdBuf::InRenderPassCmdBufQueryCmd));
// To avoid complexity, we always start and end these queries inside the render pass. If the
// render pass has not yet started, the query is deferred until it does.
......@@ -5718,7 +5713,7 @@ angle::Result ContextVk::beginRenderPassQuery(QueryVk *queryVk)
angle::Result ContextVk::endRenderPassQuery(QueryVk *queryVk)
{
// Emit debug-util markers before calling the query command.
ANGLE_TRY(handleQueryEvent(rx::QueryEventCmdBuf::InRenderPassCmdBufQueryCmd));
ANGLE_TRY(handleGraphicsEventLog(rx::GraphicsEventCmdBuf::InRenderPassCmdBufQueryCmd));
if (mRenderPassCommandBuffer)
{
......
......@@ -53,7 +53,7 @@ struct ContextVkPerfCounters
ContextVkDescriptorSetList descriptorSetsAllocated;
};
enum class QueryEventCmdBuf
enum class GraphicsEventCmdBuf
{
NotInQueryCmd = 0,
InOutsideCmdBufQueryCmd = 1,
......@@ -219,7 +219,7 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
// Record GL API calls for debuggers
void logEvent(const char *eventString);
void endEventLog(angle::EntryPoint entryPoint, PipelineType pipelineType);
void endEventLogForQuery();
void endEventLogForClearOrQuery();
bool isViewportFlipEnabledForDrawFBO() const;
bool isViewportFlipEnabledForReadFBO() const;
......@@ -627,8 +627,7 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
void onProgramExecutableReset(ProgramExecutableVk *executableVk);
angle::Result handleMidRenderPassClearEvent();
angle::Result handleQueryEvent(QueryEventCmdBuf queryEventType);
angle::Result handleGraphicsEventLog(GraphicsEventCmdBuf queryEventType);
private:
// Dirty bits.
......@@ -1074,14 +1073,14 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
// The following is used when creating debug-util markers for graphics debuggers (e.g. AGI). A
// given gl{Begin|End}Query command may result in commands being submitted to the outside or
// render-pass command buffer. The ContextVk::handleQueryEvent() method records the
// render-pass command buffer. The ContextVk::handleGraphicsEventLog() method records the
// appropriate command buffer for use by ContextVk::endEventLogForQuery(). The knowledge of
// which command buffer to use depends on the particular type of query (e.g. samples
// vs. timestamp), and is only known by the query code, which is what calls
// ContextVk::handleQueryEvent(). After all back-end processing of the gl*Query command is
// complete, the front-end calls ContextVk::endEventLogForQuery(), which needs to know which
// ContextVk::handleGraphicsEventLog(). After all back-end processing of the gl*Query command
// is complete, the front-end calls ContextVk::endEventLogForQuery(), which needs to know which
// command buffer to call endDebugUtilsLabelEXT() for.
QueryEventCmdBuf mQueryEventType;
GraphicsEventCmdBuf mQueryEventType;
// Transform feedback buffers.
angle::FastUnorderedSet<const vk::BufferHelper *,
......
......@@ -40,7 +40,7 @@ void DebugAnnotatorVk::endEvent(gl::Context *context,
if (vkCmdBeginDebugUtilsLabelEXT && context)
{
ContextVk *contextVk = vk::GetImpl(static_cast<gl::Context *>(context));
if (isDrawOrClearEntryPoint(entryPoint))
if (isDrawEntryPoint(entryPoint))
{
contextVk->endEventLog(entryPoint, PipelineType::Graphics);
}
......@@ -48,9 +48,9 @@ void DebugAnnotatorVk::endEvent(gl::Context *context,
{
contextVk->endEventLog(entryPoint, PipelineType::Compute);
}
else if (isQueryEntryPoint(entryPoint))
else if (isClearOrQueryEntryPoint(entryPoint))
{
contextVk->endEventLogForQuery();
contextVk->endEventLogForClearOrQuery();
}
}
}
......@@ -60,15 +60,10 @@ bool DebugAnnotatorVk::getStatus()
return true;
}
bool DebugAnnotatorVk::isDrawOrClearEntryPoint(angle::EntryPoint entryPoint) const
bool DebugAnnotatorVk::isDrawEntryPoint(angle::EntryPoint entryPoint) const
{
switch (entryPoint)
{
case angle::EntryPoint::GLClear:
case angle::EntryPoint::GLClearBufferfi:
case angle::EntryPoint::GLClearBufferfv:
case angle::EntryPoint::GLClearBufferiv:
case angle::EntryPoint::GLClearBufferuiv:
case angle::EntryPoint::GLDrawArrays:
case angle::EntryPoint::GLDrawArraysIndirect:
case angle::EntryPoint::GLDrawArraysInstanced:
......@@ -125,10 +120,15 @@ bool DebugAnnotatorVk::isDispatchEntryPoint(angle::EntryPoint entryPoint) const
}
}
bool DebugAnnotatorVk::isQueryEntryPoint(angle::EntryPoint entryPoint) const
bool DebugAnnotatorVk::isClearOrQueryEntryPoint(angle::EntryPoint entryPoint) const
{
switch (entryPoint)
{
case angle::EntryPoint::GLClear:
case angle::EntryPoint::GLClearBufferfi:
case angle::EntryPoint::GLClearBufferfv:
case angle::EntryPoint::GLClearBufferiv:
case angle::EntryPoint::GLClearBufferuiv:
case angle::EntryPoint::GLBeginQuery:
case angle::EntryPoint::GLBeginQueryEXT:
case angle::EntryPoint::GLBeginQueryIndexed:
......
......@@ -29,9 +29,9 @@ class DebugAnnotatorVk : public angle::LoggingAnnotator
bool getStatus() override;
private:
bool isDrawOrClearEntryPoint(angle::EntryPoint entryPoint) const;
bool isDrawEntryPoint(angle::EntryPoint entryPoint) const;
bool isDispatchEntryPoint(angle::EntryPoint entryPoint) const;
bool isQueryEntryPoint(angle::EntryPoint entryPoint) const;
bool isClearOrQueryEntryPoint(angle::EntryPoint entryPoint) const;
// Note: To avoid any race conditions between threads, this class has no private data; all
// events are stored in ContextVk.
......
......@@ -501,6 +501,16 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
vk::Framebuffer *currentFramebuffer = nullptr;
ANGLE_TRY(getFramebuffer(contextVk, &currentFramebuffer, nullptr));
ASSERT(contextVk->hasStartedRenderPassWithFramebuffer(currentFramebuffer));
// Emit debug-util markers for this mid-render-pass clear
ANGLE_TRY(
contextVk->handleGraphicsEventLog(rx::GraphicsEventCmdBuf::InRenderPassCmdBufQueryCmd));
}
else
{
// Emit debug-util markers for this outside-render-pass clear
ANGLE_TRY(
contextVk->handleGraphicsEventLog(rx::GraphicsEventCmdBuf::InOutsideCmdBufQueryCmd));
}
const bool preferDrawOverClearAttachments =
......@@ -2344,9 +2354,6 @@ angle::Result FramebufferVk::clearWithCommand(ContextVk *contextVk,
updateRenderPassReadOnlyDepthMode(contextVk, renderpassCommands);
}
// Emit debug-util markers for this mid-render-pass clear
ANGLE_TRY(contextVk->handleMidRenderPassClearEvent());
VkClearRect rect = {};
rect.rect.extent.width = scissoredRenderArea.width;
rect.rect.extent.height = scissoredRenderArea.height;
......
......@@ -2800,7 +2800,7 @@ angle::Result QueryHelper::beginQuery(ContextVk *contextVk)
CommandBuffer *commandBuffer;
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer({}, &commandBuffer));
ANGLE_TRY(contextVk->handleQueryEvent(rx::QueryEventCmdBuf::InOutsideCmdBufQueryCmd));
ANGLE_TRY(contextVk->handleGraphicsEventLog(rx::GraphicsEventCmdBuf::InOutsideCmdBufQueryCmd));
beginQueryImpl(contextVk, commandBuffer, commandBuffer);
......@@ -2817,7 +2817,7 @@ angle::Result QueryHelper::endQuery(ContextVk *contextVk)
CommandBuffer *commandBuffer;
ANGLE_TRY(contextVk->getOutsideRenderPassCommandBuffer({}, &commandBuffer));
ANGLE_TRY(contextVk->handleQueryEvent(rx::QueryEventCmdBuf::InOutsideCmdBufQueryCmd));
ANGLE_TRY(contextVk->handleGraphicsEventLog(rx::GraphicsEventCmdBuf::InOutsideCmdBufQueryCmd));
endQueryImpl(contextVk, commandBuffer);
......
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