From 2443f3608ab7501ece7941e45030b7d32f81985a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 8 Apr 2026 23:51:15 -0700 Subject: [PATCH] d3d12: Fix MinGW cross-build error in resource_state_if_promoted When cross-compiling with MinGW, d3d12_resource_state.cpp fails to compile with: d3d12_resource_state.cpp:161:83: error: call to non-'constexpr' function 'D3D12_RESOURCE_STATES operator|(D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES)' 161 | D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE | | D3D12_RESOURCE_STATE_COPY_SOURCE | D3D12_RESOURCE_STATE_COPY_DEST; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/share/mingw-w64/include/minwindef.h:163, from /usr/share/mingw-w64/include/windef.h:9, from /usr/share/mingw-w64/include/windows.h:69, from /usr/share/mingw-w64/include/rpc.h:16, from /usr/share/mingw-w64/include/unknwn.h:7, from ../subprojects/DirectX-Headers-1.0/include/wsl/winadapter.h:6, from ../src/gallium/drivers/d3d12/d3d12_common.h:29, from ../src/gallium/drivers/d3d12/d3d12_bufmgr.h:31, from ../src/gallium/drivers/d3d12/d3d12_resource_state.cpp:24: ../subprojects/DirectX-Headers-1.0/include/directx/d3d12.h:3540:1: note: 'D3D12_RESOURCE_STATES operator|(D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES)' declared here 3540 | DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_STATES ) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ The DEFINE_ENUM_FLAG_OPERATORS macro in the MinGW winnt.h header defines operator| for D3D12_RESOURCE_STATES as inline but not constexpr. (The DirectX-Headers WSL stubs do define it as constexpr, but when building with MinGW, windows.h is pulled in via winadapter.h and its non-constexpr definition wins.) Calling a non-constexpr function to initialize a constexpr variable is ill-formed in C++. Fix by changing static constexpr to static const, which avoids the constexpr context while still giving the variable static storage duration. Fixes: fe48cd7c5a59 ("d3d12: Allow state promotion for non-simultaneous access textures") Signed-off-by: Vinson Lee Reviewed-by: Jesse Natalie Part-of: --- src/gallium/drivers/d3d12/d3d12_resource_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/d3d12/d3d12_resource_state.cpp b/src/gallium/drivers/d3d12/d3d12_resource_state.cpp index 981140f035d..412ac2bda8b 100644 --- a/src/gallium/drivers/d3d12/d3d12_resource_state.cpp +++ b/src/gallium/drivers/d3d12/d3d12_resource_state.cpp @@ -157,7 +157,7 @@ resource_state_if_promoted(D3D12_RESOURCE_STATES desired_state, bool simultaneous_access, const d3d12_subresource_state *current_state) { - static constexpr D3D12_RESOURCE_STATES promotable_states = + static const D3D12_RESOURCE_STATES promotable_states = D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_COPY_SOURCE | D3D12_RESOURCE_STATE_COPY_DEST; if (simultaneous_access || (desired_state & ~promotable_states) == D3D12_RESOURCE_STATE_COMMON) {