protonscr

Compilation failure on DXVK 2.6 with latest Clang-Mingw due to redefined `_D3DDEVINFO_RESOURCEMANAGER` structure

dxvkclosed
doitsujin/dxvk#4813 · opened 2025-03-31 by ms178 · updated 2025-03-31 · 1 comments · github
Mms178 2025-03-31 github

Description

When compiling DXVK 2.6 with the latest Clang toolchain (llvm-mingw-20250319), the build fails due to a redefinition of the _D3DDEVINFO_RESOURCEMANAGER structure. This structure is now properly defined in the system headers included with the newer Clang toolchain, but DXVK also defines it in its own codebase, causing a conflict.

Error Message

In file included from ../../dxvk/src/dxso/dxso_util.cpp:1:
In file included from ../../dxvk/src/dxso/dxso_util.h:8:
In file included from ../../dxvk/src/dxso/../d3d9/d3d9_caps.h:3:
../../dxvk/src/dxso/../d3d9/d3d9_include.h:49:16: error: redefinition of '_D3DDEVINFO_RESOURCEMANAGER'
   49 | typedef struct _D3DDEVINFO_RESOURCEMANAGER
      |                ^
/opt/llvm-mingw/llvm-mingw-20250319-msvcrt-ubuntu-20.04-x86_64/x86_64-w64-mingw32/include/d3d9types.h:1369:16: note: previous definition is here
 1369 | typedef struct _D3DDEVINFO_RESOURCEMANAGER {
      |                ^
1 error generated.

Environment

  • DXVK version: 2.6
  • Compiler: Clang (llvm-mingw-20250319-msvcrt-ubuntu-20.04-x86_64)
  • Host OS: CachyOS
  • Build system: Meson/Ninja

Reproduction Steps

  1. Clone the DXVK 2.6 repository
  2. Set up the build environment with the latest llvm-mingw toolchain (20250319 or newer)
  3. Run the build process
  4. Observe the compilation error in the dxso_util.cpp file

Analysis

The issue occurs because:

  1. Newer versions of the MinGW headers (specifically d3d9types.h) now include a definition for _D3DDEVINFO_RESOURCEMANAGER
  2. DXVK has its own definition of this structure in d3d9_include.h (line 49)
  3. When compiling with the latest toolchain, both definitions conflict

This appears to be a backward compatibility issue where DXVK previously needed to define this structure because it was missing or incomplete in older headers.

Proposed Fix by AI

Add preprocessor guards around the structure definition in d3d9_include.h to only define it if it's not already defined in the system headers:

#ifndef _D3DDEVINFO_RESOURCEMANAGER_DEFINED
#define _D3DDEVINFO_RESOURCEMANAGER_DEFINED
typedef struct _D3DDEVINFO_RESOURCEMANAGER {
    // structure definition here
} D3DDEVINFO_RESOURCEMANAGER;
#endif

Alternatively, check if the structure is defined in the system headers using feature detection and only define it if necessary.

Additional Notes

  • This issue did not occur with older versions of the Clang-MinGW toolchain
  • Similar issues might exist for other Direct3D structures defined in DXVK that have been added to newer MinGW headers
  • A more comprehensive solution might involve checking all custom structure definitions against the latest headers

Impact

This issue blocks compilation of DXVK 2.6 with the recent Clang-MinGW toolchain, preventing users from building from source with up-to-date development environments.

Mms178 2025-03-31 github

I should add, the older llvm-mingw 20250305 works fine, hence this only reproduces with the newer version from 20250319. I pull directly from: https://github.com/mstorsjo/llvm-mingw/releases

Nothing extracted yet.