Skip tests if no adapter is available

Bug: dawn:208
Change-Id: I076fd497101dd017e8d83ae034edb7b1fa1f8581
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11941
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng 2019-10-09 16:23:22 +00:00 committed by Commit Bot service account
parent 70c8c10571
commit e79b06100f
29 changed files with 92 additions and 85 deletions

View File

@ -164,20 +164,8 @@ void DawnTestEnvironment::SetUp() {
mInstance->EnableBackendValidation(mEnableBackendValidation);
mInstance->EnableBeginCaptureOnStartup(mBeginCaptureOnStartup);
static constexpr dawn_native::BackendType kWindowlessBackends[] = {
dawn_native::BackendType::D3D12,
dawn_native::BackendType::Metal,
dawn_native::BackendType::Vulkan,
};
for (dawn_native::BackendType backend : kWindowlessBackends) {
if (detail::IsBackendAvailable(backend)) {
mInstance.get()->DiscoverDefaultAdapters();
}
}
if (detail::IsBackendAvailable(dawn_native::BackendType::OpenGL)) {
DiscoverOpenGLAdapter();
}
mInstance.get()->DiscoverDefaultAdapters();
DiscoverOpenGLAdapter();
std::cout << "Testing configuration\n"
"---------------------\n"
@ -238,7 +226,9 @@ uint32_t DawnTestEnvironment::GetVendorIdFilter() const {
void DawnTestEnvironment::DiscoverOpenGLAdapter() {
#ifdef DAWN_ENABLE_BACKEND_OPENGL
ASSERT_TRUE(glfwInit());
if (!glfwInit()) {
return;
}
glfwDefaultWindowHints();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
@ -407,7 +397,9 @@ void DawnTestBase::SetUp() {
}
}
ASSERT(mBackendAdapter);
if (!mBackendAdapter) {
return;
}
}
mPCIInfo = mBackendAdapter.GetPCIInfo();
@ -478,6 +470,10 @@ void DawnTestBase::TearDown() {
}
}
bool DawnTestBase::HasAdapter() const {
return !!mBackendAdapter;
}
void DawnTestBase::StartExpectDeviceError() {
mExpectError = true;
mError = false;

View File

@ -200,6 +200,7 @@ class DawnTestBase {
uint32_t pixelSize,
detail::Expectation* expectation);
bool HasAdapter() const;
void WaitABit();
void FlushWire();
@ -272,14 +273,31 @@ class DawnTestBase {
dawn_native::Adapter mBackendAdapter;
};
// Skip a test when the given condition is satisfied.
#define DAWN_SKIP_TEST_IF(condition) \
if (condition) { \
std::cout << "Test skipped: " #condition "." << std::endl; \
GTEST_SKIP(); \
return; \
}
template <typename Params = DawnTestParam>
class DawnTestWithParams : public DawnTestBase, public ::testing::TestWithParam<Params> {
private:
void SetUp() override final {
// DawnTestBase::SetUp() gets the adapter, and creates the device and wire.
// It's separate from TestSetUp() so we can skip tests completely if no adapter
// is available.
DawnTestBase::SetUp();
DAWN_SKIP_TEST_IF(!HasAdapter());
TestSetUp();
}
protected:
DawnTestWithParams();
~DawnTestWithParams() override = default;
void SetUp() override {
DawnTestBase::SetUp();
virtual void TestSetUp() {
}
void TearDown() override {
@ -303,12 +321,6 @@ using DawnTest = DawnTestWithParams<>;
testName##params, sizeof(testName##params) / sizeof(firstParam))), \
testing::PrintToStringParamName())
// Skip a test when the given condition is satisfied.
#define DAWN_SKIP_TEST_IF(condition) \
if (condition) { \
std::cout << "Test skipped: " #condition "." << std::endl; \
return; \
}
namespace detail {
// Helper functions used for DAWN_INSTANTIATE_TEST

View File

@ -26,8 +26,8 @@ constexpr static unsigned int kRTSize = 64;
class ColorStateTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
vsModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450

View File

@ -34,8 +34,8 @@ struct CopyConfig {
class CompressedTextureBCFormatTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
mBindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler},
{1, dawn::ShaderStage::Fragment, dawn::BindingType::SampledTexture}});

View File

@ -29,8 +29,8 @@ namespace {
class D3D12ResourceTestBase : public DawnTest {
public:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
if (UsesWire()) {
return;
}
@ -101,8 +101,8 @@ namespace {
// These tests are skipped if the harness is using the wire.
class D3D12SharedHandleValidation : public D3D12ResourceTestBase {
public:
void SetUp() override {
D3D12ResourceTestBase::SetUp();
void TestSetUp() override {
D3D12ResourceTestBase::TestSetUp();
dawnDescriptor.dimension = dawn::TextureDimension::e2D;
dawnDescriptor.format = dawn::TextureFormat::BGRA8Unorm;

View File

@ -22,8 +22,8 @@ constexpr static unsigned int kRTSize = 64;
class DepthStencilStateTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
dawn::TextureDescriptor renderTargetDescriptor;
renderTargetDescriptor.dimension = dawn::TextureDimension::e2D;

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DestroyTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DrawIndexedIndirectTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DrawIndexedTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DrawIndirectTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -21,8 +21,8 @@ constexpr uint32_t kRTSize = 4;
class DrawTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -24,8 +24,8 @@ constexpr uint32_t kBindingSize = 8;
class DynamicBufferOffsetTests : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
// Mix up dynamic and non dynamic resources in one bind group and using not continuous
// binding number to cover more cases.

View File

@ -60,8 +60,8 @@ class FenceTests : public DawnTest {
FenceTests() : mCallIndex(0) {
}
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
mockFenceOnCompletionCallback = std::make_unique<MockFenceOnCompletionCallback>();
mockPopErrorScopeCallback = std::make_unique<MockPopErrorScopeCallback>();
}

View File

@ -22,8 +22,8 @@ constexpr uint32_t kRTSize = 400;
class IndexFormatTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
}

View File

@ -20,8 +20,8 @@
class MultisampledRenderingTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
InitTexturesForTest();
}

View File

@ -19,8 +19,8 @@
class NonzeroTextureCreationTests : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
}
constexpr static uint32_t kSize = 128;

View File

@ -20,8 +20,8 @@
class OpArrayLengthTest : public DawnTest {
protected:
void SetUp() {
DawnTest::SetUp();
void TestSetUp() {
DawnTest::TestSetUp();
// Create buffers of various size to check the length() implementation
dawn::BufferDescriptor bufferDesc;

View File

@ -145,8 +145,8 @@ constexpr static float kVertices[] = {
class PrimitiveTopologyTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -26,8 +26,8 @@ constexpr RGBA8 kColors[2] = {RGBA8(0, 255, 0, 255), RGBA8(0, 0, 255, 255)};
// tested in all other rendering tests.
class RenderBundleTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -56,8 +56,8 @@ class DrawQuad {
class RenderPassLoadOpTests : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
dawn::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D;

View File

@ -22,8 +22,8 @@ constexpr dawn::TextureFormat kFormat = dawn::TextureFormat::RGBA8Unorm;
class RenderPassTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
// Shaders to draw a bottom-left triangle in blue.
mVSModule = utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(

View File

@ -38,8 +38,8 @@ namespace {
class SamplerTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
mBindGroupLayout = utils::MakeBindGroupLayout(

View File

@ -111,8 +111,8 @@ class ExpectFloat16 : public detail::Expectation {
class TextureFormatTest : public DawnTest {
protected:
void SetUp() {
DawnTest::SetUp();
void TestSetUp() {
DawnTest::TestSetUp();
}
// Structure containing all the information that tests need to know about the format.

View File

@ -78,8 +78,8 @@ protected:
return static_cast<int>(level * 10) + static_cast<int>(layer + 1);
}
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -20,8 +20,8 @@
class TextureZeroInitTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
}
dawn::TextureDescriptor CreateTextureDescriptor(uint32_t mipLevelCount,
uint32_t arrayLayerCount,

View File

@ -46,8 +46,8 @@ std::vector<destType> BitCast(std::vector<srcType> data) {
class VertexFormatTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
}

View File

@ -35,8 +35,8 @@ constexpr static unsigned int kRTCellSize = 100;
class VertexInputTest : public DawnTest {
protected:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
DawnTest::TestSetUp();
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
}

View File

@ -58,7 +58,7 @@ class BufferUploadPerf : public DawnPerfTestWithParams<BufferUploadParams> {
}
~BufferUploadPerf() override = default;
void SetUp() override;
void TestSetUp() override;
private:
void Step() override;
@ -67,8 +67,8 @@ class BufferUploadPerf : public DawnPerfTestWithParams<BufferUploadParams> {
std::vector<uint8_t> data;
};
void BufferUploadPerf::SetUp() {
DawnPerfTestWithParams<BufferUploadParams>::SetUp();
void BufferUploadPerf::TestSetUp() {
DawnPerfTestWithParams<BufferUploadParams>::TestSetUp();
dawn::BufferDescriptor desc = {};
desc.size = kBufferSize;

View File

@ -31,8 +31,7 @@ namespace {
class VulkanImageWrappingTestBase : public DawnTest {
public:
void SetUp() override {
DawnTest::SetUp();
void TestSetUp() override {
if (UsesWire() || IsIntel()) {
return;
}
@ -198,8 +197,8 @@ namespace {
class VulkanImageWrappingValidationTests : public VulkanImageWrappingTestBase {
public:
void SetUp() override {
VulkanImageWrappingTestBase::SetUp();
void TestSetUp() override {
VulkanImageWrappingTestBase::TestSetUp();
if (UsesWire() || IsIntel()) {
return;
}
@ -349,8 +348,8 @@ TEST_P(VulkanImageWrappingValidationTests, DestroyedTextureSignalSemaphoreExport
// These tests are skipped if the harness is using the wire.
class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
public:
void SetUp() override {
VulkanImageWrappingTestBase::SetUp();
void TestSetUp() override {
VulkanImageWrappingTestBase::TestSetUp();
if (UsesWire() || IsIntel()) {
return;
}