diff options
author | kkinnunen <kkinnunen@nvidia.com> | 2015-12-21 23:48:13 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-21 23:48:13 -0800 |
commit | 9ebc3f0ee6db215dde461dc4777d85988cf272dd (patch) | |
tree | 328e37f09fd0eecea68ff5b83f79fc309e3f70c4 /tests | |
parent | b39f39f5ccb39786e9325cdf08a5dc52ef78544c (diff) |
Add config options to run different GPU APIs to dm and nanobench
Add extended config specification form that can be used to run different
gpu backend with different APIs.
The configs can be specified with the form:
gpu(api=string,dit=bool,nvpr=bool,samples=int)
This replaces and removes the --gpuAPI flag.
All existing configs should still work.
Adds following documentation:
out/Debug/dm --help config
Flags:
--config: type: string default: 565 8888 gpu nonrendering
Options: 565 8888 debug gpu gpudebug gpudft gpunull msaa16 msaa4
nonrendering null nullgpu nvprmsaa16 nvprmsaa4 pdf pdf_poppler skp svg
xps or use extended form 'backend(option=value,...)'.
Extended form: 'backend(option=value,...)'
Possible backends and options:
gpu(api=string,dit=bool,nvpr=bool,samples=int) GPU backend
api type: string default: native.
Select graphics API to use with gpu backend.
Options:
native Use platform default OpenGL or OpenGL ES backend.
gl Use OpenGL.
gles Use OpenGL ES.
debug Use debug OpenGL.
null Use null OpenGL.
dit type: bool default: false.
Use device independent text.
nvpr type: bool default: false.
Use NV_path_rendering OpenGL and OpenGL ES extension.
samples type: int default: 0.
Use multisampling with N samples.
Predefined configs:
gpu = gpu()
msaa4 = gpu(samples=4)
msaa16 = gpu(samples=16)
nvprmsaa4 = gpu(nvpr=true,samples=4)
nvprmsaa16 = gpu(nvpr=true,samples=16)
gpudft = gpu(dit=true)
gpudebug = gpu(api=debug)
gpunull = gpu(api=null)
debug = gpu(api=debug)
nullgpu = gpu(api=null)
BUG=skia:2992
Committed: https://skia.googlesource.com/skia/+/e13ca329fca4c28cf4e078561f591ab27b743d23
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1490113005
Committed: https://skia.googlesource.com/skia/+/c8b4336444e7b90382e04e33665fb3b8490b825b
Review URL: https://codereview.chromium.org/1490113005
Diffstat (limited to 'tests')
-rw-r--r-- | tests/GLProgramsTest.cpp | 4 | ||||
-rw-r--r-- | tests/GrContextFactoryTest.cpp | 12 | ||||
-rw-r--r-- | tests/StringTest.cpp | 55 | ||||
-rw-r--r-- | tests/TestConfigParsing.cpp | 314 |
4 files changed, 380 insertions, 5 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 9fa8dafda6..065abf662b 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -435,18 +435,22 @@ DEF_GPUTEST(GLPrograms, reporter, factory) { return; } #if SK_ANGLE +#ifdef SK_BUILD_FOR_WIN // Some long shaders run out of temporary registers in the D3D compiler on ANGLE. if (type == GrContextFactory::kANGLE_GLContextType) { maxStages = 2; } #endif +#endif #if SK_COMMAND_BUFFER +#ifdef SK_BUILD_FOR_WIN // Some long shaders run out of temporary registers in the D3D compiler on ANGLE. // TODO(hendrikw): This only needs to happen with the ANGLE comand buffer backend. if (type == GrContextFactory::kCommandBuffer_GLContextType) { maxStages = 2; } #endif +#endif REPORTER_ASSERT(reporter, GrDrawingManager::ProgramUnitTest(context, maxStages)); } } diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp index 50bdedff9e..1b19ac68e3 100644 --- a/tests/GrContextFactoryTest.cpp +++ b/tests/GrContextFactoryTest.cpp @@ -17,10 +17,14 @@ DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter, // Test that if NVPR is requested, the context always has path rendering // or the context creation fails. GrContextFactory testFactory; - GrContext* context = testFactory.get(GrContextFactory::kNative_GLContextType, - kNone_GrGLStandard, - GrContextFactory::kEnableNVPR_GLContextOptions); - if (context) { + // Test that if NVPR is possible, caps are in sync. + for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { + GrContextFactory::GLContextType glCtxType = static_cast<GrContextFactory::GLContextType>(i); + GrContext* context = testFactory.get(glCtxType, + GrContextFactory::kEnableNVPR_GLContextOptions); + if (!context) { + continue; + } REPORTER_ASSERT( reporter, context->caps()->shaderCaps()->pathRenderingSupport()); diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp index f621dc96af..9e41c48c84 100644 --- a/tests/StringTest.cpp +++ b/tests/StringTest.cpp @@ -201,9 +201,62 @@ DEF_TEST(String_SkStrSplit, r) { results.reset(); SkStrSplit("\n", "\n", &results); - REPORTER_ASSERT(r, results.count() == 1); + REPORTER_ASSERT(r, results.count() == 0); results.reset(); SkStrSplit("", "\n", &results); REPORTER_ASSERT(r, results.count() == 0); + + results.reset(); + SkStrSplit("a", "\n", &results); + REPORTER_ASSERT(r, results.count() == 1); + REPORTER_ASSERT(r, results[0].equals("a")); +} +DEF_TEST(String_SkStrSplit_All, r) { + SkTArray<SkString> results; + SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", kStrict_SkStrSplitMode, &results); + REPORTER_ASSERT(r, results.count() == 13); + REPORTER_ASSERT(r, results[0].equals("a")); + REPORTER_ASSERT(r, results[1].equals("")); + REPORTER_ASSERT(r, results[2].equals("b")); + REPORTER_ASSERT(r, results[3].equals("c")); + REPORTER_ASSERT(r, results[4].equals("dee")); + REPORTER_ASSERT(r, results[5].equals("")); + REPORTER_ASSERT(r, results[6].equals("f")); + REPORTER_ASSERT(r, results[7].equals("")); + REPORTER_ASSERT(r, results[8].equals("")); + REPORTER_ASSERT(r, results[9].equals("")); + REPORTER_ASSERT(r, results[10].equals("")); + REPORTER_ASSERT(r, results[11].equals("g")); + REPORTER_ASSERT(r, results[12].equals("")); + + results.reset(); + SkStrSplit("\n", "\n", kStrict_SkStrSplitMode, &results); + REPORTER_ASSERT(r, results.count() == 2); + REPORTER_ASSERT(r, results[0].equals("")); + REPORTER_ASSERT(r, results[1].equals("")); + + results.reset(); + SkStrSplit("", "\n", kStrict_SkStrSplitMode, &results); + REPORTER_ASSERT(r, results.count() == 0); + + results.reset(); + SkStrSplit("a", "\n", kStrict_SkStrSplitMode, &results); + REPORTER_ASSERT(r, results.count() == 1); + REPORTER_ASSERT(r, results[0].equals("a")); + + results.reset(); + SkStrSplit(",,", ",", kStrict_SkStrSplitMode, &results); + REPORTER_ASSERT(r, results.count() == 3); + REPORTER_ASSERT(r, results[0].equals("")); + REPORTER_ASSERT(r, results[1].equals("")); + REPORTER_ASSERT(r, results[2].equals("")); + + results.reset(); + SkStrSplit(",a,b,", ",", kStrict_SkStrSplitMode, &results); + REPORTER_ASSERT(r, results.count() == 4); + REPORTER_ASSERT(r, results[0].equals("")); + REPORTER_ASSERT(r, results[1].equals("a")); + REPORTER_ASSERT(r, results[2].equals("b")); + REPORTER_ASSERT(r, results[3].equals("")); } diff --git a/tests/TestConfigParsing.cpp b/tests/TestConfigParsing.cpp new file mode 100644 index 0000000000..67d4b22e95 --- /dev/null +++ b/tests/TestConfigParsing.cpp @@ -0,0 +1,314 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "SkCommonFlagsConfig.h" +#include "Test.h" +#include <initializer_list> + +namespace { +// The code +// SkCommandLineFlags::StringArray FLAGS_config1 = make_string_array({"a", "b"}) +// can be used to construct string array that one gets with command line flags. +// For example, the call above is equivalent of +// DEFINE_string(config1, "a b", ""); +// in cases where the default command line flag value ("a b") is used. +// make_string_array can be used to construct StringArray strings that have spaces in +// them. +SkCommandLineFlags::StringArray make_string_array(std::initializer_list<const char*> strings) { + SkTArray<SkString> array; + for (auto& s : strings) { + array.push_back(SkString(s)); + } + return SkCommandLineFlags::StringArray(array); +} +} +DEF_TEST(ParseConfigs_Gpu, reporter) { + // Parses a normal config and returns correct "tag". + // Gpu config defaults work. + SkCommandLineFlags::StringArray config1 = make_string_array({"gpu"}); + SkCommandLineConfigArray configs; + ParseConfigs(config1, &configs); + + REPORTER_ASSERT(reporter, configs.count() == 1); + REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu")); + REPORTER_ASSERT(reporter, configs[0]->getViaParts().count() == 0); +#if SK_SUPPORT_GPU + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() + == GrContextFactory::kNative_GLContextType); + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false); + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false); + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0); +#endif +} + +DEF_TEST(ParseConfigs_OutParam, reporter) { + // Clears the out parameter. + SkCommandLineFlags::StringArray config1 = make_string_array({"gpu"}); + SkCommandLineConfigArray configs; + ParseConfigs(config1, &configs); + REPORTER_ASSERT(reporter, configs.count() == 1); + REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu")); + SkCommandLineFlags::StringArray config2 = make_string_array({"8888"}); + ParseConfigs(config2, &configs); + REPORTER_ASSERT(reporter, configs.count() == 1); + REPORTER_ASSERT(reporter, configs[0]->getTag().equals("8888")); +} + +DEF_TEST(ParseConfigs_DefaultConfigs, reporter) { + // Parses all default configs and returns correct "tag". + + SkCommandLineFlags::StringArray config1 = make_string_array({ + "565", "8888", "debug", "gpu", "gpudebug", "gpudft", "gpunull", "msaa16", "msaa4", + "nonrendering", "null", "nullgpu", "nvprmsaa16", "nvprmsaa4", "pdf", "pdf_poppler", + "skp", "svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui" + }); + + SkCommandLineConfigArray configs; + ParseConfigs(config1, &configs); + + REPORTER_ASSERT(reporter, configs.count() == config1.count()); + for (int i = 0; i < config1.count(); ++i) { + REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); + REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == 0); + } +#if SK_SUPPORT_GPU + REPORTER_ASSERT(reporter, !configs[0]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[2]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[3]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[4]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getUseDIText()); + REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 16); + REPORTER_ASSERT(reporter, configs[8]->asConfigGpu()->getSamples() == 4); + REPORTER_ASSERT(reporter, !configs[9]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[10]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[11]->asConfigGpu()); + REPORTER_ASSERT(reporter, configs[12]->asConfigGpu()->getSamples() == 16); + REPORTER_ASSERT(reporter, configs[12]->asConfigGpu()->getUseNVPR()); + REPORTER_ASSERT(reporter, configs[13]->asConfigGpu()->getSamples() == 4); + REPORTER_ASSERT(reporter, configs[13]->asConfigGpu()->getUseNVPR()); + REPORTER_ASSERT(reporter, !configs[14]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[15]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[16]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[17]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[18]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[23]->asConfigGpu()); +#if SK_ANGLE +#ifdef SK_BUILD_FOR_WIN + REPORTER_ASSERT(reporter, configs[19]->asConfigGpu()); +#else + REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu()); +#endif + REPORTER_ASSERT(reporter, configs[20]->asConfigGpu()); +#else + REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[20]->asConfigGpu()); +#endif +#if SK_COMMAND_BUFFER + REPORTER_ASSERT(reporter, configs[21]->asConfigGpu()); +#else + REPORTER_ASSERT(reporter, !configs[21]->asConfigGpu()); +#endif +#if SK_MESA + REPORTER_ASSERT(reporter, configs[22]->asConfigGpu()); +#else + REPORTER_ASSERT(reporter, !configs[22]->asConfigGpu()); +#endif +#endif +} + +DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) { + SkCommandLineFlags::StringArray config1 = make_string_array({ + "gpu(nvpr=true,dit=true)", + "gpu(api=angle)", + "gpu(api=angle-gl)", + "gpu(api=mesa,samples=77)", + "gpu(dit=true,api=commandbuffer)", + "gpu()", + "gpu(api=gles)" + }); + + SkCommandLineConfigArray configs; + ParseConfigs(config1, &configs); + REPORTER_ASSERT(reporter, configs.count() == config1.count()); + for (int i = 0; i < config1.count(); ++i) { + REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); + } +#if SK_SUPPORT_GPU + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() == + GrContextFactory::kNative_GLContextType); + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR()); + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText()); + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0); +#if SK_ANGLE +#ifdef SK_BUILD_FOR_WIN + REPORTER_ASSERT(reporter, configs[1]->asConfigGpu()->getContextType() == + GrContextFactory::kANGLE_GLContextType); +#else + REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); +#endif + REPORTER_ASSERT(reporter, configs[2]->asConfigGpu()->getContextType() == + GrContextFactory::kANGLE_GL_GLContextType); +#else + REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); +#endif +#if SK_MESA + REPORTER_ASSERT(reporter, configs[3]->asConfigGpu()->getContextType() == + GrContextFactory::kMESA_GLContextType); +#else + REPORTER_ASSERT(reporter, !configs[3]->asConfigGpu()); +#endif +#if SK_COMMAND_BUFFER + REPORTER_ASSERT(reporter, configs[4]->asConfigGpu()->getContextType() == + GrContextFactory::kCommandBuffer_GLContextType); + +#else + REPORTER_ASSERT(reporter, !configs[4]->asConfigGpu()); +#endif + REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() == + GrContextFactory::kNative_GLContextType); + REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseNVPR()); + REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseDIText()); + REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getSamples() == 0); + REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getContextType() == + GrContextFactory::kGLES_GLContextType); + REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR()); + REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText()); + REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0); + +#endif +} + +DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) { + SkCommandLineFlags::StringArray config1 = make_string_array({ + "gpu(nvpr=1)", // Number as bool. + "gpu(api=gl,)", // Trailing in comma. + "gpu(api=angle-glu)", // Unknown api. + "gpu(api=,samples=0)", // Empty api. + "gpu(samples=true)", // Value true as a number. + "gpu(samples=0,samples=0)", // Duplicate option key. + "gpu(,samples=0)", // Leading comma. + "gpu(samples=54", // Missing closing parenthesis. + ",,", + "gpu(", // Missing parenthesis. + "samples=54" // No backend. + "gpu(nvpr=true )", // Space. + }); + + SkCommandLineConfigArray configs; + ParseConfigs(config1, &configs); + REPORTER_ASSERT(reporter, configs.count() == config1.count()); + for (int i = 0; i < config1.count(); ++i) { + REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); + REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(config1[i])); +#if SK_SUPPORT_GPU + REPORTER_ASSERT(reporter, !configs[i]->asConfigGpu()); +#endif + } +} + + +DEF_TEST(ParseConfigs_ExtendedGpuConfigsSurprises, reporter) { + // These just list explicitly some properties of the system. + SkCommandLineFlags::StringArray config1 = make_string_array({ + // Options are not canonized -> two same configs have a different tag. + "gpu(nvpr=true,dit=true)", "gpu(dit=true,nvpr=true)", + // API native is alias for gl or gles, but it's not canonized -> different tag. + "gpu(api=native)", "gpu(api=gl)", "gpu(api=gles)", "" + // Default values are not canonized -> different tag. + "gpu", "gpu()", "gpu(samples=0)", "gpu(api=native,samples=0)" + }); + SkCommandLineConfigArray configs; + ParseConfigs(config1, &configs); + REPORTER_ASSERT(reporter, configs.count() == config1.count()); + for (int i = 0; i < config1.count(); ++i) { + REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); +#if SK_SUPPORT_GPU + REPORTER_ASSERT(reporter, configs[i]->getBackend().equals("gpu")); + REPORTER_ASSERT(reporter, configs[i]->asConfigGpu()); +#else + REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(config1[i])); +#endif + } +} +DEF_TEST(ParseConfigs_ViaParsing, reporter) { + SkCommandLineFlags::StringArray config1 = make_string_array({ + "a-b-c-8888", + "zz-qq-gpu", + "a-angle-gl" + }); + + SkCommandLineConfigArray configs; + ParseConfigs(config1, &configs); + const struct { + const char* backend; + const char* vias[3]; + } expectedConfigs[] = { + {"8888", {"a", "b", "c"}}, + {"gpu", {"zz", "qq", nullptr}}, + {"angle-gl", {"a", nullptr, nullptr}} // The angle-gl tag is only tag that contains + // hyphen. + }; + for (int i = 0; i < config1.count(); ++i) { + REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); + REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(expectedConfigs[i].backend)); + for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs[i].vias)); ++j) { + if (!expectedConfigs[i].vias[j]) { + REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == j); + break; + } + REPORTER_ASSERT(reporter, + configs[i]->getViaParts()[j].equals(expectedConfigs[i].vias[j])); + } + } +} + +DEF_TEST(ParseConfigs_ViaParsingExtendedForm, reporter) { + SkCommandLineFlags::StringArray config1 = make_string_array({ + "zz-qq-gpu(api=gles)", + "a-gpu(samples=1", + "abc-def-angle-gl(samples=1)", + }); + + SkCommandLineConfigArray configs; + ParseConfigs(config1, &configs); + const struct { + const char* backend; + const char* vias[3]; + } expectedConfigs[] = { +#if SK_SUPPORT_GPU + {"gpu", {"zz", "qq", nullptr}}, +#else + {"gpu(api=gles)", {"zz", "qq", nullptr}}, +#endif + {"gpu(samples=1", {"a", nullptr, nullptr}}, // This is not extended form, but via still + // works as expected. + {"gl(samples=1)", {"abc", "def", "angle"}} // This is not extended form. Also + // angle-gl is not a "backend" in this case. + }; + for (int i = 0; i < config1.count(); ++i) { + REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); + REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(expectedConfigs[i].backend)); + for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs[i].vias)); ++j) { + if (!expectedConfigs[i].vias[j]) { + REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == + static_cast<int>(j)); + break; + } + REPORTER_ASSERT(reporter, + configs[i]->getViaParts()[j].equals(expectedConfigs[i].vias[j])); + } + } +#if SK_SUPPORT_GPU + REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); + REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); +#endif +} |