From f122799158d64f4b4427bfa56aef7573e42c6874 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:48:01 -0400 Subject: [PATCH 1/8] Update sentry-native to 0.7.9 --- .sentrynative | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.sentrynative b/.sentrynative index 38eff585329..6804359cb32 100644 --- a/.sentrynative +++ b/.sentrynative @@ -1,2 +1,2 @@ -URL=https://github.com/getsentry/sentry-native/releases/download/0.7.8/sentry-native.zip -SHA512=be19baf750071d1156b8d091a5c9731e7c549b872958b0f2ba519c9808eeac09b8d62f4165a9168856c90114973335e88fa79b505b575cba9bb9dc9a1c351436 +URL=https://github.com/getsentry/sentry-native/releases/download/0.7.9/sentry-native.zip +SHA512=04b9df74d87a9197089cef78463d9da9533eec2d2e63c427489202aa6c2285914046691fbb12e6a0f0517ac425ee5bd2a89e05a5a66bd00f71e391c487ef0bf1 From 54c9a2373b83f63576760d0b3be3ea38620fb10a Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:49:13 -0400 Subject: [PATCH 2/8] vcpkg.json: Update builtin-baseline --- vcpkg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcpkg.json b/vcpkg.json index 6868f77cd5f..30149a5fa6c 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,7 @@ { "name": "warzone2100", "version-string": "master-branch", - "builtin-baseline": "e590c2b30c08caf1dd8d612ec602a003f9784b7d", + "builtin-baseline": "3207386cc93121b907a8c5498a43b7a312f4f55d", "dependencies": [ "physfs", "sdl2", From 0ff855680e4308cc5dfe7fc4d27870dee011ae11 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:17:30 -0400 Subject: [PATCH 3/8] Update Vulkan SDK / headers to 1.3.296 --- .github/workflows/CI_windows.yml | 4 ++-- configure_mac.cmake | 6 +++--- docker/ubuntu-22.04/Dockerfile | 2 +- docker/ubuntu-24.04/Dockerfile | 12 ++++++------ lib/ivis_opengl/CMakeLists.txt | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CI_windows.yml b/.github/workflows/CI_windows.yml index 73f683310f0..48d2d6d6a99 100644 --- a/.github/workflows/CI_windows.yml +++ b/.github/workflows/CI_windows.yml @@ -313,8 +313,8 @@ jobs: Write-Host "Current value of env:VULKAN_SDK:${env:VULKAN_SDK}" - $VULKAN_DL_URL = "https://sdk.lunarg.com/sdk/download/1.3.268.0/windows/VulkanSDK-1.3.268.0-Installer.exe?Human=true" - $VULKAN_DL_SHA256 = "8459ef49bd06b697115ddd3d97c9aec729e849cd775f5be70897718a9b3b9db5" + $VULKAN_DL_URL = "https://sdk.lunarg.com/sdk/download/1.3.296.0/windows/VulkanSDK-1.3.296.0-Installer.exe?Human=true" + $VULKAN_DL_SHA256 = "acb4ae0786fd3e558f8b3c36cc3eba91638984217ba8a6795ec64d2f9ffd8c4b" $VK_DL_BASEDIR = "${{ github.workspace }}\dl" $VK_DL_PATH = "${VK_DL_BASEDIR}\vulkan.exe" diff --git a/configure_mac.cmake b/configure_mac.cmake index a3f1f508c07..1d8a38b1bd5 100644 --- a/configure_mac.cmake +++ b/configure_mac.cmake @@ -14,10 +14,10 @@ cmake_minimum_required(VERSION 3.5...3.30) set(MIN_SUPPORTED_MACOSX_DEPLOYMENT_TARGET "10.12") # Vulkan SDK -set(VULKAN_SDK_VERSION "1.3.268.1") -set(VULKAN_SDK_DL_FILENAME "vulkansdk-macos-${VULKAN_SDK_VERSION}.dmg") +set(VULKAN_SDK_VERSION "1.3.296.0") +set(VULKAN_SDK_DL_FILENAME "vulkansdk-macos-${VULKAN_SDK_VERSION}.zip") set(VULKAN_SDK_DL_URL "https://sdk.lunarg.com/sdk/download/${VULKAN_SDK_VERSION}/mac/${VULKAN_SDK_DL_FILENAME}?Human=true") -set(VULKAN_SDK_DL_SHA256 "900c019ffac72564d7c4e9e52dd08ef7d4eb2b4425084fd4d2c3e35b36958646") +set(VULKAN_SDK_DL_SHA256 "393fd11f65a4001f12fd34fdd009c38045220ca3f735bc686d97822152b0f33c") ######################################################## diff --git a/docker/ubuntu-22.04/Dockerfile b/docker/ubuntu-22.04/Dockerfile index 0d6a70c55b9..155b3dd30d9 100644 --- a/docker/ubuntu-22.04/Dockerfile +++ b/docker/ubuntu-22.04/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get -u update \ # Install Vulkan SDK ADD https://packages.lunarg.com/lunarg-signing-key-pub.asc /tmp -ADD https://packages.lunarg.com/vulkan/1.3.268/lunarg-vulkan-1.3.268-jammy.list /etc/apt/sources.list.d +ADD https://packages.lunarg.com/vulkan/1.3.296/lunarg-vulkan-1.3.296-jammy.list /etc/apt/sources.list.d RUN apt-key add /tmp/lunarg-signing-key-pub.asc RUN apt-get -u update \ && DEBIAN_FRONTEND=noninteractive apt-get -y install vulkan-sdk \ diff --git a/docker/ubuntu-24.04/Dockerfile b/docker/ubuntu-24.04/Dockerfile index e99fe152788..8a6791ad487 100644 --- a/docker/ubuntu-24.04/Dockerfile +++ b/docker/ubuntu-24.04/Dockerfile @@ -12,13 +12,13 @@ RUN apt-get -u update \ && rm -rf /var/lib/apt/lists/* # Install Vulkan SDK -ENV VULKANSDK_SHA256 8005e2cf3e89c80cbe1c0d0a259c88248de3257b4fc6fdefb47409edb3e43ecb -ADD "https://sdk.lunarg.com/sdk/download/1.3.283.0/linux/vulkansdk-linux-x86_64-1.3.283.0.tar.xz?Human=true" "/tmp" -RUN echo "$VULKANSDK_SHA256 /tmp/vulkansdk-linux-x86_64-1.3.283.0.tar.xz" | sha256sum -c \ +ENV VULKANSDK_SHA256 79b0a1593dadc46180526250836f3e53688a9a5fb42a0e5859eb72316dc4d53e +ADD "https://sdk.lunarg.com/sdk/download/1.3.296.0/linux/vulkansdk-linux-x86_64-1.3.296.0.tar.xz?Human=true" "/tmp" +RUN echo "$VULKANSDK_SHA256 /tmp/vulkansdk-linux-x86_64-1.3.296.0.tar.xz" | sha256sum -c \ && mkdir /vulkan \ - && tar -C /vulkan -xf /tmp/vulkansdk-linux-x86_64-1.3.283.0.tar.xz \ - && rm /tmp/vulkansdk-linux-x86_64-1.3.283.0.tar.xz -ENV VULKAN_SDK="/vulkan/1.3.283.0/x86_64" + && tar -C /vulkan -xf /tmp/vulkansdk-linux-x86_64-1.3.296.0.tar.xz \ + && rm /tmp/vulkansdk-linux-x86_64-1.3.296.0.tar.xz +ENV VULKAN_SDK="/vulkan/1.3.296.0/x86_64" ENV PATH="$PATH:$VULKAN_SDK/bin" # Defines arguments which can be passed during build time. diff --git a/lib/ivis_opengl/CMakeLists.txt b/lib/ivis_opengl/CMakeLists.txt index 02ce6baea78..ea2d3429016 100644 --- a/lib/ivis_opengl/CMakeLists.txt +++ b/lib/ivis_opengl/CMakeLists.txt @@ -125,7 +125,7 @@ endif() if(WZ_ENABLE_BACKEND_VULKAN) find_package(VulkanHeaders 154) # minimum supported version of the Vulkan headers is 154 - set(_vulkanheaders_dl_gittag "vulkan-sdk-1.3.268.0") + set(_vulkanheaders_dl_gittag "vulkan-sdk-1.3.296.0") if((NOT VulkanHeaders_FOUND AND NOT ${CMAKE_VERSION} VERSION_LESS "3.11.0") AND (NOT WZ_DISABLE_FETCHCONTENT_GIT_CLONE)) # Fetch newer Vulkan headers (using FetchContent, which requires CMake 3.11+) include(FetchContent) From b0c7a5043dec7bde0012fd80dcaa958450eb914b Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 15 Oct 2024 13:39:30 -0400 Subject: [PATCH 4/8] [macOS] Fix FetchPrebuilt.cmake to support Vulkan SDK zip --- platforms/macos/cmake/FetchPrebuilt.cmake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/platforms/macos/cmake/FetchPrebuilt.cmake b/platforms/macos/cmake/FetchPrebuilt.cmake index 12ba816569c..aa295660600 100644 --- a/platforms/macos/cmake/FetchPrebuilt.cmake +++ b/platforms/macos/cmake/FetchPrebuilt.cmake @@ -287,13 +287,14 @@ function(ExtractFile filename directory) # Analyze what came out of the tar file: # - message(STATUS "extracting... [analysis]") - file(GLOB contents "${ut_dir}/*") - list(REMOVE_ITEM contents "${ut_dir}/.DS_Store") - list(LENGTH contents n) - if(NOT n EQUAL 1 OR NOT IS_DIRECTORY "${contents}") - set(contents "${ut_dir}") - endif() + set(contents "${ut_dir}") + # message(STATUS "extracting... [analysis]") + # file(GLOB contents "${ut_dir}/*") + # list(REMOVE_ITEM contents "${ut_dir}/.DS_Store") + # list(LENGTH contents n) + # if(NOT n EQUAL 1 OR NOT IS_DIRECTORY "${contents}") + # set(contents "${ut_dir}") + # endif() # Move "the one" directory to the final directory: # From 27ef53968579f8aa3164294a510391c24d281a1b Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:23:49 -0400 Subject: [PATCH 5/8] imdload: Check max polygons limit --- lib/ivis_opengl/imdload.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ivis_opengl/imdload.cpp b/lib/ivis_opengl/imdload.cpp index d73123d65d9..b5eb88a7424 100644 --- a/lib/ivis_opengl/imdload.cpp +++ b/lib/ivis_opengl/imdload.cpp @@ -46,6 +46,13 @@ #include using Vector4f = glm::vec4; +// The maximum polygons for a model is influenced by several factors: +// 1. The vertexCount *must* be less than UINT16_MAX (65535), because this special vertex index value is treated as restarting the assembly of primitives in some cases (example: Vulkan on MoltenVK) - NOTE: we currently use index_type::u16 for our model VBO_INDEX buffers +// 2. Given how the game world and models are displayed, using a very large number of polygons is effectively a waste +//#define MAX_PIE_POLYGONS 21844 // floor((UINT16_MAX-1) / 3) +#define MAX_PIE_POLYGONS 8192 +static_assert(MAX_PIE_POLYGONS <= ((UINT16_MAX-1) / 3), "MAX_PIE_POLYGONS must not currently exceed floor((UINT16_MAX-1) / 3)"); + // Scale animation numbers from int to float #define INT_SCALE 1000 @@ -1452,6 +1459,7 @@ static std::unique_ptr _imd_load_level(const WzString &filename, cons } ASSERT_OR_RETURN(nullptr, strcmp(buffer, "POLYGONS") == 0, "Expecting 'POLYGONS' directive, got: %s", buffer); + ASSERT_OR_RETURN(nullptr, npolys <= MAX_PIE_POLYGONS, "'POLYGONS' directive count (%" PRIu32") exceeds maximum supported (%" PRIu32")", npolys, MAX_PIE_POLYGONS); s.polys.resize(npolys); if (!_imd_load_polys(filename, &lineToProcess.pNextLineBegin, FileDataEnd, &s, pieVersion, npoints)) From 30a87e384191cece18eb58afa014cb1d04a9f90f Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:26:18 -0400 Subject: [PATCH 6/8] [Vulkan] Silence warning on macOS --- lib/ivis_opengl/gfx_api_vk.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ivis_opengl/gfx_api_vk.cpp b/lib/ivis_opengl/gfx_api_vk.cpp index 1405128de0a..b03dcd00720 100644 --- a/lib/ivis_opengl/gfx_api_vk.cpp +++ b/lib/ivis_opengl/gfx_api_vk.cpp @@ -1687,8 +1687,20 @@ VkPSO::VkPSO(vk::Device _dev, .setScissorCount(1); ASSERT(viewportState.viewportCount <= limits.maxViewports, "viewportCount (%" PRIu32") exceeds limits.maxViewports (%" PRIu32")", viewportState.viewportCount, limits.maxViewports); - const auto iassembly = vk::PipelineInputAssemblyStateCreateInfo() + auto iassembly = vk::PipelineInputAssemblyStateCreateInfo() .setTopology(to_vk(primitive)); +#ifdef WZ_OS_MAC + // Silence MoltenVK warning: "Metal does not support disabling primitive restart" + switch (primitive) + { + case gfx_api::primitive_type::line_strip: + case gfx_api::primitive_type::triangle_strip: + iassembly.setPrimitiveRestartEnable(vk::True); + break; + default: + break; + } +#endif uint32_t buffer_id = 0; std::vector buffers; From 3bbaa0d78274e73cc95ce90e5169a15dd25ba9bb Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:33:09 -0400 Subject: [PATCH 7/8] [macOS] Workaround for changing vsync at runtime in Vulkan mode --- lib/framework/wzapp.h | 1 + lib/sdl/main_sdl.cpp | 33 +++++++++++++++++++++++++++++++++ src/frontend.cpp | 1 + 3 files changed, 35 insertions(+) diff --git a/lib/framework/wzapp.h b/lib/framework/wzapp.h index 7e330b536b1..f02fa9ba6fb 100644 --- a/lib/framework/wzapp.h +++ b/lib/framework/wzapp.h @@ -91,6 +91,7 @@ bool wzChangeWindowMode(WINDOW_MODE mode, bool silent = false); WINDOW_MODE wzGetCurrentWindowMode(); bool wzIsFullscreen(); void wzSetWindowIsResizable(bool resizable); +void wzPostChangedSwapInterval(); bool wzIsWindowResizable(); bool wzChangeDisplayScale(unsigned int displayScale); bool wzChangeCursorScale(unsigned int cursorScale); diff --git a/lib/sdl/main_sdl.cpp b/lib/sdl/main_sdl.cpp index d5d0880dcb0..4f9ff78ad20 100644 --- a/lib/sdl/main_sdl.cpp +++ b/lib/sdl/main_sdl.cpp @@ -790,6 +790,39 @@ WINDOW_MODE wzGetToggleFullscreenMode() return altEnterToggleFullscreenMode; } +void wzPostChangedSwapInterval() +{ +#ifdef WZ_OS_MAC + if (WZbackend == video_backend::vulkan) + { + // If using Vulkan backend (and, thus, MoltenVK), + // Workaround MoltenVK issue (doesn't seem to fully accept the recreated swapchain until window resize event?) + // - Trigger a window resize event (regardless of current window mode) + auto currentMode = wzGetCurrentWindowMode(); + switch (currentMode) + { + case WINDOW_MODE::desktop_fullscreen: + case WINDOW_MODE::fullscreen: + if (wzChangeWindowMode(WINDOW_MODE::windowed)) + { + wzChangeWindowMode(currentMode); + } + break; + case WINDOW_MODE::windowed: + int currWidth = 0, currHeight = 0; + SDL_GetWindowSize(WZwindow, &currWidth, &currHeight); + + // set one bigger than current size + SDL_SetWindowSize(WZwindow, currWidth+1, currHeight+1); + + // restore the old windowed size + SDL_SetWindowSize(WZwindow, currWidth, currHeight); + break; + } + } +#endif +} + bool wzChangeWindowMode(WINDOW_MODE mode, bool silent) { auto previousMode = wzGetCurrentWindowMode(); diff --git a/src/frontend.cpp b/src/frontend.cpp index 067fa9fd7fd..99feb92db89 100644 --- a/src/frontend.cpp +++ b/src/frontend.cpp @@ -2221,6 +2221,7 @@ void seqVsyncMode() { // succeeded changing vsync mode saveCurrentSwapMode(currentVsyncMode); + wzPostChangedSwapInterval(); } } From 799b61a9141701e574771138618709ab64e5fcbc Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:39:38 -0400 Subject: [PATCH 8/8] [Vulkan] Add support for VK_EXT_layer_settings Set MoltenVK layer settings to workaround an issue --- lib/ivis_opengl/gfx_api_vk.cpp | 56 ++++++++++++++++++++++++++++++++-- lib/ivis_opengl/gfx_api_vk.h | 3 ++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/lib/ivis_opengl/gfx_api_vk.cpp b/lib/ivis_opengl/gfx_api_vk.cpp index b03dcd00720..3b713d3480a 100644 --- a/lib/ivis_opengl/gfx_api_vk.cpp +++ b/lib/ivis_opengl/gfx_api_vk.cpp @@ -79,9 +79,12 @@ const size_t MAX_FRAMES_IN_FLIGHT = 2; // Vulkan version where extension is promoted to core; extension name #define VK_NOT_PROMOTED_TO_CORE_YET 0 const std::vector> optionalInstanceExtensions = { - { VK_MAKE_VERSION(1, 1, 0) , VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME }, // used for Vulkan info output + { VK_MAKE_VERSION(1, 1, 0) , VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME } // used for Vulkan info output #if defined(VK_KHR_portability_enumeration) - { VK_NOT_PROMOTED_TO_CORE_YET , VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME} + , { VK_NOT_PROMOTED_TO_CORE_YET , VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME} +#endif +#if defined(VK_EXT_layer_settings) + , { VK_NOT_PROMOTED_TO_CORE_YET , VK_EXT_LAYER_SETTINGS_EXTENSION_NAME} #endif }; @@ -159,6 +162,15 @@ const std::vector> vulk , {_vkl_env_text("DISABLE_GAMEPP_LAYER"), _vkl_env_text("1"), true} // Gamepp }; +#if defined(VK_EXT_layer_settings) +// layer settings +// - MoltenVK: +const VkBool32 setting_mvk_config_use_metal_argument_buffers = VK_FALSE; // Disable MoltenVK Metal argument buffers (currently triggers Metal API Validation asserts) +const std::vector vulkan_mvk_layer_settings = { + {"MoltenVK", "MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", vk::LayerSettingTypeEXT::eBool32, 1, &setting_mvk_config_use_metal_argument_buffers} +}; +#endif + #if defined(WZ_DEBUG_GFX_API_LEAKS) static std::unordered_set debugLiveTextures; #endif @@ -3363,6 +3375,30 @@ bool VkRoot::setupDebugReportCallbacks(const std::vector& extension return true; } +#if defined(VK_EXT_layer_settings) +std::vector VkRoot::initLayerSettings() +{ + std::vector result; +#ifdef WZ_OS_MAC + // MoltenVK layer settings + for (const auto &it : vulkan_mvk_layer_settings) + { + if (getenv(it.pSettingName) == nullptr) + { + result.push_back(it); + debug(LOG_3D, "Setting [%s]:%s", it.pLayerName, it.pSettingName); + } + else + { + // environment variable is already set - log a warning, but allow it to take precedence + debug(LOG_INFO, "Warning: Environment variable %s is already set, and will *not* be overridden", it.pSettingName); + } + } +#endif + return result; +} +#endif + // Attempts to create a Vulkan instance (vk::Instance) with the specified extensions and layers // If successful, sets the following variable in VkRoot: // - inst (vk::Instance) @@ -3431,6 +3467,22 @@ bool VkRoot::createVulkanInstance(uint32_t apiVersion, const std::vector layerSettings; + vk::LayerSettingsCreateInfoEXT layerSettingsCreateInfo; + bool requesting_layer_settings_extension = std::any_of(extensions.begin(), extensions.end(), + [](const char *extensionName) { return (strcmp(extensionName, VK_EXT_LAYER_SETTINGS_EXTENSION_NAME) == 0);}); + if (requesting_layer_settings_extension) + { + layerSettings = initLayerSettings(); + layerSettingsCreateInfo.settingCount = static_cast(layerSettings.size()); + layerSettingsCreateInfo.pSettings = layerSettings.data(); + layerSettingsCreateInfo.pNext = instanceCreateInfo.pNext; + instanceCreateInfo.pNext = &layerSettingsCreateInfo; + debug(LOG_3D, "Using layer settings, settingCount: %" PRIu32, layerSettingsCreateInfo.settingCount); + } +#endif + VkResult result = _vkCreateInstance(reinterpret_cast(&instanceCreateInfo), nullptr, reinterpret_cast(&inst)); if (result != VK_SUCCESS) { diff --git a/lib/ivis_opengl/gfx_api_vk.h b/lib/ivis_opengl/gfx_api_vk.h index fa57a4b1b30..d1319fbe95e 100644 --- a/lib/ivis_opengl/gfx_api_vk.h +++ b/lib/ivis_opengl/gfx_api_vk.h @@ -771,6 +771,9 @@ struct VkRoot final : gfx_api::context bool getSupportedInstanceExtensions(std::vector &output, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr); bool findSupportedInstanceExtensions(std::vector extensionsToFind, std::vector &output, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr); +#if defined(VK_EXT_layer_settings) + std::vector initLayerSettings(); +#endif bool createVulkanInstance(uint32_t apiVersion, const std::vector& extensions, const std::vector& layers, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr); bool setupDebugUtilsCallbacks(const std::vector& extensions, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr); bool setupDebugReportCallbacks(const std::vector& extensions, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr);