Skip to content

Commit 9985fc7

Browse files
committed
Fix Swapchain issue working with wayland
1 parent 9a80e97 commit 9985fc7

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

.github/workflows/job-test-linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ jobs:
2424
uses: actions/download-artifact@v4
2525
with:
2626
name: Build-linux-${{ inputs.configuration }}
27+
path: Result.Linux.x64.${{ inputs.configuration }}
2728

2829
- name: Update access permission of ZEngineTests
29-
run: chmod +x ./tests/ZEngineTests
30+
run: chmod +x ./Result.Linux.x64.${{ inputs.configuration }}/tests/ZEngineTests
3031

3132
- name: Run Tests
3233
env:

.github/workflows/job-test-macOS.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@ jobs:
2020
- name: Checkout repository
2121
uses: actions/checkout@v4
2222

23-
- name: Install Dependencies
24-
run: brew install vulkan-headers vulkan-loader assimp spirv-headers spirv-tools spirv-cross glslang glfw glew yaml-cpp spdlog googletest fmt
25-
2623
- name: Download Artifacts
2724
uses: actions/download-artifact@v4
2825
with:
2926
name: Build-macOS-${{ inputs.architecture }}-${{ inputs.configuration }}
3027

3128
- name: Update access permission of ZEngineTests
32-
run: chmod +x ./tests/ZEngineTests
29+
run: chmod +x ./Result.Darwin.${{inputs.architecture}}.${{ inputs.configuration }}/tests/ZEngineTests
3330

3431
- name: Run Tests
3532
env:

.github/workflows/job-test-windows.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919

2020
- name: Download All Artifacts
2121
uses: actions/download-artifact@v4
22+
with:
23+
path: Result.Windows.x64.MultiConfig
24+
name: Build-Windows-x64-${{ inputs.configuration }}
2225

2326
- name: Run Tests
2427
shell: pwsh

Scripts/RunTests.ps1

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,20 @@ function RunTests {
6363
[string]$Configuration
6464
)
6565

66-
[string]$testExecutablePath = "tests/ZEngineTests"
67-
68-
if ($IsWindows) {
69-
$testExecutablePath = "tests/ZEngineTests.exe"
66+
[string]$testExecutablePath = ""
67+
switch ($SystemName) {
68+
"Windows" {
69+
$testExecutablePath = [IO.Path]::Combine($OutputBuildDirectory, "tests", "ZEngineTests.exe")
70+
}
71+
"Darwin" {
72+
$testExecutablePath = Join-Path $OutputBuildDirectory -ChildPath "tests/ZEngineTests"
73+
}
74+
"Linux" {
75+
$testExecutablePath = Join-Path $OutputBuildDirectory -ChildPath "tests/ZEngineTests"
76+
}
77+
Default {
78+
throw 'This system is not supported'
79+
}
7080
}
7181

7282
# Check if the executable exists

ZEngine/ZEngine/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ endif()
7575

7676
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
7777
target_link_libraries(zEngineLib PUBLIC stdc++fs)
78-
target_compile_definitions(zEngineLib PUBLIC GLFW_EXPOSE_NATIVE_X11)
78+
target_compile_definitions(zEngineLib PUBLIC GLFW_EXPOSE_NATIVE_WAYLAND)
7979
endif ()

ZEngine/ZEngine/Hardwares/VulkanDevice.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,13 +1060,10 @@ namespace ZEngine::Hardwares
10601060
{
10611061
VkSurfaceCapabilitiesKHR capabilities{};
10621062
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(PhysicalDevice, Surface, &capabilities);
1063-
if (capabilities.currentExtent.width != std::numeric_limits<uint32_t>::max())
1064-
{
1065-
SwapchainImageWidth = capabilities.currentExtent.width;
1066-
SwapchainImageHeight = capabilities.currentExtent.height;
1067-
}
1063+
SwapchainImageWidth = std::clamp(CurrentWindow->GetWidth(), capabilities.minImageExtent.width, capabilities.maxImageExtent.width);
1064+
SwapchainImageHeight = std::clamp(CurrentWindow->GetHeight(), capabilities.minImageExtent.height, capabilities.maxImageExtent.height);
10681065

1069-
auto min_image_count = std::clamp(capabilities.minImageCount, capabilities.minImageCount, capabilities.maxImageCount == 0 ? std::numeric_limits<decltype(capabilities.maxImageCount)>::max() : capabilities.maxImageCount);
1066+
auto min_image_count = SwapchainImageCount < capabilities.minImageCount ? capabilities.minImageCount : SwapchainImageCount;
10701067
VkSwapchainCreateInfoKHR swapchain_create_info = {
10711068
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, .pNext = nullptr, .surface = Surface, .minImageCount = min_image_count, .imageFormat = SurfaceFormat.format, .imageColorSpace = SurfaceFormat.colorSpace, .imageExtent = VkExtent2D{.width = SwapchainImageWidth, .height = SwapchainImageHeight},
10721069
.imageArrayLayers = 1, .imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, .preTransform = capabilities.currentTransform, .compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, .presentMode = PresentMode, .clipped = VK_TRUE

dependencies.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ FetchContent_Declare(
3333
glfw3
3434
GIT_REPOSITORY https://github.com/glfw/glfw.git
3535
GIT_SHALLOW TRUE
36-
GIT_TAG 3.3.10
36+
GIT_TAG 3.4
3737
)
3838

3939
FetchContent_Declare(

0 commit comments

Comments
 (0)