From 0832cd0fc7dd270b6eb42d2e64bf6fa67ceb910d Mon Sep 17 00:00:00 2001 From: Richard Ward Date: Thu, 18 Dec 2025 21:21:12 +0000 Subject: [PATCH] various fixes --- .github/workflows/release.yml | 11 ++++++++--- CMakeLists.txt | 1 + scripts/setup_vendor_dependencies.py | 8 +++++++- src/app/sdl3_app.hpp | 6 ++++-- src/app/sdl3_app_core.cpp | 5 ++--- src/app/sdl3_app_device.cpp | 14 ++++++-------- src/app/sdl3_app_swapchain.cpp | 4 ++-- 7 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f571eb4..bf26074 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,9 +47,10 @@ jobs: sudo apt-get update sudo apt-get install -y \ libwayland-dev \ - libwayland-egl1-mesa-dev \ libegl-dev \ - libxkbcommon-dev + libxkbcommon-dev \ + libxrandr-dev \ + cmake - name: Set up Python uses: actions/setup-python@v5 @@ -59,6 +60,9 @@ jobs: - name: Install Conan run: pip install 'conan>=2' + - name: Detect Conan profile + run: conan profile detect + - name: Vendor SDL3/Vulkan run: python scripts/setup_vendor_dependencies.py @@ -66,7 +70,7 @@ jobs: shell: bash run: | if [ -d "$BUILD_DIR" ]; then rm -rf "$BUILD_DIR"; fi - conan install . --install-folder "$BUILD_DIR" --build=missing + conan install . --output-folder "$BUILD_DIR" --build=missing -c tools.system.package_manager:mode=install - name: Configure CMake shell: bash @@ -118,6 +122,7 @@ jobs: PY - name: Publish GitHub release asset + if: github.ref != 'refs/tags/local' uses: softprops/action-gh-release@v1 with: files: release/${{ env.ZIP_NAME }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 148d750..b4c0026 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ if(BUILD_SDL3_APP) src/app/sdl3_app_render.cpp src/script/cube_script.cpp ) + target_include_directories(sdl3_app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") target_link_libraries(sdl3_app PRIVATE SDL3::SDL3 Vulkan::Vulkan lua::lua) target_compile_definitions(sdl3_app PRIVATE SDL_MAIN_HANDLED) diff --git a/scripts/setup_vendor_dependencies.py b/scripts/setup_vendor_dependencies.py index 8df5e93..cc8a0ed 100644 --- a/scripts/setup_vendor_dependencies.py +++ b/scripts/setup_vendor_dependencies.py @@ -65,7 +65,13 @@ def main(): ["-DSDL_SHARED=OFF", "-DSDL_STATIC=ON", "-DSDL_TEST=OFF", "-DBUILD_SHARED_LIBS=OFF"], ) - fetch_repo("Vulkan-Loader", "https://github.com/KhronosGroup/Vulkan-Loader.git", "sdk-1.3.275") + fetch_repo("Vulkan-Loader", "https://github.com/KhronosGroup/Vulkan-Loader.git", "sdk-1.3.261.1") + fetch_repo("Vulkan-Headers", "https://github.com/KhronosGroup/Vulkan-Headers.git", "sdk-1.3.261.1") + build_and_install( + VENDOR_DIR / "Vulkan-Headers", + VENDOR_DIR / "build-vulkan-headers", + ) + build_and_install( VENDOR_DIR / "Vulkan-Loader", VENDOR_DIR / "build-vulkan-loader", diff --git a/src/app/sdl3_app.hpp b/src/app/sdl3_app.hpp index fadf220..fcb8cc9 100644 --- a/src/app/sdl3_app.hpp +++ b/src/app/sdl3_app.hpp @@ -22,6 +22,8 @@ namespace sdl3cpp::app { +namespace script = sdl3cpp::script; + constexpr uint32_t kWidth = 1024; constexpr uint32_t kHeight = 768; @@ -120,10 +122,10 @@ private: VkDeviceMemory indexBufferMemory_ = VK_NULL_HANDLE; VkSemaphore imageAvailableSemaphore_ = VK_NULL_HANDLE; VkSemaphore renderFinishedSemaphore_ = VK_NULL_HANDLE; - CubeScript cubeScript_; + script::CubeScript cubeScript_; std::vector vertices_; std::vector indices_; - std::unordered_map shaderPathMap_; + std::unordered_map shaderPathMap_; std::unordered_map graphicsPipelines_; std::string defaultShaderKey_; VkFence inFlightFence_ = VK_NULL_HANDLE; diff --git a/src/app/sdl3_app_core.cpp b/src/app/sdl3_app_core.cpp index dd5f599..6721f63 100644 --- a/src/app/sdl3_app_core.cpp +++ b/src/app/sdl3_app_core.cpp @@ -32,8 +32,7 @@ void Sdl3App::InitSDL() { throw std::runtime_error(std::string("SDL_Init failed: ") + SDL_GetError()); } SDL_Vulkan_LoadLibrary(nullptr); - window_ = SDL_CreateWindow("SDL3 Vulkan Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - kWidth, kHeight, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE); + window_ = SDL_CreateWindow("SDL3 Vulkan Demo", kWidth, kHeight, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE); if (!window_) { throw std::runtime_error(std::string("SDL_CreateWindow failed: ") + SDL_GetError()); } @@ -65,7 +64,7 @@ void Sdl3App::MainLoop() { while (SDL_PollEvent(&event)) { if (event.type == SDL_EVENT_QUIT) { running = false; - } else if (event.type == SDL_EVENT_WINDOW_SIZE_CHANGED) { + } else if (event.type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) { framebufferResized_ = true; } } diff --git a/src/app/sdl3_app_device.cpp b/src/app/sdl3_app_device.cpp index bc4ee7c..ec8d664 100644 --- a/src/app/sdl3_app_device.cpp +++ b/src/app/sdl3_app_device.cpp @@ -16,20 +16,18 @@ void Sdl3App::CreateInstance() { appInfo.apiVersion = VK_API_VERSION_1_2; uint32_t extensionCount = 0; - if (!SDL_Vulkan_GetInstanceExtensions(window_, &extensionCount, nullptr)) { + const char* const* extensions = SDL_Vulkan_GetInstanceExtensions(&extensionCount); + if (!extensions) { throw std::runtime_error("Failed to query Vulkan extensions from SDL"); } - std::vector extensions(extensionCount); - if (!SDL_Vulkan_GetInstanceExtensions(window_, &extensionCount, extensions.data())) { - throw std::runtime_error("Failed to store Vulkan extensions from SDL"); - } + std::vector extensionList(extensions, extensions + extensionCount); VkInstanceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; createInfo.pApplicationInfo = &appInfo; - createInfo.enabledExtensionCount = static_cast(extensions.size()); - createInfo.ppEnabledExtensionNames = extensions.data(); + createInfo.enabledExtensionCount = static_cast(extensionList.size()); + createInfo.ppEnabledExtensionNames = extensionList.data(); if (vkCreateInstance(&createInfo, nullptr, &instance_) != VK_SUCCESS) { throw std::runtime_error("Failed to create Vulkan instance"); @@ -37,7 +35,7 @@ void Sdl3App::CreateInstance() { } void Sdl3App::CreateSurface() { - if (!SDL_Vulkan_CreateSurface(window_, instance_, &surface_)) { + if (!SDL_Vulkan_CreateSurface(window_, instance_, nullptr, &surface_)) { throw std::runtime_error("Failed to create Vulkan surface"); } } diff --git a/src/app/sdl3_app_swapchain.cpp b/src/app/sdl3_app_swapchain.cpp index 533c1dd..29996f3 100644 --- a/src/app/sdl3_app_swapchain.cpp +++ b/src/app/sdl3_app_swapchain.cpp @@ -143,7 +143,7 @@ void Sdl3App::RecreateSwapChain() { int width = 0; int height = 0; while (width == 0 || height == 0) { - SDL_Vulkan_GetDrawableSize(window_, &width, &height); + SDL_GetWindowSize(window_, &width, &height); SDL_Event event; SDL_WaitEvent(&event); } @@ -179,7 +179,7 @@ VkPresentModeKHR Sdl3App::ChooseSwapPresentMode(const std::vector(std::clamp(width, static_cast(capabilities.minImageExtent.width), static_cast(capabilities.maxImageExtent.width))),