Export (0) Print
Expand All

How To: Create a WARP Device

This topic shows how to create a WARP device that implements a high speed software rasterizer. To create a WARP device, simply specify that the device you are creating will use a WARP driver. This example creates a device and a swap chain at the same time.

Ff476871.wedge(en-us,VS.85).gifTo create a WARP device

  1. Define initial parameters for a swap chain.
    
    
        DXGI_SWAP_CHAIN_DESC sd;
        ZeroMemory( &sd, sizeof( sd ) );
        sd.BufferCount = 1;
        sd.BufferDesc.Width = 640;
        sd.BufferDesc.Height = 480;
        sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
        sd.BufferDesc.RefreshRate.Numerator = 60;
        sd.BufferDesc.RefreshRate.Denominator = 1;
        sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
        sd.OutputWindow = g_hWnd;
        sd.SampleDesc.Count = 1;
        sd.SampleDesc.Quality = 0;
        sd.Windowed = TRUE;
    
    
    
  2. Request a feature level that implements the features your application will need. A WARP device can be successfully created for feature levels D3D_FEATURE_LEVEL_9_1 through D3D_FEATURE_LEVEL_10_1 and starting with Windows 8 for all feature levels.
    
    
        D3D_FEATURE_LEVEL FeatureLevels = D3D_FEATURE_LEVEL_10_1;
    
    
    

    See more about feature levels in the D3D_FEATURE_LEVEL enumeration.

  3. Create the device by calling D3D11CreateDeviceAndSwapChain.


    HRESULT hr = S_OK;
    if( FAILED (hr = D3D11CreateDeviceAndSwapChain( NULL, 
                    D3D_DRIVER_TYPE_WARP,
                    NULL, 
                    0,
                    &FeatureLevels, 
                    1, 
                    D3D11_SDK_VERSION, 
                    &sd, 
                    &g_pSwapChain, 
                    &g_pd3dDevice, 
                    &FeatureLevel,
                    &g_pImmediateContext )))
    {
        return hr;
    }


You will need to supply the API call with the WARP driver type from the D3D_DRIVER_TYPE enumeration. After the method succeeds, it will return a swap chain interface, a device interface, a pointer to the feature level that was granted by the driver, and an immediate context interface.

For information about limitations creating a WARP device on certain feature levels, see Limitations Creating WARP and Reference Devices.

New for Windows 8

When a computer's primary display adapter is the "Microsoft Basic Display Adapter" (WARP adapter), that computer also has a second adapter. This second adapter is the render-only device that has no display outputs. For more info about the render-only device, see new info in Windows 8 about enumerating adapters.

Related topics

Devices

 

 

Community Additions

ADD
Show:
© 2014 Microsoft