2021-09-29 18:29:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Google LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "tools/graphite/GraphiteTestContext.h"
|
|
|
|
|
2022-03-28 19:27:44 +00:00
|
|
|
#include "experimental/graphite/include/Context.h"
|
|
|
|
#include "experimental/graphite/include/GraphiteTypes.h"
|
|
|
|
#include "experimental/graphite/include/Recording.h"
|
|
|
|
#include "src/core/SkTraceEvent.h"
|
|
|
|
#include "tools/gpu/FlushFinishTracker.h"
|
|
|
|
|
2021-10-11 15:28:21 +00:00
|
|
|
namespace skiatest::graphite {
|
2021-09-29 18:29:32 +00:00
|
|
|
|
|
|
|
GraphiteTestContext::GraphiteTestContext() {}
|
|
|
|
|
|
|
|
GraphiteTestContext::~GraphiteTestContext() {}
|
|
|
|
|
2022-04-07 20:08:04 +00:00
|
|
|
void GraphiteTestContext::submitRecordingAndWaitOnSync(skgpu::graphite::Context* context,
|
|
|
|
skgpu::graphite::Recording* recording) {
|
2022-03-28 19:27:44 +00:00
|
|
|
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
|
|
|
SkASSERT(context);
|
|
|
|
SkASSERT(recording);
|
|
|
|
|
|
|
|
if (fFinishTrackers[fCurrentFlushIdx]) {
|
|
|
|
fFinishTrackers[fCurrentFlushIdx]->waitTillFinished();
|
|
|
|
}
|
|
|
|
|
|
|
|
fFinishTrackers[fCurrentFlushIdx].reset(new sk_gpu_test::FlushFinishTracker(context));
|
|
|
|
|
|
|
|
// We add an additional ref to the current flush tracker here. This ref is owned by the finish
|
|
|
|
// callback on the flush call. The finish callback will unref the tracker when called.
|
|
|
|
fFinishTrackers[fCurrentFlushIdx]->ref();
|
|
|
|
|
2022-04-07 20:08:04 +00:00
|
|
|
skgpu::graphite::InsertRecordingInfo info;
|
2022-03-28 19:27:44 +00:00
|
|
|
info.fRecording = recording;
|
|
|
|
info.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get();
|
2022-03-30 20:55:09 +00:00
|
|
|
info.fFinishedProc = sk_gpu_test::FlushFinishTracker::FlushFinishedResult;
|
2022-03-28 19:27:44 +00:00
|
|
|
context->insertRecording(info);
|
|
|
|
|
2022-04-07 20:08:04 +00:00
|
|
|
context->submit(skgpu::graphite::SyncToCpu::kNo);
|
2022-03-28 19:27:44 +00:00
|
|
|
|
|
|
|
fCurrentFlushIdx = (fCurrentFlushIdx + 1) % SK_ARRAY_COUNT(fFinishTrackers);
|
|
|
|
}
|
|
|
|
|
2021-10-11 15:28:21 +00:00
|
|
|
} // namespace skiatest::graphite
|