From 4b7bac78a9eab3a6ed4fb2815a2d0e42cb3586e4 Mon Sep 17 00:00:00 2001 From: Jamie Madill Date: Sat, 15 Feb 2020 12:17:12 -0500 Subject: [PATCH] Vulkan: Throttle when way ahead of device. This CL adds a fence wait when we get more than 100 serials behind the device. This fixes an ASSERT when unit tests or offscreen performance tests get way ahead of the device. Bug: angleproject:3630 Bug: angleproject:4281 Change-Id: I90f9af1b2ceb2b1cd9f2f638d6d84caaeeb83bb1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2057351 Commit-Queue: Jamie Madill Reviewed-by: Ian Elliott Reviewed-by: Tim Van Patten --- src/libANGLE/renderer/vulkan/ContextVk.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp index 4fe0d7c9d..651e40ea1 100644 --- a/src/libANGLE/renderer/vulkan/ContextVk.cpp +++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp @@ -459,14 +459,16 @@ angle::Result CommandQueue::submitFrame(vk::Context *context, mInFlightCommands.emplace_back(scopedBatch.release()); - // CPU should be throttled to avoid mInFlightCommands from growing too fast. That is done - // on swap() though, and there could be multiple submissions in between (through glFlush() - // calls), so the limit is larger than the expected number of images. The - // InterleavedAttributeDataBenchmark perf test for example issues a large number of flushes. - ASSERT(mInFlightCommands.size() <= kInFlightCommandsLimit); - ANGLE_TRY(checkCompletedCommands(context)); + // CPU should be throttled to avoid mInFlightCommands from growing too fast. Important for + // off-screen scenarios. + while (mInFlightCommands.size() > kInFlightCommandsLimit) + { + ANGLE_TRY(finishToSerial(context, mInFlightCommands[0].serial, + renderer->getMaxFenceWaitTimeNs())); + } + return angle::Result::Continue; }