Skip to content

Commit f1e8dde

Browse files
author
Ori Levari
authored
User/orilevari/winmlrunner dxcore latest (#256)
* retarget to latest dxcore api surface. modify code accordingly * Remove D3D12EnableExperimentalFeatures usage
1 parent 7cd642e commit f1e8dde

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

Tools/WinMLRunner/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Required command-Line arguments:
3535
-GPU : run model on default GPU
3636
-GPUHighPerformance : run model on GPU with highest performance
3737
-GPUMinPower : run model on GPU with the least power
38-
-GPUAdapterName <adapter name substring>: run model on GPU specified by its name. NOTE: Please only use this flag on DXCore supported machines.
38+
-GPUAdapterName <adapter name substring>: run model on GPU specified by its name. NOTE: Please only use this flag on DXCore supported machines. You will need to retarget the solution to at least windows insider build 18936
3939
-CreateDeviceOnClient : create the D3D device on the client and pass it to WinML to create session
4040
-CreateDeviceInWinML : create the device inside WinML
4141
-CPUBoundInput : bind the input to the CPU

Tools/WinMLRunner/src/Run.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ HRESULT CreateSession(LearningModelSession& session, IDirect3DDevice& winrtDevic
211211
com_ptr<IDXCoreAdapterList> spAdapterList;
212212
const GUID dxGUIDs[] = { DXCORE_ADAPTER_ATTRIBUTE_D3D12_CORE_COMPUTE };
213213

214-
THROW_IF_FAILED(spFactory->GetAdapterList(dxGUIDs, ARRAYSIZE(dxGUIDs), spAdapterList.put()));
214+
THROW_IF_FAILED(spFactory->CreateAdapterList(ARRAYSIZE(dxGUIDs), dxGUIDs, IID_PPV_ARGS(spAdapterList.put())));
215215

216216
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
217217
std::string adapterNameStr = converter.to_bytes(adapterName);
@@ -221,16 +221,16 @@ HRESULT CreateSession(LearningModelSession& session, IDirect3DDevice& winrtDevic
221221
printf("Printing available adapters..\n");
222222
for (UINT i = 0; i < spAdapterList->GetAdapterCount(); i++)
223223
{
224-
THROW_IF_FAILED(spAdapterList->GetItem(i, currAdapter.put()));
224+
THROW_IF_FAILED(spAdapterList->GetAdapter(i, currAdapter.put()));
225225

226226
// If the adapter is a software adapter then don't consider it for index selection
227227
bool isHardware;
228228
size_t driverDescriptionSize;
229229
THROW_IF_FAILED(
230-
currAdapter->QueryPropertySize(DXCoreProperty::DriverDescription, &driverDescriptionSize));
230+
currAdapter->GetPropertySize(DXCoreAdapterProperty::DriverDescription, &driverDescriptionSize));
231231
CHAR* driverDescription = new CHAR[driverDescriptionSize];
232-
THROW_IF_FAILED(currAdapter->QueryProperty(DXCoreProperty::IsHardware, sizeof(isHardware), &isHardware));
233-
THROW_IF_FAILED(currAdapter->QueryProperty(DXCoreProperty::DriverDescription, driverDescriptionSize,
232+
THROW_IF_FAILED(currAdapter->GetProperty(DXCoreAdapterProperty::IsHardware, &isHardware));
233+
THROW_IF_FAILED(currAdapter->GetProperty(DXCoreAdapterProperty::DriverDescription, driverDescriptionSize,
234234
driverDescription));
235235
if (isHardware)
236236
{
@@ -258,21 +258,21 @@ HRESULT CreateSession(LearningModelSession& session, IDirect3DDevice& winrtDevic
258258
adapterName);
259259
}
260260
size_t driverDescriptionSize;
261-
THROW_IF_FAILED(spAdapter->QueryPropertySize(DXCoreProperty::DriverDescription, &driverDescriptionSize));
261+
THROW_IF_FAILED(spAdapter->GetPropertySize(DXCoreAdapterProperty::DriverDescription, &driverDescriptionSize));
262262
CHAR* driverDescription = new CHAR[driverDescriptionSize];
263-
spAdapter->QueryProperty(DXCoreProperty::DriverDescription, driverDescriptionSize, driverDescription);
263+
spAdapter->GetProperty(DXCoreAdapterProperty::DriverDescription, driverDescriptionSize, driverDescription);
264264
printf("Using adapter : %s\n", driverDescription);
265265
free(driverDescription);
266266
IUnknown* pAdapter = spAdapter.get();
267267
com_ptr<IDXGIAdapter> spDxgiAdapter;
268268
D3D_FEATURE_LEVEL d3dFeatureLevel = D3D_FEATURE_LEVEL_1_0_CORE;
269269
D3D12_COMMAND_LIST_TYPE commandQueueType = D3D12_COMMAND_LIST_TYPE_COMPUTE;
270270

271-
// Check if adapter selected has DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRFX attribute selected. If so,
271+
// Check if adapter selected has DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS attribute selected. If so,
272272
// then GPU was selected that has D3D12 and D3D11 capabilities. It would be the most stable to
273273
// use DXGI to enumerate GPU and use D3D_FEATURE_LEVEL_11_0 so that image tensorization for
274274
// video frames would be able to happen on the GPU.
275-
if (spAdapter->IsDXAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRFX))
275+
if (spAdapter->IsAttributeSupported(DXCORE_ADAPTER_ATTRIBUTE_D3D12_GRAPHICS))
276276
{
277277
d3dFeatureLevel = D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_11_0;
278278
com_ptr<IDXGIFactory4> dxgiFactory4;
@@ -291,18 +291,12 @@ HRESULT CreateSession(LearningModelSession& session, IDirect3DDevice& winrtDevic
291291
// the selectedAdapter
292292
std::cout << "Using DXGI for adapter creation.." << std::endl;
293293
LUID adapterLuid;
294-
THROW_IF_FAILED(spAdapter->GetLUID(&adapterLuid));
294+
THROW_IF_FAILED(spAdapter->GetProperty(DXCoreAdapterProperty::InstanceLuid, &adapterLuid));
295295
THROW_IF_FAILED(dxgiFactory4->EnumAdapterByLuid(adapterLuid, __uuidof(IDXGIAdapter),
296296
spDxgiAdapter.put_void()));
297297
pAdapter = spDxgiAdapter.get();
298298
}
299299
}
300-
else
301-
{
302-
// Need to enable experimental features to create D3D12 Device with adapter that has compute only
303-
// capabilities.
304-
THROW_IF_FAILED(D3D12EnableExperimentalFeatures(1, &D3D12ComputeOnlyDevices, nullptr, 0));
305-
}
306300

307301
// create D3D12Device
308302
com_ptr<ID3D12Device> d3d12Device;

0 commit comments

Comments
 (0)