turn back on gpu tests

NOTREECHECKS=true

BUG=skia:3255

Review URL: https://codereview.chromium.org/817573004
This commit is contained in:
mtklein 2015-01-15 12:46:02 -08:00 committed by Commit bot
parent ca8e350a8d
commit 82d2843cc5
6 changed files with 54 additions and 42 deletions

View File

@ -23,6 +23,7 @@ DEFINE_bool(nameByHash, false,
DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
DEFINE_string(matrix, "1 0 0 0 1 0 0 0 1",
"Matrix to apply when using 'matrix' in config.");
DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?");
__SK_FORCE_IMAGE_DECODER_LINKING;
using namespace DM;
@ -138,20 +139,21 @@ static bool gpu_supported() {
static Sink* create_sink(const char* tag) {
#define SINK(t, sink, ...) if (0 == strcmp(t, tag)) { return new sink(__VA_ARGS__); }
if (gpu_supported()) {
typedef GrContextFactory Gr;
const GrGLStandard api = get_gpu_api();
SINK("gpunull", GPUSink, GrContextFactory::kNull_GLContextType, api, 0, false);
SINK("gpudebug", GPUSink, GrContextFactory::kDebug_GLContextType, api, 0, false);
SINK("gpu", GPUSink, GrContextFactory::kNative_GLContextType, api, 0, false);
SINK("gpudft", GPUSink, GrContextFactory::kNative_GLContextType, api, 0, true);
SINK("msaa4", GPUSink, GrContextFactory::kNative_GLContextType, api, 4, false);
SINK("msaa16", GPUSink, GrContextFactory::kNative_GLContextType, api, 16, false);
SINK("nvprmsaa4", GPUSink, GrContextFactory::kNVPR_GLContextType, api, 4, false);
SINK("nvprmsaa16", GPUSink, GrContextFactory::kNVPR_GLContextType, api, 16, false);
SINK("gpunull", GPUSink, Gr::kNull_GLContextType, api, 0, false, FLAGS_gpu_threading);
SINK("gpudebug", GPUSink, Gr::kDebug_GLContextType, api, 0, false, FLAGS_gpu_threading);
SINK("gpu", GPUSink, Gr::kNative_GLContextType, api, 0, false, FLAGS_gpu_threading);
SINK("gpudft", GPUSink, Gr::kNative_GLContextType, api, 0, true, FLAGS_gpu_threading);
SINK("msaa4", GPUSink, Gr::kNative_GLContextType, api, 4, false, FLAGS_gpu_threading);
SINK("msaa16", GPUSink, Gr::kNative_GLContextType, api, 16, false, FLAGS_gpu_threading);
SINK("nvprmsaa4", GPUSink, Gr::kNVPR_GLContextType, api, 4, false, FLAGS_gpu_threading);
SINK("nvprmsaa16", GPUSink, Gr::kNVPR_GLContextType, api, 16, false, FLAGS_gpu_threading);
#if SK_ANGLE
SINK("angle", GPUSink, GrContextFactory::kANGLE_GLContextType, api, 0, false);
SINK("angle", GPUSink, Gr::kANGLE_GLContextType, api, 0, false, FLAGS_gpu_threading);
#endif
#if SK_MESA
SINK("mesa", GPUSink, GrContextFactory::kMESA_GLContextType, api, 0, false);
SINK("mesa", GPUSink, Gr::kMESA_GLContextType, api, 0, false, FLAGS_gpu_threading);
#endif
}
@ -345,7 +347,7 @@ static struct : public skiatest::Reporter {
bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; }
} gTestReporter;
static SkTArray<SkAutoTDelete<skiatest::Test>, kMemcpyOK> gTests;
static SkTArray<SkAutoTDelete<skiatest::Test>, kMemcpyOK> gCPUTests, gGPUTests;
static void gather_tests() {
if (!FLAGS_tests) {
@ -356,14 +358,13 @@ static void gather_tests() {
if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) {
continue;
}
if (test->isGPUTest() /*&& !gpu_supported()*/) { // TEMPORARILY DISABLED
continue;
}
if (!test->isGPUTest() && !FLAGS_cpu) {
continue;
}
test->setReporter(&gTestReporter);
gTests.push_back().reset(test.detach());
if (test->isGPUTest() && gpu_supported()) {
gGPUTests.push_back().reset(test.detach());
} else if (!test->isGPUTest() && FLAGS_cpu) {
gCPUTests.push_back().reset(test.detach());
}
}
}
@ -372,8 +373,7 @@ static void run_test(SkAutoTDelete<skiatest::Test>* t) {
timer.start();
skiatest::Test* test = t->get();
if (!FLAGS_dryRun) {
GrContextFactory grFactory;
test->setGrContextFactory(&grFactory);
test->setGrContextFactory(GetThreadLocalGrContextFactory());
test->run();
if (!test->passed()) {
fail(SkStringPrintf("test %s failed", test->getName()));
@ -395,13 +395,13 @@ int dm_main() {
gather_sinks();
gather_tests();
gPending = gSrcs.count() * gSinks.count() + gTests.count();
gPending = gSrcs.count() * gSinks.count() + gCPUTests.count() + gGPUTests.count();
SkDebugf("%d srcs * %d sinks + %d tests == %d tasks\n",
gSrcs.count(), gSinks.count(), gTests.count(), gPending);
gSrcs.count(), gSinks.count(), gCPUTests.count() + gGPUTests.count(), gPending);
// We try to exploit as much parallelism as is safe. Most Src/Sink pairs run on any thread,
// but Sinks that identify as part of a particular enclave run serially on a single thread.
// Tests run on any thread, with a separate GrContextFactory for each GPU test.
// CPU tests run on any thread. GPU tests depend on --gpu_threading.
SkTArray<Task> enclaves[kNumEnclaves];
for (int j = 0; j < gSinks.count(); j++) {
SkTArray<Task>& tasks = enclaves[gSinks[j]->enclave()];
@ -414,7 +414,14 @@ int dm_main() {
SkTaskGroup tg;
tg.batch( Task::Run, enclaves[0].begin(), enclaves[0].count());
tg.batch(run_enclave, enclaves+1, kNumEnclaves-1);
tg.batch( run_test, gTests.begin(), gTests.count());
tg.batch( run_test, gCPUTests.begin(), gCPUTests.count());
if (FLAGS_gpu_threading) {
tg.batch(run_test, gGPUTests.begin(), gGPUTests.count());
} else {
for (int i = 0; i < gGPUTests.count(); i++) {
run_test(&gGPUTests[i]);
}
}
tg.wait();
// At this point we're back in single-threaded land.

9
dm/DMGpuSupport.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "DMGpuSupport.h"
#include "SkTLS.h"
static void* create_gr_factory() { return new GrContextFactory; }
static void delete_gr_factory(void* p) { delete (GrContextFactory*)p; }
GrContextFactory* GetThreadLocalGrContextFactory() {
return (GrContextFactory*)SkTLS::Get(create_gr_factory, delete_gr_factory);
}

View File

@ -74,4 +74,6 @@ static inline SkSurface* NewGpuSurface(GrContextFactory*,
#endif//SK_SUPPORT_GPU
GrContextFactory* GetThreadLocalGrContextFactory();
#endif//DMGpuSupport_DEFINED

View File

@ -6,7 +6,6 @@
#include "SkOSFile.h"
#include "SkPictureRecorder.h"
#include "SkRandom.h"
#include "SkTLS.h"
namespace DM {
@ -153,30 +152,23 @@ Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
DEFINE_string(gpu_threading, "none",
"none: single thread,\n"
"tls: any thread, GrContextFactory in TLS (crashy),\n"
"stack: any thread, GrContextFactory on stack (less crashy, differently so)");
GPUSink::GPUSink(GrContextFactory::GLContextType ct, GrGLStandard api, int samples, bool dfText)
GPUSink::GPUSink(GrContextFactory::GLContextType ct,
GrGLStandard api,
int samples,
bool dfText,
bool threaded)
: fContextType(ct)
, fGpuAPI(api)
, fSampleCount(samples)
, fUseDFText(dfText) {}
, fUseDFText(dfText)
, fThreaded(threaded) {}
int GPUSink::enclave() const {
return FLAGS_gpu_threading.contains("none") ? kGPUSink_Enclave : kAnyThread_Enclave;
return fThreaded ? kAnyThread_Enclave : kGPUSink_Enclave;
}
static void* CreateGrFactory() { return new GrContextFactory; }
static void DeleteGrFactory(void* p) { delete (GrContextFactory*)p; }
Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const {
GrContextFactory local, *factory = &local;
if (!FLAGS_gpu_threading.contains("stack")) {
factory = (GrContextFactory*)SkTLS::Get(CreateGrFactory, DeleteGrFactory);
}
// Does abandoning / resetting contexts make any sense if we have stack-scoped factories?
GrContextFactory* factory = GetThreadLocalGrContextFactory();
if (FLAGS_abandonGpuContext) {
factory->abandonContexts();
}

View File

@ -90,7 +90,7 @@ private:
class GPUSink : public Sink {
public:
GPUSink(GrContextFactory::GLContextType, GrGLStandard, int samples, bool dfText);
GPUSink(GrContextFactory::GLContextType, GrGLStandard, int samples, bool dfText, bool threaded);
Error draw(const Src&, SkBitmap*, SkWStream*) const SK_OVERRIDE;
int enclave() const SK_OVERRIDE;
@ -100,6 +100,7 @@ private:
GrGLStandard fGpuAPI;
int fSampleCount;
bool fUseDFText;
bool fThreaded;
};
class PDFSink : public Sink {

View File

@ -30,6 +30,7 @@
],
'sources': [
'../dm/DM.cpp',
'../dm/DMGpuSupport.cpp',
'../dm/DMSrcSink.cpp',
'../dm/DMJsonWriter.cpp',
'../gm/gm.cpp',