5d67b1797a
In nanobench we want to try and simulate a GPUs swapbuffering and not get too far ahead on the CPU. Thus we use finished callbacks to know if we get more than 3 frames ahead of the GPU. This CL adds support for Graphite to do this. Bug: skia:12974 Change-Id: I8be505c5769399dcc0f5954f9f999f4448633647 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/525186 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com>
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
/*
|
|
* Copyright 2020 Google LLC
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "tools/gpu/FlushFinishTracker.h"
|
|
|
|
#include "include/gpu/GrDirectContext.h"
|
|
#include "src/core/SkTraceEvent.h"
|
|
|
|
#ifdef SK_GRAPHITE_ENABLED
|
|
#include "experimental/graphite/include/Context.h"
|
|
#endif
|
|
|
|
#include <chrono>
|
|
|
|
namespace sk_gpu_test {
|
|
|
|
void FlushFinishTracker::waitTillFinished() {
|
|
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
|
auto begin = std::chrono::steady_clock::now();
|
|
auto end = begin;
|
|
while (!fIsFinished && (end - begin) < std::chrono::seconds(2)) {
|
|
if (fContext) {
|
|
fContext->checkAsyncWorkCompletion();
|
|
} else {
|
|
#ifdef SK_GRAPHITE_ENABLED
|
|
SkASSERT(fGraphiteContext);
|
|
fGraphiteContext->checkAsyncWorkCompletion();
|
|
#else
|
|
SkDEBUGFAIL("No valid context");
|
|
#endif
|
|
}
|
|
end = std::chrono::steady_clock::now();
|
|
}
|
|
if (!fIsFinished) {
|
|
SkDebugf("WARNING: Wait failed for flush sync. Timings might not be accurate.\n");
|
|
}
|
|
}
|
|
|
|
} //namespace sk_gpu_test
|