6

I'm invoking D3D11CreateDevice() with the following code:

ID3D11Device* md3dDevice;
ID3D11DeviceContext* md3dImmediateContext;
D3D_DRIVER_TYPE md3dDriverType = D3D_DRIVER_TYPE_HARDWARE;
createDeviceFlags = D3D11_CREATE_DEVICE_DEBUG;
HRESULT hr = D3D11CreateDevice(
            0,                 
            md3dDriverType,
            0,                 
            createDeviceFlags, 
            0, 0,              
            D3D11_SDK_VERSION,
            &md3dDevice,
            &featureLevel,
            &md3dImmediateContext);

However, the result stored in HRESTUL hr is E_FAIL. The console has the following output:

First-chance exception at 0x7590b9bc in Init Direct3D.exe: Microsoft
C++ exception: _com_error at memory location 0x0049ec64..
c:\users\andrew\desktop\code\common\d3dapp.cpp(389):
D3D11CreateDevice( 0, md3dDriverType, 0, createDeviceFlags, 0, 0, D3D11_SDK_VERSION, &md3dDevice, &featureLevel, &md3dImmediateContext)
hr=E_FAIL (0x80004005) Init Direct3D.exe has triggered a breakpoint

I do not think it is a linking issue as the code builds, but the following additional dependencies are defined:

d3d11lib
d3dx11d.lib
D3DCompiler.lib
Effects11d.lib
dxerr.lib

My next thought was that my card was not compatible with D3D11. However, this is not the case. Here is the output of dxdiag:

------------------
System Information
------------------
Time of this report: 5/14/2012, 02:29:16
       Machine name: WINDOZE
   Operating System: Windows 7 Professional 64-bit (6.1, Build 7601) Service Pack 1 (7601.win7sp1_gdr.120330-1504)
           Language: English (Regional Setting: English)
System Manufacturer: Gigabyte Technology Co., Ltd.
       System Model: GA-880GMA-UD2H
               BIOS: Award Modular BIOS v6.00PG
          Processor: AMD Phenom(tm) II X4 955 Processor (4 CPUs), ~3.2GHz
             Memory: 8192MB RAM
Available OS Memory: 8188MB RAM
          Page File: 4121MB used, 12254MB available
        Windows Dir: C:\Windows
    DirectX Version: DirectX 11
DX Setup Parameters: Not found
   User DPI Setting: Using System DPI
 System DPI Setting: 96 DPI (100 percent)
    DWM DPI Scaling: Disabled
     DxDiag Version: 6.01.7601.17514 64bit Unicode

------------
DxDiag Notes
------------
      Display Tab 1: No problems found.
      Display Tab 2: No problems found.
        Sound Tab 1: No problems found.
        Sound Tab 2: No problems found.
        Sound Tab 3: No problems found.
        Sound Tab 4: No problems found.
          Input Tab: No problems found.

--------------------
DirectX Debug Levels
--------------------
Direct3D:    0/4 (retail)
DirectDraw:  0/4 (retail)
DirectInput: 0/5 (retail)
DirectMusic: 0/5 (retail)
DirectPlay:  0/9 (retail)
DirectSound: 0/5 (retail)
DirectShow:  0/6 (retail)

---------------
Display Devices
---------------
          Card name: ATI Radeon HD 5670
       Manufacturer: Advanced Micro Devices, Inc.
          Chip type: ATI display adapter (0x68D8)
           DAC type: Internal DAC(400MHz)
         Device Key: Enum\PCI\VEN_1002&DEV_68D8&SUBSYS_56701545&REV_00
     Display Memory: 1774 MB
   Dedicated Memory: 2032 MB
      Shared Memory: 3838 MB
       Current Mode: 1920 x 1080 (32 bit) (60Hz)
       Monitor Name: Generic PnP Monitor
      Monitor Model: E2241
         Monitor Id: GSM581A
        Native Mode: 1920 x 1080(p) (60.000Hz)
        Output Type: HDMI
        Driver Name: aticfx64.dll,aticfx64.dll,aticfx64.dll,aticfx32,aticfx32,aticfx32,atiumd64.dll,atidxx64.dll,atidxx64.dll,atiumdag,atidxx32,atidxx32,atiumdva,atiumd6a.cap,atitmm64.dll
Driver File Version: 8.17.0010.1119 (English)
     Driver Version: 8.951.0.0
        DDI Version: 11
       Driver Model: WDDM 1.1
  Driver Attributes: Final Retail
   Driver Date/Size: 3/9/2012 01:14:42, 958464 bytes
        WHQL Logo'd: Yes
    WHQL Date Stamp: 
  Device Identifier: {D7B71EE2-2B98-11CF-AA72-7A76BEC2C535}
          Vendor ID: 0x1002
          Device ID: 0x68D8
          SubSys ID: 0x56701545
        Revision ID: 0x0000
 Driver Strong Name: oem1.inf:ATI.Mfg.NTamd64.6.1:ati2mtag_Evergreen:8.951.0.0:pci\ven_1002&dev_68d8
     Rank Of Driver: 00E62001
        Video Accel: ModeMPEG2_A ModeMPEG2_C 
   Deinterlace Caps: {6E8329FF-B642-418B-BCF0-BCB6591E255F}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_BOBVerticalStretch 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY 
                     {6E8329FF-B642-418B-BCF0-BCB6591E255F}: Format(In/Out)=(UYVY,UYVY) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(UYVY,UYVY) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_BOBVerticalStretch 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(UYVY,UYVY) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(YV12,0x32315659) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {3C5323C1-6FB7-44F5-9081-056BF2EE449D}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,2) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {552C0DAD-CCBC-420B-83C8-74943CF9F1A6}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,2) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {6E8329FF-B642-418B-BCF0-BCB6591E255F}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_BOBVerticalStretch 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC1,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC2,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC3,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC4,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(S340,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(S342,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
       D3D9 Overlay: Not Supported
            DXVA-HD: Not Supported
       DDraw Status: Enabled
         D3D Status: Enabled
         AGP Status: Enabled

          Card name: ATI Radeon HD 5670
       Manufacturer: Advanced Micro Devices, Inc.
          Chip type: ATI display adapter (0x68D8)
           DAC type: Internal DAC(400MHz)
         Device Key: Enum\PCI\VEN_1002&DEV_68D8&SUBSYS_56701545&REV_00
     Display Memory: 1774 MB
   Dedicated Memory: 2032 MB
      Shared Memory: 3838 MB
       Current Mode: 1600 x 900 (32 bit) (60Hz)
       Monitor Name: Generic PnP Monitor
      Monitor Model: W2043
         Monitor Id: GSM4E9D
        Native Mode: 1600 x 900(p) (60.000Hz)
        Output Type: HD15
        Driver Name: aticfx64.dll,aticfx64.dll,aticfx64.dll,aticfx32,aticfx32,aticfx32,atiumd64.dll,atidxx64.dll,atidxx64.dll,atiumdag,atidxx32,atidxx32,atiumdva,atiumd6a.cap,atitmm64.dll
Driver File Version: 8.17.0010.1119 (English)
     Driver Version: 8.951.0.0
        DDI Version: 11
       Driver Model: WDDM 1.1
  Driver Attributes: Final Retail
   Driver Date/Size: 3/9/2012 01:14:42, 958464 bytes
        WHQL Logo'd: Yes
    WHQL Date Stamp: 
  Device Identifier: {D7B71EE2-2B98-11CF-AA72-7A76BEC2C535}
          Vendor ID: 0x1002
          Device ID: 0x68D8
          SubSys ID: 0x56701545
        Revision ID: 0x0000
 Driver Strong Name: oem1.inf:ATI.Mfg.NTamd64.6.1:ati2mtag_Evergreen:8.951.0.0:pci\ven_1002&dev_68d8
     Rank Of Driver: 00E62001
        Video Accel: ModeMPEG2_A ModeMPEG2_C 
   Deinterlace Caps: {6E8329FF-B642-418B-BCF0-BCB6591E255F}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_BOBVerticalStretch 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY 
                     {6E8329FF-B642-418B-BCF0-BCB6591E255F}: Format(In/Out)=(UYVY,UYVY) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(UYVY,UYVY) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_BOBVerticalStretch 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(UYVY,UYVY) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(YV12,0x32315659) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {3C5323C1-6FB7-44F5-9081-056BF2EE449D}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,2) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {552C0DAD-CCBC-420B-83C8-74943CF9F1A6}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,2) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {6E8329FF-B642-418B-BCF0-BCB6591E255F}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_PixelAdaptive 
                     {335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY DeinterlaceTech_BOBVerticalStretch 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(NV12,0x3231564e) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY 
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC1,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC2,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC3,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC4,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(S340,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
                     {5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(S342,UNKNOWN) Frames(Prev/Fwd/Back)=(0,0,0) Caps=
       D3D9 Overlay: Not Supported
            DXVA-HD: Not Supported
       DDraw Status: Enabled
         D3D Status: Enabled
         AGP Status: Enabled

Any help as to what could be a possible cause of E_FAIL would be appreciated.

Andrew
  • 1,853
  • 1
  • 14
  • 15
  • What did you init `createDeviceFlags` to? Also you are missing a semicolon after `D3D_DRIVER_TYPE_HARDWARE` - is this the actual code you are using? – Ben May 14 '12 at 16:22
  • No, it's not the actual code, but quite close. The issue does seem to be with `createDeviceFlags`. If `createDeviceFlags = 0;` then the code works correctly. If `createDeviceFlags = D3D11_CREATE_DEVICE_DEBUG;` it fails. Why would this be an issue though? `D3D11_CREATE_DEVICE_DEBUG` is valid according to http://msdn.microsoft.com/en-us/library/windows/desktop/ff476107(v=vs.85).aspx – Andrew May 14 '12 at 16:27
  • You need to post the actual code which exhibits the problem. – Ben May 14 '12 at 17:23
  • The code that exhibits the problem is the following line `createDeviceFlags = D3D11_CREATE_DEVICE_DEBUG;` combined with the above D3D11CreateDevice() call. When `createDeviceFlags = 0;` there is no problem. – Andrew May 14 '12 at 17:31
  • `D3D_DRIVER_TYPE md3dDriverType = D3D_DRIVER_TYPE_HARDWARE createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;` is not valid code. Do you mean `D3D_DRIVER_TYPE md3dDriverType = D3D_DRIVER_TYPE_HARDWARE; createDeviceFlags = D3D11_CREATE_DEVICE_DEBUG; ` – Ben May 14 '12 at 19:21
  • I went ahead and edited the post since you were getting hung up on minute details. – Andrew May 15 '12 at 04:04
  • If you say `|= D3D11_CREATE_DEVICE_DEBUG;` you are adding a flag to the existing flages - the question will be "what other flags are set? What was the value of createDeviceFlags before the statement?" That's essential information not a minute detail. – Ben May 15 '12 at 07:29
  • In my case, setting to `Release` bypasses this issue, but that is not a solution. So in `Debug` configuration these things occur. – Martin Berger Mar 31 '13 at 14:43

2 Answers2

7

The latest version of the SDK Debug Layer is not in the legacy DirectX SDK (June 2010) release. You need to install the standalone Windows 8.0 SDK, Visual Studio 2012, or you can just install the VS 2012 Remote Debugging Tools package.

http://blogs.msdn.com/b/chuckw/archive/2013/02/26/directx-11-1-and-windows-7-update.aspx

5

The problem seems to be that you don't have Direct X Debug Runtime installed (there is an option to install it when installing Direct X SDK), but just the regular Direct X Runtime. The Direct X Runtime provides less overhead and is faster, but you can't use it to debug the applications.

--------------------
DirectX Debug Levels
--------------------
Direct3D:    0/4 (retail)
DirectDraw:  0/4 (retail)
DirectInput: 0/5 (retail)
DirectMusic: 0/5 (retail)
DirectPlay:  0/9 (retail)
DirectSound: 0/5 (retail)
DirectShow:  0/6 (retail)

Or if you have it installed, it is not turned on. You might find some useful information how to switch between Debug and Release version of Direct X Runtime.

George
  • 307
  • 3
  • 10
  • My understanding was that the flag `D3D11_CREATE_DEVICE_DEBUG` enabled the Debug Runtime in DirectX 11. The article you linked to was with respect to DirectX 9, but things have changed since then. – Andrew May 14 '12 at 17:34
  • Although, perhaps the SDK went amiss during install. I just reinstalled the SDK and the flag `D3D11_CREATE_DEVICE_DEBUG` now works properly. The June 2010 SDK release does not contain an option to install the debug runtime, it is included automatically. – Andrew May 14 '12 at 17:46