From 227568451b442ae16873ec23cd4b86cf28d00b2a Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 25 Feb 2020 22:05:39 +0000 Subject: [PATCH] Add in --no-use flags for spvc features BUG=dawn:344 Change-Id: Ifa9e1e3167ecfe7d38c16f393cec0443ea1589f2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16164 Reviewed-by: Austin Eng Commit-Queue: Ryan Harrison --- src/tests/DawnTest.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++ src/tests/DawnTest.h | 2 ++ 2 files changed, 61 insertions(+) diff --git a/src/tests/DawnTest.cpp b/src/tests/DawnTest.cpp index dcedccbcf5..47bcfb908f 100644 --- a/src/tests/DawnTest.cpp +++ b/src/tests/DawnTest.cpp @@ -163,14 +163,68 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) { } if (strcmp("--use-spvc", argv[i]) == 0) { + if (mSpvcFlagSeen) { + dawn::WarningLog() << "Multiple flags passed in that force whether or not to use " + "the spvc. This may lead to unexpected behaviour."; + } + ASSERT(!mSpvcFlagSeen); + mUseSpvc = true; + mSpvcFlagSeen = true; + continue; + } + + if (strcmp("--no-use-spvc", argv[i]) == 0) { + if (mSpvcFlagSeen) { + dawn::WarningLog() << "Multiple flags passed in that force whether or not to use " + "the spvc. This may lead to unexpected behaviour."; + } + ASSERT(!mSpvcFlagSeen); + + mUseSpvc = false; + mSpvcFlagSeen = true; continue; } if (strcmp("--use-spvc-parser", argv[i]) == 0) { + if (mSpvcParserFlagSeen) { + dawn::WarningLog() << "Multiple flags passed in that force whether or not to use " + "the spvc parser. This may cause unexpected behaviour."; + } + ASSERT(!mSpvcParserFlagSeen); + + if (!mUseSpvc) { + if (mSpvcFlagSeen) { + dawn::ErrorLog() + << "Overriding force disabling of spvc since it is required for using the " + "spvc parser. This indicates a likely misconfiguration."; + } else { + dawn::InfoLog() + << "Enabling spvc since it is required for using the spvc parser."; + } + ASSERT(!mSpvcFlagSeen); + } + mUseSpvc = true; // It's impossible to use the spvc parser without using spvc, so // turning on mUseSpvc implicitly. mUseSpvcParser = true; + mSpvcParserFlagSeen = true; + continue; + } + + if (strcmp("--no-use-spvc-parser", argv[i]) == 0) { + if (mSpvcParserFlagSeen) { + dawn::WarningLog() << "Multiple flags passed in that force whether or not to use " + "the spvc parser. This may cause unexpected behaviour."; + } + ASSERT(!mSpvcParserFlagSeen); + + // Intentionally not changing mUseSpvc, since the dependency is one-way. This will + // not correctly handle the case where spvc is off by default, then there is a spvc + // parser on flag followed by a off flag, but that is already being indicated as a + // misuse. + mUseSpvcParser = false; + mSpvcParserFlagSeen = true; continue; } @@ -209,6 +263,11 @@ DawnTestEnvironment::DawnTestEnvironment(int argc, char** argv) { "(defaults to no capture)\n" " --skip-validation: Skip Dawn validation\n" " --use-spvc: Use spvc for accessing spirv-cross\n" + " --no-use-spvc: Do not use spvc for accessing spirv-cross\n" + " --use-spvc-parser: Use spvc's spir-v parsing insteads of spirv-cross's, " + "implies --use-spvc\n" + " --no-use-spvc-parser: Do no use spvc's spir-v parsing insteads of " + "spirv-cross's\n" " --adapter-vendor-id: Select adapter by vendor id to run end2end tests" "on multi-GPU systems \n"; continue; diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h index a4dee9c3ff..4211d86e8e 100644 --- a/src/tests/DawnTest.h +++ b/src/tests/DawnTest.h @@ -156,7 +156,9 @@ class DawnTestEnvironment : public testing::Environment { bool mEnableBackendValidation = false; bool mSkipDawnValidation = false; bool mUseSpvc = false; + bool mSpvcFlagSeen = false; bool mUseSpvcParser = false; + bool mSpvcParserFlagSeen = false; bool mBeginCaptureOnStartup = false; bool mHasVendorIdFilter = false; uint32_t mVendorIdFilter = 0;