From 392b4ab6b24fd1f024b5c5c00c03377f533e005f 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 (cherry picked from commit 2443f3608ab7501ece7941e45030b7d32f81985a) Part-of: --- .pick_status.json | 2 +- src/gallium/drivers/d3d12/d3d12_resource_state.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 9a1b105b5df..bc337723ac7 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1254,7 +1254,7 @@ "description": "d3d12: Fix MinGW cross-build error in resource_state_if_promoted", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "fe48cd7c5a5942f040e7c6ff0986726e437d30b9", "notes": null 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) {