Commit 25b7b846 by Jamie Madill Committed by Commit Bot

Vulkan: Command graph linearization (Step 3).

Implements queries with the new command graph syntax. The T-Rex capture benchmark uses queries so this fixes several errors. Bug: angleproject:4029 Change-Id: Ia785f8e31257116aa3c75032dd66471b49926a78 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2021003 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com>
parent 20b1259a
...@@ -500,7 +500,11 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO ...@@ -500,7 +500,11 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
vk::Shared<vk::Fence> getLastSubmittedFence() const; vk::Shared<vk::Fence> getLastSubmittedFence() const;
// This should only be called from ResourceVk. // This should only be called from ResourceVk.
vk::CommandGraph *getCommandGraph() { return &mCommandGraph; } vk::CommandGraph *getCommandGraph()
{
ASSERT(commandGraphEnabled());
return &mCommandGraph;
}
vk::ShaderLibrary &getShaderLibrary() { return mShaderLibrary; } vk::ShaderLibrary &getShaderLibrary() { return mShaderLibrary; }
UtilsVk &getUtils() { return mUtils; } UtilsVk &getUtils() { return mUtils; }
...@@ -571,13 +575,18 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO ...@@ -571,13 +575,18 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
RenderPassCommandBuffer &getRenderPassCommandBuffer() RenderPassCommandBuffer &getRenderPassCommandBuffer()
{ {
if (!mOutsideRenderPassCommands.empty()) mOutsideRenderPassCommands.flushToPrimary(&mPrimaryCommands);
{
mOutsideRenderPassCommands.flushToPrimary(&mPrimaryCommands);
}
return mRenderPassCommands; return mRenderPassCommands;
} }
angle::Result getPrimaryCommandBuffer(vk::PrimaryCommandBuffer **primaryCommands)
{
mOutsideRenderPassCommands.flushToPrimary(&mPrimaryCommands);
ANGLE_TRY(endRenderPass());
*primaryCommands = &mPrimaryCommands;
return angle::Result::Continue;
}
egl::ContextPriority getContextPriority() const override { return mContextPriority; } egl::ContextPriority getContextPriority() const override { return mContextPriority; }
angle::Result endRenderPass(); angle::Result endRenderPass();
......
...@@ -67,11 +67,11 @@ angle::Result QueryVk::begin(const gl::Context *context) ...@@ -67,11 +67,11 @@ angle::Result QueryVk::begin(const gl::Context *context)
contextVk, &mQueryHelperTimeElapsedBegin)); contextVk, &mQueryHelperTimeElapsedBegin));
} }
mQueryHelperTimeElapsedBegin.writeTimestamp(contextVk); ANGLE_TRY(mQueryHelperTimeElapsedBegin.writeTimestamp(contextVk));
} }
else else
{ {
mQueryHelper.beginQuery(contextVk); ANGLE_TRY(mQueryHelper.beginQuery(contextVk));
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -98,11 +98,11 @@ angle::Result QueryVk::end(const gl::Context *context) ...@@ -98,11 +98,11 @@ angle::Result QueryVk::end(const gl::Context *context)
} }
else if (getType() == gl::QueryType::TimeElapsed) else if (getType() == gl::QueryType::TimeElapsed)
{ {
mQueryHelper.writeTimestamp(contextVk); ANGLE_TRY(mQueryHelper.writeTimestamp(contextVk));
} }
else else
{ {
mQueryHelper.endQuery(contextVk); ANGLE_TRY(mQueryHelper.endQuery(contextVk));
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -121,9 +121,7 @@ angle::Result QueryVk::queryCounter(const gl::Context *context) ...@@ -121,9 +121,7 @@ angle::Result QueryVk::queryCounter(const gl::Context *context)
ASSERT(getType() == gl::QueryType::Timestamp); ASSERT(getType() == gl::QueryType::Timestamp);
mQueryHelper.writeTimestamp(contextVk); return mQueryHelper.writeTimestamp(contextVk);
return angle::Result::Continue;
} }
angle::Result QueryVk::getResult(const gl::Context *context, bool wait) angle::Result QueryVk::getResult(const gl::Context *context, bool wait)
......
...@@ -108,19 +108,15 @@ void RendererVk::ensureCapsInitialized() const ...@@ -108,19 +108,15 @@ void RendererVk::ensureCapsInitialized() const
// We use secondary command buffers almost everywhere and they require a feature to be // We use secondary command buffers almost everywhere and they require a feature to be
// able to execute in the presence of queries. As a result, we won't support queries // able to execute in the presence of queries. As a result, we won't support queries
// unless that feature is available. // unless that feature is available.
// TODO(jmadill): Enable without graph. http://anglebug.com/4029
mNativeExtensions.occlusionQueryBoolean = mNativeExtensions.occlusionQueryBoolean =
vk::CommandBuffer::SupportsQueries(mPhysicalDeviceFeatures) && vk::CommandBuffer::SupportsQueries(mPhysicalDeviceFeatures);
mFeatures.commandGraph.enabled;
// From the Vulkan specs: // From the Vulkan specs:
// > The number of valid bits in a timestamp value is determined by the // > The number of valid bits in a timestamp value is determined by the
// > VkQueueFamilyProperties::timestampValidBits property of the queue on which the timestamp is // > VkQueueFamilyProperties::timestampValidBits property of the queue on which the timestamp is
// > written. Timestamps are supported on any queue which reports a non-zero value for // > written. Timestamps are supported on any queue which reports a non-zero value for
// > timestampValidBits via vkGetPhysicalDeviceQueueFamilyProperties. // > timestampValidBits via vkGetPhysicalDeviceQueueFamilyProperties.
// TODO(jmadill): Enable without graph. http://anglebug.com/4029 mNativeExtensions.disjointTimerQuery = queueFamilyProperties.timestampValidBits > 0;
mNativeExtensions.disjointTimerQuery =
queueFamilyProperties.timestampValidBits > 0 && mFeatures.commandGraph.enabled;
mNativeExtensions.queryCounterBitsTimeElapsed = queueFamilyProperties.timestampValidBits; mNativeExtensions.queryCounterBitsTimeElapsed = queueFamilyProperties.timestampValidBits;
mNativeExtensions.queryCounterBitsTimestamp = queueFamilyProperties.timestampValidBits; mNativeExtensions.queryCounterBitsTimestamp = queueFamilyProperties.timestampValidBits;
......
...@@ -1019,22 +1019,57 @@ void QueryHelper::deinit() ...@@ -1019,22 +1019,57 @@ void QueryHelper::deinit()
mQuery = 0; mQuery = 0;
} }
void QueryHelper::beginQuery(ContextVk *contextVk) angle::Result QueryHelper::beginQuery(ContextVk *contextVk)
{ {
contextVk->getCommandGraph()->beginQuery(getQueryPool(), getQuery()); if (contextVk->commandGraphEnabled())
{
contextVk->getCommandGraph()->beginQuery(getQueryPool(), getQuery());
}
else
{
vk::PrimaryCommandBuffer *primaryCommands;
ANGLE_TRY(contextVk->getPrimaryCommandBuffer(&primaryCommands));
VkQueryPool queryPool = getQueryPool()->getHandle();
primaryCommands->resetQueryPool(queryPool, mQuery, 1);
primaryCommands->beginQuery(queryPool, mQuery, 0);
}
mMostRecentSerial = contextVk->getCurrentQueueSerial(); mMostRecentSerial = contextVk->getCurrentQueueSerial();
return angle::Result::Continue;
} }
void QueryHelper::endQuery(ContextVk *contextVk) angle::Result QueryHelper::endQuery(ContextVk *contextVk)
{ {
contextVk->getCommandGraph()->endQuery(getQueryPool(), getQuery()); if (contextVk->commandGraphEnabled())
{
contextVk->getCommandGraph()->endQuery(getQueryPool(), getQuery());
}
else
{
vk::PrimaryCommandBuffer *primaryCommands;
ANGLE_TRY(contextVk->getPrimaryCommandBuffer(&primaryCommands));
VkQueryPool queryPool = getQueryPool()->getHandle();
primaryCommands->endQuery(queryPool, mQuery);
}
mMostRecentSerial = contextVk->getCurrentQueueSerial(); mMostRecentSerial = contextVk->getCurrentQueueSerial();
return angle::Result::Continue;
} }
void QueryHelper::writeTimestamp(ContextVk *contextVk) angle::Result QueryHelper::writeTimestamp(ContextVk *contextVk)
{ {
contextVk->getCommandGraph()->writeTimestamp(getQueryPool(), getQuery()); if (contextVk->commandGraphEnabled())
{
contextVk->getCommandGraph()->writeTimestamp(getQueryPool(), getQuery());
}
else
{
vk::PrimaryCommandBuffer *primaryCommands;
ANGLE_TRY(contextVk->getPrimaryCommandBuffer(&primaryCommands));
VkQueryPool queryPool = getQueryPool()->getHandle();
primaryCommands->resetQueryPool(queryPool, mQuery, 1);
primaryCommands->writeTimestamp(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, queryPool, mQuery);
}
mMostRecentSerial = contextVk->getCurrentQueueSerial(); mMostRecentSerial = contextVk->getCurrentQueueSerial();
return angle::Result::Continue;
} }
bool QueryHelper::hasPendingWork(ContextVk *contextVk) bool QueryHelper::hasPendingWork(ContextVk *contextVk)
......
...@@ -324,9 +324,9 @@ class QueryHelper final ...@@ -324,9 +324,9 @@ class QueryHelper final
// Used only by DynamicQueryPool. // Used only by DynamicQueryPool.
size_t getQueryPoolIndex() const { return mQueryPoolIndex; } size_t getQueryPoolIndex() const { return mQueryPoolIndex; }
void beginQuery(ContextVk *contextVk); angle::Result beginQuery(ContextVk *contextVk);
void endQuery(ContextVk *contextVk); angle::Result endQuery(ContextVk *contextVk);
void writeTimestamp(ContextVk *contextVk); angle::Result writeTimestamp(ContextVk *contextVk);
Serial getStoredQueueSerial() { return mMostRecentSerial; } Serial getStoredQueueSerial() { return mMostRecentSerial; }
bool hasPendingWork(ContextVk *contextVk); bool hasPendingWork(ContextVk *contextVk);
......
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