From 5fd9d0891f8458f74ec7432c8198e72fef5a0aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 20 Feb 2024 17:05:10 +0100 Subject: [PATCH] SCons: Add proper MinGW support to D3D12 deps install script Fix a couple GCC warnings. --- drivers/d3d12/d3d12ma.cpp | 1 + .../d3d12/rendering_device_driver_d3d12.cpp | 7 ++-- misc/scripts/install_d3d12_sdk_windows.py | 34 +++++++++++++++++-- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/drivers/d3d12/d3d12ma.cpp b/drivers/d3d12/d3d12ma.cpp index ad7b4e570d9e..51171141dece 100644 --- a/drivers/d3d12/d3d12ma.cpp +++ b/drivers/d3d12/d3d12ma.cpp @@ -42,6 +42,7 @@ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wnonnull-compare" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif #if defined(_MSC_VER) diff --git a/drivers/d3d12/rendering_device_driver_d3d12.cpp b/drivers/d3d12/rendering_device_driver_d3d12.cpp index 8c92737374d5..6efef0fb3468 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_device_driver_d3d12.cpp @@ -2885,7 +2885,7 @@ Vector RenderingDeviceDriverD3D12::shader_compile_binary_from_spirv(Vec uint32_t binding = (p_register % GODOT_NIR_DESCRIPTOR_SET_MULTIPLIER) / GODOT_NIR_BINDING_MULTIPLIER; DEV_ASSERT(set < (uint32_t)shader_data_in.sets_bindings.size()); - bool found = false; + [[maybe_unused]] bool found = false; for (int j = 0; j < shader_data_in.sets_bindings[set].size(); j++) { if (shader_data_in.sets_bindings[set][j].binding != binding) { continue; @@ -2903,7 +2903,6 @@ Vector RenderingDeviceDriverD3D12::shader_compile_binary_from_spirv(Vec } else { CRASH_NOW(); } - found = true; break; } @@ -2913,8 +2912,7 @@ Vector RenderingDeviceDriverD3D12::shader_compile_binary_from_spirv(Vec godot_nir_callbacks.report_sc_bit_offset_fn = [](uint32_t p_sc_id, uint64_t p_bit_offset, void *p_data) { ShaderData &shader_data_in = *(ShaderData *)p_data; - - bool found = false; + [[maybe_unused]] bool found = false; for (int j = 0; j < shader_data_in.specialization_constants.size(); j++) { if (shader_data_in.specialization_constants[j].constant_id != p_sc_id) { continue; @@ -2923,7 +2921,6 @@ Vector RenderingDeviceDriverD3D12::shader_compile_binary_from_spirv(Vec uint32_t offset_idx = SHADER_STAGES_BIT_OFFSET_INDICES[shader_data_in.stage]; DEV_ASSERT(shader_data_in.specialization_constants.write[j].stages_bit_offsets[offset_idx] == 0); shader_data_in.specialization_constants.write[j].stages_bit_offsets[offset_idx] = p_bit_offset; - found = true; break; } diff --git a/misc/scripts/install_d3d12_sdk_windows.py b/misc/scripts/install_d3d12_sdk_windows.py index 8cfa1d399b00..6dd0818b971e 100644 --- a/misc/scripts/install_d3d12_sdk_windows.py +++ b/misc/scripts/install_d3d12_sdk_windows.py @@ -3,6 +3,7 @@ import os import urllib.request import shutil +import subprocess # Base Godot dependencies path # If cross-compiling (no LOCALAPPDATA), we install in `bin` @@ -18,8 +19,8 @@ dxc_archive = os.path.join(deps_folder, dxc_filename) dxc_folder = os.path.join(deps_folder, "dxc") # Mesa NIR -mesa_version = "23.1.0-devel" -mesa_filename = "godot-nir-23.1.0-1-devel.zip" +mesa_version = "23.1.9" +mesa_filename = "godot-nir-23.1.9.zip" mesa_archive = os.path.join(deps_folder, mesa_filename) mesa_folder = os.path.join(deps_folder, "mesa") # WinPixEventRuntime @@ -70,6 +71,16 @@ print(f"Mesa NIR {mesa_filename} installed successfully.\n") # WinPixEventRuntime + +# MinGW needs DLLs converted with dlltool. +# We rely on finding gendef/dlltool to detect if we have MinGW. +# Check existence of needed tools for generating mingw library. +gendef = shutil.which("gendef") or "" +dlltool = shutil.which("dlltool") or "" +if dlltool == "": + dlltool = shutil.which("x86_64-w64-mingw32-dlltool") or "" +has_mingw = gendef != "" and dlltool != "" + print("[3/4] WinPixEventRuntime") if os.path.isfile(pix_archive): os.remove(pix_archive) @@ -81,6 +92,23 @@ print(f"Extracting WinPixEventRuntime {pix_version} to {pix_folder} ...") shutil.unpack_archive(pix_archive, pix_folder, "zip") os.remove(pix_archive) +if has_mingw: + print("Adapting WinPixEventRuntime to also support MinGW alongside MSVC.") + cwd = os.getcwd() + os.chdir(pix_folder) + subprocess.run([gendef, "./bin/x64/WinPixEventRuntime.dll"]) + subprocess.run( + [dlltool] + + "--machine i386:x86-64 --no-leading-underscore -d WinPixEventRuntime.def -D WinPixEventRuntime.dll -l ./bin/x64/libWinPixEventRuntime.a".split() + ) + subprocess.run([gendef, "./bin/ARM64/WinPixEventRuntime.dll"]) + subprocess.run( + [dlltool] + + "--machine arm64 --no-leading-underscore -d WinPixEventRuntime.def -D WinPixEventRuntime.dll -l ./bin/ARM64/libWinPixEventRuntime.a".split() + ) + os.chdir(cwd) +else: + print("MinGW wasn't found, so only MSVC support is provided for WinPixEventRuntime.") print(f"WinPixEventRuntime {pix_version} installed successfully.\n") # DirectX 12 Agility SDK @@ -100,5 +128,5 @@ print(f"DirectX 12 Agility SDK {agility_sdk_version} installed successfully.\n") # Complete message -print(f"All Direct3D 12 SDK components were installed to {deps_folder} successfully!") +print(f'All Direct3D 12 SDK components were installed to "{deps_folder}" successfully!') print('You can now build Godot with Direct3D 12 support enabled by running "scons d3d12=yes".')