Correct adapter detection
don't break when first adapter is incompatible Related-To: NEO-3691 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
0e5ca243e2
commit
7828a8ee6a
|
@ -19,6 +19,7 @@ void WINAPI ULTGetSystemInfo(SYSTEM_INFO *pSystemInfo) {
|
|||
}
|
||||
|
||||
const char *UltDxCoreAdapter::description = "Intel";
|
||||
bool UltDXCoreAdapterList::firstInvalid = false;
|
||||
|
||||
extern uint32_t numRootDevicesToEnum = 1;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ static constexpr auto error = 1;
|
|||
class UltDxCoreAdapter : public IDXCoreAdapter {
|
||||
public:
|
||||
const static char *description;
|
||||
LUID luid = {0u, 0x1234u};
|
||||
bool STDMETHODCALLTYPE IsValid() override {
|
||||
return true;
|
||||
}
|
||||
|
@ -52,8 +53,8 @@ class UltDxCoreAdapter : public IDXCoreAdapter {
|
|||
memcpy_s(propertyData, bufferSize, description, requiredSize);
|
||||
break;
|
||||
case DXCoreAdapterProperty::InstanceLuid:
|
||||
reinterpret_cast<LUID *>(propertyData)->HighPart = 0x1234;
|
||||
reinterpret_cast<LUID *>(propertyData)->LowPart = 0;
|
||||
reinterpret_cast<LUID *>(propertyData)->HighPart = luid.HighPart;
|
||||
reinterpret_cast<LUID *>(propertyData)->LowPart = luid.LowPart;
|
||||
break;
|
||||
case DXCoreAdapterProperty::HardwareID: {
|
||||
DXCoreHardwareID ret = {};
|
||||
|
@ -137,8 +138,15 @@ class UltDxCoreAdapter : public IDXCoreAdapter {
|
|||
extern uint32_t numRootDevicesToEnum;
|
||||
class UltDXCoreAdapterList : public IDXCoreAdapterList {
|
||||
public:
|
||||
static bool firstInvalid;
|
||||
HRESULT STDMETHODCALLTYPE GetAdapter(uint32_t index, REFIID riid, _COM_Outptr_ void **ppvAdapter) override {
|
||||
*reinterpret_cast<UltDxCoreAdapter **>(ppvAdapter) = new UltDxCoreAdapter;
|
||||
auto adapter = new UltDxCoreAdapter;
|
||||
if (firstInvalid && 0 == index) {
|
||||
adapter->luid.HighPart = 0u;
|
||||
adapter->luid.LowPart = 0u;
|
||||
}
|
||||
|
||||
*reinterpret_cast<UltDxCoreAdapter **>(ppvAdapter) = adapter;
|
||||
return S_OK;
|
||||
}
|
||||
uint32_t STDMETHODCALLTYPE GetAdapterCount() override {
|
||||
|
|
|
@ -128,6 +128,15 @@ TEST(WddmDiscoverDevices, givenMultipleRootDevicesExposedWhenCreateMultipleRootD
|
|||
EXPECT_EQ(requestedNumRootDevices, hwDeviceIds.size());
|
||||
}
|
||||
|
||||
TEST(WddmDiscoverDevices, givenInvalidFirstAdapterWhenDiscoveringAdaptersThenReturnAllValidAdapters) {
|
||||
VariableBackup<uint32_t> backup{&numRootDevicesToEnum, 2u};
|
||||
VariableBackup<bool> backup2{&UltDXCoreAdapterList::firstInvalid, true};
|
||||
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
auto hwDeviceIds = OSInterface::discoverDevices(executionEnvironment);
|
||||
EXPECT_EQ(1u, hwDeviceIds.size());
|
||||
}
|
||||
|
||||
TEST(WddmDiscoverDevices, givenMultipleRootDevicesExposedWhenCreateMultipleRootDevicesFlagIsSetToGreaterValueThenDiscoverSpecifiedNumberOfDevices) {
|
||||
DebugManagerStateRestore restorer{};
|
||||
VariableBackup<uint32_t> backup{&numRootDevicesToEnum};
|
||||
|
|
|
@ -345,7 +345,7 @@ std::vector<std::unique_ptr<HwDeviceId>> Wddm::discoverDevices(ExecutionEnvironm
|
|||
hwDeviceIds.push_back(std::unique_ptr<HwDeviceId>(hwDeviceId.release()));
|
||||
}
|
||||
|
||||
if (hwDeviceIds.size() == numRootDevices) {
|
||||
if (!hwDeviceIds.empty() && hwDeviceIds.size() == numRootDevices) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue