Add support for Graphite unit tests that modify context options.
We now have a GraphiteContextOptionsProc which is functionally
equivalent to GaneshContextOptionsProc, but works with Graphite
unit tests. This will allow certain Graphite unit tests to
force options on. I will use this in a followup CL to force on
WGSL code generation in Dawn for the SkSL unit tests.
Change-Id: Ie20e23f04aad36da5d5582d9f13b2a3467eee447
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/745616
Commit-Queue: Brian Osman <[email protected]>
Auto-Submit: John Stiles <[email protected]>
Reviewed-by: Brian Osman <[email protected]>
diff --git a/dm/DM.cpp b/dm/DM.cpp
index e783bfc..b63cf82 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -1558,13 +1558,15 @@
done("unit", "test", "", test.fName);
}
-static void run_graphite_test(skiatest::Test test) {
+static void run_graphite_test(skiatest::Test test, skgpu::graphite::ContextOptions options) {
DMReporter reporter;
if (!FLAGS_dryRun && !should_skip("_", "tests", "_", test.fName)) {
AutoreleasePool pool;
+ test.modifyGraphiteContextOptions(&options);
+
skiatest::ReporterContext ctx(&reporter, SkString(test.fName));
start("unit", "test", "", test.fName);
- test.graphite(&reporter);
+ test.graphite(&reporter, options);
}
done("unit", "test", "", test.fName);
}
@@ -1610,6 +1612,9 @@
gVLog = stderr;
}
+ skgpu::graphite::ContextOptions graphiteCtxOptions;
+ // Currently no command line flags directly control the Graphite context options
+
GrContextOptions grCtxOptions;
CommonFlags::SetCtxOptions(&grCtxOptions);
@@ -1678,7 +1683,7 @@
// With the parallel work running, run serial tasks and tests here on main thread.
for (Task& task : serial) { Task::Run(task); }
for (skiatest::Test& test : *gGaneshTests) { run_ganesh_test(test, grCtxOptions); }
- for (skiatest::Test& test : *gGraphiteTests) { run_graphite_test(test); }
+ for (skiatest::Test& test : *gGraphiteTests) { run_graphite_test(test, graphiteCtxOptions); }
// Wait for any remaining parallel work to complete (including any spun off of serial tasks).
parallel.wait();
diff --git a/dm/DMGpuTestProcs.cpp b/dm/DMGpuTestProcs.cpp
index bf4805b..359d9a8 100644
--- a/dm/DMGpuTestProcs.cpp
+++ b/dm/DMGpuTestProcs.cpp
@@ -92,11 +92,13 @@
namespace graphite {
-void RunWithGraphiteTestContexts(GraphiteTestFn* test, GrContextTypeFilterFn* filter,
- Reporter* reporter) {
- ContextFactory factory;
+void RunWithGraphiteTestContexts(GraphiteTestFn* test,
+ GrContextTypeFilterFn* filter,
+ Reporter* reporter,
+ const skgpu::graphite::ContextOptions& ctxOptions) {
+ ContextFactory factory(ctxOptions);
for (int typeInt = 0; typeInt < GrContextFactory::kContextTypeCnt; ++typeInt) {
- GrContextFactory::ContextType contextType = (GrContextFactory::ContextType) typeInt;
+ GrContextFactory::ContextType contextType = (GrContextFactory::ContextType)typeInt;
if (filter && !(*filter)(contextType)) {
continue;
}