From 078ef764a46b0bfc5a1a7ba678e353db4e67961c Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 26 Feb 2020 11:36:16 +0100 Subject: [PATCH] Windows: discover all devices Related-To: NEO-4208 Change-Id: I9d577ce3acc7545f7c424afcbd9869f50db200e6 Signed-off-by: Mateusz Jablonski --- .../os_interface/windows/ult_dxgi_factory.cpp | 2 ++ .../unit_test/os_interface/windows/ult_dxgi_factory.h | 10 +++++++++- .../unit_test/os_interface/windows/wddm20_tests.cpp | 8 ++++++++ shared/source/os_interface/windows/wddm/wddm.cpp | 1 - 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.cpp b/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.cpp index befc394634..622c90884d 100644 --- a/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.cpp +++ b/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.cpp @@ -24,4 +24,6 @@ void WINAPI ULTGetSystemInfo(SYSTEM_INFO *pSystemInfo) { const wchar_t *UltIDXGIAdapter1::description = L"Intel"; +extern uint32_t numRootDevicesToEnum = 0; + } // namespace NEO diff --git a/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.h b/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.h index a5b31c9c27..1a8a76fd86 100644 --- a/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.h +++ b/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.h @@ -7,6 +7,7 @@ #pragma once +#include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/memory_manager/memory_constants.h" #include @@ -93,12 +94,19 @@ class UltIDXGIAdapter1 : public IDXGIAdapter1 { } }; +extern uint32_t numRootDevicesToEnum; class UltIDXGIFactory1 : public IDXGIFactory1 { public: HRESULT STDMETHODCALLTYPE EnumAdapters1( UINT Adapter, IDXGIAdapter1 **ppAdapter) { - if (Adapter > 2) { + UINT numRootDevices = 1u; + if (numRootDevicesToEnum > 0u) { + numRootDevices = numRootDevicesToEnum; + } else if (DebugManager.flags.CreateMultipleRootDevices.get()) { + numRootDevices = static_cast(DebugManager.flags.CreateMultipleRootDevices.get()); + } + if (Adapter >= numRootDevices) { *(IDXGIAdapter1 **)ppAdapter = nullptr; return DXGI_ERROR_NOT_FOUND; } diff --git a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp index 1b2c2dbde7..445e572b13 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp @@ -39,6 +39,7 @@ namespace NEO { namespace SysCalls { extern const wchar_t *igdrclFilePath; } +extern uint32_t numRootDevicesToEnum; } // namespace NEO using namespace NEO; @@ -120,6 +121,13 @@ TEST(WddmDiscoverDevices, WhenAdapterDescriptionContainsDCHIAndgdrclPathDoesntCo EXPECT_TRUE(hwDeviceIds.empty()); } +TEST(WddmDiscoverDevices, WhenMultipleRootDevicesAreAvailableThenAllAreDiscovered) { + VariableBackup backup{&numRootDevicesToEnum}; + numRootDevicesToEnum = 3u; + auto hwDeviceIds = OSInterface::discoverDevices(); + EXPECT_EQ(numRootDevicesToEnum, hwDeviceIds.size()); +} + TEST(WddmDiscoverDevices, WhenAdapterDescriptionContainsDCHDAndgdrclPathContainsDchDThenAdapterIsDiscovered) { VariableBackup descriptionBackup(&UltIDXGIAdapter1::description); descriptionBackup = L"Intel DCH-D"; diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 6da63257cb..f241723aa5 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -287,7 +287,6 @@ std::vector> OSInterface::discoverDevices() { auto hwDeviceId = createHwDeviceIdFromAdapterLuid(*gdi, OpenAdapterDesc.AdapterLuid); if (hwDeviceId) { hwDeviceIds.push_back(std::move(hwDeviceId)); - break; } } }