DMLCreateDevice1 function (directml.h)

Creates a DirectML device for a given Direct3D 12 device.

Syntax

HRESULT DMLCreateDevice1(
  ID3D12Device            *d3d12Device,
  DML_CREATE_DEVICE_FLAGS flags,
  DML_FEATURE_LEVEL       minimumFeatureLevel,
  REFIID                  riid,
  void                    **ppv
);

Parameters

d3d12Device

Type: ID3D12Device*

A pointer to an ID3D12Device representing the Direct3D 12 device to create the DirectML device over. DirectML supports any D3D feature level, and Direct3D 12 devices created on any adapter, including WARP. However, not all features in DirectML may be available depending on the capabilities of the Direct3D 12 device. See IDMLDevice::CheckFeatureSupport for more info.

If the call to DMLCreateDevice1 is successful, then the DirectML device maintains a strong reference to the supplied Direct3D 12 device.

flags

Type: DML_CREATE_DEVICE_FLAGS

A DML_CREATE_DEVICE_FLAGS value specifying additional device creation options.

minimumFeatureLevel

Type: DML_FEATURE_LEVEL

A DML_FEATURE_LEVEL value specifying the minimum feature level support required.

This parameter can be useful for callers that require a specific version of DirectML, but who may find themselves calling into an older version of DirectML. This can happen, for example, when the user runs your application on an older version of Windows 10.

Applications that explicitly depend on functionality introduced in a particular feature level can specify it as a minimumFeatureLevel. This will guarantee that DMLCreateDevice1 won't succeed unless the underlying implementation is at least as capable as this requested minimum feature level.

Note that as this parameter specifies a minimum feature level, the underlying DirectML device may in fact support a higher feature level than the requested minimum. Once device creation succeeds, you can query all of the feature levels supported by this device using IDMLDevice::CheckFeatureSupport.

riid

Type: REFIID

A reference to the globally unique identifier (GUID) of the interface that you wish to be returned in device. This is expected to be the GUID of IDMLDevice.

ppv

Type: _COM_Outptr_opt_ void**

A pointer to a memory block that receives a pointer to the device. This is the address of a pointer to an IDMLDevice, representing the DirectML device created.

Return value

Type: HRESULT

If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

If this version of DirectML doesn't support the minimumFeatureLevel requested, then this function will return DXGI_ERROR_UNSUPPORTED.

Remarks

A newer version of this function, DMLCreateDevice1, was introduced in DirectML version 1.1.0. DMLCreateDevice1 is equivalent to calling DMLCreateDevice1 and supplying a minimumFeatureLevel of DML_FEATURE_LEVEL_1_0.

Availability

This API was introduced in DirectML version 1.1.0.

Requirements

Requirement Value
Minimum supported client Windows 10 Build 20348
Minimum supported server Windows 10 Build 20348
Target Platform Windows
Header directml.h
Library DirectML.lib
DLL DirectML.dll

See also