Diligent Engine API Reference
GraphicsEngineD3D11

Implementation of Diligent Engine API using Direct3D11

Initialization

The following code snippet shows how to initialize diligent engine in D3D11 mode.

#include "RenderDeviceFactoryD3D11.h"
using namespace Diligent;
// ...
EngineD3D11Attribs DeviceAttribs;
DeviceAttribs.DebugFlags =
// Get pointer to the function that returns the factory
#ifdef ENGINE_DLL
GetEngineFactoryD3D11Type GetEngineFactoryD3D11 = nullptr;
// Load the dll and import GetEngineFactoryD3D11() function
LoadGraphicsEngineD3D11(GetEngineFactoryD3D11);
#endif
auto *pFactoryD3D11 = GetEngineFactoryD3D11();
pFactoryD3D11->CreateDeviceAndContextsD3D11( DeviceAttribs, &pRenderDevice, &pImmediateContext, 0 );
pFactoryD3D11->CreateSwapChainD3D11( pRenderDevice, pImmediateContext, SwapChainDesc, hWnd, &pSwapChain );

Alternatively, the engine can be initialized by attaching to existing D3D11 device and immediate context (see below).

Interoperability with Direct3D11

Diligent Engine exposes methods to access internal D3D11 objects, is able to create diligent engine buffers and textures from existing Direct3D11 buffers and textures, and can be initialized by attaching to existing D3D11 device and immediate context.

Accessing Native D3D11 objects

Below are some of the methods that provide access to internal D3D11 objects:

Function Description
ID3D11Buffer *IBufferD3D11::GetD3D11Buffer() returns a pointer to the ID3D11Buffer interface of the internal Direct3D11 buffer object
ID3D11Resource* ITextureD3D11::GetD3D11Texture() returns a pointer to the ID3D11Resource interface of the internal Direct3D11 texture object
ID3D11View* IBufferViewD3D11()::GetD3D11View() returns a pointer to the ID3D11View interface of the internal d3d11 object representing the buffer view
ID3D11View* ITextureViewD3D11::GetD3D11View() returns a pointer to the ID3D11View interface of the internal d3d11 object representing the texture view
ID3D11Device* IRenderDeviceD3D11::GetD3D11Device() returns a pointer to the native D3D11 device object
ID3D11DeviceContext* IDeviceContextD3D11::GetD3D11DeviceContext() returns a pointer to the native ID3D11DeviceContext object

Creating Diligent Engine Objects from D3D11 Resources

Initializing the Engine by Attaching to Existing D3D11 Device and Immediate Context

The code snippet below shows how diligent engine can be attached to D3D11 device returned by Unity

IUnityGraphicsD3D11* d3d = interfaces->Get<IUnityGraphicsD3D11>();
ID3D11Device* d3d11NativeDevice = d3d->GetDevice();
CComPtr<ID3D11DeviceContext> d3d11ImmediateContext;
d3d11NativeDevice->GetImmediateContext(&d3d11ImmediateContext);
auto *pFactoryD3d11 = GetEngineFactoryD3D11();
EngineD3D11Attribs Attribs;
pFactoryD3d11->AttachToD3D11Device(d3d11NativeDevice, d3d11ImmediateContext, Attribs, &m_Device, &m_Context, 0);

For more information about interoperability with D3D11, please visit Diligent Engine web site

References

Diligent Engine on the Web

Interoperability with Direct3D11

Architecture of D3D11-based implementation

Release Notes

2.1

New features

API Changes

Bug fixes

2.0

Reworked the API to follow D3D12 style

1.0

Initial release

Copyright 2015-2018 Egor Yusov

diligentgraphics.com