Convert ID2D1Device1 to ID3D11Device

155 views Asked by At

I want to implement NVIDIA Reflex to My Direct2D application. I have a ID2D11Device, but NvAPI_D3D_SetSleepMode requires Direct3DDevice.

I know that Direct2D is based on Direct3D. So, I think that I can acquire Direct3D Device from Direct2D Device. But, I can't find any solution.

How to get Direct3D device from Direct2D device? If I misunderstand conceptions, please let me make know a right concepts. Thanks.

1

There are 1 answers

0
Chuck Walbourn On BEST ANSWER

When you created the ID2D1Device, you had to start with a Direct3D device. Use that one.

// Obtain the underlying DXGI device of the Direct3D11.1 device.
    DX::ThrowIfFailed(
        m_d3dDevice.As(&dxgiDevice)
        );

    // Obtain the Direct2D device for 2-D rendering.
    DX::ThrowIfFailed(
        m_d2dFactory->CreateDevice(dxgiDevice.Get(), &m_d2dDevice)
        );

    // And get its corresponding device context object.
    DX::ThrowIfFailed(
        m_d2dDevice->CreateDeviceContext(
            D2D1_DEVICE_CONTEXT_OPTIONS_NONE,
            &m_d2dContext
            )
        );