Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-128226

Windows platform plugin links d3d9 which is not always present

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.0, 6.7.2, 6.8.0 Beta4
    • QPA: Direct2D, QPA: Windows
    • None
    • Windows

    Description

      Although symbol usage is disabled when OpenGL is disabled since `Windows: Do not use D3D9.DLL with -no-feature-opengl` (Idd2ea14dd9d0bf800d5183c22e30df25066af26e) was merged, when OpenGL is enabled this is still the case.

      The problem is that, as was explained in the merged patch already, `d3d9.dll` might not be available on certain configurations, leading to failure of using the Windows platform plugin.

      The proper solution for this would be to load `d3d9.dll` dynamically, something like this would suffice (assuming d3d9 headers to be available in already set include directories):

      From acc84c79a584f25bd4b8eeb8571138bfd79a88dc Mon Sep 17 00:00:00 2001
      From: Fatih Uzunoglu <fuzun54@outlook.com>
      Date: Thu, 15 Aug 2024 16:14:12 +0300
      Subject: [PATCH] Do not link D3D9Reportedly, Windows 11 may not provide d3d9.dll
      ---
       src/plugins/platforms/direct2d/CMakeLists.txt          | 1 -
       src/plugins/platforms/windows/CMakeLists.txt           | 1 -
       src/plugins/platforms/windows/qwindowsopengltester.cpp | 5 ++++-
       3 files changed, 4 insertions(+), 3 deletions(-)diff --git a/src/plugins/platforms/direct2d/CMakeLists.txt b/src/plugins/platforms/direct2d/CMakeLists.txt
      index 4357652207..1e5856be17 100644
      --- a/src/plugins/platforms/direct2d/CMakeLists.txt
      +++ b/src/plugins/platforms/direct2d/CMakeLists.txt
      @@ -78,7 +78,6 @@ qt_internal_add_plugin(QWindowsDirect2DIntegrationPlugin
               winspool
               wtsapi32
               comdlg32
      -        d3d9
       )
       
       # Resources:
      diff --git a/src/plugins/platforms/windows/CMakeLists.txt b/src/plugins/platforms/windows/CMakeLists.txt
      index cb9be899a7..2822184f2e 100644
      --- a/src/plugins/platforms/windows/CMakeLists.txt
      +++ b/src/plugins/platforms/windows/CMakeLists.txt
      @@ -65,7 +65,6 @@ qt_internal_add_plugin(QWindowsIntegrationPlugin
               winspool
               wtsapi32
               comdlg32
      -        d3d9
       )
       
       # Resources:
      diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
      index 6a790bcc1b..7f40d25bbb 100644
      --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
      +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
      @@ -65,7 +65,10 @@ private:
       
       QDirect3D9Handle::QDirect3D9Handle()
       {
      -    m_direct3D9 = Direct3DCreate9(D3D_SDK_VERSION);
      +    QSystemLibrary d3d9dll("d3d9");
      +    typedef IDirect3D9* (*Direct3DCreate9Func)(UINT);
      +    if (const auto direct3DCreate9 = (Direct3DCreate9Func)(d3d9dll.resolve("Direct3DCreate9")))
      +        m_direct3D9 = direct3DCreate9(D3D_SDK_VERSION);
       }
       
       QDirect3D9Handle::~QDirect3D9Handle()
      -- 
      2.45.2 

      CC owolff, vestbo 

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            fuzun Fatih Uzunoglu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes