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:
parent
8076b2ad73
commit
5c2f1678be
|
@ -121,6 +121,7 @@ option_if_not_defined(DAWN_ENABLE_TSAN "Enable thread sanitizer" OFF)
|
|||
option_if_not_defined(DAWN_ENABLE_MSAN "Enable memory sanitizer" OFF)
|
||||
option_if_not_defined(DAWN_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF)
|
||||
|
||||
option_if_not_defined(DAWN_ENABLE_D3D11 "Enable compilation of the D3D11 backend" ${ENABLE_D3D11})
|
||||
option_if_not_defined(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12})
|
||||
option_if_not_defined(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL})
|
||||
option_if_not_defined(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON)
|
||||
|
@ -267,6 +268,7 @@ if (${TINT_BUILD_REGEX_FUZZER})
|
|||
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
||||
endif()
|
||||
|
||||
message(STATUS "Dawn build D3D11 backend: ${DAWN_ENABLE_D3D11}")
|
||||
message(STATUS "Dawn build D3D12 backend: ${DAWN_ENABLE_D3D12}")
|
||||
message(STATUS "Dawn build Metal backend: ${DAWN_ENABLE_METAL}")
|
||||
message(STATUS "Dawn build Vulkan backend: ${DAWN_ENABLE_VULKAN}")
|
||||
|
@ -401,6 +403,9 @@ target_link_libraries(dawn_internal_config INTERFACE dawn_public_config)
|
|||
if (DAWN_ALWAYS_ASSERT OR IS_DEBUG_BUILD)
|
||||
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_ASSERTS")
|
||||
endif()
|
||||
if (DAWN_ENABLE_D3D11)
|
||||
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D11")
|
||||
endif()
|
||||
if (DAWN_ENABLE_D3D12)
|
||||
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D12")
|
||||
endif()
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue