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>
54 lines
1.4 KiB
C++
54 lines
1.4 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.
|
|
*/
|
|
|
|
#ifndef FlushFinishTracker_DEFINED
|
|
#define FlushFinishTracker_DEFINED
|
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
class GrDirectContext;
|
|
|
|
#ifdef SK_GRAPHITE_ENABLED
|
|
namespace skgpu { class Context; }
|
|
#endif
|
|
|
|
namespace sk_gpu_test {
|
|
|
|
class FlushFinishTracker : public SkRefCnt {
|
|
public:
|
|
static void FlushFinished(void* finishedContext) {
|
|
auto tracker = static_cast<FlushFinishTracker*>(finishedContext);
|
|
tracker->setFinished();
|
|
tracker->unref();
|
|
}
|
|
|
|
FlushFinishTracker(GrDirectContext* context) : fContext(context) {}
|
|
#ifdef SK_GRAPHITE_ENABLED
|
|
FlushFinishTracker(skgpu::Context* context) : fGraphiteContext(context) {}
|
|
#endif
|
|
|
|
void setFinished() { fIsFinished = true; }
|
|
|
|
void waitTillFinished();
|
|
|
|
private:
|
|
GrDirectContext* fContext = nullptr;
|
|
#ifdef SK_GRAPHITE_ENABLED
|
|
skgpu::Context* fGraphiteContext = nullptr;
|
|
#endif
|
|
|
|
// Currently we don't have the this bool be atomic cause all current uses of this class happen
|
|
// on a single thread. In other words we call flush, checkAsyncWorkCompletion, and
|
|
// waitTillFinished all on the same thread. If we ever want to support the flushing and waiting
|
|
// to happen on different threads then we should make this atomic.
|
|
bool fIsFinished = false;
|
|
};
|
|
|
|
} //namespace sk_gpu_test
|
|
|
|
#endif
|