Commit db09eb68 by Antonio Maiorano Committed by Commit Bot

Increase the max fence wait time in debug builds

Also minor refactor to avoid duplicating the constant by having both RendererVk and ContextVk retrieve the wait time via new member function RendererVk::getMaxFenceWaitTimeNs(). BUG=angleproject:3915 Change-Id: I9a283a4e0f34a6a1f840c350dc667f4fc27f59e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1810066Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e34564ba
......@@ -98,9 +98,6 @@ constexpr size_t kDefaultBufferSize = kDefaultValueSize * 16;
constexpr size_t kDefaultPoolAllocatorPageSize = 16 * 1024;
constexpr size_t kDriverUniformsAllocatorPageSize = 4 * 1024;
// Wait a maximum of 10s. If that times out, we declare it a failure.
constexpr uint64_t kMaxFenceWaitTimeNs = 10'000'000'000llu;
constexpr size_t kInFlightCommandsLimit = 100u;
// Initially dumping the command graphs is disabled.
......@@ -1293,7 +1290,7 @@ void ContextVk::handleDeviceLost()
for (CommandBatch &batch : mInFlightCommands)
{
// On device loss we need to wait for fence to be signaled before destroying it
VkResult status = batch.fence.get().wait(device, kMaxFenceWaitTimeNs);
VkResult status = batch.fence.get().wait(device, getMaxFenceWaitTimeNs());
// If the wait times out, it is probably not possible to recover from lost device
ASSERT(status == VK_SUCCESS || status == VK_ERROR_DEVICE_LOST);
......@@ -2741,7 +2738,7 @@ angle::Result ContextVk::checkCompletedCommands()
angle::Result ContextVk::finishToSerial(Serial serial)
{
bool timedOut = false;
angle::Result result = finishToSerialOrTimeout(serial, kMaxFenceWaitTimeNs, &timedOut);
angle::Result result = finishToSerialOrTimeout(serial, getMaxFenceWaitTimeNs(), &timedOut);
// Don't tolerate timeout. If such a large wait time results in timeout, something's wrong.
if (timedOut)
......@@ -2775,7 +2772,7 @@ angle::Result ContextVk::finishToSerialOrTimeout(Serial serial, uint64_t timeout
// Wait for it finish
VkDevice device = getDevice();
VkResult status = batch.fence.get().wait(device, kMaxFenceWaitTimeNs);
VkResult status = batch.fence.get().wait(device, getMaxFenceWaitTimeNs());
// If timed out, report it as such.
if (status == VK_TIMEOUT)
......@@ -2918,7 +2915,7 @@ angle::Result ContextVk::getTimestamp(uint64_t *timestampOut)
// Wait for the submission to finish. Given no semaphores, there is hope that it would execute
// in parallel with what's already running on the GPU.
ANGLE_VK_TRY(this, fence.get().wait(device, kMaxFenceWaitTimeNs));
ANGLE_VK_TRY(this, fence.get().wait(device, getMaxFenceWaitTimeNs()));
// Get the query results
constexpr VkQueryResultFlags queryFlags = VK_QUERY_RESULT_WAIT_BIT | VK_QUERY_RESULT_64_BIT;
......@@ -3026,4 +3023,10 @@ bool ContextVk::shouldUseOldRewriteStructSamplers() const
{
return mRenderer->getFeatures().forceOldRewriteStructSamplers.enabled;
}
uint64_t ContextVk::getMaxFenceWaitTimeNs() const
{
return getRenderer()->getMaxFenceWaitTimeNs();
}
} // namespace rx
......@@ -504,6 +504,8 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::RenderPassO
bool shouldUseOldRewriteStructSamplers() const;
uint64_t getMaxFenceWaitTimeNs() const;
vk::PipelineHelper *mCurrentGraphicsPipeline;
vk::PipelineAndSerial *mCurrentComputePipeline;
gl::PrimitiveMode mCurrentDrawMode;
......
......@@ -49,8 +49,6 @@ namespace
{
// Update the pipeline cache every this many swaps.
constexpr uint32_t kPipelineCacheVkUpdatePeriod = 60;
// Wait a maximum of 10s. If that times out, we declare it a failure.
constexpr uint64_t kMaxFenceWaitTimeNs = 10'000'000'000llu;
// Per the Vulkan specification, as long as Vulkan 1.1+ is returned by vkEnumerateInstanceVersion,
// ANGLE must indicate the highest version of Vulkan functionality that it uses. The Vulkan
// validation layers will issue messages for any core functionality that requires a higher version.
......@@ -481,7 +479,7 @@ angle::Result WaitFences(vk::Context *context,
std::vector<vk::Shared<vk::Fence>> *fences,
bool block)
{
uint64_t timeout = block ? kMaxFenceWaitTimeNs : 0;
uint64_t timeout = block ? context->getRenderer()->getMaxFenceWaitTimeNs() : 0;
// Iterate backwards over the fences, removing them from the list in constant time when they are
// complete.
......@@ -1668,4 +1666,18 @@ std::string RendererVk::getAndClearLastValidationMessage(uint32_t *countSinceLas
return std::move(mLastValidationMessage);
}
uint64_t RendererVk::getMaxFenceWaitTimeNs() const
{
// Wait a maximum of 10s. If that times out, we declare it a failure.
constexpr uint64_t kMaxFenceWaitTimeNs = 10'000'000'000llu;
#if defined(NDEBUG)
return kMaxFenceWaitTimeNs;
#else
// More time in debug builds (e.g. SwiftShader debug needs more time)
return kMaxFenceWaitTimeNs * 100;
#endif
}
} // namespace rx
......@@ -164,6 +164,8 @@ class RendererVk : angle::NonCopyable
void onNewValidationMessage(const std::string &message);
std::string getAndClearLastValidationMessage(uint32_t *countSinceLastClear);
uint64_t getMaxFenceWaitTimeNs() const;
private:
angle::Result initializeDevice(DisplayVk *displayVk, uint32_t queueFamilyIndex);
void ensureCapsInitialized() const;
......
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