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:
parent
70c8c10571
commit
e79b06100f
|
@ -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();
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}});
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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>();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
class MultisampledRenderingTest : public DawnTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
DawnTest::SetUp();
|
||||
void TestSetUp() override {
|
||||
DawnTest::TestSetUp();
|
||||
|
||||
InitTexturesForTest();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue