microsoft / D3D9On12

The Direct3D9-On-12 mapping layer
MIT License
335 stars 36 forks source link

Application crashes when enabling graphics debug in Visual Studio 2022 on intel iris xe graphics card. #91

Open Hubert-Du opened 1 month ago

Hubert-Du commented 1 month ago

Application crashes when enabling graphics debug in Visual Studio 2022 on intel iris xe graphics card. Some information about the Intel iris Xe graphics card: https://www.tomshardware.com/news/intel-xe-arc-swap-to-dx9-emulation.

>   D3D12Core.dll!IUnknown::QueryInterface<struct IDXGIAdapter>(struct IDXGIAdapter * *)    Unknown
    D3D12Core.dll!D3D12ValidateAndCreateDevice()    Unknown
    D3D12.dll!00007fffd2b46c5b()    Unknown
    DXCaptureReplay.dll!GRFXTool::CCompatibilityMode::_D3D12CreateDevice(long &,long (*)(struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *),struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureCall::Call__D3D12CreateDevice(class GRFXTool::CaptureToolLayer *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)  Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceRealGenerated(class GRFXTool::CaptureToolLayer *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceWrapGenerated(void *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceGenerated(struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)   Unknown
    D3D12.dll!00007fffd2b4662e()    Unknown
    d3d9on12.dll!00007fffd2b74ae0() Unknown
    d3d9on12.dll!00007fffd2bedf7b() Unknown
    d3d9.dll!CreateDeviceLHDDI()    Unknown
    d3d9.dll!D3D9CreateDirectDrawObject()   Unknown
    d3d9.dll!FetchDirectDrawData()  Unknown
    d3d9.dll!InternalDirectDrawCreate() Unknown
    d3d9.dll!CEnum::CEnum() Unknown
    d3d9.dll!Direct3DCreate9Impl()  Unknown
    d3d9.dll!Direct3DCreate9()  Unknown
    dxdiagn.dll!00007ff811a2d75d()  Unknown
    dxdiagn.dll!00007ff811a0ff30()  Unknown
    dxdiagn.dll!00007ff8119f51ae()  Unknown
    dxdiagn.dll!00007ff8119fa88f()  Unknown
    dxdiagn.dll!00007ff8119fa54a()  Unknown
    VsGraphicsExperiment.dll!00007ff8161c9587() Unknown
    VsGraphicsExperiment.dll!00007ff8161ace1a() Unknown
    VsGraphicsExperiment.dll!00007ff8161acefd() Unknown
    ntdll.dll!RtlpTpWorkCallback()  Unknown
    ntdll.dll!TppWorkerThread() Unknown
    kernel32.dll!BaseThreadInitThunk()  Unknown
    ntdll.dll!RtlUserThreadStart()  Unknown
Hubert-Du commented 1 month ago

I cannot capture frame when enabling graphics debug, and I can capture frame when I disable Intel Iris Xe graphics adaptor. Application crashes when the following call stack appear, the call stack can be triggered in many ways.

D3D12Core.dll!IUnknown::QueryInterface<struct IDXGIAdapter>(struct IDXGIAdapter * *)    Unknown
    D3D12Core.dll!D3D12ValidateAndCreateDevice()    Unknown
    D3D12.dll!00007fffd2b46c5b()    Unknown
    DXCaptureReplay.dll!GRFXTool::CCompatibilityMode::_D3D12CreateDevice(long &,long (*)(struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *),struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureCall::Call__D3D12CreateDevice(class GRFXTool::CaptureToolLayer *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)  Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceRealGenerated(class GRFXTool::CaptureToolLayer *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceWrapGenerated(void *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceGenerated(struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)   Unknown
    D3D12.dll!00007fffd2b4662e()    Unknown
jenatali commented 1 month ago

The Visual Studio Graphics Debugger does not support D3D9, and should not be used for D3D12. For D3D12 debugging, use PIX. For D3D9, the only Microsoft-supported tool is the old PIX that came in the June 2010 DirectX SDK, but there exist 3rd party tools with varying levels of support.

Hubert-Du commented 1 month ago

The Visual Studio Graphics Debugger does not support D3D9, and should not be used for D3D12. For D3D12 debugging, use PIX. For D3D9, the only Microsoft-supported tool is the old PIX that came in the June 2010 DirectX SDK, but there exist 3rd party tools with varying levels of support.

We didn't use D3D9, our directx version is DirectX11, but see the following call stacks, the issue can be also triggered by QT.

    D3D12Core.dll!IUnknown::QueryInterface<struct IDXGIAdapter>(struct IDXGIAdapter * *)    Unknown
    D3D12Core.dll!D3D12ValidateAndCreateDevice()    Unknown
    D3D12.dll!00007fffd2b46c5b()    Unknown
    DXCaptureReplay.dll!GRFXTool::CCompatibilityMode::_D3D12CreateDevice(long &,long (*)(struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *),struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureCall::Call__D3D12CreateDevice(class GRFXTool::CaptureToolLayer *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)  Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceRealGenerated(class GRFXTool::CaptureToolLayer *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceWrapGenerated(void *,struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)    Unknown
    DXCaptureReplay.dll!GRFXTool::GeneratedCaptureWrapper::D3D12CreateDeviceGenerated(struct IUnknown *,enum D3D_FEATURE_LEVEL,struct _GUID const &,void * *)   Unknown
    D3D12.dll!00007fffd2b4662e()    Unknown
    d3d9on12.dll!00007fffd2b74ae0() Unknown
    d3d9on12.dll!00007fffd2bedf7b() Unknown
    d3d9.dll!CreateDeviceLHDDI()    Unknown
    d3d9.dll!D3D9CreateDirectDrawObject()   Unknown
    d3d9.dll!FetchDirectDrawData()  Unknown
    d3d9.dll!InternalDirectDrawCreate() Unknown
    d3d9.dll!CEnum::CEnum() Unknown
    d3d9.dll!Direct3DCreate9Impl()  Unknown
    d3d9.dll!Direct3DCreate9()  Unknown
    qwindowsd.dll!QDirect3D9Handle::QDirect3D9Handle() Line 109 C++
    qwindowsd.dll!GpuDescription::detect() Line 129 C++
    qwindowsd.dll!QWindowsWindow::forcedScreenForGLWindow(const QWindow * w) Line 1570  C++
    qwindowsd.dll!calcPosition(const QWindow * w, const QSharedPointer<QWindowCreationContext> & context, const QMargins & invMargins) Line 566 C++
    qwindowsd.dll!WindowCreationData::create(const QWindow * w, const QWindowsWindowData & data, QString title) Line 795    C++
    qwindowsd.dll!QWindowsWindowData::create(const QWindow * w, const QWindowsWindowData & parameters, const QString & title) Line 1608 C++
    qwindowsd.dll!QWindowsIntegration::createPlatformWindow(QWindow * window) Line 375  C++
    Qt6Guid.dll!QWindowPrivate::create(bool recursive, unsigned __int64 nativeHandle) Line 548  C++
    Qt6Guid.dll!QWindow::create() Line 679  C++
    Qt6Widgetsd.dll!QWidgetPrivate::create() Line 1315  C++
    Qt6Widgetsd.dll!QWidget::create(unsigned __int64 window, bool initializeWindow, bool destroyOldWindow) Line 1180    C++
    Qt6Widgetsd.dll!QWidgetPrivate::createWinId() Line 2399 C++
    Qt6Widgetsd.dll!QWidget::winId() Line 2365  C++
>   VEAuthor.exe!QWinWidget::init() Line 89 C++
    VEAuthor.exe!QWinWidget::QWinWidget(HWND__ * hParentWnd, QObject * parent, QFlags<enum Qt::WindowType> f) Line 60   C++
    VEAuthor.exe!rh::ui::ErrorPopupService::Initialize() Line 18    C++
    VEAuthor.exe!MainWindowImpl::OnTop(int _menu) Line 7519 C++
    VEAuthor.exe!InitAndMessageLoop(HINSTANCE__ * hCurInstance, char * lpCmdLine, int nCmdShow, void * hMutex) Line 1088    C++
    VEAuthor.exe!WinMain(HINSTANCE__ * hCurInstance, HINSTANCE__ * __formal, char * lpCmdLine, int nCmdShow) Line 1169  C++
    [External Code] 
Hubert-Du commented 1 month ago

I guess the problem is that the DXCaptureReplay.dll!GRFXTool::CCompatibilityMode::_D3D12CreateDevice has some compatibility issue.

Hubert-Du commented 1 month ago

To work around this crash, I need to disable my Intel Iris Xe graphics adaptor. I guess this information is important for you.

jenatali commented 1 month ago

Thanks for reporting this. We'll need to follow up with the Visual Studio Graphics Diagnostics folks to figure out what to do here.

Hubert-Du commented 1 month ago

Thank you very much, I guess the crash problem is caused by that Intel didn't provide the native support for D3D9, and the D3D9on12 has some compatibility issue. Many library will cause the crash in graphics debug if the library want to query some capability, for example, the QWinWidget, it's very simple to reproduce this issue: An application shows QWinWidget in graphics debug mode in Intel Iris Xe graphics adaptor.

Looking at the call stack, we can see any way to trigger "Direct3DCreate9()" in graphics debug with Intel Iris Xe adaptor will crash.