Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency and Vulkan SDK updates #4095

Merged
merged 8 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/CI_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions .sentrynative
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions configure_mac.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")

########################################################

Expand Down
2 changes: 1 addition & 1 deletion docker/ubuntu-22.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
12 changes: 6 additions & 6 deletions docker/ubuntu-24.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions lib/framework/wzapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/ivis_opengl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
70 changes: 67 additions & 3 deletions lib/ivis_opengl/gfx_api_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::tuple<uint32_t, const char*>> 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
};

Expand Down Expand Up @@ -159,6 +162,15 @@ const std::vector<std::tuple<_vkl_env_text_type, _vkl_env_text_type, bool>> 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<vk::LayerSettingEXT> 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<const VkTexture*> debugLiveTextures;
#endif
Expand Down Expand Up @@ -1687,8 +1699,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<vk::VertexInputBindingDescription> buffers;
Expand Down Expand Up @@ -3351,6 +3375,30 @@ bool VkRoot::setupDebugReportCallbacks(const std::vector<const char*>& extension
return true;
}

#if defined(VK_EXT_layer_settings)
std::vector<vk::LayerSettingEXT> VkRoot::initLayerSettings()
{
std::vector<vk::LayerSettingEXT> 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)
Expand Down Expand Up @@ -3419,6 +3467,22 @@ bool VkRoot::createVulkanInstance(uint32_t apiVersion, const std::vector<const c
});
debug(LOG_3D, "Using instance extensions: %s", instanceExtensionsAsString.c_str());

#if defined(VK_EXT_layer_settings)
std::vector<vk::LayerSettingEXT> 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<uint32_t>(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<const VkInstanceCreateInfo*>(&instanceCreateInfo), nullptr, reinterpret_cast<VkInstance*>(&inst));
if (result != VK_SUCCESS)
{
Expand Down
3 changes: 3 additions & 0 deletions lib/ivis_opengl/gfx_api_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,9 @@ struct VkRoot final : gfx_api::context

bool getSupportedInstanceExtensions(std::vector<VkExtensionProperties> &output, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr);
bool findSupportedInstanceExtensions(std::vector<const char*> extensionsToFind, std::vector<const char*> &output, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr);
#if defined(VK_EXT_layer_settings)
std::vector<vk::LayerSettingEXT> initLayerSettings();
#endif
bool createVulkanInstance(uint32_t apiVersion, const std::vector<const char*>& extensions, const std::vector<const char*>& layers, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr);
bool setupDebugUtilsCallbacks(const std::vector<const char*>& extensions, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr);
bool setupDebugReportCallbacks(const std::vector<const char*>& extensions, PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr);
Expand Down
8 changes: 8 additions & 0 deletions lib/ivis_opengl/imdload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
#include <glm/vec4.hpp>
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

Expand Down Expand Up @@ -1452,6 +1459,7 @@ static std::unique_ptr<iIMDShape> _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))
Expand Down
33 changes: 33 additions & 0 deletions lib/sdl/main_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 8 additions & 7 deletions platforms/macos/cmake/FetchPrebuilt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down
1 change: 1 addition & 0 deletions src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,7 @@ void seqVsyncMode()
{
// succeeded changing vsync mode
saveCurrentSwapMode(currentVsyncMode);
wzPostChangedSwapInterval();
}
}

Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "warzone2100",
"version-string": "master-branch",
"builtin-baseline": "e590c2b30c08caf1dd8d612ec602a003f9784b7d",
"builtin-baseline": "3207386cc93121b907a8c5498a43b7a312f4f55d",
"dependencies": [
"physfs",
"sdl2",
Expand Down
Loading