Update additional tools to take a GrDirectContext
GM was updated in: https://skia-review.googlesource.com/c/skia/+/300172 (Make GM::onGpuSetup take a GrDirectContext) This CL updates: skpbench, nanobench, and some testing infrastructure. Only minor changes were made to the unit tests as they will be updated en masse in a follow up cl. Change-Id: Ieffc98865d4c9fc73e292d3c807ed4ae2081745a Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300220 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
eba2958922
commit
00f78de600
2
BUILD.gn
2
BUILD.gn
@ -1455,6 +1455,8 @@ if (skia_enable_tools) {
|
||||
sources = [
|
||||
"tools/gpu/BackendTextureImageFactory.cpp",
|
||||
"tools/gpu/BackendTextureImageFactory.h",
|
||||
"tools/gpu/FlushFinishTracker.cpp",
|
||||
"tools/gpu/FlushFinishTracker.h",
|
||||
"tools/gpu/GrContextFactory.cpp",
|
||||
"tools/gpu/GrTest.cpp",
|
||||
"tools/gpu/MemoryCache.cpp",
|
||||
|
@ -68,6 +68,7 @@ extern bool gSkVMJITViaDylib;
|
||||
|
||||
#endif
|
||||
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
@ -229,7 +230,7 @@ struct GPUTarget : public Target {
|
||||
}
|
||||
void endTiming() override {
|
||||
if (this->contextInfo.testContext()) {
|
||||
this->contextInfo.testContext()->flushAndWaitOnSync(contextInfo.grContext());
|
||||
this->contextInfo.testContext()->flushAndWaitOnSync(contextInfo.directContext());
|
||||
}
|
||||
}
|
||||
void fence() override { this->contextInfo.testContext()->finish(); }
|
||||
@ -267,7 +268,7 @@ struct GPUTarget : public Target {
|
||||
const GrGLubyte* version;
|
||||
if (this->contextInfo.backend() == GrBackendApi::kOpenGL) {
|
||||
const GrGLInterface* gl =
|
||||
static_cast<GrGLGpu*>(this->contextInfo.grContext()->priv().getGpu())
|
||||
static_cast<GrGLGpu*>(this->contextInfo.directContext()->priv().getGpu())
|
||||
->glInterface();
|
||||
GR_GL_CALL_RET(gl, version, GetString(GR_GL_VERSION));
|
||||
log.appendString("GL_VERSION", (const char*)(version));
|
||||
@ -285,9 +286,11 @@ struct GPUTarget : public Target {
|
||||
}
|
||||
|
||||
void dumpStats() override {
|
||||
this->contextInfo.grContext()->priv().printCacheStats();
|
||||
this->contextInfo.grContext()->priv().printGpuStats();
|
||||
this->contextInfo.grContext()->priv().printContextStats();
|
||||
auto context = this->contextInfo.directContext();
|
||||
|
||||
context->priv().printCacheStats();
|
||||
context->priv().printGpuStats();
|
||||
context->priv().printContextStats();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <utility>
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
auto context = ctxInfo.directContext();
|
||||
static const int kW = 10;
|
||||
static const int kH = 10;
|
||||
static const size_t kRowBytes = sizeof(uint32_t) * kW;
|
||||
|
@ -54,7 +54,7 @@ DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, options) {
|
||||
testFactory.abandonContexts();
|
||||
|
||||
// Test that creating a context in a share group with an abandoned context fails.
|
||||
ContextInfo info2 = testFactory.getSharedContextInfo(info1.grContext());
|
||||
ContextInfo info2 = testFactory.getSharedContextInfo(info1.directContext());
|
||||
REPORTER_ASSERT(reporter, !info2.grContext());
|
||||
info1.grContext()->unref();
|
||||
|
||||
@ -62,7 +62,7 @@ DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, options) {
|
||||
ContextInfo info3 = testFactory.getContextInfo(ctxType);
|
||||
|
||||
// Creating a context in a share group may fail, but should never crash.
|
||||
ContextInfo info4 = testFactory.getSharedContextInfo(info3.grContext());
|
||||
ContextInfo info4 = testFactory.getSharedContextInfo(info3.directContext());
|
||||
if (!info4.grContext()) {
|
||||
continue;
|
||||
}
|
||||
@ -70,7 +70,7 @@ DEF_GPUTEST(GrContextFactory_sharedContexts, reporter, options) {
|
||||
REPORTER_ASSERT(reporter, info3.testContext() != info4.testContext());
|
||||
|
||||
// Passing a different index should create a new (unique) context.
|
||||
ContextInfo info5 = testFactory.getSharedContextInfo(info3.grContext(), 1);
|
||||
ContextInfo info5 = testFactory.getSharedContextInfo(info3.directContext(), 1);
|
||||
REPORTER_ASSERT(reporter, info5.grContext());
|
||||
REPORTER_ASSERT(reporter, info5.testContext());
|
||||
REPORTER_ASSERT(reporter, info5.grContext() != info4.grContext());
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
using sk_gpu_test::GrContextFactory;
|
||||
|
||||
void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColorType ct,
|
||||
void basic_texture_test(skiatest::Reporter* reporter, GrDirectContext* context, SkColorType ct,
|
||||
GrRenderable renderable) {
|
||||
const int kWidth = 16;
|
||||
const int kHeight = 16;
|
||||
@ -92,11 +92,13 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColo
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrUploadPixelsTests, reporter, ctxInfo) {
|
||||
auto direct = ctxInfo.directContext();
|
||||
|
||||
// RGBA
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_SkColorType, GrRenderable::kNo);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_SkColorType, GrRenderable::kYes);
|
||||
basic_texture_test(reporter, direct, kRGBA_8888_SkColorType, GrRenderable::kNo);
|
||||
basic_texture_test(reporter, direct, kRGBA_8888_SkColorType, GrRenderable::kYes);
|
||||
|
||||
// BGRA
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_SkColorType, GrRenderable::kNo);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_SkColorType, GrRenderable::kYes);
|
||||
basic_texture_test(reporter, direct, kBGRA_8888_SkColorType, GrRenderable::kNo);
|
||||
basic_texture_test(reporter, direct, kBGRA_8888_SkColorType, GrRenderable::kYes);
|
||||
}
|
||||
|
@ -860,7 +860,7 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
|
||||
GrContextFactory testFactory(options);
|
||||
GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
|
||||
ContextInfo ctxInfo = testFactory.getContextInfo(ctxType);
|
||||
GrContext* ctx = ctxInfo.grContext();
|
||||
auto ctx = ctxInfo.directContext();
|
||||
if (!ctx) {
|
||||
continue;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ static void check_565(skiatest::Reporter* reporter,
|
||||
}
|
||||
}
|
||||
|
||||
static void run_test(skiatest::Reporter* reporter, GrContext* context, int arraySize,
|
||||
static void run_test(skiatest::Reporter* reporter, GrDirectContext* context, int arraySize,
|
||||
SkColorType colorType) {
|
||||
SkTDArray<uint16_t> controlPixelData;
|
||||
// We will read back into an 8888 buffer since 565/4444 read backs aren't supported
|
||||
@ -147,12 +147,12 @@ static const int CONTROL_ARRAY_SIZE = DEV_W * DEV_H;
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RGBA4444TextureTest, reporter, ctxInfo) {
|
||||
if (ctxInfo.grContext()->colorTypeSupportedAsImage(kARGB_4444_SkColorType)) {
|
||||
run_test(reporter, ctxInfo.grContext(), CONTROL_ARRAY_SIZE, kARGB_4444_SkColorType);
|
||||
run_test(reporter, ctxInfo.directContext(), CONTROL_ARRAY_SIZE, kARGB_4444_SkColorType);
|
||||
}
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RGB565TextureTest, reporter, ctxInfo) {
|
||||
if (ctxInfo.grContext()->colorTypeSupportedAsImage(kRGB_565_SkColorType)) {
|
||||
run_test(reporter, ctxInfo.grContext(), CONTROL_ARRAY_SIZE, kRGB_565_SkColorType);
|
||||
run_test(reporter, ctxInfo.directContext(), CONTROL_ARRAY_SIZE, kRGB_565_SkColorType);
|
||||
}
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ static void test_readpixels_texture(skiatest::Reporter* reporter,
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
auto context = ctxInfo.directContext();
|
||||
SkBitmap bmp = make_src_bitmap();
|
||||
|
||||
// On the GPU we will also try reading back from a non-renderable texture.
|
||||
|
@ -48,7 +48,7 @@ static void validate_alpha_data(skiatest::Reporter* reporter, int w, int h, cons
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
auto context = ctxInfo.directContext();
|
||||
|
||||
unsigned char alphaData[X_SIZE * Y_SIZE];
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
|
||||
#include "include/gpu/GrContext.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRenderTargetContext.h"
|
||||
@ -87,7 +87,7 @@ static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectConte
|
||||
}
|
||||
|
||||
static void test_copy_to_surface(skiatest::Reporter* reporter,
|
||||
GrContext* context,
|
||||
GrDirectContext* context,
|
||||
GrSurfaceContext* dstContext,
|
||||
const char* testName) {
|
||||
|
||||
@ -116,7 +116,7 @@ static void test_copy_to_surface(skiatest::Reporter* reporter,
|
||||
|
||||
#ifdef SK_GL
|
||||
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
|
||||
GrContext* context = ctxInfo.grContext();
|
||||
auto context = ctxInfo.directContext();
|
||||
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
|
||||
static const int kWidth = 16;
|
||||
static const int kHeight = 16;
|
||||
|
@ -211,9 +211,9 @@ DEF_GPUTEST(SurfaceSemaphores, reporter, options) {
|
||||
reporter, SkString(sk_gpu_test::GrContextFactory::ContextTypeName(contextType)));
|
||||
if (ctxInfo.grContext()) {
|
||||
sk_gpu_test::ContextInfo child1 =
|
||||
factory.getSharedContextInfo(ctxInfo.grContext(), 0);
|
||||
factory.getSharedContextInfo(ctxInfo.directContext(), 0);
|
||||
sk_gpu_test::ContextInfo child2 =
|
||||
factory.getSharedContextInfo(ctxInfo.grContext(), 1);
|
||||
factory.getSharedContextInfo(ctxInfo.directContext(), 1);
|
||||
if (!child1.grContext() || !child2.grContext()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ DEF_GPUTEST(VkDrawableImportTest, reporter, options) {
|
||||
reporter, SkString(sk_gpu_test::GrContextFactory::ContextTypeName(contextType)));
|
||||
if (ctxInfo.grContext()) {
|
||||
sk_gpu_test::ContextInfo child =
|
||||
factory.getSharedContextInfo(ctxInfo.grContext(), 0);
|
||||
factory.getSharedContextInfo(ctxInfo.directContext(), 0);
|
||||
if (!child.grContext()) {
|
||||
continue;
|
||||
}
|
||||
|
30
tools/gpu/FlushFinishTracker.cpp
Normal file
30
tools/gpu/FlushFinishTracker.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
#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)) {
|
||||
fContext->checkAsyncWorkCompletion();
|
||||
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
|
@ -9,10 +9,8 @@
|
||||
#define FlushFinishTracker_DEFINED
|
||||
|
||||
#include "include/core/SkRefCnt.h"
|
||||
#include "include/gpu/GrContext.h"
|
||||
#include "src/core/SkTraceEvent.h"
|
||||
|
||||
#include <chrono>
|
||||
class GrDirectContext;
|
||||
|
||||
namespace sk_gpu_test {
|
||||
|
||||
@ -24,25 +22,14 @@ public:
|
||||
tracker->unref();
|
||||
}
|
||||
|
||||
FlushFinishTracker(GrContext* context) : fContext(context) {}
|
||||
FlushFinishTracker(GrDirectContext* context) : fContext(context) {}
|
||||
|
||||
void setFinished() { fIsFinished = true; }
|
||||
|
||||
void 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)) {
|
||||
fContext->checkAsyncWorkCompletion();
|
||||
end = std::chrono::steady_clock::now();
|
||||
}
|
||||
if (!fIsFinished) {
|
||||
SkDebugf("WARNING: Wait failed for flush sync. Timings might not be accurate.\n");
|
||||
}
|
||||
}
|
||||
void waitTillFinished();
|
||||
|
||||
private:
|
||||
GrContext* fContext;
|
||||
GrDirectContext* fContext;
|
||||
|
||||
// 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
|
||||
|
@ -6,6 +6,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "tools/gpu/GrContextFactory.h"
|
||||
#ifdef SK_GL
|
||||
@ -129,12 +130,13 @@ void GrContextFactory::releaseResourcesAndAbandonContexts() {
|
||||
}
|
||||
}
|
||||
|
||||
GrContext* GrContextFactory::get(ContextType type, ContextOverrides overrides) {
|
||||
return this->getContextInfo(type, overrides).grContext();
|
||||
GrDirectContext* GrContextFactory::get(ContextType type, ContextOverrides overrides) {
|
||||
return this->getContextInfo(type, overrides).directContext();
|
||||
}
|
||||
|
||||
ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOverrides overrides,
|
||||
GrContext* shareContext, uint32_t shareIndex) {
|
||||
GrDirectContext* shareContext,
|
||||
uint32_t shareIndex) {
|
||||
// (shareIndex != 0) -> (shareContext != nullptr)
|
||||
SkASSERT((shareIndex == 0) || (shareContext != nullptr));
|
||||
|
||||
@ -302,10 +304,14 @@ ContextInfo GrContextFactory::getContextInfoInternal(ContextType type, ContextOv
|
||||
if (ContextOverrides::kAvoidStencilBuffers & overrides) {
|
||||
grOptions.fAvoidStencilBuffers = true;
|
||||
}
|
||||
sk_sp<GrContext> grCtx;
|
||||
sk_sp<GrDirectContext> grCtx;
|
||||
{
|
||||
auto restore = testCtx->makeCurrentAndAutoRestore();
|
||||
grCtx = testCtx->makeGrContext(grOptions);
|
||||
// CONTEXT TODO: makeGrContext should return an sk_sp<GrDirectContext>
|
||||
auto tmp = testCtx->makeGrContext(grOptions);
|
||||
if (tmp) {
|
||||
grCtx = sk_ref_sp<GrDirectContext>(tmp->asDirectContext());
|
||||
}
|
||||
}
|
||||
if (!grCtx.get()) {
|
||||
return ContextInfo();
|
||||
@ -331,7 +337,8 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOverrides
|
||||
return this->getContextInfoInternal(type, overrides, nullptr, 0);
|
||||
}
|
||||
|
||||
ContextInfo GrContextFactory::getSharedContextInfo(GrContext* shareContext, uint32_t shareIndex) {
|
||||
ContextInfo GrContextFactory::getSharedContextInfo(GrDirectContext* shareContext,
|
||||
uint32_t shareIndex) {
|
||||
SkASSERT(shareContext);
|
||||
for (int i = 0; i < fContexts.count(); ++i) {
|
||||
if (!fContexts[i].fAbandoned && fContexts[i].fGrContext == shareContext) {
|
||||
|
@ -8,8 +8,8 @@
|
||||
#ifndef GrContextFactory_DEFINED
|
||||
#define GrContextFactory_DEFINED
|
||||
|
||||
#include "include/gpu/GrContext.h"
|
||||
#include "include/gpu/GrContextOptions.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
|
||||
#include "include/private/SkTArray.h"
|
||||
#include "tools/gpu/gl/GLTestContext.h"
|
||||
@ -135,17 +135,17 @@ public:
|
||||
* overrides. To get multiple contexts in a single share group, pass the same shareContext,
|
||||
* with different values for shareIndex.
|
||||
*/
|
||||
ContextInfo getSharedContextInfo(GrContext* shareContext, uint32_t shareIndex = 0);
|
||||
ContextInfo getSharedContextInfo(GrDirectContext* shareContext, uint32_t shareIndex = 0);
|
||||
|
||||
/**
|
||||
* Get a GrContext initialized with a type of GL context. It also makes the GL context current.
|
||||
*/
|
||||
GrContext* get(ContextType type, ContextOverrides overrides = ContextOverrides::kNone);
|
||||
GrDirectContext* get(ContextType type, ContextOverrides overrides = ContextOverrides::kNone);
|
||||
const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
|
||||
|
||||
private:
|
||||
ContextInfo getContextInfoInternal(ContextType type, ContextOverrides overrides,
|
||||
GrContext* shareContext, uint32_t shareIndex);
|
||||
GrDirectContext* shareContext, uint32_t shareIndex);
|
||||
|
||||
struct Context {
|
||||
ContextType fType;
|
||||
@ -153,8 +153,8 @@ private:
|
||||
GrContextOptions fOptions;
|
||||
GrBackendApi fBackend;
|
||||
TestContext* fTestContext;
|
||||
GrContext* fGrContext;
|
||||
GrContext* fShareContext;
|
||||
GrDirectContext* fGrContext;
|
||||
GrDirectContext* fShareContext;
|
||||
uint32_t fShareIndex;
|
||||
|
||||
bool fAbandoned;
|
||||
@ -173,10 +173,8 @@ public:
|
||||
GrBackendApi backend() const { return GrContextFactory::ContextTypeBackend(fType); }
|
||||
|
||||
// TODO: remove 'grContext' - replacing all instances w/ 'directContext'
|
||||
GrContext* grContext() const { return fGrContext; }
|
||||
GrDirectContext* directContext() const {
|
||||
return fGrContext ? fGrContext->asDirectContext() : nullptr;
|
||||
}
|
||||
GrContext* grContext() const { return fContext; }
|
||||
GrDirectContext* directContext() const { return fContext; }
|
||||
|
||||
TestContext* testContext() const { return fTestContext; }
|
||||
|
||||
@ -190,14 +188,16 @@ public:
|
||||
const GrContextOptions& options() const { return fOptions; }
|
||||
|
||||
private:
|
||||
ContextInfo(GrContextFactory::ContextType type, TestContext* testContext, GrContext* grContext,
|
||||
ContextInfo(GrContextFactory::ContextType type,
|
||||
TestContext* testContext,
|
||||
GrDirectContext* context,
|
||||
const GrContextOptions& options)
|
||||
: fType(type), fTestContext(testContext), fGrContext(grContext), fOptions(options) {}
|
||||
: fType(type), fTestContext(testContext), fContext(context), fOptions(options) {}
|
||||
|
||||
GrContextFactory::ContextType fType = GrContextFactory::kGL_ContextType;
|
||||
// Valid until the factory destroys it via abandonContexts() or destroyContexts().
|
||||
TestContext* fTestContext = nullptr;
|
||||
GrContext* fGrContext = nullptr;
|
||||
GrDirectContext* fContext = nullptr;
|
||||
GrContextOptions fOptions;
|
||||
|
||||
friend class GrContextFactory;
|
||||
|
@ -21,18 +21,13 @@
|
||||
|
||||
namespace sk_gpu_test {
|
||||
|
||||
sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context,
|
||||
sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrDirectContext* direct,
|
||||
GrRenderable renderable,
|
||||
GrSurfaceOrigin origin,
|
||||
const GrImageInfo& imageInfo,
|
||||
const void* data,
|
||||
size_t rowBytes) {
|
||||
if (context->abandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto direct = context->asDirectContext();
|
||||
if (!direct) {
|
||||
if (direct->abandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,13 @@
|
||||
#include "src/gpu/GrPipeline.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
|
||||
class GrDirectContext;
|
||||
class GrProgramInfo;
|
||||
|
||||
namespace sk_gpu_test {
|
||||
|
||||
/** Makes a texture proxy containing the passed in color data. */
|
||||
sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext*,
|
||||
sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrDirectContext*,
|
||||
GrRenderable,
|
||||
GrSurfaceOrigin,
|
||||
const GrImageInfo&,
|
||||
|
@ -8,9 +8,8 @@
|
||||
|
||||
#include "tools/gpu/TestContext.h"
|
||||
|
||||
#include "include/gpu/GrContext.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "src/core/SkTraceEvent.h"
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "tools/gpu/FlushFinishTracker.h"
|
||||
#include "tools/gpu/GpuTimer.h"
|
||||
|
||||
@ -35,7 +34,7 @@ SkScopeExit TestContext::makeCurrentAndAutoRestore() const {
|
||||
return asr;
|
||||
}
|
||||
|
||||
void TestContext::flushAndWaitOnSync(GrContext* context) {
|
||||
void TestContext::flushAndWaitOnSync(GrDirectContext* context) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
SkASSERT(context);
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "tools/gpu/FenceSync.h"
|
||||
|
||||
class GrContext;
|
||||
class GrDirectContext;
|
||||
struct GrContextOptions;
|
||||
|
||||
namespace sk_gpu_test {
|
||||
@ -70,7 +71,7 @@ public:
|
||||
* unfinished flushes active on the GPU at a time. If we have 2 outstanding flushes then we will
|
||||
* wait on the CPU until one has finished.
|
||||
*/
|
||||
void flushAndWaitOnSync(GrContext* context);
|
||||
void flushAndWaitOnSync(GrDirectContext* context);
|
||||
|
||||
/**
|
||||
* This notifies the context that we are deliberately testing abandoning
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "include/core/SkSurfaceProps.h"
|
||||
#include "include/effects/SkPerlinNoiseShader.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "src/core/SkOSFile.h"
|
||||
#include "src/core/SkTaskGroup.h"
|
||||
#include "src/gpu/GrCaps.h"
|
||||
@ -105,7 +106,7 @@ public:
|
||||
|
||||
void waitIfNeeded();
|
||||
|
||||
sk_gpu_test::FlushFinishTracker* newFlushTracker(GrContext* context);
|
||||
sk_gpu_test::FlushFinishTracker* newFlushTracker(GrDirectContext* context);
|
||||
|
||||
private:
|
||||
enum { kMaxFrameLag = 3 };
|
||||
@ -122,8 +123,8 @@ enum class ExitErr {
|
||||
kSoftware = 70
|
||||
};
|
||||
|
||||
static void flush_with_sync(GrContext*, GpuSync&);
|
||||
static void draw_skp_and_flush_with_sync(GrContext*, SkSurface*, const SkPicture*, GpuSync&);
|
||||
static void flush_with_sync(GrDirectContext*, GpuSync&);
|
||||
static void draw_skp_and_flush_with_sync(GrDirectContext*, SkSurface*, const SkPicture*, GpuSync&);
|
||||
static sk_sp<SkPicture> create_warmup_skp();
|
||||
static sk_sp<SkPicture> create_skp_from_svg(SkStream*, const char* filename);
|
||||
static bool mkdir_p(const SkString& name);
|
||||
@ -137,14 +138,16 @@ public:
|
||||
// Draw an SkPicture to the provided surface, flush the surface, and sync the GPU.
|
||||
// You may use the static draw_skp_and_flush_with_sync declared above.
|
||||
// returned int tells how many draw/flush/sync were done.
|
||||
virtual int drawAndFlushAndSync(GrContext*, SkSurface* surface, GpuSync& gpuSync) = 0;
|
||||
virtual int drawAndFlushAndSync(GrDirectContext*, SkSurface* surface, GpuSync& gpuSync) = 0;
|
||||
};
|
||||
|
||||
class StaticSkp : public SkpProducer {
|
||||
public:
|
||||
StaticSkp(sk_sp<SkPicture> skp) : fSkp(skp) {}
|
||||
|
||||
int drawAndFlushAndSync(GrContext* context, SkSurface* surface, GpuSync& gpuSync) override {
|
||||
int drawAndFlushAndSync(GrDirectContext* context,
|
||||
SkSurface* surface,
|
||||
GpuSync& gpuSync) override {
|
||||
draw_skp_and_flush_with_sync(context, surface, fSkp.get(), gpuSync);
|
||||
return 1;
|
||||
}
|
||||
@ -186,7 +189,9 @@ public:
|
||||
}
|
||||
|
||||
// Draw the whole animation once.
|
||||
int drawAndFlushAndSync(GrContext* context, SkSurface* surface, GpuSync& gpuSync) override {
|
||||
int drawAndFlushAndSync(GrDirectContext* context,
|
||||
SkSurface* surface,
|
||||
GpuSync& gpuSync) override {
|
||||
for (int i=0; i<this->count(); i++){
|
||||
draw_skp_and_flush_with_sync(context, surface, this->frame(i).get(), gpuSync);
|
||||
}
|
||||
@ -200,7 +205,7 @@ private:
|
||||
std::vector<SkDocumentPage> fFrames;
|
||||
};
|
||||
|
||||
static void ddl_sample(GrContext* context, DDLTileHelper* tiles, GpuSync& gpuSync,
|
||||
static void ddl_sample(GrDirectContext* context, DDLTileHelper* tiles, GpuSync& gpuSync,
|
||||
Sample* sample, SkTaskGroup* recordingTaskGroup, SkTaskGroup* gpuTaskGroup,
|
||||
std::chrono::high_resolution_clock::time_point* startStopTime) {
|
||||
using clock = std::chrono::high_resolution_clock;
|
||||
@ -241,7 +246,7 @@ static void ddl_sample(GrContext* context, DDLTileHelper* tiles, GpuSync& gpuSyn
|
||||
}
|
||||
}
|
||||
|
||||
static void run_ddl_benchmark(sk_gpu_test::TestContext* testContext, GrContext *context,
|
||||
static void run_ddl_benchmark(sk_gpu_test::TestContext* testContext, GrDirectContext *context,
|
||||
sk_sp<SkSurface> dstSurface, SkPicture* inputPicture,
|
||||
std::vector<Sample>* samples) {
|
||||
using clock = std::chrono::high_resolution_clock;
|
||||
@ -333,7 +338,7 @@ static void run_ddl_benchmark(sk_gpu_test::TestContext* testContext, GrContext *
|
||||
|
||||
}
|
||||
|
||||
static void run_benchmark(GrContext* context, SkSurface* surface, SkpProducer* skpp,
|
||||
static void run_benchmark(GrDirectContext* context, SkSurface* surface, SkpProducer* skpp,
|
||||
std::vector<Sample>* samples) {
|
||||
using clock = std::chrono::high_resolution_clock;
|
||||
const Sample::duration sampleDuration = std::chrono::milliseconds(FLAGS_sampleMs);
|
||||
@ -366,7 +371,7 @@ static void run_benchmark(GrContext* context, SkSurface* surface, SkpProducer* s
|
||||
context->submit(true);
|
||||
}
|
||||
|
||||
static void run_gpu_time_benchmark(sk_gpu_test::GpuTimer* gpuTimer, GrContext* context,
|
||||
static void run_gpu_time_benchmark(sk_gpu_test::GpuTimer* gpuTimer, GrDirectContext* context,
|
||||
SkSurface* surface, const SkPicture* skp,
|
||||
std::vector<Sample>* samples) {
|
||||
using sk_gpu_test::PlatformTimerQuery;
|
||||
@ -551,7 +556,7 @@ int main(int argc, char** argv) {
|
||||
sk_gpu_test::GrContextFactory factory(ctxOptions);
|
||||
sk_gpu_test::ContextInfo ctxInfo =
|
||||
factory.getContextInfo(config->getContextType(), config->getContextOverrides());
|
||||
GrContext* ctx = ctxInfo.grContext();
|
||||
GrDirectContext* ctx = ctxInfo.directContext();
|
||||
if (!ctx) {
|
||||
exitf(ExitErr::kUnavailable, "failed to create context for config %s",
|
||||
config->getTag().c_str());
|
||||
@ -643,7 +648,7 @@ int main(int argc, char** argv) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void flush_with_sync(GrContext* context, GpuSync& gpuSync) {
|
||||
static void flush_with_sync(GrDirectContext* context, GpuSync& gpuSync) {
|
||||
gpuSync.waitIfNeeded();
|
||||
|
||||
GrFlushInfo flushInfo;
|
||||
@ -654,7 +659,7 @@ static void flush_with_sync(GrContext* context, GpuSync& gpuSync) {
|
||||
context->submit();
|
||||
}
|
||||
|
||||
static void draw_skp_and_flush_with_sync(GrContext* context, SkSurface* surface,
|
||||
static void draw_skp_and_flush_with_sync(GrDirectContext* context, SkSurface* surface,
|
||||
const SkPicture* skp, GpuSync& gpuSync) {
|
||||
auto canvas = surface->getCanvas();
|
||||
canvas->drawPicture(skp);
|
||||
@ -741,7 +746,7 @@ void GpuSync::waitIfNeeded() {
|
||||
}
|
||||
}
|
||||
|
||||
sk_gpu_test::FlushFinishTracker* GpuSync::newFlushTracker(GrContext* context) {
|
||||
sk_gpu_test::FlushFinishTracker* GpuSync::newFlushTracker(GrDirectContext* context) {
|
||||
fFinishTrackers[fCurrentFlushIdx].reset(new sk_gpu_test::FlushFinishTracker(context));
|
||||
|
||||
sk_gpu_test::FlushFinishTracker* tracker = fFinishTrackers[fCurrentFlushIdx].get();
|
||||
|
Loading…
Reference in New Issue
Block a user