Coming to DirectX 12: D3D9On12 and D3D11On12 Resource Interop APIs

Avatar

Randy

D3D is introducing D3D9on12 with resource interop APIs and adding similar resource interop APIs to D3D11on12.  With this new support, callers can now retrieve the underlying D3D12 resource from the D3D11 or D3D9 resource object even when the resource was created with D3D11 or D3D9 API.   The new D3D9On12 API can be found in the insider SDK in D3D9on12.h.  These features are available in Windows Insider builds now and do not require new drivers to work.

You can explicitly create D3D9 with D3D9On12 using new overrides:

D3D9 begins by creating an active display adapter enumerator.  These new entry points allow you to override each adapter to use D3D9On12 or not by setting Enable9On12 to TRUE and a D3D12 device with an adapter LUID that matches the adapter you want to provide.  Optionally use an entry with a nullptr D3D12 device to match any active display adapter and have D3D9On12 create the D3D12 device.

Call QueryInterface on the D3D9 device for IDirect3DDevice9On12 to find out if the device is running on 9On12.  QueryInterface will fail with E_NOINTERFACE when not running on D3D9On12.

From this interface, you can retrieve the underlying D3D12 device:

IDirect3DDevice9On12 also has resource interop APIs to access the underlying D3D12 resource.  Begin by calling UnwrapUnderlyingResource to retrieve the D3D12 resource pointer.  UnwrapUnderlyingResource also takes an ID3D12Queue instance as an input parameter.  Any pending work accessing the resource causes fence waits to be scheduled on this queue.  Callers can then queue further work on this queue, including a signal on a caller owned fence.

Once D3D12 work has been scheduled, call ReturnUnderlyingResource.   ReturnUnderlyingResource API takes a list of ID3D12Fence instances and a parallel list of signal values.  This must include any pending work against the resource submitted by the caller.  The translation layer defers the waits for these resources until work is scheduled against the resource.

Be aware that unwrapping a resource checks out the resource from the translation layer.  No translation layer usage through either the D3D9 API may be scheduled while the resource is checked out.

Similar support is also added to D3D11On12 with the ID3D11On12Device2.

The main difference is that UnwrapUnderlyingResource does not flush and may schedule GPU work.  You should flush after calling this method if the you externally wait for completion.

This support is available now in the latest preview OS.  For further information, the spec is also available here.

Avatar
Randy Tidd

Follow Randy   

0 comments

    Leave a comment