Tech Notes: Device Enumeration for PC

Matt ConteBlog Hero Image
Welcome to another installation of the Oculus tech note series. This week's note focuses on the PC graphics device enumeration procedure required for native code.
For Unity and Unreal titles, the PC graphics device enumeration procedure is handled within the integration. If you are using native code however, you will need to use the LUID filled in by the second parameter to ovr_Create() to compare against the DXGI adapter LUID during enumeration. (Note that this example is for DX11, but the process is similar for DX12.) This implementation will allow systems that have multiple GPUs (such as laptops with switching GPU graphics or desktops with SLI) to properly target the Rift HMD. Essentially if you don't do this, your title won't work for these systems.
We have provided snippets below as an example.:
// return true to retry later (e.g. after display lost)
static bool MainLoop(bool retryCreate)
{
    ...
    
    // During initialization 
    ovrSession session;
    ovrGraphicsLuid luid;
    ovrResult result = ovr_Create(&session, &luid);
    if (!OVR_SUCCESS(result))
        return retryCreate;

    ovrHmdDesc hmdDesc = ovr_GetHmdDesc(session);

    // Setup Device and Graphics
    IDXGIFactory4 * DXGIFactory = nullptr;
    HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(&DXGIFactory));
    VALIDATE((hr == ERROR_SUCCESS), "CreateDXGIFactory1 failed");

    IDXGIAdapter * Adapter = nullptr;
    for (UINT iAdapter = 0; DXGIFactory->EnumAdapters(iAdapter, &Adapter) != DXGI_ERROR_NOT_FOUND; ++iAdapter)
    {
        DXGI_ADAPTER_DESC adapterDesc;
        Adapter->GetDesc(&adapterDesc);
        if (memcmp(&adapterDesc.AdapterLuid, &luid, sizeof(LUID)) == 0)
            break;
        Release(Adapter);
    }

    ID3D11Device           * Device;
    ID3D11DeviceContext    * Context;
    auto DriverType = Adapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE;
    hr = D3D11CreateDevice(Adapter, DriverType, 0, 0, 0, 0, D3D11_SDK_VERSION, &Device, 0, &Context);
    Release(Adapter);
    VALIDATE((hr == ERROR_SUCCESS), "D3D11CreateDevice failed");
    
    ...
}
That’s all you need to properly target the Rift HMD in a native engine.
Drop us a comment in this post with topics you would like the team to consider for future tech notes.
Rift
Unity
Unreal
Did you find this page helpful?
Explore more
GDC 2026 Highlights: What's Next on Meta Horizon OS
Catch up on GDC 2026: where VR is headed, what's new in Meta Horizon OS, and the tools and Store updates helping developers ship faster.
All, Apps, Design, GDC, Games, Quest, Unity, Unreal
The State of VR at GDC 2026: Building a Sustainable Future
Explore the state of VR from GDC 2026: stronger app discovery, growing Meta Quest usage, more $1M+ titles, and much more.
All, Design, Games, Hand tracking, Optimization, Quest, Unity, Unreal
Faster Builds, Smarter Discovery, and the LiveOps Playbook: What to Know After GDC Day 2
Explore Day 2 at GDC 2026: tools to speed up builds, optimize Store discovery, and learn LiveOps strategies from Gorilla Tag.
All, Apps, Design, GDC, Games, Optimization, Quest, Unity, Unreal

Get the latest updates from Meta Horizon.

Get access to highlights and announcements delivered to your inbox.