locked
Getting D3D11CreateDeviceAndSwapChain to work with debug flag RRS feed

  • Question

  • Hi, I am brand new to directx 11 and trying to learn it. I am trying to run a directx 11 tutorial where I simply create a blank window. I can't create the device though if I set the debug flag. Relevant code is as follows:

    #include <d3d11.h>
    #include <d3dx11.h>
    #include <DxErr.h>

    ...

    unsigned int creationFlags = 0;

    #ifdef _DEBUG
        creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
    #endif

    HRESULT result;
    unsigned int driver=0;

    for (driver=0;driver<totalDriverTypes;++driver) {
        result = D3D11CreateDeviceAndSwapChain (NULL, driverTypes[driver],NULL,creationFlags,
            featureLevels,totalFeatureLevels, D3D11_SDK_VERSION, &swapChainDesc, &swapChain_,
            &d3dDevice_, &featureLevel_, &d3dContext_);

    ...

    }

    I am on Windows 7, running in debug mode in Visual C++ 2010 Express, using the June 2010 Directx sdk. I know my graphics card is only directx 10.1 compatible, but D3D_FEATURE_LEVEL_10_1 is in my featureLevels array. If I just set creationFlags to 0, then it works fine. But when it is set to D3D11_CREATE_DEVICE_DEBUG, the result = An undetermined error occurred hr=E_FAIL. I tried uninstalling and re-installing the SDK, as it has fixed this issue for others, but it didn't work. Also, in the output I see a lot of errors about not being able to open pdb files, though I'm not sure if those can be safely ignored or not:

    'BlankWindow.exe': Loaded 'C:\Users\Alex\Documents\Visual Studio 2010\Projects\BlankWindow\Debug\BlankWindow.exe', Symbols loaded.
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\d3d11.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\dxgi.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\apphelp.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Unloaded 'C:\Windows\SysWOW64\apphelp.dll'
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\wintrust.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Cannot find or open the PDB file
    'BlankWindow.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll'
    'BlankWindow.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll'
    'BlankWindow.exe': Unloaded 'C:\Windows\SysWOW64\cfgmgr32.dll'
    'BlankWindow.exe': Loaded 'C:\Windows\SysWOW64\atidxx32.dll', Cannot find or open the PDB file

    When I run with creationFlags=D3D11_CREATE_DEVICE_DEBUG, I see the following error in the console after D3D11CreateDeviceAndSwapChain  is run:

    First-chance exception at 0x7752c41f in BlankWindow.exe: Microsoft C++ exception: _com_error at memory location 0x0036ed50..

    Is there something I missing in my includes, or in my environment setup that could be causing this? I didn't see anything specific in the SDK that is required to run directx 11 in debug mode.

    Thanks,

    Alex

    Sunday, March 24, 2013 11:39 PM

Answers