Adapter AdapterEnumeration::ExtractAdapterDetails()

in library/src/AdapterEnumeration.cpp [128:174]


Adapter AdapterEnumeration::ExtractAdapterDetails(const com_ptr<IDXCoreAdapter>& adapter) const
{
	Adapter details;
	DeviceDiscoveryError error;
	
	// Extract the adapter LUID and convert it to an int64_t
	LUID instanceLuid;
	error = CheckHresult(adapter->GetProperty(DXCoreAdapterProperty::InstanceLuid, &instanceLuid));
	if (error) {
		throw error.Wrap(L"IDXCoreAdapter::GetProperty() failed for property InstanceLuid");
	}
	details.InstanceLuid = Int64FromLuid(instanceLuid);
	
	// Extract the PnP hardware ID information
	error = CheckHresult(adapter->GetProperty(DXCoreAdapterProperty::HardwareID, &details.HardwareID));
	if (error) {
		throw error.Wrap(L"IDXCoreAdapter::GetProperty() failed for property HardwareID");
	}
	
	// Extract the boolean specifying whether the adapter is a hardware device
	error = CheckHresult(adapter->GetProperty(DXCoreAdapterProperty::IsHardware, &details.IsHardware));
	if (error) {
		throw error.Wrap(L"IDXCoreAdapter::GetProperty() failed for property IsHardware");
	}
	
	// Extract the boolean specifying whether the adapter is an integrated GPU
	error = CheckHresult(adapter->GetProperty(DXCoreAdapterProperty::IsIntegrated, &details.IsIntegrated));
	if (error) {
		throw error.Wrap(L"IDXCoreAdapter::GetProperty() failed for property IsIntegrated");
	}
	
	// Extract the boolean specifying whether the adapter is detachable
	error = CheckHresult(adapter->GetProperty(DXCoreAdapterProperty::IsDetachable, &details.IsDetachable));
	if (error) {
		throw error.Wrap(L"IDXCoreAdapter::GetProperty() failed for property IsDetachable");
	}
	
	// Determine whether the adapter supports display
	details.SupportsDisplay =
		adapter->IsAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS) ||
		adapter->IsAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS);
	
	// Determine whether the adapter supports compute
	details.SupportsCompute = adapter->IsAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS);
	
	return details;
}