d3d11: add tests in AdapterDiscoveryTests test suit for d3d11

Bug: dawn:1705
Change-Id: I0841e00b9595651882c7b1c5ae21f00d0201c5a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130680
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Peng Huang
2023-05-01 23:05:42 +00:00
committed by Dawn LUCI CQ
parent 8076b2ad73
commit 5c2f1678be
3 changed files with 65 additions and 5 deletions

View File

@@ -573,16 +573,19 @@ source_set("end2end_tests_sources") {
libs = []
if (dawn_enable_d3d11 || dawn_enable_d3d12) {
libs += [
"d3d11.lib",
"dxgi.lib",
]
}
if (dawn_enable_d3d12) {
sources += [
"end2end/D3D12CachingTests.cpp",
"end2end/D3D12ResourceWrappingTests.cpp",
"end2end/VideoViewsTests_win.cpp",
]
libs += [
"d3d11.lib",
"dxgi.lib",
]
}
if (dawn_enable_metal) {

View File

@@ -28,6 +28,10 @@
#include "dawn/native/VulkanBackend.h"
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
#if defined(DAWN_ENABLE_BACKEND_D3D11)
#include "dawn/native/D3D11Backend.h"
#endif // defined(DAWN_ENABLE_BACKEND_D3D11)
#if defined(DAWN_ENABLE_BACKEND_D3D12)
#include "dawn/native/D3D12Backend.h"
#endif // defined(DAWN_ENABLE_BACKEND_D3D12)
@@ -89,6 +93,54 @@ TEST(AdapterDiscoveryTests, OnlyVulkan) {
}
#endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
#if defined(DAWN_ENABLE_BACKEND_D3D11)
// Test discovering only D3D11 adapters
TEST(AdapterDiscoveryTests, OnlyD3D11) {
dawn::native::Instance instance;
dawn::native::d3d11::AdapterDiscoveryOptions options;
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D11);
}
}
// Test discovering a D3D11 adapter from a prexisting DXGI adapter
TEST(AdapterDiscoveryTests, MatchingDXGIAdapterD3D11) {
using Microsoft::WRL::ComPtr;
ComPtr<IDXGIFactory4> dxgiFactory;
HRESULT hr = ::CreateDXGIFactory2(0, IID_PPV_ARGS(&dxgiFactory));
ASSERT_EQ(hr, S_OK);
for (uint32_t adapterIndex = 0;; ++adapterIndex) {
ComPtr<IDXGIAdapter1> dxgiAdapter = nullptr;
if (dxgiFactory->EnumAdapters1(adapterIndex, &dxgiAdapter) == DXGI_ERROR_NOT_FOUND) {
break; // No more adapters to enumerate.
}
dawn::native::Instance instance;
dawn::native::d3d11::AdapterDiscoveryOptions options;
options.dxgiAdapter = std::move(dxgiAdapter);
instance.DiscoverAdapters(&options);
const auto& adapters = instance.GetAdapters();
for (const auto& adapter : adapters) {
wgpu::AdapterProperties properties;
adapter.GetProperties(&properties);
EXPECT_EQ(properties.backendType, wgpu::BackendType::D3D11);
}
}
}
#endif // defined(DAWN_ENABLE_BACKEND_D3D11)
#if defined(DAWN_ENABLE_BACKEND_D3D12)
// Test discovering only D3D12 adapters
TEST(AdapterDiscoveryTests, OnlyD3D12) {
@@ -107,7 +159,7 @@ TEST(AdapterDiscoveryTests, OnlyD3D12) {
}
// Test discovering a D3D12 adapter from a prexisting DXGI adapter
TEST(AdapterDiscoveryTests, MatchingDXGIAdapter) {
TEST(AdapterDiscoveryTests, MatchingDXGIAdapterD3D12) {
using Microsoft::WRL::ComPtr;
ComPtr<IDXGIFactory4> dxgiFactory;