From 5e27de3e18e6274f15a2f3d665d7023b5ef6826e Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Feb 2024 21:24:04 +0100 Subject: [PATCH 01/39] fix compilation on linux --- examples/engine/triangle/src/main.cpp | 2 +- examples/engine/triangle/xmake.lua | 56 +++++------ modules/stormkit/Core/Utils/DynamicLoader.mpp | 1 - modules/stormkit/Log/Logger.mpp | 2 +- modules/stormkit/Log/Severity.mpp | 32 +++---- src/Core/posix/DynamicLoader.mpp | 6 +- src/Core/win32/DynamicLoader.mpp | 6 +- src/Engine/Renderer.cpp | 13 ++- src/Engine/Renderer/Renderer.cpp | 94 ------------------- src/Wsi/linux/common/XKB.mpp | 2 +- src/Wsi/linux/wayland/WindowImpl.mpp | 9 +- src/Wsi/linux/x11/WindowImpl.mpp | 24 +++-- xmake.lua | 13 --- xmake/frozen.lua | 13 +++ 14 files changed, 103 insertions(+), 170 deletions(-) delete mode 100644 src/Engine/Renderer/Renderer.cpp create mode 100644 xmake/frozen.lua diff --git a/examples/engine/triangle/src/main.cpp b/examples/engine/triangle/src/main.cpp index d96af7ec..b5d1fb29 100644 --- a/examples/engine/triangle/src/main.cpp +++ b/examples/engine/triangle/src/main.cpp @@ -23,7 +23,7 @@ auto main(std::span args) -> int { // core::setupSignalHandler(); auto logger = log::Logger::createLoggerInstance(); - logger.ilog("Using StormKit {}.{}.{} (branch: {}, commit_hash: {}), built with {}", + logger.ilog("Using StormKit {}.{}.{}\n branch: {}\n commit_hash: {}\n built with {}", core::STORMKIT_MAJOR_VERSION, core::STORMKIT_MINOR_VERSION, core::STORMKIT_PATCH_VERSION, diff --git a/examples/engine/triangle/xmake.lua b/examples/engine/triangle/xmake.lua index cbde4e73..e04fc6f2 100644 --- a/examples/engine/triangle/xmake.lua +++ b/examples/engine/triangle/xmake.lua @@ -1,28 +1,28 @@ --- add_requires("nzsl", { configs = { fs_watcher = false } }) --- --- target("triangle") --- do --- set_kind("binary") --- set_languages("cxxlatest", "clatest") --- --- -- add_rules("@nzsl/compile.shaders") --- add_rules("compile.shaders") --- add_deps("stormkit-core", "stormkit-main", "stormkit-log", "stormkit-wsi", "stormkit-engine") --- --- if is_mode("debug") then --- add_defines("STORMKIT_BUILD_DEBUG") --- add_defines("STORMKIT_ASSERT=1") --- set_suffixname("-d") --- else --- add_defines("STORMKIT_ASSERT=0") --- end --- --- add_files("src/*.cpp") --- add_files("src/*.mpp") --- add_files("shaders/*.nzsl") --- if is_plat("windows") then --- add_files("win32/*.manifest") --- end --- --- set_group("examples/stormkit-engine") --- end +add_requires("nzsl", { configs = { toolchain = "", runtimes = "", fs_watcher = false } }) + +target("triangle") +do + set_kind("binary") + set_languages("cxxlatest", "clatest") + + -- add_rules("@nzsl/compile.shaders") + add_rules("compile.shaders") + add_deps("stormkit-core", "stormkit-main", "stormkit-log", "stormkit-wsi", "stormkit-engine") + + if is_mode("debug") then + add_defines("STORMKIT_BUILD_DEBUG") + add_defines("STORMKIT_ASSERT=1") + set_suffixname("-d") + else + add_defines("STORMKIT_ASSERT=0") + end + + add_files("src/*.cpp") + add_files("src/*.mpp") + add_files("shaders/*.nzsl") + if is_plat("windows") then + add_files("win32/*.manifest") + end + + set_group("examples/stormkit-engine") +end diff --git a/modules/stormkit/Core/Utils/DynamicLoader.mpp b/modules/stormkit/Core/Utils/DynamicLoader.mpp index 01efcbd2..44e9c760 100644 --- a/modules/stormkit/Core/Utils/DynamicLoader.mpp +++ b/modules/stormkit/Core/Utils/DynamicLoader.mpp @@ -12,7 +12,6 @@ export module stormkit.Core:Utils.DynamicLoader; import std; - import :Utils.Assert; import :Utils.Pimpl; diff --git a/modules/stormkit/Log/Logger.mpp b/modules/stormkit/Log/Logger.mpp index 52a75934..3a0d1d80 100644 --- a/modules/stormkit/Log/Logger.mpp +++ b/modules/stormkit/Log/Logger.mpp @@ -147,7 +147,7 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// template - auto Logger::log(Severity severity, + STORMKIT_FORCE_INLINE auto Logger::log(Severity severity, const Module& m, std::string_view format_string, Args&&...param_args) -> void { diff --git a/modules/stormkit/Log/Severity.mpp b/modules/stormkit/Log/Severity.mpp index 6b63305d..e087f28f 100644 --- a/modules/stormkit/Log/Severity.mpp +++ b/modules/stormkit/Log/Severity.mpp @@ -5,6 +5,7 @@ module; #include +#include export module stormkit.Log:Severity; @@ -14,7 +15,6 @@ import frozen; import stormkit.Core; - export { namespace stormkit::log { enum class Severity { @@ -51,23 +51,23 @@ export { //////////////////////////////////////////////////////////////////// namespace stormkit::log { - namespace details { - constexpr auto SEVERITY_TO_STRING = [] { - using namespace std::literals; - - return frozen::make_unordered_map({ - { Severity::Info, "Info"sv }, - { Severity::Warning, "Warning"sv }, - { Severity::Error, "Error"sv }, - { Severity::Fatal, "Fatal"sv }, - { Severity::Debug, "Debug"sv }, - }); - }(); - } // namespace details + namespace details { namespace { + constexpr auto SEVERITY_TO_STRING = [] { + using namespace std::literals; + + return frozen::make_unordered_map({ + { Severity::Info, "Info"sv }, + { Severity::Warning, "Warning"sv }, + { Severity::Error, "Error"sv }, + { Severity::Fatal, "Fatal"sv }, + { Severity::Debug, "Debug"sv }, + }); + }(); + }} // namespace details //////////////////////////////////////// //////////////////////////////////////// - constexpr auto toStringView(Severity severity) noexcept -> std::string_view { + STORMKIT_FORCE_INLINE constexpr auto toStringView(Severity severity) noexcept -> std::string_view { const auto it = details::SEVERITY_TO_STRING.find(severity); core::expects(it != std::ranges::cend(details::SEVERITY_TO_STRING)); @@ -76,7 +76,7 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto toString(Severity severity) -> std::string { + STORMKIT_FORCE_INLINE constexpr auto toString(Severity severity) -> std::string { return std::string { toStringView(severity) }; } } // namespace stormkit::log diff --git a/src/Core/posix/DynamicLoader.mpp b/src/Core/posix/DynamicLoader.mpp index 4d633e56..880661df 100644 --- a/src/Core/posix/DynamicLoader.mpp +++ b/src/Core/posix/DynamicLoader.mpp @@ -27,11 +27,11 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - constexpr DynamicLoaderImpl() noexcept = default; + STORMKIT_FORCE_INLINE constexpr DynamicLoaderImpl() noexcept = default; ///////////////////////////////////// ///////////////////////////////////// - ~DynamicLoaderImpl() noexcept { + STORMKIT_FORCE_INLINE ~DynamicLoaderImpl() noexcept { if (m_library_handle) [[likely]] m_library_handle = nullptr; } @@ -46,7 +46,7 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - DynamicLoaderImpl(DynamicLoaderImpl&& other) noexcept + STORMKIT_FORCE_INLINE DynamicLoaderImpl(DynamicLoaderImpl&& other) noexcept : m_library_handle { std::exchange(other.m_library_handle, nullptr) } {} ///////////////////////////////////// diff --git a/src/Core/win32/DynamicLoader.mpp b/src/Core/win32/DynamicLoader.mpp index 76280824..7d9bfcdc 100644 --- a/src/Core/win32/DynamicLoader.mpp +++ b/src/Core/win32/DynamicLoader.mpp @@ -26,11 +26,11 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - constexpr DynamicLoaderImpl() noexcept = default; + STORMKIT_FORCE_INLINE constexpr DynamicLoaderImpl() noexcept = default; ///////////////////////////////////// ///////////////////////////////////// - ~DynamicLoaderImpl() noexcept { + STORMKIT_FORCE_INLINE ~DynamicLoaderImpl() noexcept { if (m_library_handle) [[likely]] m_library_handle = nullptr; } @@ -45,7 +45,7 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - DynamicLoaderImpl(DynamicLoaderImpl&& other) noexcept + STORMKIT_FORCE_INLINE DynamicLoaderImpl(DynamicLoaderImpl&& other) noexcept : m_library_handle { std::exchange(other.m_library_handle, nullptr) } {} ///////////////////////////////////// diff --git a/src/Engine/Renderer.cpp b/src/Engine/Renderer.cpp index d8231833..300c75f9 100644 --- a/src/Engine/Renderer.cpp +++ b/src/Engine/Renderer.cpp @@ -18,11 +18,22 @@ using namespace std::literals; namespace stormkit::engine { LOGGER("stormkit.Renderer") + ///////////////////////////////////// ///////////////////////////////////// - auto Renderer::doInitInstance(std::string_view application_name) noexcept + auto Renderer::doInit(std::string_view application_name, + std::optional>) noexcept -> gpu::Expected { ilog("Initializing Renderer"); + return doInitInstance(application_name).and_then([this]() noexcept { + return doInitDevice(); + }); + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto Renderer::doInitInstance(std::string_view application_name) noexcept + -> gpu::Expected { } ///////////////////////////////////// diff --git a/src/Engine/Renderer/Renderer.cpp b/src/Engine/Renderer/Renderer.cpp deleted file mode 100644 index a084490d..00000000 --- a/src/Engine/Renderer/Renderer.cpp +++ /dev/null @@ -1,94 +0,0 @@ -module; - -#include - -module stormkit.Engine; - -import std; - -import stormkit.Core; -import stormkit.Log; -import stormkit.Wsi; -import stormkit.Gpu; - -import :Renderer; - -using namespace std::literals; - -namespace stormkit::engine { - LOGGER("stormkit.Renderer") - - namespace { - } // namespace - - ///////////////////////////////////// - ///////////////////////////////////// - auto Renderer::doInit(std::string_view application_name, - std::optional> window) noexcept - -> gpu::Expected { - ilog("Initializing Renderer"); - return doInitInstance(application_name).and_then([this]() noexcept { - return doInitDevice(); - }); - } - - ///////////////////////////////////// - ///////////////////////////////////// - auto Renderer::doInitInstance(std::string_view application_name) noexcept - -> gpu::Expected { - } - - ///////////////////////////////////// - ///////////////////////////////////// - auto Renderer::doInitDevice() noexcept -> gpu::Expected { - } - - ///////////////////////////////////// - ///////////////////////////////////// - auto Renderer::threadLoop(std::stop_token token) noexcept -> void { - // const auto create_info = vk::CommandPoolCreateInfo {}.setFlags( - // vk::CommandPoolCreateFlagBits::eTransient | - // vk::CommandPoolCreateFlagBits::eResetCommandBuffer); - // auto command_pool = vk::raii::CommandPool { m_device, create_info }; - // - // const auto& images = m_render_surface->images(); - // auto&& command_buffers = createCommandBuffers(m_device, command_pool, std::size(images)); - // - // for (const auto i : core::range(std::size(images))) { - // const auto& image = images[i]; - // auto& command_buffer = command_buffers[i]; - // - // command_buffer.begin(vk::CommandBufferBeginInfo {}.setFlags( - // vk::CommandBufferUsageFlagBits::eOneTimeSubmit)); - // - // transitionImageLayout(command_buffer, - // image, - // vk::ImageLayout::eUndefined, - // vk::ImageLayout::ePresentSrcKHR); - // - // command_buffer.end(); - // } - // - // auto fence = - // vk::raii::Fence { m_device, - // vk::FenceCreateInfo {}.setFlags(vk::FenceCreateFlagBits::eSignaled) - // }; - // - // submit(m_raster_queue, command_buffers, {}, {}, *fence); - // - // // fence.wait(); - // - // for (;;) { - // if (token.stop_requested()) return; - // - // m_render_surface->acquireNextFrame() - // .transform([this](auto&& frame) { m_render_surface->present(frame); }) - // .transform_error([](auto&& error) { - // elog("Failed to acquire frame, reason: {}", error); - // return std::forward(error); - // }); - // } - // - // m_device->waitIdle(); - } -} // namespace stormkit::engine diff --git a/src/Wsi/linux/common/XKB.mpp b/src/Wsi/linux/common/XKB.mpp index e27f9764..a2819273 100644 --- a/src/Wsi/linux/common/XKB.mpp +++ b/src/Wsi/linux/common/XKB.mpp @@ -4,7 +4,7 @@ module; - +#include #include diff --git a/src/Wsi/linux/wayland/WindowImpl.mpp b/src/Wsi/linux/wayland/WindowImpl.mpp index 2d1e1b1b..582a9d00 100644 --- a/src/Wsi/linux/wayland/WindowImpl.mpp +++ b/src/Wsi/linux/wayland/WindowImpl.mpp @@ -4,7 +4,15 @@ module; +#include +#include +#include + +#include +#include +#include +#include #include @@ -12,7 +20,6 @@ export module stormkit.Wsi:Linux.Wayland.WindowImpl; import std; - import stormkit.Core; import :Types; diff --git a/src/Wsi/linux/x11/WindowImpl.mpp b/src/Wsi/linux/x11/WindowImpl.mpp index 0387343b..53b7122d 100644 --- a/src/Wsi/linux/x11/WindowImpl.mpp +++ b/src/Wsi/linux/x11/WindowImpl.mpp @@ -4,7 +4,23 @@ module; - +extern "C" { +#include +#include + +#include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wkeyword-macro" +#define explicit _explicit +#include +#undef explicit +#pragma GCC diagnostic pop +#include +#include +#include +#include +#include +} #include @@ -12,7 +28,6 @@ export module stormkit.Wsi:Linux.X11.WindowImpl; import std; - import stormkit.Core; import :Types; @@ -107,11 +122,6 @@ export namespace stormkit::wsi::linux::x11 { common::XKBMods m_xkb_mods; - xcb_intern_atom_cookie_t m_protocol_cookie; - xcb_intern_atom_cookie_t m_close_cookie; - xcb_intern_atom_cookie_t m_state_cookie; - xcb_intern_atom_cookie_t m_state_fullscreen_cookie; - struct WindowHints { uint32_t flags = 0; uint32_t functions = 0; diff --git a/xmake.lua b/xmake.lua index debc6ee7..51c9777b 100644 --- a/xmake.lua +++ b/xmake.lua @@ -150,19 +150,6 @@ modules = { }, } -package("frozen", function() - set_homepage("https://github.com/serge-sans-paille/frozen") - set_description("A header-only, constexpr alternative to gperf for C++14 users") - set_license("Apache-2.0") - - set_urls("https://github.com/Arthapz/frozen.git") - -- set_sourcedir("../frozen") - - on_install(function(package) - import("package.tools.xmake").install(package, { enable_module = true, enable_std_import = true, enable_tests = false, enable_benchmark = false }) - end) -end) - local allowedmodes = { "debug", "release", diff --git a/xmake/frozen.lua b/xmake/frozen.lua new file mode 100644 index 00000000..ce596330 --- /dev/null +++ b/xmake/frozen.lua @@ -0,0 +1,13 @@ +package("frozen", function() + set_homepage("https://github.com/serge-sans-paille/frozen") + set_description("A header-only, constexpr alternative to gperf for C++14 users") + set_license("Apache-2.0") + + set_urls("https://github.com/Arthapz/frozen.git") + -- set_sourcedir("../frozen") + + on_install(function(package) + import("package.tools.xmake").install(package, { enable_module = true, enable_std_import = true, enable_tests = false, enable_benchmark = false }) + end) +end) + From 757cd5ec381c55a0202c2f1857cbb91e481c7eb3 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Feb 2024 21:24:40 +0100 Subject: [PATCH 02/39] apply clang-format --- examples/engine/triangle/src/Constants.mpp | 1 - examples/engine/triangle/src/main.cpp | 14 +- examples/entities/gameoflife/src/App.cpp | 4 +- examples/entities/gameoflife/src/Renderer.cpp | 28 +- examples/entities/gameoflife/src/Renderer.mpp | 16 +- examples/entities/gameoflife/src/Systems.cpp | 8 +- examples/entities/gameoflife/src/Systems.mpp | 10 +- examples/log/console-logger/src/main.cpp | 4 +- examples/log/file-logger/src/main.cpp | 4 +- examples/wsi/event_handler/src/main.cpp | 2 +- examples/wsi/polling/src/main.cpp | 2 +- include/stormkit/Core/MemoryMacro.hpp | 92 +++-- include/stormkit/Core/PimplImplMacro.hpp | 2 +- include/stormkit/Core/PlatformMacro.hpp | 6 +- include/stormkit/Gpu/Core/VulkanMacro.hpp | 6 +- include/stormkit/Log/LogMacro.hpp | 28 +- modules/stormkit/Core.mpp | 4 - .../stormkit/Core/Containers/RingBuffer.mpp | 1 - modules/stormkit/Core/Containers/Tree.mpp | 39 ++- modules/stormkit/Core/Containers/Utils.mpp | 8 +- modules/stormkit/Core/Coroutines.mpp | 20 +- modules/stormkit/Core/Hash/HashMap.mpp | 3 +- modules/stormkit/Core/Meta/NamedType.mpp | 2 +- .../stormkit/Core/Parallelism/ThreadPool.mpp | 7 +- .../stormkit/Core/Parallelism/ThreadUtils.mpp | 1 - modules/stormkit/Core/String/Encodings.mpp | 17 +- modules/stormkit/Core/String/Format.mpp | 4 +- modules/stormkit/Core/Utils/Algorithms.mpp | 24 +- modules/stormkit/Core/Utils/App.mpp | 1 - modules/stormkit/Core/Utils/AsCast.mpp | 4 +- modules/stormkit/Core/Utils/Assert.mpp | 1 - modules/stormkit/Core/Utils/Color.mpp | 1 - modules/stormkit/Core/Utils/Descriptors.mpp | 1 - modules/stormkit/Core/Utils/ErrorHandling.mpp | 30 +- modules/stormkit/Core/Utils/Expected.mpp | 1 - modules/stormkit/Core/Utils/Flags.mpp | 1 - modules/stormkit/Core/Utils/Functional.mpp | 13 +- modules/stormkit/Core/Utils/Handle.mpp | 1 - modules/stormkit/Core/Utils/Math.mpp | 20 +- modules/stormkit/Core/Utils/Monadic.mpp | 27 +- modules/stormkit/Core/Utils/Numerics.mpp | 1 - modules/stormkit/Core/Utils/Singleton.mpp | 2 +- modules/stormkit/Engine/Core/Application.mpp | 16 +- .../Engine/Renderer/BakedFrameGraph.mpp | 7 +- .../Engine/Renderer/FrameGraphBuilder.mpp | 69 ++-- .../Engine/Renderer/GraphResource.mpp | 16 +- .../stormkit/Engine/Renderer/GraphTask.mpp | 2 +- .../Engine/Renderer/GraphTaskBuilder.mpp | 4 +- modules/stormkit/Entities.mpp | 19 +- modules/stormkit/Gpu/Core/Device.mpp | 66 ++-- modules/stormkit/Gpu/Core/Instance.mpp | 20 +- modules/stormkit/Gpu/Core/Sync.mpp | 43 +-- modules/stormkit/Gpu/Core/Types.mpp | 122 ++++--- .../stormkit/Gpu/Execution/CommandBuffer.mpp | 199 +++++------ .../stormkit/Gpu/Execution/Descriptors.mpp | 9 +- modules/stormkit/Gpu/Execution/Pipeline.mpp | 96 +++--- .../Gpu/Execution/RasterPipelineState.mpp | 1 - modules/stormkit/Gpu/Execution/RenderPass.mpp | 100 +++--- modules/stormkit/Gpu/Resource/Buffer.mpp | 3 +- modules/stormkit/Gpu/Resource/Image.mpp | 86 ++--- modules/stormkit/Gpu/Resource/Shader.mpp | 59 ++-- modules/stormkit/Gpu/Vulkan/Utils.mpp | 32 +- modules/stormkit/Gpu/Vulkan/vma.mpp | 1 - modules/stormkit/Image/Image.mpp | 69 ++-- modules/stormkit/Log/ConsoleLogger.mpp | 1 - modules/stormkit/Log/Logger.mpp | 28 +- modules/stormkit/Log/Severity.mpp | 3 +- modules/stormkit/Wsi/EventHandler.mpp | 1 - modules/stormkit/Wsi/Types.mpp | 1 - modules/stormkit/Wsi/Window.mpp | 5 +- src/Core/ThreadPool.cpp | 5 +- src/Core/posix/DynamicLoader.mpp | 4 +- src/Core/win32/DynamicLoader.mpp | 6 +- src/Core/win32/ThreadUtils.cpp | 6 +- src/Engine/Core/Application.cpp | 4 +- src/Engine/Renderer.cpp | 1 - src/Engine/Renderer/BakedFrameGraph.cpp | 4 +- src/Engine/Renderer/FrameGraphBuilder.cpp | 6 +- src/Engine/Systems/RenderSystem.mpp | 2 +- src/Gpu/Core/Device.cpp | 6 +- src/Gpu/Core/Instance.cpp | 2 +- src/Gpu/Core/PhysicalDevice.cpp | 34 +- src/Gpu/Execution/Pipeline.cpp | 9 +- src/Gpu/Execution/RenderPass.cpp | 5 +- src/Gpu/Resource/Buffer.cpp | 2 +- src/Image/HDRImage.mpp | 2 +- src/Image/Image.cpp | 8 +- src/Image/JPEGImage.mpp | 12 +- src/Image/KTXImage.mpp | 2 +- src/Image/PNGImage.mpp | 5 +- src/Image/PPMImage.mpp | 12 +- src/Image/TARGAImage.mpp | 2 +- src/Log/win32/LogColorizer.cpp | 6 +- src/Main/win32/Main-win.cpp | 4 +- src/Wsi/Window.cpp | 4 +- src/Wsi/iOS/InputHandlerImpl.hpp | 8 +- src/Wsi/iOS/WindowImpl.hpp | 24 +- src/Wsi/iOS/iosMain.hpp | 2 - src/Wsi/linux/WindowImpl.mpp | 16 +- src/Wsi/linux/common/XKB.mpp | 55 ++- src/Wsi/linux/wayland/Callbacks.mpp | 34 +- src/Wsi/linux/wayland/Implementation.cpp | 322 +++++++++--------- src/Wsi/linux/wayland/Log.mpp | 1 - src/Wsi/linux/wayland/WindowImpl.mpp | 118 +++---- src/Wsi/linux/x11/Log.mpp | 1 - src/Wsi/linux/x11/WindowImpl.mpp | 40 +-- src/Wsi/linux/x11/XCB.mpp | 57 ++-- src/Wsi/macOS/StormKitWindow.hpp | 20 +- src/Wsi/macOS/Utils.hpp | 2 +- src/Wsi/macOS/WindowImpl.mpp | 60 ++-- src/Wsi/macOS/macOSWindow.hpp | 49 +-- src/Wsi/win32/Log.mpp | 1 - src/Wsi/win32/WindowImpl.mpp | 3 +- tests/src/Test.mpp | 8 +- 114 files changed, 1264 insertions(+), 1249 deletions(-) diff --git a/examples/engine/triangle/src/Constants.mpp b/examples/engine/triangle/src/Constants.mpp index 4694633d..354fb275 100644 --- a/examples/engine/triangle/src/Constants.mpp +++ b/examples/engine/triangle/src/Constants.mpp @@ -13,7 +13,6 @@ import std; import stormkit.Core; import stormkit.Log; - export { struct Vertex { stormkit::core::math::Vector2F position; diff --git a/examples/engine/triangle/src/main.cpp b/examples/engine/triangle/src/main.cpp index b5d1fb29..ca6e2007 100644 --- a/examples/engine/triangle/src/main.cpp +++ b/examples/engine/triangle/src/main.cpp @@ -11,8 +11,8 @@ import stormkit.Wsi; import App; -#include #include +#include //////////////////////////////////////// //////////////////////////////////////// @@ -24,12 +24,12 @@ auto main(std::span args) -> int { auto logger = log::Logger::createLoggerInstance(); logger.ilog("Using StormKit {}.{}.{}\n branch: {}\n commit_hash: {}\n built with {}", - core::STORMKIT_MAJOR_VERSION, - core::STORMKIT_MINOR_VERSION, - core::STORMKIT_PATCH_VERSION, - core::STORMKIT_GIT_BRANCH, - core::STORMKIT_GIT_COMMIT_HASH, - STORMKIT_COMPILER); + core::STORMKIT_MAJOR_VERSION, + core::STORMKIT_MINOR_VERSION, + core::STORMKIT_PATCH_VERSION, + core::STORMKIT_GIT_BRANCH, + core::STORMKIT_GIT_COMMIT_HASH, + STORMKIT_COMPILER); try { auto app = App {}; diff --git a/examples/entities/gameoflife/src/App.cpp b/examples/entities/gameoflife/src/App.cpp index e811f6aa..6cfa6864 100644 --- a/examples/entities/gameoflife/src/App.cpp +++ b/examples/entities/gameoflife/src/App.cpp @@ -141,7 +141,7 @@ auto App::handleMouse(const stormkit::wsi::MouseButtonPushedEventData& event) -> const auto cells = m_entities.entitiesWithComponent(); const auto it = std::ranges::find_if(cells, [&](const auto e) { - const auto& position = m_entities.getComponent(e); + const auto &position = m_entities.getComponent(e); return position.x == x && position.y == y; }); @@ -152,7 +152,7 @@ auto App::handleMouse(const stormkit::wsi::MouseButtonPushedEventData& event) -> } auto App::createCell(stormkit::core::UInt32 x, stormkit::core::UInt32 y) -> void { - auto e = m_entities.makeEntity(); + auto e = m_entities.makeEntity(); auto& position = m_entities.addComponent(e); position.x = x; diff --git a/examples/entities/gameoflife/src/Renderer.cpp b/examples/entities/gameoflife/src/Renderer.cpp index 53adad9f..2c2eca17 100644 --- a/examples/entities/gameoflife/src/Renderer.cpp +++ b/examples/entities/gameoflife/src/Renderer.cpp @@ -27,8 +27,8 @@ Renderer::Renderer(Renderer&&) noexcept = default; auto Renderer::operator=(Renderer&&) noexcept -> Renderer& = default; auto Renderer::renderFrame() -> void { - const auto& surface_extent = m_surface->extent(); - const auto surface_extentf = core::math::ExtentF { surface_extent }; + const auto& surface_extent = m_surface->extent(); + const auto surface_extentf = core::math::ExtentF { surface_extent }; if (m_surface->needRecreate()) { m_surface->recreate(); @@ -51,7 +51,7 @@ auto Renderer::renderFrame() -> void { auto sets = core::makeConstObserverStaticArray(m_board.descriptor_set); - auto frame = std::move(m_surface->acquireNextFrame().value()); + auto frame = std::move(m_surface->acquireNextFrame().value()); auto& framebuffer = m_framebuffers[frame.image_index]; auto& commandbuffer = m_command_buffers[frame.image_index]; @@ -130,8 +130,8 @@ auto Renderer::doInitBaseRenderObjects() -> void { } auto Renderer::doInitMeshRenderObjects() -> void { - const auto& surface_extent = m_surface->extent(); - const auto surface_extentf = core::math::ExtentF { surface_extent }; + const auto& surface_extent = m_surface->extent(); + const auto surface_extentf = core::math::ExtentF { surface_extent }; m_board.vertex_shader = m_device->allocateShader(SHADER_DATA, gpu::ShaderStageFlag::Vertex); m_board.fragment_shader = m_device->allocateShader(SHADER_DATA, gpu::ShaderStageFlag::Fragment); @@ -148,11 +148,9 @@ auto Renderer::doInitMeshRenderObjects() -> void { .stages = gpu::ShaderStageFlag::Fragment, .descriptor_count = 1 }); m_descriptor_set_layout->bake(); - m_descriptor_pool = - m_device->allocateDescriptorPool(std::array { gpu::DescriptorPool::Size { - gpu::DescriptorType::Combined_Image_Sampler, - 1 } }, - 1); + m_descriptor_pool = m_device->allocateDescriptorPool( + std::array { gpu::DescriptorPool::Size { gpu::DescriptorType::Combined_Image_Sampler, 1 } }, + 1); m_render_pass = m_device->allocateRenderPass(description); @@ -211,9 +209,9 @@ auto Renderer::doInitMeshRenderObjects() -> void { } auto Renderer::doInitPerFrameObjects() -> void { - const auto& surface_extent = m_surface->extent(); - const auto surface_extentf = core::math::ExtentF { surface_extent }; - const auto buffering_count = m_surface->bufferingCount(); + const auto& surface_extent = m_surface->extent(); + const auto surface_extentf = core::math::ExtentF { surface_extent }; + const auto buffering_count = m_surface->bufferingCount(); m_surface_views.clear(); m_surface_views.reserve(std::size(m_surface->images())); @@ -223,8 +221,8 @@ auto Renderer::doInitPerFrameObjects() -> void { m_framebuffers.reserve(buffering_count); for (auto i : core::range(buffering_count)) { - const auto& image_view = m_surface_views[i]; - auto attachments = core::makeConstRefArray(image_view); + const auto& image_view = m_surface_views[i]; + auto attachments = core::makeConstRefArray(image_view); m_framebuffers.emplace_back(*m_render_pass, surface_extent, std::move(attachments)); } diff --git a/examples/entities/gameoflife/src/Renderer.mpp b/examples/entities/gameoflife/src/Renderer.mpp index ad656026..1e9f3bca 100644 --- a/examples/entities/gameoflife/src/Renderer.mpp +++ b/examples/entities/gameoflife/src/Renderer.mpp @@ -41,21 +41,21 @@ export { const stormkit::wsi::Window *m_window = nullptr; std::unique_ptr m_instance; - std::unique_ptr m_device; - std::unique_ptr m_surface; - stormkit::gpu::Fence *m_current_fence = nullptr; + std::unique_ptr m_device; + std::unique_ptr m_surface; + stormkit::gpu::Fence *m_current_fence = nullptr; - const stormkit::gpu::Queue *m_queue = nullptr; + const stormkit::gpu::Queue *m_queue = nullptr; std::vector m_surface_views; std::unique_ptr m_descriptor_set_layout; - std::unique_ptr m_descriptor_pool; + std::unique_ptr m_descriptor_pool; std::unique_ptr m_render_pass; struct Board { - std::vector images; - std::vector image_views; + std::vector images; + std::vector image_views; std::unique_ptr sampler; stormkit::core::UInt32 current_image = 0; @@ -69,7 +69,7 @@ export { } m_board; std::vector m_command_buffers; - std::vector m_framebuffers; + std::vector m_framebuffers; }; #ifdef STORMKIT_BUILD_MODULES diff --git a/examples/entities/gameoflife/src/Systems.cpp b/examples/entities/gameoflife/src/Systems.cpp index 6077e34b..e03784d7 100644 --- a/examples/entities/gameoflife/src/Systems.cpp +++ b/examples/entities/gameoflife/src/Systems.cpp @@ -13,8 +13,8 @@ import Components; using namespace stormkit; -UpdateBoardSystem::UpdateBoardSystem(stormkit::image::Image& board, - Renderer& renderer, +UpdateBoardSystem::UpdateBoardSystem(stormkit::image::Image & board, + Renderer & renderer, entities::EntityManager& manager) : entities::System { manager, 0, { PositionComponent::TYPE } }, m_board { &board }, m_renderer { &renderer }, m_last_update { Clock::now() } { @@ -99,7 +99,7 @@ auto UpdateBoardSystem::update(stormkit::core::Secondf delta) -> void { cell.adjacent_alive_cells == 3 || (cell.alive && cell.adjacent_alive_cells == 2); if (alive && !m_manager->hasEntity(cell.e)) { - auto e = m_manager->makeEntity(); + auto e = m_manager->makeEntity(); auto& position = m_manager->addComponent(e); position.x = cell.x; position.y = cell.y; @@ -147,7 +147,7 @@ auto UpdateBoardSystem::postUpdate() -> void { using namespace stormkit::core::literals; if (m_updated) { m_updated = false; - auto& board = *m_board; + auto & board = *m_board; const auto& extent = board.extent(); for (auto i : core::range(extent.width * extent.height)) { diff --git a/examples/entities/gameoflife/src/Systems.mpp b/examples/entities/gameoflife/src/Systems.mpp index 28f4bb63..aa6b2316 100644 --- a/examples/entities/gameoflife/src/Systems.mpp +++ b/examples/entities/gameoflife/src/Systems.mpp @@ -26,8 +26,8 @@ export { class UpdateBoardSystem final: public stormkit::entities::System { public: - UpdateBoardSystem(stormkit::image::Image& board, - Renderer& renderer, + UpdateBoardSystem(stormkit::image::Image & board, + Renderer & renderer, stormkit::entities::EntityManager& manager); ~UpdateBoardSystem() override; @@ -46,9 +46,9 @@ export { auto onMessageReceived(const stormkit::entities::Message& message) -> void override {}; - bool m_is_on_edit_mode = true; - stormkit::image::Image *m_board = nullptr; - Renderer *m_renderer = nullptr; + bool m_is_on_edit_mode = true; + stormkit::image::Image *m_board = nullptr; + Renderer *m_renderer = nullptr; Clock::time_point m_last_update; diff --git a/examples/log/console-logger/src/main.cpp b/examples/log/console-logger/src/main.cpp index 072d0108..769ebb9d 100644 --- a/examples/log/console-logger/src/main.cpp +++ b/examples/log/console-logger/src/main.cpp @@ -26,8 +26,8 @@ struct std::formatter: std::formatter, Char struct Foo { core::UInt32 a = 0u; - float b = 2.3f; - Bar c = Bar {}; + float b = 2.3f; + Bar c = Bar {}; }; template diff --git a/examples/log/file-logger/src/main.cpp b/examples/log/file-logger/src/main.cpp index dd4a4b22..b28ff6be 100644 --- a/examples/log/file-logger/src/main.cpp +++ b/examples/log/file-logger/src/main.cpp @@ -28,8 +28,8 @@ struct std::formatter: std::formatter, Char struct Foo { stormkit::core::UInt32 a = 0u; - float b = 2.3f; - Bar c = Bar {}; + float b = 2.3f; + Bar c = Bar {}; }; template diff --git a/examples/wsi/event_handler/src/main.cpp b/examples/wsi/event_handler/src/main.cpp index 59844ad7..5fbff5b2 100644 --- a/examples/wsi/event_handler/src/main.cpp +++ b/examples/wsi/event_handler/src/main.cpp @@ -8,8 +8,8 @@ import stormkit.Core; import stormkit.Log; import stormkit.Wsi; -#include #include +#include NAMED_LOGGER(logger, "StormKit.Examples.Log.EventHandler"); diff --git a/examples/wsi/polling/src/main.cpp b/examples/wsi/polling/src/main.cpp index 97154ee5..b6729b28 100644 --- a/examples/wsi/polling/src/main.cpp +++ b/examples/wsi/polling/src/main.cpp @@ -8,8 +8,8 @@ import stormkit.Core; import stormkit.Log; import stormkit.Wsi; -#include #include +#include NAMED_LOGGER(polling_logger, "StormKit.Examples.Log.Polling"); diff --git a/include/stormkit/Core/MemoryMacro.hpp b/include/stormkit/Core/MemoryMacro.hpp index cdf099a8..08e9f439 100644 --- a/include/stormkit/Core/MemoryMacro.hpp +++ b/include/stormkit/Core/MemoryMacro.hpp @@ -14,37 +14,37 @@ #define SINGLE_ARG(...) __VA_ARGS__ #define ALLOCATE_HELPERS(T) \ - template \ + template \ [[nodiscard]] static inline auto allocate(Args&&...args) { \ return std::make_unique(std::forward(args)...); \ } /// \exclude -#define DECLARE_PTR_AND_REF_TEMPLATE_(x, y) \ - template \ - using x##OwnedPtr = std::unique_ptr>; \ - template \ - using x##SharedPtr = std::shared_ptr>; \ - template \ +#define DECLARE_PTR_AND_REF_TEMPLATE_(x, y) \ + template \ + using x##OwnedPtr = std::unique_ptr>; \ + template \ + using x##SharedPtr = std::shared_ptr>; \ + template \ using x##std::shared_ptr = std::shared_ptr>; \ - template \ - using x##WeakPtr = std::weak_ptr>; \ - template \ - using x##ConstWeakPtr = std::weak_ptr>; \ - template \ - using x##Ref = stormkit::core::NakedRef>; \ - template \ + template \ + using x##WeakPtr = std::weak_ptr>; \ + template \ + using x##ConstWeakPtr = std::weak_ptr>; \ + template \ + using x##Ref = stormkit::core::NakedRef>; \ + template \ using x##ConstRef = stormkit::core::NakedRef>; /// \exclude -#define DECLARE_PTR_AND_REF_(x) \ - using x##OwnedPtr = std::unique_ptr; \ - using x##SharedPtr = std::shared_ptr; \ - using x##std::shared_ptr = std::shared_ptr; \ - using x##WeakPtr = std::weak_ptr; \ - using x##ConstWeakPtr = std::weak_ptr; \ - using x##Ref = stormkit::core::NakedRef; \ - using x##ConstRef = stormkit::core::NakedRef; +#define DECLARE_PTR_AND_REF_(x) \ + using x##OwnedPtr = std::unique_ptr; \ + using x##SharedPtr = std::shared_ptr; \ + using x##std::shared_ptr = std::shared_ptr; \ + using x##WeakPtr = std::weak_ptr; \ + using x##ConstWeakPtr = std::weak_ptr; \ + using x##Ref = stormkit::core::NakedRef; \ + using x##ConstRef = stormkit::core::NakedRef; /// \brief Declare pointer and reference_wrapper aliases to a type /// \param type The type to declare aliases @@ -63,22 +63,34 @@ #define STORMKIT_RAII_CAPSULE_OPAQUE(name, x, _constructor, _deleter, release_value) \ struct name##Scoped { \ - template \ + template \ name##Scoped(Args&&...args) noexcept { \ m_handle = _constructor(std::forward(args)...); \ } \ - explicit name##Scoped(x v) noexcept { m_handle = v; } \ - ~name##Scoped() noexcept { destroy(); } \ + explicit name##Scoped(x v) noexcept { \ + m_handle = v; \ + } \ + ~name##Scoped() noexcept { \ + destroy(); \ + } \ name##Scoped(name##Scoped& other) = delete; \ auto operator=(name##Scoped& other) -> name##Scoped& = delete; \ - name##Scoped(name##Scoped&& other) noexcept { m_handle = other.release(); } \ + name##Scoped(name##Scoped&& other) noexcept { \ + m_handle = other.release(); \ + } \ auto operator=(name##Scoped&& other) noexcept -> name##Scoped& { \ m_handle = other.release(); \ return *this; \ } \ - operator x() noexcept { return m_handle; } \ - auto handle() noexcept -> x& { return m_handle; } \ - auto handle() const noexcept -> x { return m_handle; } \ + operator x() noexcept { \ + return m_handle; \ + } \ + auto handle() noexcept -> x& { \ + return m_handle; \ + } \ + auto handle() const noexcept -> x { \ + return m_handle; \ + } \ auto release() noexcept -> x { \ auto tmp = std::exchange(m_handle, release_value); \ return tmp; \ @@ -95,15 +107,21 @@ x m_handle = release_value; \ }; -#define STORMKIT_RAII_CAPSULE(name, x, deleter) \ - struct name##Deleter { \ - auto operator()(x *ptr) const noexcept -> void { if(ptr) [[likely]] deleter(ptr); } \ - }; \ +#define STORMKIT_RAII_CAPSULE(name, x, deleter) \ + struct name##Deleter { \ + auto operator()(x *ptr) const noexcept -> void { \ + if (ptr) [[likely]] \ + deleter(ptr); \ + } \ + }; \ using name##Scoped = std::unique_ptr; -#define STORMKIT_RAII_CAPSULE_PP(name, x, deleter) \ - struct name##Deleter { \ - auto operator()(x *ptr) const noexcept -> void { if(ptr) [[likely]] deleter(&ptr); } \ - }; \ +#define STORMKIT_RAII_CAPSULE_PP(name, x, deleter) \ + struct name##Deleter { \ + auto operator()(x *ptr) const noexcept -> void { \ + if (ptr) [[likely]] \ + deleter(&ptr); \ + } \ + }; \ using name##Scoped = std::unique_ptr; #define STORMKIT_FORWARD(x) static_cast(x); diff --git a/include/stormkit/Core/PimplImplMacro.hpp b/include/stormkit/Core/PimplImplMacro.hpp index 006fb243..b4c998ca 100644 --- a/include/stormkit/Core/PimplImplMacro.hpp +++ b/include/stormkit/Core/PimplImplMacro.hpp @@ -8,7 +8,7 @@ #define PIMPL_IMPLEMENTATION \ namespace stormkit::core { \ template \ - Pimpl::Pimpl() noexcept(not Defer) { \ + Pimpl::Pimpl() noexcept(not Defer) { \ if constexpr (Defer) init(); \ } \ template \ diff --git a/include/stormkit/Core/PlatformMacro.hpp b/include/stormkit/Core/PlatformMacro.hpp index 764d4d82..30a36d88 100644 --- a/include/stormkit/Core/PlatformMacro.hpp +++ b/include/stormkit/Core/PlatformMacro.hpp @@ -23,10 +23,10 @@ #define STORMKIT_IMPORT __declspec(dllimport) #define STORMKIT_RESTRICT __restrict #define STORMKIT_PRIVATE - #define STORMKIT_FORCE_INLINE __forceinline + #define STORMKIT_FORCE_INLINE __forceinline #elif defined(_MSC_VER) and defined(__clang__) - #define STORMKIT_EXPORT __declspec(dllexport) - #define STORMKIT_IMPORT __declspec(dllimport) + #define STORMKIT_EXPORT __declspec(dllexport) + #define STORMKIT_IMPORT __declspec(dllimport) #define STORMKIT_PRIVATE [[gnu::visibility("hidden")]] #define STORMKIT_RESTRICT __restrict #define STORMKIT_FORCE_INLINE [[gnu::always_inline]] inline diff --git a/include/stormkit/Gpu/Core/VulkanMacro.hpp b/include/stormkit/Gpu/Core/VulkanMacro.hpp index 68f22170..d7eb60d8 100644 --- a/include/stormkit/Gpu/Core/VulkanMacro.hpp +++ b/include/stormkit/Gpu/Core/VulkanMacro.hpp @@ -15,9 +15,9 @@ checkVkError(_result, STORMKIT_STRINGIFY(line)); \ } while (false); #else - #define CHECK_VK_ERROR(line) \ - { \ - const auto _result = line; \ + #define CHECK_VK_ERROR(line) \ + { \ + const auto _result = line; \ core::ensures(_result == vk::Result::eSuccess); \ } #endif diff --git a/include/stormkit/Log/LogMacro.hpp b/include/stormkit/Log/LogMacro.hpp index c056882d..7247adef 100644 --- a/include/stormkit/Log/LogMacro.hpp +++ b/include/stormkit/Log/LogMacro.hpp @@ -5,52 +5,56 @@ #ifndef STORMKIT_LOG_MACRO_HPP #define STORMKIT_LOG_MACRO_HPP -#define NAMED_LOGGER(NAME, module_chars) namespace { constexpr auto NAME = stormkit::log::Module { module_chars }; } +#define NAMED_LOGGER(NAME, module_chars) \ + namespace { \ + constexpr auto NAME = stormkit::log::Module { module_chars }; \ + } #define LOGGER(module) \ NAMED_LOGGER(LOG_MODULE, module) \ - template \ + template \ auto dlog(Args&&...args)->void { \ LOG_MODULE.dlog(std::forward(args)...); \ } \ - template \ + template \ auto ilog(Args&&...args)->void { \ LOG_MODULE.ilog(std::forward(args)...); \ } \ - template \ + template \ auto wlog(Args&&...args)->void { \ LOG_MODULE.wlog(std::forward(args)...); \ } \ - template \ + template \ auto elog(Args&&...args)->void { \ LOG_MODULE.elog(std::forward(args)...); \ } \ - template \ + template \ auto flog(Args&&...args)->void { \ LOG_MODULE.flog(std::forward(args)...); \ } -#define IN_MODULE_NAMED_LOGGER(NAME, module_chars) inline constexpr auto NAME = stormkit::log::Module { module_chars } ; +#define IN_MODULE_NAMED_LOGGER(NAME, module_chars) \ + inline constexpr auto NAME = stormkit::log::Module { module_chars }; #define IN_MODULE_LOGGER(module) \ IN_MODULE_NAMED_LOGGER(LOG_MODULE, module) \ - template \ + template \ auto dlog(Args&&...args)->void { \ LOG_MODULE.dlog(std::forward(args)...); \ } \ - template \ + template \ auto ilog(Args&&...args)->void { \ LOG_MODULE.ilog(std::forward(args)...); \ } \ - template \ + template \ auto wlog(Args&&...args)->void { \ LOG_MODULE.wlog(std::forward(args)...); \ } \ - template \ + template \ auto elog(Args&&...args)->void { \ LOG_MODULE.elog(std::forward(args)...); \ } \ - template \ + template \ auto flog(Args&&...args)->void { \ LOG_MODULE.flog(std::forward(args)...); \ } diff --git a/modules/stormkit/Core.mpp b/modules/stormkit/Core.mpp index 889b82ed..19c02d6c 100644 --- a/modules/stormkit/Core.mpp +++ b/modules/stormkit/Core.mpp @@ -6,10 +6,6 @@ export module stormkit.Core; // clang-format off - - - - // clang-format on export import :Configuration; diff --git a/modules/stormkit/Core/Containers/RingBuffer.mpp b/modules/stormkit/Core/Containers/RingBuffer.mpp index 7b6dd75f..c216d35d 100644 --- a/modules/stormkit/Core/Containers/RingBuffer.mpp +++ b/modules/stormkit/Core/Containers/RingBuffer.mpp @@ -10,7 +10,6 @@ export module stormkit.Core:Containers.RingBuffer; import std; - import :Utils.Assert; import :Utils.Numerics; import :Utils.Byte; diff --git a/modules/stormkit/Core/Containers/Tree.mpp b/modules/stormkit/Core/Containers/Tree.mpp index 7e8b89a5..8018a717 100644 --- a/modules/stormkit/Core/Containers/Tree.mpp +++ b/modules/stormkit/Core/Containers/Tree.mpp @@ -12,7 +12,6 @@ export module stormkit.Core:Containers.Tree; import std; - import :Utils.Numerics; import :Utils.Handle; @@ -25,10 +24,10 @@ export namespace stormkit::core { static constexpr auto INVALID_INDEX = IndexType { IndexType::INVALID_HANDLE_VALUE }; [[nodiscard]] auto name() const noexcept -> const std::string&; - auto setName(std::string name) noexcept -> void; + auto setName(std::string name) noexcept -> void; [[nodiscard]] auto parent() const noexcept -> IndexType; - auto setParent(IndexType index) noexcept -> void; + auto setParent(IndexType index) noexcept -> void; auto nextSibling() const noexcept -> IndexType; auto setNextSibling(IndexType index) noexcept -> void; @@ -42,10 +41,10 @@ export namespace stormkit::core { auto invalidate() noexcept -> void; private: - IndexType m_parent = INVALID_INDEX; - IndexType m_next_sibling = INVALID_INDEX; - IndexType m_first_child = INVALID_INDEX; - DirtyBitType m_dirty_bits = 0; + IndexType m_parent = INVALID_INDEX; + IndexType m_next_sibling = INVALID_INDEX; + IndexType m_first_child = INVALID_INDEX; + DirtyBitType m_dirty_bits = 0; std::string m_name; }; @@ -70,7 +69,7 @@ export namespace stormkit::core { auto getFreeNode() -> TreeNodeIndexType; - auto insert(TreeNodeType&& node, + auto insert(TreeNodeType && node, TreeNodeIndexType parent_index, TreeNodeIndexType previous_sibling) -> TreeNodeIndexType; auto remove(TreeNodeIndexType index) -> void; @@ -90,21 +89,21 @@ export namespace stormkit::core { [[nodiscard]] auto end() const noexcept; [[nodiscard]] auto cend() const noexcept; - auto clearDirties() noexcept -> void; + auto clearDirties() noexcept -> void; [[nodiscard]] auto dirties() const noexcept -> std::span; - auto genDotFile(std::filesystem::path filepath, + auto genDotFile(std::filesystem::path filepath, std::function colorize_node) const -> void; - auto genDotFile(std::filesystem::path filepath, - core::UInt32 highlight, + auto genDotFile(std::filesystem::path filepath, + core::UInt32 highlight, std::function colorize_node) const -> void; private: - TreeNodeIndexType m_first_free_index = 0; - std::vector m_tree; + TreeNodeIndexType m_first_free_index = 0; + std::vector m_tree; std::vector m_dirties; }; } // namespace stormkit::core @@ -245,7 +244,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - auto Tree::insert(TreeNodeType&& node, + auto Tree::insert(TreeNodeType && node, TreeNodeIndexType parent_index, TreeNodeIndexType previous_sibling) -> TreeNodeIndexType { const auto index = getFreeNode(); @@ -306,8 +305,8 @@ namespace stormkit::core { auto queue = std::deque {}; queue.emplace_back(index); while (not queue.empty()) { - auto current_index = queue.front(); - auto& current_node = m_tree[current_index]; + auto current_index = queue.front(); + auto& current_node = m_tree[current_index]; queue.pop_front(); auto child_index = current_node.firstChild(); @@ -433,7 +432,7 @@ namespace stormkit::core { //////////////////////////////////////// template auto Tree::genDotFile( - std::filesystem::path filepath, + std::filesystem::path filepath, std::function colorize_node) const -> void { auto stream = std::fstream(filepath, std::ios::out); @@ -470,8 +469,8 @@ namespace stormkit::core { //////////////////////////////////////// template auto Tree::genDotFile( - std::filesystem::path filepath, - core::UInt32 highlight, + std::filesystem::path filepath, + core::UInt32 highlight, std::function colorize_node) const -> void { std::fstream stream(filepath.string(), std::ios::out); diff --git a/modules/stormkit/Core/Containers/Utils.mpp b/modules/stormkit/Core/Containers/Utils.mpp index 7699f4e2..8bea3fba 100644 --- a/modules/stormkit/Core/Containers/Utils.mpp +++ b/modules/stormkit/Core/Containers/Utils.mpp @@ -50,11 +50,9 @@ export namespace stormkit::core { Pred, Proj1, Proj2> - constexpr auto findFirstNotOf(R1&& first, - R2&& second, - Pred pred = {}, - Proj1 proj1 = {}, - Proj2 proj2 = {}) -> decltype(auto) { + constexpr auto + findFirstNotOf(R1&& first, R2&& second, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) + -> decltype(auto) { auto first1 = std::ranges::begin(first); auto last1 = std::ranges::end(first); auto first2 = std::ranges::begin(second); diff --git a/modules/stormkit/Core/Coroutines.mpp b/modules/stormkit/Core/Coroutines.mpp index 8ffe9732..67693244 100644 --- a/modules/stormkit/Core/Coroutines.mpp +++ b/modules/stormkit/Core/Coroutines.mpp @@ -111,7 +111,7 @@ namespace std { private: [[no_unique_address]] _Allocator __alloc; // \expos - _Rng&& __range; // \expos + _Rng && __range; // \expos }; template @@ -174,7 +174,7 @@ namespace std { static void operator delete(void *__ptr, std::size_t __frameSize) noexcept { _Alloc& __alloc = __get_allocator(__ptr, __frameSize); - _Alloc __localAlloc(std::move(__alloc)); + _Alloc __localAlloc(std::move(__alloc)); __alloc.~Alloc(); __localAlloc.deallocate(static_cast(__ptr), __padded_frame_size(__frameSize)); @@ -202,14 +202,14 @@ namespace std { friend class generator; __generator_promise_base *__root_; - std::coroutine_handle<> __parentOrLeaf_; + std::coroutine_handle<> __parentOrLeaf_; // Note: Using manual_lifetime here to avoid extra calls to exception_ptr // constructor/destructor in cases where it is not needed (i.e. where this // generator coroutine is not used as a nested coroutine). // This member is lazily constructed by the __yield_sequence_awaiter::await_suspend() // method if this generator is used as a nested generator. __manual_lifetime __exception_; - __manual_lifetime<_Ref> __value_; + __manual_lifetime<_Ref> __value_; explicit __generator_promise_base(std::coroutine_handle<> thisCoro) noexcept : __root_(this), __parentOrLeaf_(thisCoro) {} @@ -241,8 +241,8 @@ namespace std { template std::coroutine_handle<> await_suspend(std::coroutine_handle<_Promise> __h) noexcept { - _Promise& __promise = __h.promise(); - __generator_promise_base& __root = *__promise.__root_; + _Promise & __promise = __h.promise(); + __generator_promise_base& __root = *__promise.__root_; if (&__root != &__promise) { auto __parent = __promise.__parentOrLeaf_; __root.__parentOrLeaf_ = __parent; @@ -514,7 +514,7 @@ namespace std { private: __coroutine_handle __coro_; - bool __started_ = false; + bool __started_ = false; }; // Specialisation for type-erased allocator implementation. @@ -595,7 +595,7 @@ namespace std { explicit iterator(__promise_base *__promise, std::coroutine_handle<> __coro) noexcept : __promise_(__promise), __coro_(__coro) {} - __promise_base *__promise_; + __promise_base *__promise_; std::coroutine_handle<> __coro_; }; @@ -623,9 +623,9 @@ namespace std { __promise_base *__get_promise() noexcept { return __promise_; } private: - __promise_base *__promise_; + __promise_base *__promise_; std::coroutine_handle<> __coro_; - bool __started_ = false; + bool __started_ = false; }; } // namespace std diff --git a/modules/stormkit/Core/Hash/HashMap.mpp b/modules/stormkit/Core/Hash/HashMap.mpp index 46d129ff..c0277493 100644 --- a/modules/stormkit/Core/Hash/HashMap.mpp +++ b/modules/stormkit/Core/Hash/HashMap.mpp @@ -14,8 +14,7 @@ export namespace stormkit::core { class Hash = ankerl::unordered_dense::hash, class KeyEqual = std::equal_to, class AllocatorOrContainer = std::allocator>> - using HashMap = - ankerl::unordered_dense::map; + using HashMap = ankerl::unordered_dense::map; template, diff --git a/modules/stormkit/Core/Meta/NamedType.mpp b/modules/stormkit/Core/Meta/NamedType.mpp index cbe3d2c1..173de109 100644 --- a/modules/stormkit/Core/Meta/NamedType.mpp +++ b/modules/stormkit/Core/Meta/NamedType.mpp @@ -12,7 +12,6 @@ export module stormkit.Core:Meta.NamedType; import std; - // import :Hash; import :Utils.Numerics; @@ -236,6 +235,7 @@ namespace stormkit::core { template constexpr auto NamedType::operator=(NamedType &&) noexcept( std::is_nothrow_move_assignable_v) -> NamedType & = default; + // clang-format on // template diff --git a/modules/stormkit/Core/Parallelism/ThreadPool.mpp b/modules/stormkit/Core/Parallelism/ThreadPool.mpp index 40145f57..b0bdda88 100644 --- a/modules/stormkit/Core/Parallelism/ThreadPool.mpp +++ b/modules/stormkit/Core/Parallelism/ThreadPool.mpp @@ -10,7 +10,6 @@ export module stormkit.Core:Parallelism.ThreadPool; import std; - import :Utils.Algorithms; import :Utils.Numerics; import :Parallelism.ThreadUtils; @@ -127,11 +126,9 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// STORMKIT_FORCE_INLINE auto ThreadPool::setName(std::string_view name) noexcept -> void { - //for (auto&& [i, worker] : m_workers | std::views::enumerate) { + // for (auto&& [i, worker] : m_workers | std::views::enumerate) { auto i = 0; - for (auto&& worker : m_workers) { - setThreadName(worker, std::format("{}:{}", name, i++)); - } + for (auto&& worker : m_workers) { setThreadName(worker, std::format("{}:{}", name, i++)); } } //////////////////////////////////////// diff --git a/modules/stormkit/Core/Parallelism/ThreadUtils.mpp b/modules/stormkit/Core/Parallelism/ThreadUtils.mpp index 1c4609ee..2e16fb0f 100644 --- a/modules/stormkit/Core/Parallelism/ThreadUtils.mpp +++ b/modules/stormkit/Core/Parallelism/ThreadUtils.mpp @@ -10,7 +10,6 @@ export module stormkit.Core:Parallelism.ThreadUtils; import std; - export namespace stormkit::core { STORMKIT_API auto setCurrentThreadName(std::string_view name) -> void; STORMKIT_API auto setThreadName(std::thread& thread, std::string_view name) -> void; diff --git a/modules/stormkit/Core/String/Encodings.mpp b/modules/stormkit/Core/String/Encodings.mpp index 39b21427..71fcb2bc 100644 --- a/modules/stormkit/Core/String/Encodings.mpp +++ b/modules/stormkit/Core/String/Encodings.mpp @@ -13,7 +13,6 @@ export module stormkit.Core:String.Encodings; import std; - import :Utils.AsCast; import :Utils.Numerics; @@ -45,7 +44,7 @@ namespace stormkit::core { inline auto asciiToUtf16(std::string_view input) -> std::u16string { auto output = std::u16string {}; #if not defined(STORMKIT_COMPILER_CLANG) - auto state = std::mbstate_t {}; + auto state = std::mbstate_t {}; output.resize(std::size(input)); auto len = 0ull; @@ -67,7 +66,7 @@ namespace stormkit::core { inline auto utf16ToAscii(std::u16string_view input) -> std::string { auto output = std::string {}; #if not defined(STORMKIT_COMPILER_CLANG) - auto state = std::mbstate_t {}; + auto state = std::mbstate_t {}; output.resize(std::size(input)); for (const auto& c : input) @@ -83,7 +82,7 @@ namespace stormkit::core { //////////////////////////////////////// inline auto asciiToWide(std::string_view input) -> std::wstring { [[maybe_unused]] auto state = std::mbstate_t {}; - auto output = std::wstring {}; + auto output = std::wstring {}; output.resize(std::size(input)); [[maybe_unused]] auto len = 0ull; @@ -96,7 +95,7 @@ namespace stormkit::core { &state)) > 0u) input_it += len; #elif defined(STORMKIT_COMPILER_CLANG) - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #else while ((len = std::mbrtoc8(std::bit_cast(std::data(output)) + i++, input_it, @@ -118,7 +117,7 @@ namespace stormkit::core { #if defined(STORMKIT_COMPILER_MSVC) for (const auto& c : input) std::c16rtomb(std::data(output), core::as(c), &state); #elif defined(STORMKIT_COMPILER_CLANG) - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #else for (const auto& c : input) std::c8rtomb(std::data(output), core::narrow(c), &state); #endif @@ -137,7 +136,7 @@ namespace stormkit::core { auto bytes = toByteSpan(output); std::ranges::copy(asByteView(input), std::ranges::begin(bytes)); #elif defined(STORMKIT_COMPILER_CLANG) - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #else auto len = 0ull; auto input_it = std::data(input); @@ -158,14 +157,14 @@ namespace stormkit::core { //////////////////////////////////////// inline auto utf8ToAscii(std::u8string_view input) -> std::string { [[maybe_unused]] auto state = std::mbstate_t {}; - auto output = std::string {}; + auto output = std::string {}; output.resize(std::size(input)); #if defined(STORMKIT_COMPILER_MSVC) auto bytes = toByteSpan(output); std::ranges::copy(asByteView(input), std::ranges::begin(bytes)); #elif defined(STORMKIT_COMPILER_CLANG) - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #else for (const auto& c : input) std::c8rtomb(std::data(output), c, &state); #endif diff --git a/modules/stormkit/Core/String/Format.mpp b/modules/stormkit/Core/String/Format.mpp index 07b48776..e857f220 100644 --- a/modules/stormkit/Core/String/Format.mpp +++ b/modules/stormkit/Core/String/Format.mpp @@ -2,7 +2,7 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution -module; +module; #include "magic_enum.hpp" @@ -66,7 +66,7 @@ namespace std { template template auto formatter::format(const stormkit::core::Secondf& data, - FormatContext& ctx) const + FormatContext & ctx) const -> decltype(ctx.out()) { return formatter::format(data.count(), ctx); } diff --git a/modules/stormkit/Core/Utils/Algorithms.mpp b/modules/stormkit/Core/Utils/Algorithms.mpp index cb1584ed..d4dcb735 100644 --- a/modules/stormkit/Core/Utils/Algorithms.mpp +++ b/modules/stormkit/Core/Utils/Algorithms.mpp @@ -9,23 +9,23 @@ import std; import :Meta; export namespace stormkit::core { - template::value_type> Predicate> [[nodiscard]] constexpr auto copyIf(Range&& input, Predicate&& predicate) noexcept; - template::value_type&> Lambda> [[nodiscard]] constexpr auto transform(Range&& input, Lambda&& lambda) noexcept; - template::value_type> Predicate, + template::value_type> Predicate, std::invocable::value_type&> Lambda> [[nodiscard]] constexpr auto transformIf(Range&& input, Predicate&& predicate, Lambda&& lambda) noexcept; template< - std::ranges::input_range Range, - IsUnaryPredicate::value_type> Predicate, + std::ranges::input_range Range, + IsUnaryPredicate::value_type> Predicate, std::invocable::value_type&> Lambda, std::output_iterator< std::invoke_result_t::value_type&>> @@ -42,7 +42,7 @@ export namespace stormkit::core { namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - template::value_type> Predicate> constexpr auto copyIf(Range&& input, Predicate&& predicate) noexcept { auto output = std::vector::value_type> {}; @@ -57,7 +57,7 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - template::value_type&> Lambda> constexpr auto transform(Range&& input, Lambda&& lambda) noexcept { auto output = std::vector< @@ -72,8 +72,8 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - template::value_type> Predicate, + template::value_type> Predicate, std::invocable::value_type&> Lambda> constexpr auto transformIf(Range&& input, Predicate&& predicate, Lambda&& lambda) noexcept { auto output = std::vector< @@ -92,8 +92,8 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template< - std::ranges::input_range Range, - IsUnaryPredicate::value_type> Predicate, + std::ranges::input_range Range, + IsUnaryPredicate::value_type> Predicate, std::invocable::value_type&> Lambda, std::output_iterator< std::invoke_result_t::value_type&>> diff --git a/modules/stormkit/Core/Utils/App.mpp b/modules/stormkit/Core/Utils/App.mpp index 01bfd2f2..b9970490 100644 --- a/modules/stormkit/Core/Utils/App.mpp +++ b/modules/stormkit/Core/Utils/App.mpp @@ -12,7 +12,6 @@ export module stormkit.Core:Utils.App; import std; - import :Utils.Numerics; export namespace stormkit::core { diff --git a/modules/stormkit/Core/Utils/AsCast.mpp b/modules/stormkit/Core/Utils/AsCast.mpp index 1ba1d152..87339c5d 100644 --- a/modules/stormkit/Core/Utils/AsCast.mpp +++ b/modules/stormkit/Core/Utils/AsCast.mpp @@ -10,7 +10,6 @@ export module stormkit.Core:Utils.AsCast; import std; - import :Utils.Assert; import :Meta.Concepts; import :Meta.Traits; @@ -259,8 +258,7 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template To, IsEnumeration From> - STORMKIT_FORCE_INLINE constexpr auto as(const From& value) noexcept - -> UnderlyingType { + STORMKIT_FORCE_INLINE constexpr auto as(const From& value) noexcept -> UnderlyingType { using T = UnderlyingType; return static_cast(value); } diff --git a/modules/stormkit/Core/Utils/Assert.mpp b/modules/stormkit/Core/Utils/Assert.mpp index 353eb0dc..2235b606 100644 --- a/modules/stormkit/Core/Utils/Assert.mpp +++ b/modules/stormkit/Core/Utils/Assert.mpp @@ -12,7 +12,6 @@ import std; import :Utils.Descriptors; - export namespace stormkit::core { enum class AssertType { Assert, diff --git a/modules/stormkit/Core/Utils/Color.mpp b/modules/stormkit/Core/Utils/Color.mpp index 39aded9e..8faac09f 100644 --- a/modules/stormkit/Core/Utils/Color.mpp +++ b/modules/stormkit/Core/Utils/Color.mpp @@ -12,7 +12,6 @@ export module stormkit.Core:Utils.Color; import std; - import :Hash; import :Utils.Numerics; import :Utils.Math; diff --git a/modules/stormkit/Core/Utils/Descriptors.mpp b/modules/stormkit/Core/Utils/Descriptors.mpp index 09b7ab1b..988d2227 100644 --- a/modules/stormkit/Core/Utils/Descriptors.mpp +++ b/modules/stormkit/Core/Utils/Descriptors.mpp @@ -12,7 +12,6 @@ export module stormkit.Core:Utils.Descriptors; import std; - export namespace stormkit::core { [[nodiscard]] auto getSTDErr() noexcept -> std::FILE *; [[nodiscard]] auto getSTDOut() noexcept -> std::FILE *; diff --git a/modules/stormkit/Core/Utils/ErrorHandling.mpp b/modules/stormkit/Core/Utils/ErrorHandling.mpp index 33595078..937dece8 100644 --- a/modules/stormkit/Core/Utils/ErrorHandling.mpp +++ b/modules/stormkit/Core/Utils/ErrorHandling.mpp @@ -18,7 +18,7 @@ import :Utils.Descriptors; export namespace stormkit::core { template [[nodiscard]] constexpr auto - expectsWithMessage(std::string&& message, + expectsWithMessage(std::string && message, std::source_location location = std::source_location::current()) noexcept -> decltype(auto); // optional overload @@ -27,15 +27,17 @@ export namespace stormkit::core { expects(std::source_location location = std::source_location::current()) noexcept -> decltype(auto); // optional overload - [[nodiscard]] constexpr auto expectsWithMessage( - std::string&& message, - std::source_location location = std::source_location::current()) noexcept -> decltype(auto); + [[nodiscard]] constexpr auto + expectsWithMessage(std::string && message, + std::source_location location = std::source_location::current()) noexcept + -> decltype(auto); - [[nodiscard]] constexpr auto expects( - std::source_location location = std::source_location::current()) noexcept -> decltype(auto); + [[nodiscard]] constexpr auto + expects(std::source_location location = std::source_location::current()) noexcept + -> decltype(auto); - [[nodiscard]] constexpr auto log(std::invocable auto&& logger, - std::string&& message) noexcept -> decltype(auto); + [[nodiscard]] constexpr auto log(std::invocable auto&& logger, std::string&& message) noexcept + -> decltype(auto); [[nodiscard]] constexpr auto throwError() noexcept -> decltype(auto); } // namespace stormkit::core @@ -54,8 +56,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - constexpr auto expectsWithMessage(std::string&& message, - std::source_location location) noexcept -> decltype(auto) { + constexpr auto expectsWithMessage(std::string&& message, std::source_location location) noexcept + -> decltype(auto) { return [message = std::move(message), location = std::move(location)] NORETURN_LAMBDA() -> std::optional { auto stderr = getSTDErr(); @@ -117,8 +119,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto expectsWithMessage(std::string&& message, - std::source_location location) noexcept -> decltype(auto) { + constexpr auto expectsWithMessage(std::string&& message, std::source_location location) noexcept + -> decltype(auto) { return [message = std::move(message), location = std::move(location)] NORETURN_LAMBDA( auto&& error) -> std::expected> { auto stderr = getSTDErr(); @@ -182,8 +184,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto log(std::invocable auto&& logger, - std::string&& message) noexcept -> decltype(auto) { + constexpr auto log(std::invocable auto&& logger, std::string&& message) noexcept + -> decltype(auto) { return [logger = std::forward, message = std::move(message)] NORETURN_LAMBDA( auto&& error) -> std::expected> { diff --git a/modules/stormkit/Core/Utils/Expected.mpp b/modules/stormkit/Core/Utils/Expected.mpp index 3c6311e7..214e4a57 100644 --- a/modules/stormkit/Core/Utils/Expected.mpp +++ b/modules/stormkit/Core/Utils/Expected.mpp @@ -10,7 +10,6 @@ export module stormkit.Core:Utils.Expected; import std; - import :Meta; import :Utils.AsCast; diff --git a/modules/stormkit/Core/Utils/Flags.mpp b/modules/stormkit/Core/Utils/Flags.mpp index ca1988ce..9b161817 100644 --- a/modules/stormkit/Core/Utils/Flags.mpp +++ b/modules/stormkit/Core/Utils/Flags.mpp @@ -10,7 +10,6 @@ export module stormkit.Core:Utils.Flags; import std; - import :Utils.AsCast; import :Meta; diff --git a/modules/stormkit/Core/Utils/Functional.mpp b/modules/stormkit/Core/Utils/Functional.mpp index 40054b6d..46bcf43b 100644 --- a/modules/stormkit/Core/Utils/Functional.mpp +++ b/modules/stormkit/Core/Utils/Functional.mpp @@ -19,7 +19,7 @@ export namespace stormkit::core { template [[nodiscard]] constexpr auto - either(T&& optional, + either(T && optional, std::invocable::value_type> auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto); @@ -39,9 +39,8 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE constexpr auto - either(bool condition, - std::invocable auto&& true_, - std::invocable auto&& false_) noexcept -> decltype(auto) { + either(bool condition, std::invocable auto&& true_, std::invocable auto&& false_) noexcept + -> decltype(auto) { if (condition) return true_(); return false_(); } @@ -50,7 +49,7 @@ namespace stormkit::core { ///////////////////////////////////// template STORMKIT_FORCE_INLINE constexpr auto - either(T&& optional, + either(T && optional, std::invocable::value_type> auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto) { if (optional != std::nullopt) return true_(*std::forward(optional)); @@ -68,8 +67,8 @@ namespace stormkit::core { ///////////////////////////////////// template // requires(std::invocable) - STORMKIT_FORCE_INLINE constexpr auto toUnary(Func&& func, - Args&&...args) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto toUnary(Func&& func, Args&&...args) noexcept + -> decltype(auto) { return [_func = std::forward(func), ... _args = std::forward(args)]( auto&& first) noexcept(noexcept(func(first, std::forward(args)...))) { return _func(std::forward(first), std::forward(_args)...); diff --git a/modules/stormkit/Core/Utils/Handle.mpp b/modules/stormkit/Core/Utils/Handle.mpp index de06ce3a..f881dabc 100644 --- a/modules/stormkit/Core/Utils/Handle.mpp +++ b/modules/stormkit/Core/Utils/Handle.mpp @@ -12,7 +12,6 @@ export module stormkit.Core:Utils.Handle; import std; - import :Hash; import :Utils.AsCast; import :Utils.Numerics; diff --git a/modules/stormkit/Core/Utils/Math.mpp b/modules/stormkit/Core/Utils/Math.mpp index 67ed97c1..2ba6ed38 100644 --- a/modules/stormkit/Core/Utils/Math.mpp +++ b/modules/stormkit/Core/Utils/Math.mpp @@ -312,26 +312,26 @@ export { /// \param factor UnderlyingType factor to multiply /// \returns A newly constructed extent equal to this extent multiplied with /// `factor` - [[nodiscard]] constexpr auto - operator*(UnderlyingType factor) const noexcept -> Extent; + [[nodiscard]] constexpr auto operator*(UnderlyingType factor) const noexcept + -> Extent; /// \brief Divide an extent with a factor. /// \param factor UnderlyingType factor to divide /// \returns A newly constructed extent equal to this extent Divided with `factor` - [[nodiscard]] constexpr auto - operator/(UnderlyingType factor) const noexcept -> Extent; + [[nodiscard]] constexpr auto operator/(UnderlyingType factor) const noexcept + -> Extent; /// \brief Multiply this extent with a factor. /// \param factor UnderlyingType factor to multiply /// \returns A reference to this after the multiplication with `factor` - [[nodiscard]] constexpr auto - operator*=(UnderlyingType factor) noexcept -> Extent&; + [[nodiscard]] constexpr auto operator*=(UnderlyingType factor) noexcept + -> Extent&; /// \brief Divide this extent with a factor. /// \param factor UnderlyingType factor to divide /// \returns A reference to this after the division with `factor` - [[nodiscard]] constexpr auto - operator/=(UnderlyingType factor) noexcept -> Extent&; + [[nodiscard]] constexpr auto operator/=(UnderlyingType factor) noexcept + -> Extent&; /// \output_section Publics member /// \brief Width attribute. @@ -445,8 +445,8 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - constexpr auto - Extent::operator<=>(const Extent& other) const noexcept -> OrderingType { + constexpr auto Extent::operator<=>(const Extent& other) const noexcept + -> OrderingType { if (auto ret = width <=> other.width; ret != 0) return ret; if (auto ret = height <=> other.height; ret != 0) return ret; if (auto ret = depth <=> other.depth; ret != 0) return ret; diff --git a/modules/stormkit/Core/Utils/Monadic.mpp b/modules/stormkit/Core/Utils/Monadic.mpp index 56d20dc0..5b1398fa 100644 --- a/modules/stormkit/Core/Utils/Monadic.mpp +++ b/modules/stormkit/Core/Utils/Monadic.mpp @@ -39,12 +39,12 @@ export namespace stormkit::core::monadic { [[nodiscard]] constexpr auto map(auto&& first, auto&& second) noexcept -> decltype(auto); - [[nodiscard]] constexpr auto - either(std::regular_invocable auto&&...visitors) noexcept -> decltype(auto); + [[nodiscard]] constexpr auto either(std::regular_invocable auto&&...visitors) noexcept + -> decltype(auto); template [[nodiscard]] constexpr auto either(IsUnaryPredicate auto&& predicate, - std::invocable auto&& true_, + std::invocable auto && true_, std::invocable auto&& false_) noexcept -> decltype(auto); [[nodiscard]] constexpr auto isEqual() noexcept -> decltype(auto); @@ -110,8 +110,8 @@ namespace stormkit::core::monadic { template First, std::invocable&&> Second> - STORMKIT_FORCE_INLINE constexpr auto map(First&& first, - Second&& second) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto map(First&& first, Second&& second) noexcept + -> decltype(auto) { return [first = std::forward(first), second = std::forward(second)](T&& args) noexcept -> decltype(auto) { @@ -121,8 +121,8 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto map(auto&& first, - auto&& second) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto map(auto&& first, auto&& second) noexcept + -> decltype(auto) { return [first = std::forward(first), second = std::forward(second)]( auto&&...args) noexcept -> decltype(auto) { @@ -133,10 +133,10 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE constexpr auto - either(IsUnaryPredicate auto&& predicate, - std::invocable auto&& true_, - std::invocable auto&& false_) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto either(IsUnaryPredicate auto&& predicate, + std::invocable auto && true_, + std::invocable auto && false_) noexcept + -> decltype(auto) { [predicate = std::move(predicate), true_ = std::move(true_), false_ = std::move(false_)]( auto&& elem) noexcept -> decltype(auto) { if (predicate(elem)) return first(std::forward(elem)); @@ -147,8 +147,9 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE constexpr auto isEqual() noexcept -> decltype(auto) { - return - [](const auto& first, const auto& second) noexcept { return core::isEqual(first, second); }; + return [](const auto& first, const auto& second) noexcept { + return core::isEqual(first, second); + }; } ///////////////////////////////////// diff --git a/modules/stormkit/Core/Utils/Numerics.mpp b/modules/stormkit/Core/Utils/Numerics.mpp index aa103225..dcfc40a7 100644 --- a/modules/stormkit/Core/Utils/Numerics.mpp +++ b/modules/stormkit/Core/Utils/Numerics.mpp @@ -10,7 +10,6 @@ export module stormkit.Core:Utils.Numerics; import std; - import :Meta.Traits; import :Meta.Concepts; import :Utils.AsCast; diff --git a/modules/stormkit/Core/Utils/Singleton.mpp b/modules/stormkit/Core/Utils/Singleton.mpp index 6389455d..22611d24 100644 --- a/modules/stormkit/Core/Utils/Singleton.mpp +++ b/modules/stormkit/Core/Utils/Singleton.mpp @@ -16,7 +16,7 @@ export namespace stormkit::core { Singleton(Singleton&&) = delete; Singleton(const Singleton&) = delete; - auto operator=(Singleton&&) -> Singleton& = delete; + auto operator=(Singleton&&) -> Singleton & = delete; auto operator=(const Singleton&) -> Singleton& = delete; protected: diff --git a/modules/stormkit/Engine/Core/Application.mpp b/modules/stormkit/Engine/Core/Application.mpp index 8365241d..d9e7ff9f 100644 --- a/modules/stormkit/Engine/Core/Application.mpp +++ b/modules/stormkit/Engine/Core/Application.mpp @@ -92,15 +92,15 @@ namespace stormkit::engine { //////////////////////////////////////// //////////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Application::operator=(Application&&) noexcept -> Application& = default; + STORMKIT_FORCE_INLINE auto Application::operator=(Application&&) noexcept + -> Application& = default; //////////////////////////////////////// //////////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Application::create(std::string_view application_name, - const core::math::ExtentU& window_extent, - std::string window_title) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Application::create(std::string_view application_name, + const core::math::ExtentU& window_extent, + std::string window_title) noexcept + -> Expected try { return Application { application_name, window_extent, std::move(window_title), @@ -133,8 +133,8 @@ namespace stormkit::engine { //////////////////////////////////////// //////////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Application::eventHandler(this auto& self) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto Application::eventHandler(this auto& self) noexcept + -> decltype(auto) { return self.m_event_handler.get(); } diff --git a/modules/stormkit/Engine/Renderer/BakedFrameGraph.mpp b/modules/stormkit/Engine/Renderer/BakedFrameGraph.mpp index 1868a51e..f03168c2 100644 --- a/modules/stormkit/Engine/Renderer/BakedFrameGraph.mpp +++ b/modules/stormkit/Engine/Renderer/BakedFrameGraph.mpp @@ -26,11 +26,11 @@ export namespace stormkit::engine { gpu::CommandBuffer cmb; std::vector clear_values = {}; - gpu::RenderPass renderpass; - gpu::FrameBuffer framebuffer; + gpu::RenderPass renderpass; + gpu::FrameBuffer framebuffer; }; - std::vector tasks; + std::vector tasks; std::vector images = {}; std::vector image_views = {}; std::vector buffers = {}; @@ -44,6 +44,7 @@ export namespace stormkit::engine { public: struct Frame {}; + BakedFrameGraph(const FrameGraphBuilder& builder, Data && data, BakedFrameGraph *old = nullptr); diff --git a/modules/stormkit/Engine/Renderer/FrameGraphBuilder.mpp b/modules/stormkit/Engine/Renderer/FrameGraphBuilder.mpp index 1af5f439..93337f9a 100644 --- a/modules/stormkit/Engine/Renderer/FrameGraphBuilder.mpp +++ b/modules/stormkit/Engine/Renderer/FrameGraphBuilder.mpp @@ -45,18 +45,17 @@ export namespace stormkit::engine { bool cull_imune = false) noexcept -> GraphTask&; template - auto setRetainedResource(std::string name, - Description&& description, - const Resource& image) -> GraphResource&; + auto setRetainedResource(std::string name, Description&& description, const Resource& image) + -> GraphResource&; auto setFinalResource(GraphID final) noexcept -> void; auto reset() noexcept -> void; auto bake() -> void; - auto createFrameGraph(const gpu::Device& device, - BakedFrameGraph *old = nullptr) -> BakedFrameGraph; - auto allocateFrameGraph(const gpu::Device& device, - BakedFrameGraph *old = nullptr) -> std::unique_ptr; + auto createFrameGraph(const gpu::Device& device, BakedFrameGraph *old = nullptr) + -> BakedFrameGraph; + auto allocateFrameGraph(const gpu::Device& device, BakedFrameGraph *old = nullptr) + -> std::unique_ptr; auto hasTask(GraphID id) const noexcept -> bool; auto hasTask(std::string_view name) const noexcept -> bool; @@ -126,7 +125,7 @@ export namespace stormkit::engine { auto buildBufferPhysicalDescriptions(const GraphTask& task) noexcept -> std::vector; auto buildRenderPassPhysicalDescription( - const GraphTask& task, + const GraphTask & task, core::HashMap& layouts) noexcept -> RenderPassData; auto allocatePhysicalResources(const gpu::Device& device) -> BakedFrameGraph::Data; @@ -194,12 +193,12 @@ namespace stormkit::engine { auto& task = m_tasks.emplace_back(id, std::move(name), type, cull_imune); m_datas.emplace_back(std::vector { sizeof(TaskData) }); - task.onSetup = [setup = std::move(setup)](core::Byte& data, + task.onSetup = [setup = std::move(setup)](core::Byte & data, GraphTaskBuilder& builder) noexcept { setup(core::as(data), builder); }; task.onExecute = [execute = std::move( - execute)](const core::Byte& data, + execute)](const core::Byte & data, std::optional> renderpass, gpu::CommandBuffer& cmb) noexcept { execute(core::as(data), std::move(renderpass), cmb); @@ -214,7 +213,7 @@ namespace stormkit::engine { ///////////////////////////////////// template inline auto FrameGraphBuilder::setRetainedResource(std::string name, - Description&& description, + Description && description, const Resource& image) -> GraphResource& { auto& graph_resource = m_resources.emplace_back(std::move(name), @@ -240,8 +239,8 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - FrameGraphBuilder::hasTask(std::string_view name) const noexcept -> bool { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::hasTask(std::string_view name) const noexcept + -> bool { return std::ranges::any_of(m_tasks, [&](const auto& t) noexcept { return t.name() == name; }); } @@ -249,25 +248,25 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - FrameGraphBuilder::getTask(this auto& self, - std::string_view name) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto & self, + std::string_view name) noexcept + -> decltype(auto) { return core::as>(self.getTask(name)); } ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto& self, - GraphID id) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto& self, GraphID id) noexcept + -> decltype(auto) { return core::as>(self.getTask(id)); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - FrameGraphBuilder::getTask(this auto& self, - std::string_view name) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto & self, + std::string_view name) noexcept + -> decltype(auto) { const auto it = std::ranges::find_if(self.m_tasks, [&](const auto& t) noexcept { return t.name() == name; }); @@ -280,8 +279,8 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto& self, - GraphID id) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto& self, GraphID id) noexcept + -> decltype(auto) { auto it = std::ranges::find_if(self.m_tasks, [&](const auto& t) noexcept { return t.id() == id; }); @@ -301,8 +300,8 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - FrameGraphBuilder::hasResource(std::string_view name) const noexcept -> bool { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::hasResource(std::string_view name) const noexcept + -> bool { return std::ranges::any_of(m_resources, [&](const auto& t) noexcept { return std::visit([&](auto&& t) { return t.name() == name; }, t); }); @@ -311,25 +310,25 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - FrameGraphBuilder::getResource(this auto& self, - std::string_view name) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getResource(this auto & self, + std::string_view name) noexcept + -> decltype(auto) { return core::as>(self.getResource(name)); } ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - FrameGraphBuilder::getResource(this auto& self, GraphID id) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getResource(this auto& self, GraphID id) noexcept + -> decltype(auto) { return core::as>(self.getResource(id)); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - FrameGraphBuilder::getResource(this auto& self, - std::string_view name) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getResource(this auto & self, + std::string_view name) noexcept + -> decltype(auto) { const auto visitor = [name](auto&& value) noexcept { return value.name() == name; }; auto it = std::ranges::find_if(self.m_resources, [&](auto&& value) noexcept { @@ -344,8 +343,8 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - FrameGraphBuilder::getResource(this auto& self, GraphID id) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getResource(this auto& self, GraphID id) noexcept + -> decltype(auto) { const auto visitor = [id](auto&& value) noexcept { return value.id() == id; }; auto it = std::ranges::find_if(self.m_resources, [&](auto&& value) noexcept { diff --git a/modules/stormkit/Engine/Renderer/GraphResource.mpp b/modules/stormkit/Engine/Renderer/GraphResource.mpp index a76f840f..478f280b 100644 --- a/modules/stormkit/Engine/Renderer/GraphResource.mpp +++ b/modules/stormkit/Engine/Renderer/GraphResource.mpp @@ -108,8 +108,8 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - GraphResource::operator=(GraphResource&& other) noexcept -> GraphResource& = default; + STORMKIT_FORCE_INLINE auto GraphResource::operator=(GraphResource&& other) noexcept + -> GraphResource& = default; ///////////////////////////////////// ///////////////////////////////////// @@ -142,16 +142,16 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - GraphResource::writers() const noexcept -> const std::vector& { + STORMKIT_FORCE_INLINE auto GraphResource::writers() const noexcept + -> const std::vector& { return m_writers; } ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - GraphResource::readers() const noexcept -> const std::vector& { + STORMKIT_FORCE_INLINE auto GraphResource::readers() const noexcept + -> const std::vector& { return m_readers; } @@ -165,8 +165,8 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - GraphResource::description() const noexcept -> const Description& { + STORMKIT_FORCE_INLINE auto GraphResource::description() const noexcept + -> const Description& { return m_description; } } // namespace stormkit::engine diff --git a/modules/stormkit/Engine/Renderer/GraphTask.mpp b/modules/stormkit/Engine/Renderer/GraphTask.mpp index e5aa85ae..a0ef5048 100644 --- a/modules/stormkit/Engine/Renderer/GraphTask.mpp +++ b/modules/stormkit/Engine/Renderer/GraphTask.mpp @@ -19,7 +19,7 @@ import :Renderer.GraphID; export namespace stormkit::engine { class GraphTaskBuilder; - class STORMKIT_API GraphTask { + class STORMKIT_API GraphTask { public: enum class Type { Graphics, diff --git a/modules/stormkit/Engine/Renderer/GraphTaskBuilder.mpp b/modules/stormkit/Engine/Renderer/GraphTaskBuilder.mpp index 49feaac5..f74b99d4 100644 --- a/modules/stormkit/Engine/Renderer/GraphTaskBuilder.mpp +++ b/modules/stormkit/Engine/Renderer/GraphTaskBuilder.mpp @@ -65,7 +65,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - GraphTaskBuilder::GraphTaskBuilder(const GraphTaskBuilder& other) noexcept = default; + GraphTaskBuilder::GraphTaskBuilder(const GraphTaskBuilder& other) noexcept = default; ///////////////////////////////////// ///////////////////////////////////// @@ -75,7 +75,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - GraphTaskBuilder::GraphTaskBuilder(GraphTaskBuilder&& other) noexcept = default; + GraphTaskBuilder::GraphTaskBuilder(GraphTaskBuilder&& other) noexcept = default; ///////////////////////////////////// ///////////////////////////////////// diff --git a/modules/stormkit/Entities.mpp b/modules/stormkit/Entities.mpp index 702b5f37..4098aaa4 100644 --- a/modules/stormkit/Entities.mpp +++ b/modules/stormkit/Entities.mpp @@ -14,7 +14,6 @@ import std; import stormkit.Core; - export namespace stormkit::entities { using Entity = core::UInt32; inline constexpr auto INVALID_ENTITY = Entity { 0 }; @@ -58,7 +57,7 @@ export namespace stormkit::entities { } // namespace literals struct Message { - core::UInt32 id; + core::UInt32 id; std::vector entities; }; @@ -73,9 +72,9 @@ export namespace stormkit::entities { MessageBus(MessageBus&&); auto operator=(MessageBus&&) -> MessageBus&; - auto push(Message&& message) -> void; + auto push(Message &&message) -> void; [[nodiscard]] auto top() const -> const Message&; - auto pop() -> void; + auto pop() -> void; [[nodiscard]] auto empty() const noexcept -> bool; @@ -121,13 +120,13 @@ export namespace stormkit::entities { protected: virtual auto onMessageReceived(const Message& message) -> void = 0; - EntityManager *m_manager; + EntityManager *m_manager; core::HashSet m_entities; friend class EntityManager; private: - core::UInt32 m_priority; + core::UInt32 m_priority; ComponentTypes m_types; }; @@ -207,18 +206,18 @@ export namespace stormkit::entities { auto removeFromSystems(Entity e) -> void; auto getNeededEntities(System& system) -> void; - Entity m_next_valid_entity = 1; + Entity m_next_valid_entity = 1; std::queue m_free_entities; - core::HashSet m_entities; + core::HashSet m_entities; mutable std::vector m_cached_entities; - mutable bool m_cached_entities_dirty = true; + mutable bool m_cached_entities_dirty = true; core::HashSet m_added_entities; core::HashSet m_updated_entities; core::HashSet m_removed_entities; - core::HashMap> m_registered_components_for_entities; + core::HashMap> m_registered_components_for_entities; std::set, System::Predicate> m_systems; core::HashMap> m_components; diff --git a/modules/stormkit/Gpu/Core/Device.mpp b/modules/stormkit/Gpu/Core/Device.mpp index 6474aee7..83a1de86 100644 --- a/modules/stormkit/Gpu/Core/Device.mpp +++ b/modules/stormkit/Gpu/Core/Device.mpp @@ -40,8 +40,8 @@ export namespace stormkit::gpu { }; Device(const PhysicalDevice& physical_device, - const Instance& instance, - const Info& info, + const Instance & instance, + const Info & info, Tag); ~Device(); @@ -52,27 +52,27 @@ export namespace stormkit::gpu { auto operator=(Device&&) noexcept -> Device&; [[nodiscard]] static auto create(const PhysicalDevice& physical_device, - const Instance& instance, + const Instance & instance, const Info& info = { true, false }) noexcept -> Device; - [[nodiscard]] static auto - allocate(const PhysicalDevice& physical_device, - const Instance& instance, - const Info& info = { true, false }) noexcept -> std::unique_ptr; + [[nodiscard]] static auto allocate(const PhysicalDevice& physical_device, + const Instance & instance, + const Info & info = { true, false }) noexcept + -> std::unique_ptr; auto waitIdle() const noexcept -> void; - [[nodiscard]] auto - waitForFences(std::span> fences, - bool wait_all = true, - const std::chrono::milliseconds& timeout = - std::chrono::milliseconds::max()) const noexcept -> Expected; - [[nodiscard]] auto - waitForFence(const Fence& fence, - const std::chrono::milliseconds& timeout = - std::chrono::milliseconds::max()) const noexcept -> Expected; - - auto - resetFences(std::span> fences) const noexcept -> void; + [[nodiscard]] auto waitForFences(std::span> fences, + bool wait_all = true, + const std::chrono::milliseconds& timeout = + std::chrono::milliseconds::max()) const noexcept + -> Expected; + [[nodiscard]] auto waitForFence(const Fence & fence, + const std::chrono::milliseconds& timeout = + std::chrono::milliseconds::max()) const noexcept + -> Expected; + + auto resetFences(std::span> fences) const noexcept + -> void; auto resetFence(const Fence& fence) const noexcept -> void; [[nodiscard]] auto rasterQueueEntry() const noexcept -> const QueueEntry&; @@ -92,9 +92,8 @@ export namespace stormkit::gpu { template auto setObjectName(const T& object, std::string_view name) const -> void; - auto setObjectName(core::UInt64 object, - DebugObjectType type, - std::string_view name) const -> void; + auto setObjectName(core::UInt64 object, DebugObjectType type, std::string_view name) const + -> void; private: core::NakedRef m_physical_device; @@ -137,9 +136,10 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Device::waitForFence( - const Fence& fence, - const std::chrono::milliseconds& timeout) const noexcept -> Expected { + STORMKIT_FORCE_INLINE auto + Device::waitForFence(const Fence & fence, + const std::chrono::milliseconds& timeout) const noexcept + -> Expected { return waitForFences(core::makeNakedRefArray(fence), true, timeout); } @@ -157,8 +157,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Device::asyncTransfertQueueEntry() const noexcept -> const QueueEntry& { + STORMKIT_FORCE_INLINE auto Device::asyncTransfertQueueEntry() const noexcept + -> const QueueEntry& { core::expects(m_async_transfert_queue != std::nullopt); return *m_async_transfert_queue; @@ -166,8 +166,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Device::asyncComputeQueueEntry() const noexcept -> const QueueEntry& { + STORMKIT_FORCE_INLINE auto Device::asyncComputeQueueEntry() const noexcept + -> const QueueEntry& { core::expects(m_async_compute_queue != std::nullopt); return *m_async_compute_queue; @@ -207,16 +207,16 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Device::vmaFunctionTable() const noexcept -> const vma::VulkanFunctions& { + STORMKIT_FORCE_INLINE auto Device::vmaFunctionTable() const noexcept + -> const vma::VulkanFunctions& { return m_vma_function_table; } ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Device::setObjectName(const T& object, - std::string_view name) const -> void { + STORMKIT_FORCE_INLINE auto Device::setObjectName(const T& object, std::string_view name) const + -> void { setObjectName(std::bit_cast(*(object.vkHandle())), T::DEBUG_TYPE, name); } diff --git a/modules/stormkit/Gpu/Core/Instance.mpp b/modules/stormkit/Gpu/Core/Instance.mpp index 99698833..59e09659 100644 --- a/modules/stormkit/Gpu/Core/Instance.mpp +++ b/modules/stormkit/Gpu/Core/Instance.mpp @@ -14,8 +14,6 @@ import std; import stormkit.Core; - - import stormkit.Gpu.Vulkan; import :Core.Types; @@ -40,9 +38,11 @@ export namespace stormkit::gpu { auto operator=(Instance&&) noexcept -> Instance&; [[nodiscard]] static auto create(std::string app_name = "", - bool verbose = (core::STORMKIT_BUILD_TYPE == "Debug")) noexcept -> Expected; - [[nodiscard]] static auto allocate(std::string app_name = "", - bool verbose = (core::STORMKIT_BUILD_TYPE == "Debug")) noexcept + bool verbose = (core::STORMKIT_BUILD_TYPE == + "Debug")) noexcept -> Expected; + [[nodiscard]] static auto + allocate(std::string app_name = "", + bool verbose = (core::STORMKIT_BUILD_TYPE == "Debug")) noexcept -> Expected>; [[nodiscard]] auto physicalDevices() const noexcept -> const std::vector&; @@ -83,13 +83,13 @@ export namespace stormkit::gpu { auto doRetrievePhysicalDevices() noexcept -> VulkanExpected; std::string m_app_name; - bool m_validation_layers_enabled; + bool m_validation_layers_enabled; core::DeferInit m_vk_context; core::DeferInit m_vk_instance; core::DeferInit m_vk_messenger; - std::vector m_extensions; + std::vector m_extensions; std::vector m_physical_devices; }; @@ -170,14 +170,16 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Instance::create(std::string app_name, bool enable_validation) noexcept + STORMKIT_FORCE_INLINE auto Instance::create(std::string app_name, + bool enable_validation) noexcept -> Expected try { return Instance { std::move(app_name), enable_validation, Tag {} }; } catch (Result result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Instance::allocate(std::string app_name, bool enable_validation) noexcept + STORMKIT_FORCE_INLINE auto Instance::allocate(std::string app_name, + bool enable_validation) noexcept -> Expected> try { return std::make_unique(std::move(app_name), enable_validation, Tag {}); } catch (Result result) { return std::unexpected(result); } diff --git a/modules/stormkit/Gpu/Core/Sync.mpp b/modules/stormkit/Gpu/Core/Sync.mpp index 4a66c29b..d1d2f60d 100644 --- a/modules/stormkit/Gpu/Core/Sync.mpp +++ b/modules/stormkit/Gpu/Core/Sync.mpp @@ -40,17 +40,18 @@ export namespace stormkit::gpu { Fence(Fence&&) noexcept; auto operator=(Fence&&) noexcept -> Fence&; - [[nodiscard]] static auto create(const Device& device, - bool signaled = false) noexcept -> Expected; + [[nodiscard]] static auto create(const Device& device, bool signaled = false) noexcept + -> Expected; [[nodiscard]] static auto createSignaled(const Device& device) noexcept -> Expected; [[nodiscard]] static auto allocate(const Device& device, bool signaled = false) noexcept -> Expected>; - [[nodiscard]] static auto - allocateSignaled(const Device& device) noexcept -> Expected>; + [[nodiscard]] static auto allocateSignaled(const Device& device) noexcept + -> Expected>; - [[nodiscard]] auto wait(const std::chrono::milliseconds& wait_for = - std::chrono::milliseconds::max()) const -> Expected; - auto reset() -> void; + [[nodiscard]] auto + wait(const std::chrono::milliseconds& wait_for = std::chrono::milliseconds::max()) const + -> Expected; + auto reset() -> void; [[nodiscard]] auto status() const noexcept -> Expected; @@ -76,8 +77,8 @@ export namespace stormkit::gpu { auto operator=(Semaphore&&) noexcept -> Semaphore&; [[nodiscard]] auto create(const Device& device) noexcept -> Expected; - [[nodiscard]] auto - allocate(const Device& device) noexcept -> Expected>; + [[nodiscard]] auto allocate(const Device& device) noexcept + -> Expected>; [[nodiscard]] auto vkHandle() const noexcept -> const vk::raii::Semaphore&; @@ -135,15 +136,15 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Fence::create(const Device& device, - bool signaled) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Fence::create(const Device& device, bool signaled) noexcept + -> Expected try { return Fence { device, signaled, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Fence::createSignaled(const Device& device) noexcept -> Expected { + STORMKIT_FORCE_INLINE auto Fence::createSignaled(const Device& device) noexcept + -> Expected { return create(device, true); } @@ -156,15 +157,15 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Fence::allocateSignaled(const Device& device) noexcept -> Expected> { + STORMKIT_FORCE_INLINE auto Fence::allocateSignaled(const Device& device) noexcept + -> Expected> { return allocate(device, true); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Fence::wait(const std::chrono::milliseconds& wait_for) const -> Expected { + STORMKIT_FORCE_INLINE auto Fence::wait(const std::chrono::milliseconds& wait_for) const + -> Expected { return device().waitForFence(*this, wait_for); } @@ -204,13 +205,13 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Semaphore::operator=(Semaphore&& other) noexcept -> Semaphore& = default; + STORMKIT_FORCE_INLINE auto Semaphore::operator=(Semaphore&& other) noexcept + -> Semaphore& = default; ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Semaphore::create(const Device& device) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Semaphore::create(const Device& device) noexcept + -> Expected try { return Semaphore { device, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } diff --git a/modules/stormkit/Gpu/Core/Types.mpp b/modules/stormkit/Gpu/Core/Types.mpp index f18a8fdf..bbab6808 100644 --- a/modules/stormkit/Gpu/Core/Types.mpp +++ b/modules/stormkit/Gpu/Core/Types.mpp @@ -1021,14 +1021,15 @@ export { [[nodiscard]] constexpr auto isDepthFormat(PixelFormat format) noexcept -> bool; [[nodiscard]] constexpr auto getChannelCountFor(PixelFormat format) noexcept -> core::UInt8; - [[nodiscard]] constexpr auto - getArraySizeByChannelFor(PixelFormat format) noexcept -> core::UInt8; + [[nodiscard]] constexpr auto getArraySizeByChannelFor(PixelFormat format) noexcept + -> core::UInt8; - [[nodiscard]] auto - computeMipLevel(const core::math::ExtentU& extent) noexcept -> core::UInt32; - [[nodiscard]] constexpr auto computeUniformBufferOffsetAlignement( - core::RangeExtent size, - const RenderCapabilities& capabilities) noexcept -> core::RangeExtent; + [[nodiscard]] auto computeMipLevel(const core::math::ExtentU& extent) noexcept + -> core::UInt32; + [[nodiscard]] constexpr auto + computeUniformBufferOffsetAlignement(core::RangeExtent size, + const RenderCapabilities& capabilities) noexcept + -> core::RangeExtent; [[nodiscard]] auto toString(const PhysicalDeviceInfo& data) noexcept; @@ -1036,24 +1037,29 @@ export { [[nodiscard]] constexpr auto as(From&&) noexcept -> To; template<> - [[nodiscard]] constexpr auto as( - const gpu::Viewport& viewport) noexcept -> vk::Viewport; + [[nodiscard]] constexpr auto + as(const gpu::Viewport& viewport) noexcept + -> vk::Viewport; template<> - [[nodiscard]] constexpr auto as( - const core::math::ExtentU& extent) noexcept -> vk::Extent3D; + [[nodiscard]] constexpr auto + as(const core::math::ExtentU& extent) noexcept + -> vk::Extent3D; template<> - [[nodiscard]] constexpr auto as( - const vk::Extent3D& extent) noexcept -> core::math::ExtentU; + [[nodiscard]] constexpr auto + as(const vk::Extent3D& extent) noexcept + -> core::math::ExtentU; template<> - [[nodiscard]] constexpr auto as( - const core::math::ExtentU& extent) noexcept -> vk::Extent2D; + [[nodiscard]] constexpr auto + as(const core::math::ExtentU& extent) noexcept + -> vk::Extent2D; template<> - [[nodiscard]] constexpr auto as( - const vk::Extent2D& extent) noexcept -> core::math::ExtentU; + [[nodiscard]] constexpr auto + as(const vk::Extent2D& extent) noexcept + -> core::math::ExtentU; template<> [[nodiscard]] constexpr auto as( @@ -1064,12 +1070,14 @@ export { const core::math::Vector2I& offset) noexcept -> vk::Offset2D; template<> - [[nodiscard]] constexpr auto as( - const vk::Offset3D& offset) noexcept -> core::math::Vector3I; + [[nodiscard]] constexpr auto + as(const vk::Offset3D& offset) noexcept + -> core::math::Vector3I; template<> - [[nodiscard]] constexpr auto as( - const vk::Offset2D& offset) noexcept -> core::math::Vector2I; + [[nodiscard]] constexpr auto + as(const vk::Offset2D& offset) noexcept + -> core::math::Vector2I; } // namespace stormkit::gpu FLAG_ENUM(stormkit::gpu::QueueFlag) @@ -1115,8 +1123,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - ParentRef::operator=(const ParentRef&) noexcept -> ParentRef& = default; + STORMKIT_FORCE_INLINE auto ParentRef::operator=(const ParentRef&) noexcept + -> ParentRef& = default; ///////////////////////////////////// ///////////////////////////////////// @@ -1126,8 +1134,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto - ParentRef::operator=(ParentRef&&) noexcept -> ParentRef& = default; + STORMKIT_FORCE_INLINE auto ParentRef::operator=(ParentRef&&) noexcept + -> ParentRef& = default; ///////////////////////////////////// ///////////////////////////////////// @@ -1170,8 +1178,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto - getChannelCountFor(PixelFormat format) noexcept -> core::UInt8 { + STORMKIT_FORCE_INLINE constexpr auto getChannelCountFor(PixelFormat format) noexcept + -> core::UInt8 { switch (format) { case PixelFormat::R8_SNorm: case PixelFormat::R8_UNorm: @@ -1247,8 +1255,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto - getArraySizeByChannelFor(PixelFormat format) noexcept -> core::UInt8 { + STORMKIT_FORCE_INLINE constexpr auto getArraySizeByChannelFor(PixelFormat format) noexcept + -> core::UInt8 { switch (format) { case PixelFormat::R8_SNorm: case PixelFormat::R8_UNorm: @@ -1333,8 +1341,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - computeMipLevel(const core::math::ExtentU& extent) noexcept -> core::UInt32 { + STORMKIT_FORCE_INLINE auto computeMipLevel(const core::math::ExtentU& extent) noexcept + -> core::UInt32 { const auto as_float = core::math::ExtentF { extent }; return core::narrow(core::math::floor( @@ -1344,9 +1352,10 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto computeUniformBufferOffsetAlignement( - core::RangeExtent size, - const RenderCapabilities& capabilities) noexcept -> core::RangeExtent { + STORMKIT_FORCE_INLINE constexpr auto + computeUniformBufferOffsetAlignement(core::RangeExtent size, + const RenderCapabilities& capabilities) noexcept + -> core::RangeExtent { const auto min_ubo_align = capabilities.limits.min_uniform_buffer_offset_alignment; if (min_ubo_align > 0) size = (size + min_ubo_align - 1) & ~(min_ubo_align - 1); @@ -1389,72 +1398,81 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template<> - [[nodiscard]] constexpr auto as( - const gpu::Viewport& viewport) noexcept -> vk::Viewport { + [[nodiscard]] constexpr auto + as(const gpu::Viewport& viewport) noexcept + -> vk::Viewport { return viewport.operator vk::Viewport(); } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto as( - const core::math::ExtentU& extent) noexcept -> vk::Extent3D { + STORMKIT_FORCE_INLINE constexpr auto + as(const core::math::ExtentU& extent) noexcept + -> vk::Extent3D { return vk::Extent3D { extent.width, extent.height, extent.depth }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto as( - const vk::Extent3D& extent) noexcept -> core::math::ExtentU { + STORMKIT_FORCE_INLINE constexpr auto + as(const vk::Extent3D& extent) noexcept + -> core::math::ExtentU { return { extent.width, extent.height, extent.depth }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto as( - const core::math::ExtentU& extent) noexcept -> vk::Extent2D { + STORMKIT_FORCE_INLINE constexpr auto + as(const core::math::ExtentU& extent) noexcept + -> vk::Extent2D { return vk::Extent2D { extent.width, extent.height }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto as( - const vk::Extent2D& extent) noexcept -> core::math::ExtentU { + STORMKIT_FORCE_INLINE constexpr auto + as(const vk::Extent2D& extent) noexcept + -> core::math::ExtentU { return { extent.width, extent.height }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto as( - const core::math::Vector3I& extent) noexcept -> vk::Offset3D { + STORMKIT_FORCE_INLINE constexpr auto + as(const core::math::Vector3I& extent) noexcept + -> vk::Offset3D { return vk::Offset3D { extent.x, extent.y, extent.z }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto as( - const core::math::Vector2I& extent) noexcept -> vk::Offset2D { + STORMKIT_FORCE_INLINE constexpr auto + as(const core::math::Vector2I& extent) noexcept + -> vk::Offset2D { return vk::Offset2D { extent.x, extent.y }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto as( - const vk::Offset3D& offset) noexcept -> core::math::Vector3I { + STORMKIT_FORCE_INLINE constexpr auto + as(const vk::Offset3D& offset) noexcept + -> core::math::Vector3I { return { offset.x, offset.y, offset.z }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto as( - const vk::Offset2D& offset) noexcept -> core::math::Vector2I { + STORMKIT_FORCE_INLINE constexpr auto + as(const vk::Offset2D& offset) noexcept + -> core::math::Vector2I { return { offset.x, offset.y }; } } // namespace stormkit::gpu diff --git a/modules/stormkit/Gpu/Execution/CommandBuffer.mpp b/modules/stormkit/Gpu/Execution/CommandBuffer.mpp index 2f9cf95f..6e7f6508 100644 --- a/modules/stormkit/Gpu/Execution/CommandBuffer.mpp +++ b/modules/stormkit/Gpu/Execution/CommandBuffer.mpp @@ -40,12 +40,12 @@ export namespace stormkit::gpu { Queue(Queue&&) noexcept; auto operator=(Queue&&) noexcept -> Queue&; - [[nodiscard]] static auto - create(const Device& device, - const Device::QueueEntry& entry) noexcept -> Expected; - [[nodiscard]] static auto - allocate(const Device& device, - const Device::QueueEntry& entry) noexcept -> Expected>; + [[nodiscard]] static auto create(const Device & device, + const Device::QueueEntry& entry) noexcept + -> Expected; + [[nodiscard]] static auto allocate(const Device & device, + const Device::QueueEntry& entry) noexcept + -> Expected>; auto waitIdle() const noexcept -> void; @@ -130,8 +130,8 @@ export namespace stormkit::gpu { std::optional inheritance_info = std::nullopt) -> void; auto end() -> void; - auto beginRenderPass(const RenderPass& render_pass, - const FrameBuffer& framebuffer, + auto beginRenderPass(const RenderPass & render_pass, + const FrameBuffer & framebuffer, std::span clear_values = std::array { ClearValue { ClearColor { .color = core::RGBColorDef::Silver } } }, bool secondary_commandbuffers = false) -> void; @@ -162,11 +162,11 @@ export namespace stormkit::gpu { core::UInt32 first_index = 0u, core::Int32 vertex_offset = 0, core::UInt32 first_instance = 0u) -> void; - auto drawIndirect(const Buffer& buffer, + auto drawIndirect(const Buffer & buffer, core::RangeExtent offset, core::UInt32 draw_count, core::UInt32 stride) -> void; - auto drawIndexedIndirect(const Buffer& buffer, + auto drawIndexedIndirect(const Buffer & buffer, core::RangeExtent offset, core::UInt32 draw_count, core::UInt32 stride) -> void; @@ -177,45 +177,45 @@ export namespace stormkit::gpu { core::UInt64 offset = 0, bool large_indices = false) -> void; auto - bindDescriptorSets(const Pipeline& pipeline, - const PipelineLayout& layout, + bindDescriptorSets(const Pipeline & pipeline, + const PipelineLayout & layout, std::span> descriptor_sets, std::span dynamic_offsets = {}) -> void; - auto copyBuffer(const Buffer& src, - const Buffer& dst, + auto copyBuffer(const Buffer & src, + const Buffer & dst, core::RangeExtent size, core::UInt64 src_offset = 0u, core::UInt64 dst_offset = 0u) -> void; - auto copyBufferToImage(const Buffer& src, - const Image& dst, + auto copyBufferToImage(const Buffer & src, + const Image & dst, std::span buffer_image_copies = {}) -> void; - auto copyImageToBuffer(const Image& src, - const Buffer& dst, + auto copyImageToBuffer(const Image & src, + const Buffer & dst, std::span buffer_image_copies = {}) -> void; - auto copyImage(const Image& src, - const Image& dst, + auto copyImage(const Image & src, + const Image & dst, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceLayers& src_subresource_layers, const ImageSubresourceLayers& dst_subresource_layers, - const core::math::ExtentU& extent) -> void; + const core::math::ExtentU & extent) -> void; - auto resolveImage(const Image& src, - const Image& dst, + auto resolveImage(const Image & src, + const Image & dst, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceLayers& src_subresource_layers = {}, const ImageSubresourceLayers& dst_subresource_layers = {}) -> void; - auto blitImage(const Image& src, - const Image& dst, + auto blitImage(const Image & src, + const Image & dst, ImageLayout src_layout, ImageLayout dst_layout, std::span regions, Filter filter) -> void; - auto transitionImageLayout(const Image& image, + auto transitionImageLayout(const Image & image, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceRange& subresource_range = {}) -> void; @@ -230,7 +230,7 @@ export namespace stormkit::gpu { std::span buffer_memory_barriers, std::span image_memory_barriers) -> void; - auto pushConstants(const PipelineLayout& pipeline_layout, + auto pushConstants(const PipelineLayout & pipeline_layout, ShaderStageFlag stage, std::span data, core::UInt32 offset = 0u) -> void; @@ -262,8 +262,8 @@ export namespace stormkit::gpu { CommandPool(CommandPool&&) noexcept; auto operator=(CommandPool&&) noexcept -> CommandPool&; - [[nodiscard]] static auto create(const Device& device, - const Queue& queue) noexcept -> Expected; + [[nodiscard]] static auto create(const Device& device, const Queue& queue) noexcept + -> Expected; [[nodiscard]] static auto allocate(const Device& device, const Queue& queue) noexcept -> Expected>; @@ -358,15 +358,15 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Queue::create(const Device& device, - const Device::QueueEntry& entry) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Queue::create(const Device & device, + const Device::QueueEntry& entry) noexcept + -> Expected try { return Queue { device, entry, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Queue::allocate(const Device& device, + STORMKIT_FORCE_INLINE auto Queue::allocate(const Device & device, const Device::QueueEntry& entry) noexcept -> Expected> try { return std::make_unique(device, entry, Tag {}); @@ -420,7 +420,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - CommandBuffer::CommandBuffer(const CommandPool& command_pool, + CommandBuffer::CommandBuffer(const CommandPool & command_pool, CommandBufferLevel level, vk::raii::CommandBuffer&& command_buffer, Deleter deleter) @@ -439,8 +439,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandBuffer::operator=(CommandBuffer&&) noexcept -> CommandBuffer& = default; + STORMKIT_FORCE_INLINE auto CommandBuffer::operator=(CommandBuffer&&) noexcept + -> CommandBuffer& = default; ///////////////////////////////////// ///////////////////////////////////// @@ -454,8 +454,7 @@ namespace stormkit::gpu { STORMKIT_FORCE_INLINE auto CommandBuffer::submit(std::span> wait_semaphores, std::span> signal_semaphores, - core::OptionalRef fence) const noexcept - -> void { + core::OptionalRef fence) const noexcept -> void { auto cmbs = std::array { core::NakedRef { *this } }; queue().submit(cmbs, wait_semaphores, signal_semaphores, std::move(fence)); @@ -475,9 +474,9 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandBuffer::beginDebugRegion(std::string_view name, - const core::RGBColorF& color) -> void { + STORMKIT_FORCE_INLINE auto CommandBuffer::beginDebugRegion(std::string_view name, + const core::RGBColorF& color) + -> void { core::expects(m_state == State::Recording); const auto& dispatcher = toRaiiVkHandle()(device()).getDispatcher(); @@ -491,9 +490,9 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandBuffer::insertDebugLabel(std::string_view name, - const core::RGBColorF& color) -> void { + STORMKIT_FORCE_INLINE auto CommandBuffer::insertDebugLabel(std::string_view name, + const core::RGBColorF& color) + -> void { core::expects(m_state == State::Recording); const auto& dispatcher = toRaiiVkHandle()(device()).getDispatcher(); @@ -518,9 +517,9 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandBuffer::begin(bool one_time_submit, - std::optional inheritance_info) -> void { + STORMKIT_FORCE_INLINE auto CommandBuffer::begin(bool one_time_submit, + std::optional inheritance_info) + -> void { core::expects(m_state == State::Recording); const auto vk_inheritance_info = core::either( @@ -563,8 +562,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::beginRenderPass(const RenderPass& render_pass, - const FrameBuffer& framebuffer, + CommandBuffer::beginRenderPass(const RenderPass & render_pass, + const FrameBuffer & framebuffer, std::span clear_values, bool secondary_commandbuffers) -> void { core::expects(m_state == State::Recording); @@ -629,9 +628,9 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandBuffer::setViewport(core::UInt32 first_viewport, - std::span viewports) -> void { + STORMKIT_FORCE_INLINE auto CommandBuffer::setViewport(core::UInt32 first_viewport, + std::span viewports) + -> void { core::expects(m_state == State::Recording); const auto vk_viewports = viewports | @@ -643,9 +642,9 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandBuffer::setScissor(core::UInt32 first_scissor, - std::span scissors) -> void { + STORMKIT_FORCE_INLINE auto CommandBuffer::setScissor(core::UInt32 first_scissor, + std::span scissors) + -> void { core::expects(m_state == State::Recording); const auto vk_scissors = scissors | std::views::transform(core::monadic::as()) | @@ -674,8 +673,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandBuffer::setBlendConstants(std::span constants) -> void { + STORMKIT_FORCE_INLINE auto CommandBuffer::setBlendConstants(std::span constants) + -> void { core::expects(m_state == State::Recording); float data[] = { constants[0], constants[1], constants[2], constants[3] }; @@ -761,7 +760,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::drawIndirect(const Buffer& buffer, + STORMKIT_FORCE_INLINE auto CommandBuffer::drawIndirect(const Buffer & buffer, core::RangeExtent offset, core::UInt32 draw_count, core::UInt32 stride) -> void { @@ -773,7 +772,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::drawIndexedIndirect(const Buffer& buffer, + STORMKIT_FORCE_INLINE auto CommandBuffer::drawIndexedIndirect(const Buffer & buffer, core::RangeExtent offset, core::UInt32 draw_count, core::UInt32 stride) -> void { @@ -814,8 +813,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto CommandBuffer::bindDescriptorSets( - const Pipeline& pipeline, - const PipelineLayout& layout, + const Pipeline & pipeline, + const PipelineLayout & layout, std::span> descriptor_sets, std::span dynamic_offsets) -> void { core::expects(m_state == State::Recording); @@ -836,8 +835,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::copyBuffer(const Buffer& src, - const Buffer& dst, + STORMKIT_FORCE_INLINE auto CommandBuffer::copyBuffer(const Buffer & src, + const Buffer & dst, core::RangeExtent size, core::UInt64 src_offset, core::UInt64 dst_offset) -> void { @@ -850,10 +849,11 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::copyBufferToImage( - const Buffer& src, - const Image& dst, - std::span buffer_image_copies) -> void { + STORMKIT_FORCE_INLINE auto + CommandBuffer::copyBufferToImage(const Buffer & src, + const Image & dst, + std::span buffer_image_copies) + -> void { core::expects(m_state == State::Recording); const auto DEFAULT_COPY = @@ -890,10 +890,11 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::copyImageToBuffer( - const Image& src, - const Buffer& dst, - std::span buffer_image_copies) -> void { + STORMKIT_FORCE_INLINE auto + CommandBuffer::copyImageToBuffer(const Image & src, + const Buffer & dst, + std::span buffer_image_copies) + -> void { core::expects(m_state == State::Recording); const auto DEFAULT_COPY = @@ -931,13 +932,13 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::copyImage(const Image& src, - const Image& dst, + CommandBuffer::copyImage(const Image & src, + const Image & dst, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceLayers& src_subresource_layers, const ImageSubresourceLayers& dst_subresource_layers, - const core::math::ExtentU& extent) -> void { + const core::math::ExtentU & extent) -> void { core::expects(m_state == State::Recording); const auto vk_src_subresource_layers = vk::ImageSubresourceLayers { @@ -969,8 +970,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::resolveImage(const Image& src, - const Image& dst, + CommandBuffer::resolveImage(const Image & src, + const Image & dst, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceLayers& src_subresource_layers, @@ -1007,8 +1008,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::blitImage(const Image& src, - const Image& dst, + STORMKIT_FORCE_INLINE auto CommandBuffer::blitImage(const Image & src, + const Image & dst, ImageLayout src_layout, ImageLayout dst_layout, std::span regions, @@ -1052,11 +1053,12 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::transitionImageLayout( - const Image& image, - ImageLayout src_layout, - ImageLayout dst_layout, - const ImageSubresourceRange& subresource_range) -> void { + STORMKIT_FORCE_INLINE auto + CommandBuffer::transitionImageLayout(const Image & image, + ImageLayout src_layout, + ImageLayout dst_layout, + const ImageSubresourceRange& subresource_range) + -> void { core::expects(m_state == State::Recording); const auto vk_src_layout = core::narrow(src_layout); @@ -1091,13 +1093,14 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::pipelineBarrier( - PipelineStageFlag src_mask, - PipelineStageFlag dst_mask, - DependencyFlag dependency, - std::span memory_barriers, - std::span buffer_memory_barriers, - std::span image_memory_barriers) -> void { + STORMKIT_FORCE_INLINE auto + CommandBuffer::pipelineBarrier(PipelineStageFlag src_mask, + PipelineStageFlag dst_mask, + DependencyFlag dependency, + std::span memory_barriers, + std::span buffer_memory_barriers, + std::span image_memory_barriers) + -> void { const auto vk_memory_barriers = memory_barriers | std::views::transform([](auto&& barrier) noexcept -> decltype(auto) { return vk::MemoryBarrier { @@ -1191,31 +1194,31 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandBuffer::vkHandle() const noexcept -> const vk::raii::CommandBuffer& { + STORMKIT_FORCE_INLINE auto CommandBuffer::vkHandle() const noexcept + -> const vk::raii::CommandBuffer& { return m_vk_command_buffer; } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandPool::create(const Device& device, - const Queue& queue) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto CommandPool::create(const Device& device, + const Queue & queue) noexcept + -> Expected try { return CommandPool { device, queue, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto CommandPool::allocate(const Device& device, - const Queue& queue) noexcept + const Queue & queue) noexcept -> Expected> try { return std::make_unique(device, queue, Tag {}); } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - CommandPool::vkHandle() const noexcept -> const vk::raii::CommandPool& { + STORMKIT_FORCE_INLINE auto CommandPool::vkHandle() const noexcept + -> const vk::raii::CommandPool& { return m_vk_command_pool; } } // namespace stormkit::gpu diff --git a/modules/stormkit/Gpu/Execution/Descriptors.mpp b/modules/stormkit/Gpu/Execution/Descriptors.mpp index 51e27abe..aa004afa 100644 --- a/modules/stormkit/Gpu/Execution/Descriptors.mpp +++ b/modules/stormkit/Gpu/Execution/Descriptors.mpp @@ -12,7 +12,6 @@ export module stormkit.Gpu:Execution.Descriptors; import std; - import stormkit.Core; import :Core; @@ -303,7 +302,9 @@ namespace stormkit::gpu { const auto create_info = vk::DescriptorSetLayoutCreateInfo {}.setBindings(vk_bindings); - this->device().vkHandle().createDescriptorSetLayout(create_info) + this->device() + .vkHandle() + .createDescriptorSetLayout(create_info) .transform(core::monadic::set(m_vk_descriptor_set_layout)) .transform_error(core::monadic::map(core::monadic::as(), core::throwError())); } @@ -389,7 +390,9 @@ namespace stormkit::gpu { .setMaxSets(max_sets) .setPoolSizes(pool_sizes); - this->device().vkHandle().createDescriptorPool(create_info) + this->device() + .vkHandle() + .createDescriptorPool(create_info) .transform(core::monadic::set(m_vk_descriptor_pool)) .transform_error(core::monadic::map(core::monadic::as(), core::throwError())); } diff --git a/modules/stormkit/Gpu/Execution/Pipeline.mpp b/modules/stormkit/Gpu/Execution/Pipeline.mpp index dadc2c1c..dd88939c 100644 --- a/modules/stormkit/Gpu/Execution/Pipeline.mpp +++ b/modules/stormkit/Gpu/Execution/Pipeline.mpp @@ -36,10 +36,10 @@ export namespace stormkit::gpu { PipelineCache(PipelineCache&&) noexcept; auto operator=(PipelineCache&&) noexcept -> PipelineCache&; - [[nodiscard]] static auto - create(const Device& device, - std::filesystem::path cache_path) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device& device, + [[nodiscard]] static auto create(const Device & device, + std::filesystem::path cache_path) noexcept + -> Expected; + [[nodiscard]] static auto allocate(const Device & device, std::filesystem::path cache_path) noexcept -> Expected>; @@ -91,10 +91,10 @@ export namespace stormkit::gpu { PipelineLayout(PipelineLayout&&) noexcept; auto operator=(PipelineLayout&&) noexcept -> PipelineLayout&; - [[nodiscard]] static auto - create(const Device& device, - const RasterPipelineLayout& layout) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device& device, + [[nodiscard]] static auto create(const Device & device, + const RasterPipelineLayout& layout) noexcept + -> Expected; + [[nodiscard]] static auto allocate(const Device & device, const RasterPipelineLayout& layout) noexcept -> Expected>; @@ -118,10 +118,10 @@ export namespace stormkit::gpu { static constexpr auto DEBUG_TYPE = DebugObjectType::Pipeline; - Pipeline(const Device& device, - const RasterPipelineState& state, - const PipelineLayout& layout, - const RenderPass& render_pass, + Pipeline(const Device & device, + const RasterPipelineState & state, + const PipelineLayout & layout, + const RenderPass & render_pass, std::optional> cache, Tag); ~Pipeline(); @@ -133,17 +133,17 @@ export namespace stormkit::gpu { auto operator=(Pipeline&&) noexcept -> Pipeline&; [[nodiscard]] static auto - create(const Device& device, - const RasterPipelineState& state, - const PipelineLayout& layout, - const RenderPass& render_pass, + create(const Device & device, + const RasterPipelineState & state, + const PipelineLayout & layout, + const RenderPass & render_pass, std::optional> cache) noexcept -> Expected; [[nodiscard]] static auto - allocate(const Device& device, - const RasterPipelineState& state, - const PipelineLayout& layout, - const RenderPass& render_pass, + allocate(const Device & device, + const RasterPipelineState & state, + const PipelineLayout & layout, + const RenderPass & render_pass, std::optional> cache) noexcept -> Expected>; @@ -197,12 +197,12 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - PipelineCache::operator=(PipelineCache&& other) noexcept -> PipelineCache& = default; + STORMKIT_FORCE_INLINE auto PipelineCache::operator=(PipelineCache&& other) noexcept + -> PipelineCache& = default; ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PipelineCache::create(const Device& device, + STORMKIT_FORCE_INLINE auto PipelineCache::create(const Device & device, std::filesystem::path cache_path) noexcept -> Expected try { return PipelineCache { device, std::move(cache_path), Tag {} }; @@ -210,7 +210,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PipelineCache::allocate(const Device& device, + STORMKIT_FORCE_INLINE auto PipelineCache::allocate(const Device & device, std::filesystem::path cache_path) noexcept -> Expected> try { return std::make_unique(device, std::move(cache_path), Tag {}); @@ -218,8 +218,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - PipelineCache::vkHandle() const noexcept -> const vk::raii::PipelineCache& { + STORMKIT_FORCE_INLINE auto PipelineCache::vkHandle() const noexcept + -> const vk::raii::PipelineCache& { return m_vk_pipeline_cache; } @@ -264,12 +264,12 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - PipelineLayout::operator=(PipelineLayout&& other) noexcept -> PipelineLayout& = default; + STORMKIT_FORCE_INLINE auto PipelineLayout::operator=(PipelineLayout&& other) noexcept + -> PipelineLayout& = default; ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PipelineLayout::create(const Device& device, + STORMKIT_FORCE_INLINE auto PipelineLayout::create(const Device & device, const RasterPipelineLayout& layout) noexcept -> Expected try { return PipelineLayout { device, layout, Tag {} }; @@ -277,7 +277,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PipelineLayout::allocate(const Device& device, + STORMKIT_FORCE_INLINE auto PipelineLayout::allocate(const Device & device, const RasterPipelineLayout& layout) noexcept -> Expected> try { return std::make_unique(device, layout, Tag {}); @@ -285,18 +285,18 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - PipelineLayout::vkHandle() const noexcept -> const vk::raii::PipelineLayout& { + STORMKIT_FORCE_INLINE auto PipelineLayout::vkHandle() const noexcept + -> const vk::raii::PipelineLayout& { return m_vk_pipeline_layout; } ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - Pipeline::Pipeline(const Device& device, - const RasterPipelineState& state, - const PipelineLayout& layout, - const RenderPass& render_pass, + Pipeline::Pipeline(const Device & device, + const RasterPipelineState & state, + const PipelineLayout & layout, + const RenderPass & render_pass, std::optional> cache, Tag) : DeviceObject { device }, m_state { state } { @@ -314,16 +314,16 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Pipeline::operator=(Pipeline&& other) noexcept -> Pipeline& = default; + STORMKIT_FORCE_INLINE auto Pipeline::operator=(Pipeline&& other) noexcept + -> Pipeline& = default; ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - Pipeline::create(const Device& device, - const RasterPipelineState& state, - const PipelineLayout& layout, - const RenderPass& render_pass, + Pipeline::create(const Device & device, + const RasterPipelineState & state, + const PipelineLayout & layout, + const RenderPass & render_pass, std::optional> cache) noexcept -> Expected try { return Pipeline { device, state, layout, render_pass, std::move(cache), Tag {} }; @@ -332,10 +332,10 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - Pipeline::allocate(const Device& device, - const RasterPipelineState& state, - const PipelineLayout& layout, - const RenderPass& render_pass, + Pipeline::allocate(const Device & device, + const RasterPipelineState & state, + const PipelineLayout & layout, + const RenderPass & render_pass, std::optional> cache) noexcept -> Expected> try { return std::make_unique(device, @@ -354,8 +354,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Pipeline::rasterState() const noexcept -> const RasterPipelineState& { + STORMKIT_FORCE_INLINE auto Pipeline::rasterState() const noexcept + -> const RasterPipelineState& { core::expects(core::is(m_state)); return core::as(m_state); } diff --git a/modules/stormkit/Gpu/Execution/RasterPipelineState.mpp b/modules/stormkit/Gpu/Execution/RasterPipelineState.mpp index 3f208fc6..54e64458 100644 --- a/modules/stormkit/Gpu/Execution/RasterPipelineState.mpp +++ b/modules/stormkit/Gpu/Execution/RasterPipelineState.mpp @@ -10,7 +10,6 @@ export module stormkit.Gpu:Execution.RasterPipelineState; import std; - import stormkit.Core; import :Core; diff --git a/modules/stormkit/Gpu/Execution/RenderPass.mpp b/modules/stormkit/Gpu/Execution/RenderPass.mpp index df7755ef..b74d2d4e 100644 --- a/modules/stormkit/Gpu/Execution/RenderPass.mpp +++ b/modules/stormkit/Gpu/Execution/RenderPass.mpp @@ -35,8 +35,8 @@ export { public: static constexpr auto DEBUG_TYPE = DebugObjectType::FrameBuffer; - FrameBuffer(const RenderPass& render_pass, - const core::math::ExtentU& size, + FrameBuffer(const RenderPass & render_pass, + const core::math::ExtentU & size, std::vector> attachments, Tag); ~FrameBuffer(); @@ -48,19 +48,19 @@ export { auto operator=(FrameBuffer&&) noexcept -> FrameBuffer&; [[nodiscard]] static auto - create(const RenderPass& render_pass, - const core::math::ExtentU& size, + create(const RenderPass & render_pass, + const core::math::ExtentU & size, std::vector> attachments) noexcept -> Expected; [[nodiscard]] static auto - allocate(const RenderPass& render_pass, - const core::math::ExtentU& size, + allocate(const RenderPass & render_pass, + const core::math::ExtentU & size, std::vector> attachments) noexcept -> Expected>; [[nodiscard]] auto extent() const noexcept -> const core::math::ExtentU&; - [[nodiscard]] auto - attachments() const noexcept -> const std::vector>&; + [[nodiscard]] auto attachments() const noexcept + -> const std::vector>&; [[nodiscard]] auto vkHandle() const noexcept -> const vk::raii::Framebuffer&; @@ -126,25 +126,25 @@ export { RenderPass(RenderPass&&) noexcept; auto operator=(RenderPass&&) noexcept -> RenderPass&; - [[nodiscard]] static auto - create(const Device& device, - const RenderPassDescription& description) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device& device, + [[nodiscard]] static auto create(const Device & device, + const RenderPassDescription& description) noexcept + -> Expected; + [[nodiscard]] static auto allocate(const Device & device, const RenderPassDescription& description) noexcept -> Expected>; - [[nodiscard]] auto - createFrameBuffer(const core::math::ExtentU& size, - std::vector> attachments) - const noexcept -> Expected; - [[nodiscard]] auto - allocateFrameBuffer(const core::math::ExtentU& size, - std::vector> attachments) - const noexcept -> Expected>; + [[nodiscard]] auto createFrameBuffer( + const core::math::ExtentU & size, + std::vector> attachments) const noexcept + -> Expected; + [[nodiscard]] auto allocateFrameBuffer( + const core::math::ExtentU & size, + std::vector> attachments) const noexcept + -> Expected>; [[nodiscard]] auto isCompatible(const RenderPass& render_pass) const noexcept -> bool; - [[nodiscard]] auto - isCompatible(const RenderPassDescription& description) const noexcept -> bool; + [[nodiscard]] auto isCompatible(const RenderPassDescription& description) const noexcept + -> bool; [[nodiscard]] auto description() const noexcept -> const RenderPassDescription&; @@ -186,8 +186,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - FrameBuffer::FrameBuffer(const RenderPass& render_pass, - const core::math::ExtentU& extent, + FrameBuffer::FrameBuffer(const RenderPass & render_pass, + const core::math::ExtentU & extent, std::vector> attachments, Tag) : DeviceObject { render_pass.device() }, RenderPassObject { render_pass }, @@ -202,7 +202,9 @@ namespace stormkit::gpu { .setHeight(m_extent.height) .setLayers(1); - device().vkHandle().createFramebuffer(create_info) + device() + .vkHandle() + .createFramebuffer(create_info) .transform(core::monadic::set(m_vk_framebuffer)) .transform_error(core::monadic::map(core::monadic::as(), core::throwError())); } @@ -223,14 +225,14 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - FrameBuffer::operator=(FrameBuffer&& other) noexcept -> FrameBuffer& = default; + STORMKIT_FORCE_INLINE auto FrameBuffer::operator=(FrameBuffer&& other) noexcept + -> FrameBuffer& = default; ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - FrameBuffer::create(const RenderPass& render_pass, - const core::math::ExtentU& size, + FrameBuffer::create(const RenderPass & render_pass, + const core::math::ExtentU & size, std::vector> attachments) noexcept -> Expected try { return FrameBuffer { render_pass, size, std::move(attachments), Tag {} }; @@ -239,8 +241,8 @@ namespace stormkit::gpu { ////////////////////////////////////p/ ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - FrameBuffer::allocate(const RenderPass& render_pass, - const core::math::ExtentU& size, + FrameBuffer::allocate(const RenderPass & render_pass, + const core::math::ExtentU & size, std::vector> attachments) noexcept -> Expected> try { return std::make_unique(render_pass, size, std::move(attachments), Tag {}); @@ -261,8 +263,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - FrameBuffer::vkHandle() const noexcept -> const vk::raii::Framebuffer& { + STORMKIT_FORCE_INLINE auto FrameBuffer::vkHandle() const noexcept + -> const vk::raii::Framebuffer& { return m_vk_framebuffer; } @@ -285,12 +287,12 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - RenderPass::operator=(RenderPass&& other) noexcept -> RenderPass& = default; + STORMKIT_FORCE_INLINE auto RenderPass::operator=(RenderPass&& other) noexcept + -> RenderPass& = default; ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto RenderPass::create(const Device& device, + STORMKIT_FORCE_INLINE auto RenderPass::create(const Device & device, const RenderPassDescription& description) noexcept -> Expected try { return RenderPass { device, description, Tag {} }; @@ -299,7 +301,7 @@ namespace stormkit::gpu { ////////////////////////////////////p/ ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - RenderPass::allocate(const Device& device, + RenderPass::allocate(const Device & device, const RenderPassDescription& description) noexcept -> Expected> try { return std::make_unique(device, description, Tag {}); @@ -307,19 +309,19 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - RenderPass::createFrameBuffer(const core::math::ExtentU& extent, - std::vector> attachments) - const noexcept -> Expected { + STORMKIT_FORCE_INLINE auto RenderPass::createFrameBuffer( + const core::math::ExtentU & extent, + std::vector> attachments) const noexcept + -> Expected { return FrameBuffer::create(*this, extent, std::move(attachments)); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - RenderPass::allocateFrameBuffer(const core::math::ExtentU& extent, - std::vector> attachments) - const noexcept -> Expected> { + STORMKIT_FORCE_INLINE auto RenderPass::allocateFrameBuffer( + const core::math::ExtentU & extent, + std::vector> attachments) const noexcept + -> Expected> { return FrameBuffer::allocate(*this, extent, std::move(attachments)); } @@ -335,15 +337,15 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - RenderPass::description() const noexcept -> const RenderPassDescription& { + STORMKIT_FORCE_INLINE auto RenderPass::description() const noexcept + -> const RenderPassDescription& { return m_description; } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - RenderPass::vkHandle() const noexcept -> const vk::raii::RenderPass& { + STORMKIT_FORCE_INLINE auto RenderPass::vkHandle() const noexcept + -> const vk::raii::RenderPass& { return m_vk_render_pass; } } // namespace stormkit::gpu diff --git a/modules/stormkit/Gpu/Resource/Buffer.mpp b/modules/stormkit/Gpu/Resource/Buffer.mpp index e6dc5cfa..1ecac90a 100644 --- a/modules/stormkit/Gpu/Resource/Buffer.mpp +++ b/modules/stormkit/Gpu/Resource/Buffer.mpp @@ -10,7 +10,6 @@ export module stormkit.Gpu:Resource.Buffer; import std; - import stormkit.Core; import :Core; @@ -165,7 +164,7 @@ namespace stormkit::gpu { if (!m_mapped_pointer) { auto _ = device().vmaAllocator().mapMemory(*m_vma_allocation, - std::bit_cast(&m_mapped_pointer)); + std::bit_cast(&m_mapped_pointer)); m_mapped_pointer += offset; } diff --git a/modules/stormkit/Gpu/Resource/Image.mpp b/modules/stormkit/Gpu/Resource/Image.mpp index ab363c8e..0f61e2d9 100644 --- a/modules/stormkit/Gpu/Resource/Image.mpp +++ b/modules/stormkit/Gpu/Resource/Image.mpp @@ -57,8 +57,8 @@ export namespace stormkit::gpu { Sampler(Sampler&&) noexcept; auto operator=(Sampler&&) noexcept -> Sampler&; - [[nodiscard]] static auto create(const Device& device, - const Settings& settings) noexcept -> Expected; + [[nodiscard]] static auto create(const Device& device, const Settings& settings) noexcept + -> Expected; [[nodiscard]] static auto allocate(const Device& device, const Settings& settings) noexcept -> Expected>; @@ -87,8 +87,8 @@ export namespace stormkit::gpu { public: static constexpr auto DEBUG_TYPE = DebugObjectType::Image_View; - ImageView(const Device& device, - const Image& image, + ImageView(const Device & device, + const Image & image, ImageViewType type, const ImageSubresourceRange& subresource_range, Tag); @@ -100,14 +100,15 @@ export namespace stormkit::gpu { ImageView(ImageView&&) noexcept; auto operator=(ImageView&&) noexcept -> ImageView&; - [[nodiscard]] static auto create( - const Device& device, - const Image& image, - ImageViewType type = ImageViewType::T2D, - const ImageSubresourceRange& subresource_range = {}) noexcept -> Expected; [[nodiscard]] static auto - allocate(const Device& device, - const Image& image, + create(const Device & device, + const Image & image, + ImageViewType type = ImageViewType::T2D, + const ImageSubresourceRange& subresource_range = {}) noexcept + -> Expected; + [[nodiscard]] static auto + allocate(const Device & device, + const Image & image, ImageViewType type = ImageViewType::T2D, const ImageSubresourceRange& subresource_range = {}) noexcept -> Expected>; @@ -153,11 +154,11 @@ export namespace stormkit::gpu { Image(Image&&) noexcept; auto operator=(Image&&) noexcept -> Image&; - [[nodiscard]] static auto create(const Device& device, - const CreateInfo& info) noexcept -> Expected; - [[nodiscard]] static auto - allocate(const Device& device, - const CreateInfo& create_info) noexcept -> Expected>; + [[nodiscard]] static auto create(const Device& device, const CreateInfo& info) noexcept + -> Expected; + [[nodiscard]] static auto allocate(const Device & device, + const CreateInfo& create_info) noexcept + -> Expected>; [[nodiscard]] auto extent() const noexcept -> const core::math::ExtentU&; [[nodiscard]] auto format() const noexcept -> PixelFormat; @@ -172,10 +173,10 @@ export namespace stormkit::gpu { private: Image(const Device& device, const CreateInfo& info); - Image(const Device& device, + Image(const Device & device, const core::math::ExtentU& extent, PixelFormat format, - vk::Image&& image, + vk::Image && image, Tag); core::math::ExtentU m_extent = { 0, 0, 0 }; @@ -204,7 +205,7 @@ export namespace stormkit::gpu { core::UInt32 src_queue_family_index = QUEUE_FAMILY_IGNORED; core::UInt32 dst_queue_family_index = QUEUE_FAMILY_IGNORED; - const Image& image; + const Image & image; ImageSubresourceRange range; }; } // namespace stormkit::gpu @@ -253,15 +254,15 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Sampler::create(const Device& device, - const Settings& settings) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Sampler::create(const Device & device, + const Settings& settings) noexcept + -> Expected try { return Sampler { device, settings, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Sampler::allocate(const Device& device, + STORMKIT_FORCE_INLINE auto Sampler::allocate(const Device & device, const Settings& settings) noexcept -> Expected> try { return std::make_unique(device, settings, Tag {}); @@ -287,8 +288,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE ImageView::ImageView(const Device& device, - const Image& image, + STORMKIT_FORCE_INLINE ImageView::ImageView(const Device & device, + const Image & image, ImageViewType type, const ImageSubresourceRange& subresource_range, Tag) @@ -329,24 +330,25 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - ImageView::operator=(ImageView&& other) noexcept -> ImageView& = default; + STORMKIT_FORCE_INLINE auto ImageView::operator=(ImageView&& other) noexcept + -> ImageView& = default; ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto ImageView::create( - const Device& device, - const Image& image, - ImageViewType type, - const ImageSubresourceRange& subresource_range) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto + ImageView::create(const Device & device, + const Image & image, + ImageViewType type, + const ImageSubresourceRange& subresource_range) noexcept + -> Expected try { return ImageView { device, image, type, subresource_range, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - ImageView::allocate(const Device& device, - const Image& image, + ImageView::allocate(const Device & device, + const Image & image, ImageViewType type, const ImageSubresourceRange& subresource_range) noexcept -> Expected> try { @@ -361,8 +363,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - ImageView::subresourceRange() const noexcept -> const ImageSubresourceRange& { + STORMKIT_FORCE_INLINE auto ImageView::subresourceRange() const noexcept + -> const ImageSubresourceRange& { return m_subresource_range; } @@ -422,8 +424,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE Image::Image(const Device& device, - const core::math::ExtentU& extent, + STORMKIT_FORCE_INLINE Image::Image(const Device & device, + const core::math::ExtentU & extent, gpu::PixelFormat format, [[maybe_unused]] vk::Image&& image, Tag) @@ -446,15 +448,15 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Image::create(const Device& device, - const CreateInfo& create_info) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Image::create(const Device & device, + const CreateInfo& create_info) noexcept + -> Expected try { return Image { device, create_info, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Image::allocate(const Device& device, + STORMKIT_FORCE_INLINE auto Image::allocate(const Device & device, const CreateInfo& create_info) noexcept -> Expected> try { return std::make_unique(device, create_info, Tag {}); diff --git a/modules/stormkit/Gpu/Resource/Shader.mpp b/modules/stormkit/Gpu/Resource/Shader.mpp index 383f7d89..5ebca20f 100644 --- a/modules/stormkit/Gpu/Resource/Shader.mpp +++ b/modules/stormkit/Gpu/Resource/Shader.mpp @@ -23,7 +23,7 @@ namespace stormkit::gpu { public: static constexpr auto DEBUG_TYPE = DebugObjectType::Shader_Module; - Shader(const Device& device, + Shader(const Device & device, const std::filesystem::path& filepath, ShaderStageFlag type, Tag); @@ -37,25 +37,25 @@ namespace stormkit::gpu { Shader(Shader&&) noexcept; auto operator=(Shader&&) noexcept -> Shader&; - [[nodiscard]] static auto loadFromFile(const Device& device, + [[nodiscard]] static auto loadFromFile(const Device & device, const std::filesystem::path& filepath, ShaderStageFlag type) noexcept -> Expected; - [[nodiscard]] static auto fromBytes(const Device& device, + [[nodiscard]] static auto fromBytes(const Device & device, std::span data, ShaderStageFlag type) noexcept -> Expected; - [[nodiscard]] static auto fromSpirvIDs(const Device& device, + [[nodiscard]] static auto fromSpirvIDs(const Device & device, std::span data, ShaderStageFlag type) noexcept -> Expected; - [[nodiscard]] static auto allocateAndLoadFromFile(const Device& device, + [[nodiscard]] static auto allocateAndLoadFromFile(const Device & device, const std::filesystem::path& filepath, ShaderStageFlag type) noexcept -> Expected>; - [[nodiscard]] static auto - allocateFromBytes(const Device& device, + [[nodiscard]] static auto allocateFromBytes(const Device & device, std::span data, - ShaderStageFlag type) noexcept -> Expected>; - [[nodiscard]] static auto allocateFromSpirvIDs(const Device& device, + ShaderStageFlag type) noexcept + -> Expected>; + [[nodiscard]] static auto allocateFromSpirvIDs(const Device & device, std::span data, ShaderStageFlag type) noexcept -> Expected>; @@ -85,7 +85,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - Shader::Shader(const Device& device, + Shader::Shader(const Device & device, const std::filesystem::path& filepath, ShaderStageFlag type, Tag) @@ -103,7 +103,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - Shader::Shader(const Device& device, + Shader::Shader(const Device & device, std::span data, ShaderStageFlag type, Tag) @@ -135,43 +135,44 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Shader::loadFromFile(const Device& device, - const std::filesystem::path& filepath, - ShaderStageFlag type) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Shader::loadFromFile(const Device & device, + const std::filesystem::path& filepath, + ShaderStageFlag type) noexcept + -> Expected try { return Shader { device, std::move(filepath), type, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Shader::fromBytes(const Device& device, - std::span data, - ShaderStageFlag type) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Shader::fromBytes(const Device & device, + std::span data, + ShaderStageFlag type) noexcept + -> Expected try { return Shader { device, data, type, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Shader::fromSpirvIDs(const Device& device, - std::span data, - ShaderStageFlag type) noexcept -> Expected try { + STORMKIT_FORCE_INLINE auto Shader::fromSpirvIDs(const Device & device, + std::span data, + ShaderStageFlag type) noexcept + -> Expected try { return Shader { device, data, type, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Shader::allocateAndLoadFromFile( - const Device& device, - const std::filesystem::path& filepath, - ShaderStageFlag type) noexcept -> Expected> try { + STORMKIT_FORCE_INLINE auto + Shader::allocateAndLoadFromFile(const Device & device, + const std::filesystem::path& filepath, + ShaderStageFlag type) noexcept + -> Expected> try { return std::make_unique(device, filepath, type, Tag {}); } catch (const Result& result) { return std::unexpected(result); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Shader::allocateFromBytes(const Device& device, + STORMKIT_FORCE_INLINE auto Shader::allocateFromBytes(const Device & device, std::span data, ShaderStageFlag type) noexcept -> Expected> try { @@ -180,7 +181,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Shader::allocateFromSpirvIDs(const Device& device, + STORMKIT_FORCE_INLINE auto Shader::allocateFromSpirvIDs(const Device & device, std::span data, ShaderStageFlag type) noexcept -> Expected> try { diff --git a/modules/stormkit/Gpu/Vulkan/Utils.mpp b/modules/stormkit/Gpu/Vulkan/Utils.mpp index 520d9bd8..0bd8f48f 100644 --- a/modules/stormkit/Gpu/Vulkan/Utils.mpp +++ b/modules/stormkit/Gpu/Vulkan/Utils.mpp @@ -44,8 +44,8 @@ export namespace stormkit::gpu { template requires(core::Is, vk::Result>) - auto vkCall(T& object, - Func&& func, + auto vkCall(T & object, + Func && func, std::span possible_results, Args&&...args) noexcept -> VulkanExpected; @@ -62,29 +62,29 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE constexpr auto - vkMakeVersion(T major, T minor, T patch) noexcept -> core::UInt32 { + STORMKIT_FORCE_INLINE constexpr auto vkMakeVersion(T major, T minor, T patch) noexcept + -> core::UInt32 { return vkVersionMajor(major) | vkVersionMinor(minor) | vkVersionPatch(patch); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto - vkVersionMajor(std::integral auto version) noexcept -> core::UInt32 { + STORMKIT_FORCE_INLINE constexpr auto vkVersionMajor(std::integral auto version) noexcept + -> core::UInt32 { return core::as(version >> 22u); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto - vkVersionMinor(std::integral auto version) noexcept -> core::UInt32 { + STORMKIT_FORCE_INLINE constexpr auto vkVersionMinor(std::integral auto version) noexcept + -> core::UInt32 { return core::as((version >> 12u) & 0x3ffu); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto - vkVersionPatch(std::integral auto version) noexcept -> core::UInt32 { + STORMKIT_FORCE_INLINE constexpr auto vkVersionPatch(std::integral auto version) noexcept + -> core::UInt32 { return core::as(version & 0xfffu); } @@ -98,8 +98,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE constexpr auto checkFlag(vk::Flags value, - vk::Flags flag) noexcept -> bool { + STORMKIT_FORCE_INLINE constexpr auto checkFlag(vk::Flags value, vk::Flags flag) noexcept + -> bool { return (value & flag) == flag; } @@ -107,8 +107,8 @@ namespace stormkit::gpu { ///////////////////////////////////// template requires(core::Is, vk::Result>) - STORMKIT_FORCE_INLINE auto - vkCall(T& value, Func&& func_ref, Args&&...args) noexcept -> VulkanExpected { + STORMKIT_FORCE_INLINE auto vkCall(T& value, Func&& func_ref, Args&&...args) noexcept + -> VulkanExpected { return vkCall(value, std::forward(func_ref), { vk::Result::eSuccess }, @@ -119,8 +119,8 @@ namespace stormkit::gpu { ///////////////////////////////////// template requires(core::Is, vk::Result>) - STORMKIT_FORCE_INLINE auto vkCall(T& value, - Func&& func_ref, + STORMKIT_FORCE_INLINE auto vkCall(T & value, + Func && func_ref, std::span possible_results, Args&&...args) noexcept -> VulkanExpected { auto func = std::mem_fn(std::forward(func_ref)); diff --git a/modules/stormkit/Gpu/Vulkan/vma.mpp b/modules/stormkit/Gpu/Vulkan/vma.mpp index 00551754..5f9e1dec 100644 --- a/modules/stormkit/Gpu/Vulkan/vma.mpp +++ b/modules/stormkit/Gpu/Vulkan/vma.mpp @@ -21,4 +21,3 @@ export namespace VMA_HPP_NAMESPACE { } // namespace raii } // namespace VMA_HPP_NAMESPACE #endif - diff --git a/modules/stormkit/Image/Image.mpp b/modules/stormkit/Image/Image.mpp index c7b85e70..49f214e5 100644 --- a/modules/stormkit/Image/Image.mpp +++ b/modules/stormkit/Image/Image.mpp @@ -12,7 +12,6 @@ import std; import stormkit.Core; - export namespace stormkit::image { class STORMKIT_API Image { public: @@ -105,13 +104,13 @@ export namespace stormkit::image { }; struct ImageData { - core::math::ExtentU extent = { 0u, 0u, 0u }; - core::UInt32 channel_count = 0u; - core::UInt32 bytes_per_channel = 0u; - core::UInt32 layers = 1u; - core::UInt32 faces = 1u; - core::UInt32 mip_levels = 1u; - Format format = Format::Undefined; + core::math::ExtentU extent = { 0u, 0u, 0u }; + core::UInt32 channel_count = 0u; + core::UInt32 bytes_per_channel = 0u; + core::UInt32 layers = 1u; + core::UInt32 faces = 1u; + core::UInt32 mip_levels = 1u; + Format format = Format::Undefined; std::vector data = {}; }; @@ -130,17 +129,17 @@ export namespace stormkit::image { auto operator=(Image&& rhs) noexcept -> Image&; [[nodiscard]] auto loadFromFile(std::filesystem::path filepath, - Codec codec = Codec::Autodetect) noexcept + Codec codec = Codec::Autodetect) noexcept -> std::expected; [[nodiscard]] auto loadFromMemory(std::span data, Codec codec = Codec::Autodetect) noexcept -> std::expected; [[nodiscard]] auto saveToFile(std::filesystem::path filename, - Codec codec, - CodecArgs args = CodecArgs::Binary) const noexcept + Codec codec, + CodecArgs args = CodecArgs::Binary) const noexcept -> std::expected; - [[nodiscard]] auto saveToMemory(Codec codec, + [[nodiscard]] auto saveToMemory(Codec codec, CodecArgs args = CodecArgs::Binary) const noexcept -> std::expected, Error>; @@ -156,22 +155,22 @@ export namespace stormkit::image { [[nodiscard]] auto rotate270() const noexcept -> Image; [[nodiscard]] auto pixel(core::RangeExtent id, - core::UInt32 layer = 0u, - core::UInt32 face = 0u, - core::UInt32 level = 0u) noexcept -> std::span; + core::UInt32 layer = 0u, + core::UInt32 face = 0u, + core::UInt32 level = 0u) noexcept -> std::span; [[nodiscard]] auto pixel(core::RangeExtent id, - core::UInt32 layer = 0u, - core::UInt32 face = 0u, - core::UInt32 level = 0u) const noexcept + core::UInt32 layer = 0u, + core::UInt32 face = 0u, + core::UInt32 level = 0u) const noexcept -> std::span; [[nodiscard]] auto pixel(core::math::Vector3U position, - core::UInt32 layer = 0u, - core::UInt32 face = 0u, - core::UInt32 level = 0u) noexcept -> std::span; + core::UInt32 layer = 0u, + core::UInt32 face = 0u, + core::UInt32 level = 0u) noexcept -> std::span; [[nodiscard]] auto pixel(core::math::Vector3U position, - core::UInt32 layer = 0u, - core::UInt32 face = 0u, - core::UInt32 level = 0u) const noexcept + core::UInt32 layer = 0u, + core::UInt32 face = 0u, + core::UInt32 level = 0u) const noexcept -> std::span; [[nodiscard]] auto extent(core::UInt32 level = 0u) const noexcept -> core::math::ExtentU; @@ -243,9 +242,9 @@ namespace stormkit::image { ///////////////////////////////////// ///////////////////////////////////// inline auto Image::pixel(core::RangeExtent index, - core::UInt32 layer, - core::UInt32 face, - core::UInt32 level) noexcept -> std::span { + core::UInt32 layer, + core::UInt32 face, + core::UInt32 level) noexcept -> std::span { core::expects(m_data.mip_levels > level); core::expects(m_data.faces > face); core::expects(m_data.layers > layer); @@ -262,8 +261,8 @@ namespace stormkit::image { ///////////////////////////////////// ///////////////////////////////////// inline auto Image::pixel(core::RangeExtent index, - core::UInt32 layer, - core::UInt32 face, + core::UInt32 layer, + core::UInt32 face, core::UInt32 level) const noexcept -> std::span { core::expects(m_data.mip_levels > level); core::expects(m_data.faces > face); @@ -282,9 +281,9 @@ namespace stormkit::image { ///////////////////////////////////// ///////////////////////////////////// inline auto Image::pixel(core::math::Vector3U position, - core::UInt32 layer, - core::UInt32 face, - core::UInt32 level) noexcept -> std::span { + core::UInt32 layer, + core::UInt32 face, + core::UInt32 level) noexcept -> std::span { const auto mip_extent = extent(level); const auto id = position.x + (position.y * mip_extent.width) + @@ -296,8 +295,8 @@ namespace stormkit::image { ///////////////////////////////////// ///////////////////////////////////// inline auto Image::pixel(core::math::Vector3U position, - core::UInt32 layer, - core::UInt32 face, + core::UInt32 layer, + core::UInt32 face, core::UInt32 level) const noexcept -> std::span { const auto mip_extent = extent(level); @@ -364,7 +363,7 @@ namespace stormkit::image { inline auto Image::size( [[maybe_unused]] core::UInt32 layer, // TODO Use layer and face to get correct size [[maybe_unused]] core::UInt32 face, - core::UInt32 level) const noexcept -> core::RangeExtent { + core::UInt32 level) const noexcept -> core::RangeExtent { core::expects(m_data.mip_levels > level); core::expects(m_data.faces > face); core::expects(m_data.layers > layer); diff --git a/modules/stormkit/Log/ConsoleLogger.mpp b/modules/stormkit/Log/ConsoleLogger.mpp index 71f72525..0e5eb1ec 100644 --- a/modules/stormkit/Log/ConsoleLogger.mpp +++ b/modules/stormkit/Log/ConsoleLogger.mpp @@ -12,7 +12,6 @@ import std; import stormkit.Core; - import :Logger; import :Severity; diff --git a/modules/stormkit/Log/Logger.mpp b/modules/stormkit/Log/Logger.mpp index 3a0d1d80..59761360 100644 --- a/modules/stormkit/Log/Logger.mpp +++ b/modules/stormkit/Log/Logger.mpp @@ -40,8 +40,8 @@ export namespace stormkit::log { [[nodiscard]] static auto allocateLoggerInstance(Args&&...param_args) -> std::unique_ptr; template - static auto log(Severity severity, - const Module& module, + static auto log(Severity severity, + const Module & module, std::string_view format_string, Args&&...param_args) -> void; @@ -69,7 +69,7 @@ export namespace stormkit::log { protected: LogClock::time_point m_start_time; - Severity m_log_level; + Severity m_log_level; }; struct Module { @@ -135,7 +135,8 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::allocateLoggerInstance(Args&&...param_args) -> std::unique_ptr { + STORMKIT_FORCE_INLINE auto Logger::allocateLoggerInstance(Args&&...param_args) + -> std::unique_ptr { using LogClock = std::chrono::high_resolution_clock; static_assert(std::is_base_of::value, "T must inherit Logger"); @@ -147,14 +148,14 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::log(Severity severity, - const Module& m, - std::string_view format_string, - Args&&...param_args) -> void { + STORMKIT_FORCE_INLINE auto Logger::log(Severity severity, + const Module & m, + std::string_view format_string, + Args&&...param_args) -> void { core::expects(hasLogger()); - const auto format = format_string; - auto memory_buffer = std::string {}; + const auto format = format_string; + auto memory_buffer = std::string {}; std::vformat_to(std::back_inserter(memory_buffer), format, std::make_format_args(param_args...)); @@ -165,9 +166,10 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::log(Severity severity, std::string_view format_string, Args&&...param_args) - -> void { - log(severity, Module{}, format_string, std::forward(param_args)...); + STORMKIT_FORCE_INLINE auto Logger::log(Severity severity, + std::string_view format_string, + Args&&...param_args) -> void { + log(severity, Module {}, format_string, std::forward(param_args)...); } //////////////////////////////////////// diff --git a/modules/stormkit/Log/Severity.mpp b/modules/stormkit/Log/Severity.mpp index e087f28f..3a0272c8 100644 --- a/modules/stormkit/Log/Severity.mpp +++ b/modules/stormkit/Log/Severity.mpp @@ -67,7 +67,8 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto toStringView(Severity severity) noexcept -> std::string_view { + STORMKIT_FORCE_INLINE constexpr auto toStringView(Severity severity) noexcept + -> std::string_view { const auto it = details::SEVERITY_TO_STRING.find(severity); core::expects(it != std::ranges::cend(details::SEVERITY_TO_STRING)); diff --git a/modules/stormkit/Wsi/EventHandler.mpp b/modules/stormkit/Wsi/EventHandler.mpp index 72df87be..52a84452 100644 --- a/modules/stormkit/Wsi/EventHandler.mpp +++ b/modules/stormkit/Wsi/EventHandler.mpp @@ -12,7 +12,6 @@ import std; import stormkit.Core; - import :Types; import :Window; diff --git a/modules/stormkit/Wsi/Types.mpp b/modules/stormkit/Wsi/Types.mpp index 7eb5a002..30fb377e 100644 --- a/modules/stormkit/Wsi/Types.mpp +++ b/modules/stormkit/Wsi/Types.mpp @@ -14,7 +14,6 @@ import frozen; import stormkit.Core; - export { namespace stormkit::wsi { enum class WM { diff --git a/modules/stormkit/Wsi/Window.mpp b/modules/stormkit/Wsi/Window.mpp index ac1b8e2d..36d9c0da 100644 --- a/modules/stormkit/Wsi/Window.mpp +++ b/modules/stormkit/Wsi/Window.mpp @@ -12,7 +12,6 @@ import std; import stormkit.Core; - import :Types; namespace stormkit::wsi { @@ -57,12 +56,12 @@ export namespace stormkit::wsi { [[nodiscard]] auto mouseLocked() const noexcept -> bool; [[nodiscard]] auto fullscreen() const noexcept -> bool; - auto setKeyRepeatEnabled(bool enabled) noexcept -> void; + auto setKeyRepeatEnabled(bool enabled) noexcept -> void; [[nodiscard]] auto keyRepeatEnabled() const noexcept -> bool; auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; static auto setMousePositionOnDesktop(const core::math::Vector2U& position) noexcept -> void; diff --git a/src/Core/ThreadPool.cpp b/src/Core/ThreadPool.cpp index 6e69ad25..3d5f50ec 100644 --- a/src/Core/ThreadPool.cpp +++ b/src/Core/ThreadPool.cpp @@ -50,7 +50,10 @@ namespace stormkit::core { ///////////////////////////////////// auto ThreadPool::joinAll() -> void { for ([[maybe_unused]] const auto i : range(m_worker_count)) - postTask(Task::Type::Terminate, [] {}, ThreadPool::NoFuture); + postTask( + Task::Type::Terminate, + [] {}, + ThreadPool::NoFuture); for (auto& thread : m_workers) if (thread.joinable()) thread.join(); diff --git a/src/Core/posix/DynamicLoader.mpp b/src/Core/posix/DynamicLoader.mpp index 880661df..1d00986b 100644 --- a/src/Core/posix/DynamicLoader.mpp +++ b/src/Core/posix/DynamicLoader.mpp @@ -13,7 +13,6 @@ export module stormkit.Core:Utils.DynamicLoaderImpl; import std; - import :Utils.Expected; import :Utils.Numerics; import :Utils.AsCast; @@ -51,7 +50,8 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto operator=(DynamicLoaderImpl&& other) noexcept -> DynamicLoaderImpl& { + STORMKIT_FORCE_INLINE auto operator=(DynamicLoaderImpl&& other) noexcept + -> DynamicLoaderImpl& { if (&other == this) [[unlikely]] return *this; diff --git a/src/Core/win32/DynamicLoader.mpp b/src/Core/win32/DynamicLoader.mpp index 7d9bfcdc..bb1b4610 100644 --- a/src/Core/win32/DynamicLoader.mpp +++ b/src/Core/win32/DynamicLoader.mpp @@ -12,7 +12,6 @@ export module stormkit.Core:Utils.DynamicLoaderImpl; import std; - import :Utils.Expected; import :Utils.Numerics; import :Utils.AsCast; @@ -37,7 +36,7 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - DynamicLoaderImpl(const DynamicLoaderImpl&) = delete; + DynamicLoaderImpl(const DynamicLoaderImpl&) = delete; ///////////////////////////////////// ///////////////////////////////////// @@ -50,7 +49,8 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto operator=(DynamicLoaderImpl&& other) noexcept -> DynamicLoaderImpl& { + STORMKIT_FORCE_INLINE auto operator=(DynamicLoaderImpl&& other) noexcept + -> DynamicLoaderImpl& { if (&other == this) [[unlikely]] return *this; diff --git a/src/Core/win32/ThreadUtils.cpp b/src/Core/win32/ThreadUtils.cpp index 80a421ac..9885e2d4 100644 --- a/src/Core/win32/ThreadUtils.cpp +++ b/src/Core/win32/ThreadUtils.cpp @@ -12,10 +12,10 @@ inline constexpr auto MS_VC_EXCEPTION = DWORD { 0x406D1388 }; #pragma pack(push, 8) struct ThreadNameInfo { - DWORD dwType = 0x1000; + DWORD dwType = 0x1000; LPCSTR szName; - DWORD dwThreadID; - DWORD dwFlags = 0; + DWORD dwThreadID; + DWORD dwFlags = 0; }; #pragma pack(pop) diff --git a/src/Engine/Core/Application.cpp b/src/Engine/Core/Application.cpp index 9da1fdba..585b912b 100644 --- a/src/Engine/Core/Application.cpp +++ b/src/Engine/Core/Application.cpp @@ -15,9 +15,9 @@ import stormkit.Entities; import :Systems.RenderSystem; namespace stormkit::engine { - Application::Application(std::string_view application_name, + Application::Application(std::string_view application_name, const core::math::ExtentU& window_extent, - std::string window_title, + std::string window_title, PrivateTag) { m_window = wsi::Window { std::move(window_title), window_extent, wsi::WindowStyle::Close }; m_event_handler = wsi::EventHandler {}; diff --git a/src/Engine/Renderer.cpp b/src/Engine/Renderer.cpp index 300c75f9..5c7f4fc9 100644 --- a/src/Engine/Renderer.cpp +++ b/src/Engine/Renderer.cpp @@ -18,7 +18,6 @@ using namespace std::literals; namespace stormkit::engine { LOGGER("stormkit.Renderer") - ///////////////////////////////////// ///////////////////////////////////// auto Renderer::doInit(std::string_view application_name, diff --git a/src/Engine/Renderer/BakedFrameGraph.cpp b/src/Engine/Renderer/BakedFrameGraph.cpp index 1054e613..6324a279 100644 --- a/src/Engine/Renderer/BakedFrameGraph.cpp +++ b/src/Engine/Renderer/BakedFrameGraph.cpp @@ -15,8 +15,8 @@ import :Renderer.BakedFrameGraph; namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - BakedFrameGraph::BakedFrameGraph(const FrameGraphBuilder& builder, - Data&& data, + BakedFrameGraph::BakedFrameGraph(const FrameGraphBuilder & builder, + Data && data, [[maybe_unused]] BakedFrameGraph *old) : m_builder { &builder }, m_data { std::move(data) } { } diff --git a/src/Engine/Renderer/FrameGraphBuilder.cpp b/src/Engine/Renderer/FrameGraphBuilder.cpp index 49381e70..38f9ca2c 100644 --- a/src/Engine/Renderer/FrameGraphBuilder.cpp +++ b/src/Engine/Renderer/FrameGraphBuilder.cpp @@ -33,8 +33,8 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - auto FrameGraphBuilder::createFrameGraph(const gpu::Device& device, - BakedFrameGraph *old) -> BakedFrameGraph { + auto FrameGraphBuilder::createFrameGraph(const gpu::Device& device, BakedFrameGraph *old) + -> BakedFrameGraph { auto data = allocatePhysicalResources(device); return BakedFrameGraph { *this, std::move(data), old }; @@ -209,7 +209,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// auto FrameGraphBuilder::buildRenderPassPhysicalDescription( - const GraphTask& task, + const GraphTask & task, core::HashMap& layouts) noexcept -> RenderPassData { auto to_remove = std::vector {}; diff --git a/src/Engine/Systems/RenderSystem.mpp b/src/Engine/Systems/RenderSystem.mpp index e5251f5c..fa7a097c 100644 --- a/src/Engine/Systems/RenderSystem.mpp +++ b/src/Engine/Systems/RenderSystem.mpp @@ -62,4 +62,4 @@ namespace stormkit::engine { ///////////////////////////////////// inline auto RenderSystem::onMessageReceived(const entities::Message& message) -> void { } -} // namespace stormkit::gpu +} // namespace stormkit::engine diff --git a/src/Gpu/Core/Device.cpp b/src/Gpu/Core/Device.cpp index 7171f8c8..942d0bd7 100644 --- a/src/Gpu/Core/Device.cpp +++ b/src/Gpu/Core/Device.cpp @@ -49,8 +49,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// Device::Device(const PhysicalDevice& physical_device, - const Instance& instance, - const Info& info, + const Instance & instance, + const Info & info, Tag) : InstanceObject { instance }, m_physical_device { &physical_device } { const auto& queue_families = m_physical_device->queueFamilies(); @@ -225,7 +225,7 @@ namespace stormkit::gpu { ///////////////////////////////////// auto Device::waitForFences(std::span> fences, bool wait_all, - const std::chrono::milliseconds& timeout) const noexcept + const std::chrono::milliseconds & timeout) const noexcept -> Expected { const auto vk_fences = fences | std::views::transform(toVkHandle()) | std::ranges::to(); diff --git a/src/Gpu/Core/Instance.cpp b/src/Gpu/Core/Instance.cpp index 2795a481..73cb7595 100644 --- a/src/Gpu/Core/Instance.cpp +++ b/src/Gpu/Core/Instance.cpp @@ -135,7 +135,7 @@ namespace stormkit::gpu { m_vk_context = vk::raii::Context(); const auto exts = m_vk_context->enumerateInstanceExtensionProperties(); - m_extensions = exts | std::views::transform([](auto&& extension) noexcept { + m_extensions = exts | std::views::transform([](auto &&extension) noexcept { return std::string { extension.extensionName }; }) | std::ranges::to(); diff --git a/src/Gpu/Core/PhysicalDevice.cpp b/src/Gpu/Core/PhysicalDevice.cpp index 138e2bec..3de5a61a 100644 --- a/src/Gpu/Core/PhysicalDevice.cpp +++ b/src/Gpu/Core/PhysicalDevice.cpp @@ -29,7 +29,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// PhysicalDevice::PhysicalDevice(vk::raii::PhysicalDevice physical_device, - const Instance& instance) + const Instance & instance) : InstanceObject { instance }, m_vk_physical_device { std::move(physical_device) } { const auto properties = m_vk_physical_device.getProperties(); const auto features = m_vk_physical_device.getFeatures(); @@ -189,30 +189,30 @@ namespace stormkit::gpu { m_capabilities.limits.max_framebuffer_height = properties.limits.maxFramebufferHeight; m_capabilities.limits.max_framebuffer_layers = properties.limits.maxFramebufferLayers; m_capabilities.limits.framebuffer_color_sample_counts = - core::narrow(properties.limits.framebufferColorSampleCounts - .operator vk::SampleCountFlags::MaskType()); + core::narrow(properties.limits.framebufferColorSampleCounts. + operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.framebuffer_depth_sample_counts = - core::narrow(properties.limits.framebufferDepthSampleCounts - .operator vk::SampleCountFlags::MaskType()); + core::narrow(properties.limits.framebufferDepthSampleCounts. + operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.framebuffer_stencil_sample_counts = - core::narrow(properties.limits.framebufferStencilSampleCounts - .operator vk::SampleCountFlags::MaskType()); + core::narrow(properties.limits.framebufferStencilSampleCounts. + operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.framebuffer_no_attachments_sample_counts = - core::narrow(properties.limits.framebufferNoAttachmentsSampleCounts - .operator vk::SampleCountFlags::MaskType()); + core::narrow(properties.limits.framebufferNoAttachmentsSampleCounts. + operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.max_color_attachments = properties.limits.maxColorAttachments; m_capabilities.limits.sampled_image_color_sample_counts = - core::narrow(properties.limits.sampledImageColorSampleCounts - .operator vk::SampleCountFlags::MaskType()); + core::narrow(properties.limits.sampledImageColorSampleCounts. + operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.sampled_image_integer_sample_counts = - core::narrow(properties.limits.sampledImageIntegerSampleCounts - .operator vk::SampleCountFlags::MaskType()); + core::narrow(properties.limits.sampledImageIntegerSampleCounts. + operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.sampled_image_depth_sample_counts = - core::narrow(properties.limits.sampledImageDepthSampleCounts - .operator vk::SampleCountFlags::MaskType()); + core::narrow(properties.limits.sampledImageDepthSampleCounts. + operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.sampled_image_stencil_sample_counts = - core::narrow(properties.limits.sampledImageStencilSampleCounts - .operator vk::SampleCountFlags::MaskType()); + core::narrow(properties.limits.sampledImageStencilSampleCounts. + operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.storage_image_sample_counts = core::narrow( properties.limits.storageImageSampleCounts.operator vk::SampleCountFlags::MaskType()); m_capabilities.limits.max_sample_mask_words = properties.limits.maxSampleMaskWords; diff --git a/src/Gpu/Execution/Pipeline.cpp b/src/Gpu/Execution/Pipeline.cpp index 294f8114..55a2cec5 100644 --- a/src/Gpu/Execution/Pipeline.cpp +++ b/src/Gpu/Execution/Pipeline.cpp @@ -17,10 +17,11 @@ import :Execution.RasterPipelineState; namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - auto Pipeline::doInitRasterPipeline(const PipelineLayout& layout, - const RenderPass& render_pass, - std::optional> - pipeline_cache) noexcept -> VulkanExpected { + auto Pipeline::doInitRasterPipeline( + const PipelineLayout & layout, + const RenderPass & render_pass, + std::optional> pipeline_cache) noexcept + -> VulkanExpected { const auto& state = core::as(m_state); const auto binding_descriptions = diff --git a/src/Gpu/Execution/RenderPass.cpp b/src/Gpu/Execution/RenderPass.cpp index 95c34c2a..629b80f2 100644 --- a/src/Gpu/Execution/RenderPass.cpp +++ b/src/Gpu/Execution/RenderPass.cpp @@ -101,8 +101,9 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// // TODO finish this - auto RenderPassDescription::isCompatible( - const RenderPassDescription& description) const noexcept -> bool { + auto + RenderPassDescription::isCompatible(const RenderPassDescription& description) const noexcept + -> bool { if (std::size(subpasses) == std::size(description.subpasses)) return false; for (auto i : core::range(std::size(subpasses))) { diff --git a/src/Gpu/Resource/Buffer.cpp b/src/Gpu/Resource/Buffer.cpp index f85b1e53..3e2f04f0 100644 --- a/src/Gpu/Resource/Buffer.cpp +++ b/src/Gpu/Resource/Buffer.cpp @@ -54,7 +54,7 @@ namespace stormkit::gpu { ///////////////////////////////////// auto Buffer::findMemoryType(core::UInt type_filter, vk::MemoryPropertyFlags properties, - const vk::PhysicalDeviceMemoryProperties& mem_properties, + const vk::PhysicalDeviceMemoryProperties & mem_properties, [[maybe_unused]] const vk::MemoryRequirements& mem_requirements) -> core::UInt { for (auto i : core::range(mem_properties.memoryTypeCount)) { diff --git a/src/Image/HDRImage.mpp b/src/Image/HDRImage.mpp index 1244eae9..a52533e8 100644 --- a/src/Image/HDRImage.mpp +++ b/src/Image/HDRImage.mpp @@ -14,7 +14,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadHDR(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveHDR(const image::Image& image, + [[nodiscard]] auto saveHDR(const image::Image & image, const std::filesystem::path& filepath) noexcept -> std::expected; diff --git a/src/Image/Image.cpp b/src/Image/Image.cpp index 84c0503c..0f49839b 100644 --- a/src/Image/Image.cpp +++ b/src/Image/Image.cpp @@ -223,8 +223,8 @@ namespace stormkit::image { ///////////////////////////////////// ///////////////////////////////////// - auto Image::loadFromFile(std::filesystem::path filepath, - Image::Codec codec) noexcept -> std::expected { + auto Image::loadFromFile(std::filesystem::path filepath, Image::Codec codec) noexcept + -> std::expected { filepath = std::filesystem::canonical(filepath); core::expects(codec != Image::Codec::Unknown); @@ -355,8 +355,8 @@ namespace stormkit::image { ///////////////////////////////////// ///////////////////////////////////// - auto Image::loadFromMemory(std::span data, - Image::Codec codec) noexcept -> std::expected { + auto Image::loadFromMemory(std::span data, Image::Codec codec) noexcept + -> std::expected { core::expects(codec != Image::Codec::Unknown); core::expects(!std::empty(data)); diff --git a/src/Image/JPEGImage.mpp b/src/Image/JPEGImage.mpp index 79e8ad4b..1c9849d1 100644 --- a/src/Image/JPEGImage.mpp +++ b/src/Image/JPEGImage.mpp @@ -26,7 +26,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadJPG(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveJPG(const image::Image& image, + [[nodiscard]] auto saveJPG(const image::Image & image, const std::filesystem::path& filepath) noexcept -> std::expected; @@ -44,7 +44,7 @@ namespace stormkit::image::details { namespace jpg { struct ErrorData { std::jmp_buf setjmp_buffer; - std::string msg; + std::string msg; }; ///////////////////////////////////// @@ -68,7 +68,7 @@ namespace stormkit::image::details { ///////////////////////////////////// auto loadJPG(std::span data) noexcept -> std::expected { - auto image_memory = std::vector {}; + auto image_memory = std::vector {}; volatile auto format = Format {}; // NOTE volatile for error: variable ‘format’ might be // clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] auto extent = core::math::ExtentU {}; @@ -165,7 +165,7 @@ namespace stormkit::image::details { Error { .reason = Reason::Failed_To_Save, .str_error = error_data.msg }); } - auto data = image_rgb.data(0, 0, 0); + auto data = image_rgb.data(0, 0, 0); const auto& extent = image_rgb.extent(0); jpeg_create_compress(&info); @@ -223,12 +223,12 @@ namespace stormkit::image::details { info.client_data = &error_data; error_mgr.error_exit = jpg::error_callback; - auto data = image_rgb.data(0, 0, 0); + auto data = image_rgb.data(0, 0, 0); const auto& extent = image_rgb.extent(0); jpeg_create_compress(&info); - using ulong = unsigned long; + using ulong = unsigned long; auto out_size = ulong { 0 }; jpeg_mem_dest(&info, &output_ptr, &out_size); diff --git a/src/Image/KTXImage.mpp b/src/Image/KTXImage.mpp index f987a8d3..4fd0df92 100644 --- a/src/Image/KTXImage.mpp +++ b/src/Image/KTXImage.mpp @@ -23,7 +23,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadKTX(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveKTX(const image::Image& image, + [[nodiscard]] auto saveKTX(const image::Image & image, const std::filesystem::path& filepath) noexcept -> std::expected; diff --git a/src/Image/PNGImage.mpp b/src/Image/PNGImage.mpp index 1723d00e..a94ac14c 100644 --- a/src/Image/PNGImage.mpp +++ b/src/Image/PNGImage.mpp @@ -13,7 +13,6 @@ export module stormkit.Image:PNGImage; import std; - import stormkit.Core; import :Image; @@ -22,7 +21,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadPNG(std::span data) noexcept -> std::expected; - [[nodiscard]] auto savePNG(const image::Image& image, + [[nodiscard]] auto savePNG(const image::Image & image, const std::filesystem::path& filepath) noexcept -> std::expected; @@ -39,7 +38,7 @@ namespace stormkit::image::details { namespace png { struct ReadParam { - core::RangeExtent readed; + core::RangeExtent readed; std::span& data; }; diff --git a/src/Image/PPMImage.mpp b/src/Image/PPMImage.mpp index a81c6756..0402da64 100644 --- a/src/Image/PPMImage.mpp +++ b/src/Image/PPMImage.mpp @@ -14,8 +14,8 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadPPM(std::span data) noexcept -> std::expected; - [[nodiscard]] auto savePPM(const image::Image& image, - image::Image::CodecArgs args, + [[nodiscard]] auto savePPM(const image::Image & image, + image::Image::CodecArgs args, const std::filesystem::path& filepath) noexcept -> std::expected; @@ -42,8 +42,8 @@ namespace stormkit::image::details { ///////////////////////////////////// ///////////////////////////////////// - auto savePPM(const image::Image& image, - image::Image::CodecArgs args, + auto savePPM(const image::Image & image, + image::Image::CodecArgs args, const std::filesystem::path& filepath) noexcept -> std::expected { auto result = savePPM(image, args); @@ -65,8 +65,8 @@ namespace stormkit::image::details { ///////////////////////////////////// auto savePPM(const image::Image& image, image::Image::CodecArgs args) noexcept -> std::expected, image::Image::Error> { - const auto output_image = image.toFormat(Format::RGB8_UNorm); - const auto& data = output_image.imageData(); + const auto output_image = image.toFormat(Format::RGB8_UNorm); + const auto& data = output_image.imageData(); auto output = std::vector {}; diff --git a/src/Image/TARGAImage.mpp b/src/Image/TARGAImage.mpp index 9fa903f6..7b9ea796 100644 --- a/src/Image/TARGAImage.mpp +++ b/src/Image/TARGAImage.mpp @@ -14,7 +14,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadTGA(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveTGA(const image::Image& image, + [[nodiscard]] auto saveTGA(const image::Image & image, const std::filesystem::path& filepath) noexcept -> std::expected; diff --git a/src/Log/win32/LogColorizer.cpp b/src/Log/win32/LogColorizer.cpp index 578d1ea2..59d2cc52 100644 --- a/src/Log/win32/LogColorizer.cpp +++ b/src/Log/win32/LogColorizer.cpp @@ -31,7 +31,8 @@ namespace stormkit::log::details { ///////////////////////////////////// ///////////////////////////////////// auto colorifyBegin(Severity severity, bool to_stderr) noexcept -> void { - auto output = (to_stderr) ? GetStdHandle(STD_ERROR_HANDLE) : GetStdHandle(STD_OUTPUT_HANDLE); + auto output = + (to_stderr) ? GetStdHandle(STD_ERROR_HANDLE) : GetStdHandle(STD_OUTPUT_HANDLE); auto background = KBLA; auto text = KWHT; @@ -65,7 +66,8 @@ namespace stormkit::log::details { ///////////////////////////////////// ///////////////////////////////////// auto colorifyEnd(bool to_stderr) noexcept -> void { - auto output = (to_stderr) ? GetStdHandle(STD_ERROR_HANDLE) : GetStdHandle(STD_OUTPUT_HANDLE); + auto output = + (to_stderr) ? GetStdHandle(STD_ERROR_HANDLE) : GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(output, (KBLA << 4) + KWHT); } } // namespace stormkit::log::details diff --git a/src/Main/win32/Main-win.cpp b/src/Main/win32/Main-win.cpp index 2e616627..47994231 100644 --- a/src/Main/win32/Main-win.cpp +++ b/src/Main/win32/Main-win.cpp @@ -32,7 +32,7 @@ auto __stdcall main(int argc, char **argv) -> int { auto args = std::vector {}; args.reserve(argc); - for (auto &&i : stormkit::core::range(argc)) args.emplace_back(argv[i]); + for (auto&& i : stormkit::core::range(argc)) args.emplace_back(argv[i]); return userMain(args); } @@ -53,7 +53,7 @@ auto __stdcall WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) -> int { auto args = std::vector {}; args.reserve(argc); - for (auto &&i : stormkit::core::range(argc)) args.emplace_back(argv[i]); + for (auto&& i : stormkit::core::range(argc)) args.emplace_back(argv[i]); return userMain(args); } diff --git a/src/Wsi/Window.cpp b/src/Wsi/Window.cpp index 714898a0..707ace02 100644 --- a/src/Wsi/Window.cpp +++ b/src/Wsi/Window.cpp @@ -99,9 +99,9 @@ namespace stormkit::wsi { ///////////////////////////////////// ///////////////////////////////////// - auto Window::create(std::string title, + auto Window::create(std::string title, const core::math::ExtentU& size, - WindowStyle style) noexcept -> void { + WindowStyle style) noexcept -> void { m_impl->create(std::move(title), size, style); } diff --git a/src/Wsi/iOS/InputHandlerImpl.hpp b/src/Wsi/iOS/InputHandlerImpl.hpp index c2512f1b..013b9006 100644 --- a/src/Wsi/iOS/InputHandlerImpl.hpp +++ b/src/Wsi/iOS/InputHandlerImpl.hpp @@ -18,15 +18,15 @@ namespace storm::window { InputHandlerImpl(); ~InputHandlerImpl(); - InputHandlerImpl(InputHandlerImpl &&); - InputHandlerImpl &operator=(InputHandlerImpl &&); + InputHandlerImpl(InputHandlerImpl&&); + InputHandlerImpl& operator=(InputHandlerImpl&&); static bool isKeyPressed(Key key); static bool isMouseButtonPressed(MouseButton button); static void setMousePosition(core::math::Vector2U position); - static void setMousePosition(core::math::Vector2U position, const Window &relative_to); + static void setMousePosition(core::math::Vector2U position, const Window& relative_to); static core::math::Vector2U getMousePosition(); - static core::math::Vector2U getMousePosition(const Window &relative_to); + static core::math::Vector2U getMousePosition(const Window& relative_to); static void setVirtualKeyboardVisible(bool visible); diff --git a/src/Wsi/iOS/WindowImpl.hpp b/src/Wsi/iOS/WindowImpl.hpp index 31bd813b..9970e55b 100644 --- a/src/Wsi/iOS/WindowImpl.hpp +++ b/src/Wsi/iOS/WindowImpl.hpp @@ -28,22 +28,22 @@ namespace storm::window { class STORMKIT_PRIVATE WindowImpl: public storm::window::AbstractWindow { public: WindowImpl() noexcept; - WindowImpl(const std::string &title, - const storm::window::VideoSettings &settings, - storm::window::WindowStyle style) noexcept; + WindowImpl(const std::string & title, + const storm::window::VideoSettings& settings, + storm::window::WindowStyle style) noexcept; ~WindowImpl() override; - void create(const std::string &title, - const storm::window::VideoSettings &settings, - storm::window::WindowStyle style) noexcept override; + void create(const std::string & title, + const storm::window::VideoSettings& settings, + storm::window::WindowStyle style) noexcept override; void close() noexcept override; - bool pollEvent(storm::window::Event &event, void *native_event) noexcept override; - bool waitEvent(storm::window::Event &event, + bool pollEvent(storm::window::Event& event, void *native_event) noexcept override; + bool waitEvent(storm::window::Event & event, [[maybe_unused]] void *native_event) noexcept override; - void setTitle(const std::string &title) noexcept override; - void setVideoSettings(const storm::window::VideoSettings &settings) noexcept override; + void setTitle(const std::string& title) noexcept override; + void setVideoSettings(const storm::window::VideoSettings& settings) noexcept override; storm::core::Extentu size() const noexcept override; @@ -53,9 +53,9 @@ namespace storm::window { storm::window::NativeHandle nativeHandle() const noexcept override; private: - UIWindowPtr m_window; + UIWindowPtr m_window; ViewControllerPtr m_view_controller; - ViewPtr m_view; + ViewPtr m_view; }; } // namespace storm::window diff --git a/src/Wsi/iOS/iosMain.hpp b/src/Wsi/iOS/iosMain.hpp index dced5d17..9472046f 100644 --- a/src/Wsi/iOS/iosMain.hpp +++ b/src/Wsi/iOS/iosMain.hpp @@ -2,8 +2,6 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution - - int iosMain(int argc, char **argv); int iosMain(); diff --git a/src/Wsi/linux/WindowImpl.mpp b/src/Wsi/linux/WindowImpl.mpp index b358aeb2..59da5e17 100644 --- a/src/Wsi/linux/WindowImpl.mpp +++ b/src/Wsi/linux/WindowImpl.mpp @@ -56,12 +56,12 @@ export namespace stormkit::wsi::linux { [[nodiscard]] auto mouseHidden() const noexcept -> bool; [[nodiscard]] auto fullscreen() const noexcept -> bool; - auto setKeyRepeatEnabled(bool enabled) noexcept -> void; + auto setKeyRepeatEnabled(bool enabled) noexcept -> void; [[nodiscard]] auto keyRepeatEnabled() const noexcept -> bool; auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; static auto setMousePositionOnDesktop(WM wm, const core::math::Vector2U& position) noexcept -> void; @@ -102,10 +102,10 @@ namespace stormkit::wsi::linux { ///////////////////////////////////// ///////////////////////////////////// - inline WindowImpl::WindowImpl(WM wm, - std::string title, + inline WindowImpl::WindowImpl(WM wm, + std::string title, const core::math::ExtentU& extent, - WindowStyle style) + WindowStyle style) : m_wm { wm } { if (m_wm == WM::X11) m_impl = x11::WindowImpl { std::move(title), extent, style }; else if (m_wm == WM::Wayland) @@ -122,9 +122,9 @@ namespace stormkit::wsi::linux { ///////////////////////////////////// ///////////////////////////////////// - inline auto WindowImpl::create(std::string title, + inline auto WindowImpl::create(std::string title, const core::math::ExtentU& extent, - WindowStyle style) -> void { + WindowStyle style) -> void { switch (m_wm) { CASE_DO(WM::X11, x11, create(std::move(title), extent, style)); CASE_DO(WM::Wayland, wayland, create(std::move(title), extent, style)); @@ -402,7 +402,7 @@ namespace stormkit::wsi::linux { ///////////////////////////////////// ///////////////////////////////////// - inline auto WindowImpl::setMousePositionOnDesktop(WM wm, + inline auto WindowImpl::setMousePositionOnDesktop(WM wm, const core::math::Vector2U& position) noexcept -> void { switch (wm) { diff --git a/src/Wsi/linux/common/XKB.mpp b/src/Wsi/linux/common/XKB.mpp index a2819273..234b127f 100644 --- a/src/Wsi/linux/common/XKB.mpp +++ b/src/Wsi/linux/common/XKB.mpp @@ -17,7 +17,6 @@ import std; import stormkit.Core; import stormkit.Log; - import :Types; #define STORMKIT_XKB_SCOPED(name, type) \ @@ -69,33 +68,33 @@ export namespace stormkit::wsi::linux::common { /// IMPLEMENTATION /// //////////////////////////////////////////////////////////////////// -#define STORMKIT_XKB_SCOPED(name, type, var, global, deleter) \ - inline name##Scoped::name##Scoped(type *handle) noexcept : m_handle { handle } { \ - if (m_handle != nullptr) var++; \ - } \ - \ - inline name##Scoped::~name##Scoped() noexcept { \ - if (m_handle != nullptr) { \ - var--; \ - \ - if (var == 0) { \ - deleter(m_handle); \ - m_handle = nullptr; \ - global = nullptr; \ - } \ - } \ - } \ - \ - inline name##Scoped::name##Scoped(name##Scoped&& other) noexcept \ - : m_handle { std::exchange(other.m_handle, nullptr) } { \ - } \ - \ - inline auto name##Scoped::operator=(name##Scoped && other) noexcept -> name##Scoped& { \ - if (this == &other) return *this; \ - \ - m_handle = std::exchange(other.m_handle, nullptr); \ - \ - return *this; \ +#define STORMKIT_XKB_SCOPED(name, type, var, global, deleter) \ + inline name##Scoped::name##Scoped(type *handle) noexcept : m_handle { handle } { \ + if (m_handle != nullptr) var++; \ + } \ + \ + inline name##Scoped::~name##Scoped() noexcept { \ + if (m_handle != nullptr) { \ + var--; \ + \ + if (var == 0) { \ + deleter(m_handle); \ + m_handle = nullptr; \ + global = nullptr; \ + } \ + } \ + } \ + \ + inline name##Scoped::name##Scoped(name##Scoped&& other) noexcept \ + : m_handle { std::exchange(other.m_handle, nullptr) } { \ + } \ + \ + inline auto name##Scoped::operator=(name##Scoped&& other) noexcept -> name##Scoped& { \ + if (this == &other) return *this; \ + \ + m_handle = std::exchange(other.m_handle, nullptr); \ + \ + return *this; \ } namespace stormkit::wsi::linux::common { diff --git a/src/Wsi/linux/wayland/Callbacks.mpp b/src/Wsi/linux/wayland/Callbacks.mpp index 965029ad..54082e46 100644 --- a/src/Wsi/linux/wayland/Callbacks.mpp +++ b/src/Wsi/linux/wayland/Callbacks.mpp @@ -21,10 +21,10 @@ import :Linux.Wayland.Log; namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto registryHandler(void *data, + auto registryHandler(void *data, wl_registry *registry, core::UInt32 id, - const char *interface, + const char *interface, core::UInt32 version) noexcept -> void; ///////////////////////////////////// @@ -42,11 +42,11 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto toplevelConfigureHandler(void *data, + auto toplevelConfigureHandler(void *data, xdg_toplevel *xdg_tl, - core::Int32 width, - core::Int32 height, - wl_array *states) noexcept -> void; + core::Int32 width, + core::Int32 height, + wl_array *states) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// @@ -61,11 +61,11 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// auto shellPingHandler(void *data, xdg_wm_base *xdg_shell, core::UInt32 serial) noexcept -> void; - auto shellSurfaceConfigureHandler(void *data, + auto shellSurfaceConfigureHandler(void *data, wl_shell_surface *shell_surface, - core::UInt32 edges, - core::Int32 width, - core::Int32 height) noexcept -> void; + core::UInt32 edges, + core::Int32 width, + core::Int32 height) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// @@ -74,14 +74,14 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto relativePointerRelativeMotionHandler(void *data, + auto relativePointerRelativeMotionHandler(void *data, zwp_relative_pointer_v1 *pointer, - core::UInt32 time_hi, - core::UInt32 time_lw, - wl_fixed_t dx, - wl_fixed_t dy, - wl_fixed_t dx_unaccel, - wl_fixed_t dy_unaccel) noexcept -> void; + core::UInt32 time_hi, + core::UInt32 time_lw, + wl_fixed_t dx, + wl_fixed_t dy, + wl_fixed_t dx_unaccel, + wl_fixed_t dy_unaccel) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// diff --git a/src/Wsi/linux/wayland/Implementation.cpp b/src/Wsi/linux/wayland/Implementation.cpp index 9ace40c8..4872526e 100644 --- a/src/Wsi/linux/wayland/Implementation.cpp +++ b/src/Wsi/linux/wayland/Implementation.cpp @@ -29,8 +29,8 @@ import :Linux.Wayland.Log; namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto outputGeometryHandler(void *data, - wl_output *output, + auto outputGeometryHandler(void *data, + wl_output *output, core::Int32 x, core::Int32 y, core::Int32 pwidth, @@ -42,12 +42,12 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto outputModeHandler(void *data, - wl_output *wl_output, + auto outputModeHandler(void *data, + wl_output *wl_output, core::UInt32 flags, - core::Int32 width, - core::Int32 height, - core::Int32 refresh) noexcept -> void; + core::Int32 width, + core::Int32 height, + core::Int32 refresh) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// @@ -68,32 +68,32 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerEnterHandler(void *data, - wl_pointer *pointer, + auto pointerEnterHandler(void *data, + wl_pointer *pointer, core::UInt32 serial, - wl_surface *surface, - wl_fixed_t surface_x, - wl_fixed_t surface_y) noexcept -> void; + wl_surface *surface, + wl_fixed_t surface_x, + wl_fixed_t surface_y) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerLeaveHandler(void *data, - wl_pointer *pointer, + auto pointerLeaveHandler(void *data, + wl_pointer *pointer, core::UInt32 serial, - wl_surface *surface) noexcept -> void; + wl_surface *surface) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerMotionHandler(void *data, - wl_pointer *pointer, + auto pointerMotionHandler(void *data, + wl_pointer *pointer, core::UInt32 time, - wl_fixed_t surface_x, - wl_fixed_t surface_y) noexcept -> void; + wl_fixed_t surface_x, + wl_fixed_t surface_y) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerButtonHandler(void *data, - wl_pointer *pointer, + auto pointerButtonHandler(void *data, + wl_pointer *pointer, core::UInt32 serial, core::UInt32 time, core::UInt32 button, @@ -101,11 +101,11 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisHandler(void *data, - wl_pointer *pointer, + auto pointerAxisHandler(void *data, + wl_pointer *pointer, core::UInt32 time, core::UInt32 axis, - wl_fixed_t value) noexcept -> void; + wl_fixed_t value) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// @@ -113,50 +113,50 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisSourceHandler(void *data, - wl_pointer *pointer, + auto pointerAxisSourceHandler(void *data, + wl_pointer *pointer, core::UInt32 axis_source) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisStopHandler(void *data, - wl_pointer *pointer, + auto pointerAxisStopHandler(void *data, + wl_pointer *pointer, core::UInt32 time, core::UInt32 axis) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisDiscreteHandler(void *data, - wl_pointer *pointer, + auto pointerAxisDiscreteHandler(void *data, + wl_pointer *pointer, core::UInt32 axis, - core::Int32 discrete) noexcept -> void; + core::Int32 discrete) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto keyboardKeymapHandler(void *data, + auto keyboardKeymapHandler(void *data, wl_keyboard *keyboard, core::UInt32 format, - core::Int32 fd, + core::Int32 fd, core::UInt32 size) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto keyboardEnterHandler(void *data, + auto keyboardEnterHandler(void *data, wl_keyboard *keyboard, core::UInt32 serial, - wl_surface *surface, - wl_array *keys) noexcept -> void; + wl_surface *surface, + wl_array *keys) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto keyboardLeaveHandler(void *data, + auto keyboardLeaveHandler(void *data, wl_keyboard *keyboard, core::UInt32 serial, - wl_surface *surface) noexcept -> void; + wl_surface *surface) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto keyboardKeyHandler(void *data, + auto keyboardKeyHandler(void *data, wl_keyboard *keyboard, core::UInt32 serial, core::UInt32 time, @@ -165,7 +165,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardModifiersHandler(void *data, + auto keyboardModifiersHandler(void *data, wl_keyboard *keyboard, core::UInt32 serial, core::UInt32 mods_depressed, @@ -175,10 +175,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardRepeatInfoHandler(void *data, + auto keyboardRepeatInfoHandler(void *data, wl_keyboard *keyboard, - core::Int32 rate, - core::Int32 delay) noexcept -> void; + core::Int32 rate, + core::Int32 delay) noexcept -> void; namespace { auto globals = Globals {}; @@ -612,7 +612,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto WindowImpl::surfaceOutputEnter([[maybe_unused]] wl_surface *surface, - wl_output *output) noexcept -> void { + wl_output *output) noexcept -> void { m_current_output.reset(output); } @@ -632,9 +632,9 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto WindowImpl::toplevelConfigure([[maybe_unused]] xdg_toplevel *xdg_tl, - std::int32_t width, - std::int32_t height, - wl_array *state) noexcept -> void { + std::int32_t width, + std::int32_t height, + wl_array *state) noexcept -> void { dlog("XDG Shell configure: {}:{}", width, height); m_open = true; @@ -674,8 +674,8 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto WindowImpl::shellSurfaceConfigure([[maybe_unused]] wl_shell_surface *xdg_tl, - [[maybe_unused]] std::uint32_t edges, - std::int32_t width, + [[maybe_unused]] std::uint32_t edges, + std::int32_t width, std::int32_t height) noexcept -> void { dlog("WL Shell configure: {}:{}", width, height); @@ -690,7 +690,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::seatCapabilities([[maybe_unused]] wl_seat *seat, + auto WindowImpl::seatCapabilities([[maybe_unused]] wl_seat *seat, [[maybe_unused]] std::uint32_t capabilities) noexcept -> void { } @@ -698,10 +698,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto WindowImpl::pointerEnter([[maybe_unused]] wl_pointer *pointer, - std::uint32_t serial, + std::uint32_t serial, [[maybe_unused]] wl_surface *surface, - [[maybe_unused]] wl_fixed_t surface_x, - [[maybe_unused]] wl_fixed_t surface_y) noexcept -> void { + [[maybe_unused]] wl_fixed_t surface_x, + [[maybe_unused]] wl_fixed_t surface_y) noexcept -> void { m_pointer_serial = serial; if (!m_mouse_locked) unhideMouse(); @@ -713,9 +713,9 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::pointerLeave([[maybe_unused]] wl_pointer *pointer, + auto WindowImpl::pointerLeave([[maybe_unused]] wl_pointer *pointer, [[maybe_unused]] std::uint32_t serial, - [[maybe_unused]] wl_surface *surface) noexcept -> void { + [[maybe_unused]] wl_surface *surface) noexcept -> void { m_pointer_serial = serial; WindowImplBase::mouseExitedEvent(); @@ -723,10 +723,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::pointerMotion([[maybe_unused]] wl_pointer *pointer, + auto WindowImpl::pointerMotion([[maybe_unused]] wl_pointer *pointer, [[maybe_unused]] std::uint32_t time, - wl_fixed_t surface_x, - wl_fixed_t surface_y) noexcept -> void { + wl_fixed_t surface_x, + wl_fixed_t surface_y) noexcept -> void { if (m_mouse_locked) return; m_mouse_state.position_in_window.x = wl_fixed_to_int(surface_x); @@ -738,15 +738,15 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::pointerButton([[maybe_unused]] wl_pointer *pointer, + auto WindowImpl::pointerButton([[maybe_unused]] wl_pointer *pointer, [[maybe_unused]] std::uint32_t serial, [[maybe_unused]] std::uint32_t time, - std::uint32_t button, - std::uint32_t state) noexcept -> void { + std::uint32_t button, + std::uint32_t state) noexcept -> void { #define BUTTON_HANDLER(a, b) \ case a: { \ auto it = std::ranges::find_if(m_mouse_state.button_state, \ - [](const auto& s) { return s.button == a; }); \ + [](const auto &s) { return s.button == a; }); \ it->down = down; \ if (down) \ WindowImplBase::mouseDownEvent(b, \ @@ -786,9 +786,9 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto WindowImpl::keyboardKeymap([[maybe_unused]] wl_keyboard *keyboard, - std::uint32_t format, - std::int32_t fd, - std::uint32_t size) noexcept -> void { + std::uint32_t format, + std::int32_t fd, + std::uint32_t size) noexcept -> void { if (format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { auto map_shm = reinterpret_cast(mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0)); @@ -802,10 +802,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardEnter([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardEnter([[maybe_unused]] wl_keyboard *keyboard, [[maybe_unused]] std::uint32_t serial, - [[maybe_unused]] wl_surface *surface, - wl_array *keys) noexcept -> void { + [[maybe_unused]] wl_surface *surface, + wl_array *keys) noexcept -> void { WindowImplBase::gainedFocusEvent(); auto data = static_cast(keys->data); @@ -825,19 +825,19 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardLeave([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardLeave([[maybe_unused]] wl_keyboard *keyboard, [[maybe_unused]] std::uint32_t serial, - [[maybe_unused]] wl_surface *surface) noexcept -> void { + [[maybe_unused]] wl_surface *surface) noexcept -> void { WindowImplBase::lostFocusEvent(); } ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardKey([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardKey([[maybe_unused]] wl_keyboard *keyboard, [[maybe_unused]] std::uint32_t serial, [[maybe_unused]] std::uint32_t time, - std::uint32_t key, - std::uint32_t state) noexcept -> void { + std::uint32_t key, + std::uint32_t state) noexcept -> void { auto character = char {}; const auto keycode = key + 8; @@ -860,12 +860,12 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardModifiers([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardModifiers([[maybe_unused]] wl_keyboard *keyboard, [[maybe_unused]] std::uint32_t serial, - std::uint32_t mods_depressed, - std::uint32_t mods_latched, - std::uint32_t mods_locked, - std::uint32_t group) noexcept -> void { + std::uint32_t mods_depressed, + std::uint32_t mods_latched, + std::uint32_t mods_locked, + std::uint32_t group) noexcept -> void { xkb_state_update_mask(m_xkb_state.get(), mods_depressed, mods_latched, @@ -886,10 +886,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// auto WindowImpl::relativePointerRelativeMotion([[maybe_unused]] zwp_relative_pointer_v1 *pointer, - [[maybe_unused]] std::uint32_t time_hi, - [[maybe_unused]] std::uint32_t time_lw, - [[maybe_unused]] wl_fixed_t dx, - [[maybe_unused]] wl_fixed_t dy, + [[maybe_unused]] std::uint32_t time_hi, + [[maybe_unused]] std::uint32_t time_lw, + [[maybe_unused]] wl_fixed_t dx, + [[maybe_unused]] wl_fixed_t dy, wl_fixed_t dx_unaccel, wl_fixed_t dy_unaccel) noexcept -> void { m_mouse_state.position_in_window.x += wl_fixed_to_int(dx_unaccel); @@ -1042,10 +1042,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto registryHandler(void *data, + auto registryHandler(void *data, wl_registry *registry, core::UInt32 id, - const char *interface, + const char *interface, core::UInt32 version) noexcept -> void { auto& globals = *static_cast(data); @@ -1083,23 +1083,23 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto registryRemoverHandler([[maybe_unused]] void *data, + auto registryRemoverHandler([[maybe_unused]] void *data, [[maybe_unused]] wl_registry *registry, - core::UInt32 id) noexcept -> void { + core::UInt32 id) noexcept -> void { dlog("Wayland registry lost {}", id); } ///////////////////////////////////// ///////////////////////////////////// - auto outputGeometryHandler(void *data, - [[maybe_unused]] wl_output *output, + auto outputGeometryHandler(void *data, + [[maybe_unused]] wl_output *output, [[maybe_unused]] core::Int32 x, [[maybe_unused]] core::Int32 y, [[maybe_unused]] core::Int32 pwidth, [[maybe_unused]] core::Int32 pheight, [[maybe_unused]] core::Int32 subpixels, - const char *make, - const char *model, + const char *make, + const char *model, [[maybe_unused]] core::Int32 transform) noexcept -> void { auto& globals = *static_cast(data); auto& monitor = globals.monitors[output]; @@ -1113,12 +1113,12 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto outputModeHandler(void *data, - [[maybe_unused]] wl_output *wl_output, + auto outputModeHandler(void *data, + [[maybe_unused]] wl_output *wl_output, [[maybe_unused]] core::UInt32 flags, - core::Int32 width, - core::Int32 height, - [[maybe_unused]] core::Int32 refresh) noexcept -> void { + core::Int32 width, + core::Int32 height, + [[maybe_unused]] core::Int32 refresh) noexcept -> void { auto& globals = *static_cast(data); auto& monitor = globals.monitors[wl_output]; @@ -1127,14 +1127,14 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto outputDoneHandler([[maybe_unused]] void *data, + auto outputDoneHandler([[maybe_unused]] void *data, [[maybe_unused]] wl_output *wl_output) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto outputScaleHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_output *wl_output, + auto outputScaleHandler([[maybe_unused]] void *data, + [[maybe_unused]] wl_output *wl_output, [[maybe_unused]] core::Int32 factor) noexcept -> void { } @@ -1147,18 +1147,18 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto surfaceLeaveHandler([[maybe_unused]] void *data, + auto surfaceLeaveHandler([[maybe_unused]] void *data, [[maybe_unused]] wl_surface *surface, - [[maybe_unused]] wl_output *output) noexcept -> void { + [[maybe_unused]] wl_output *output) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto toplevelConfigureHandler(void *data, + auto toplevelConfigureHandler(void *data, xdg_toplevel *xdg_tl, - core::Int32 width, - core::Int32 height, - wl_array *states) noexcept -> void { + core::Int32 width, + core::Int32 height, + wl_array *states) noexcept -> void { auto *window = static_cast(data); window->toplevelConfigure(xdg_tl, width, height, states); } @@ -1181,18 +1181,18 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto shellPingHandler([[maybe_unused]] void *data, - xdg_wm_base *xdg_shell, - core::UInt32 serial) noexcept -> void { + xdg_wm_base *xdg_shell, + core::UInt32 serial) noexcept -> void { ilog("Ping received from shell"); xdg_wm_base_pong(xdg_shell, serial); } - auto shellSurfaceConfigureHandler(void *data, + auto shellSurfaceConfigureHandler(void *data, wl_shell_surface *shell_surface, - core::UInt32 edges, - core::Int32 width, - core::Int32 height) noexcept -> void { + core::UInt32 edges, + core::Int32 width, + core::Int32 height) noexcept -> void { auto *window = static_cast(data); window->shellSurfaceConfigure(shell_surface, edges, width, height); } @@ -1200,8 +1200,8 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto shellPingHandler([[maybe_unused]] void *data, - wl_shell_surface *shell_surface, - core::UInt32 serial) noexcept -> void { + wl_shell_surface *shell_surface, + core::UInt32 serial) noexcept -> void { ilog("Ping received from shell"); wl_shell_surface_pong(shell_surface, serial); @@ -1209,9 +1209,9 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto seatCapabilitiesHandler(void *data, + auto seatCapabilitiesHandler(void *data, [[maybe_unused]] wl_seat *seat, - core::UInt32 capabilities) noexcept -> void { + core::UInt32 capabilities) noexcept -> void { auto& globals = *static_cast(data); if ((capabilities & WL_SEAT_CAPABILITY_KEYBOARD) > 0) { @@ -1233,20 +1233,20 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto seatNameHandler([[maybe_unused]] void *data, + auto seatNameHandler([[maybe_unused]] void *data, [[maybe_unused]] wl_seat *seat, - const char *name) noexcept -> void { + const char *name) noexcept -> void { dlog("WL Seat found! {}", name); } ///////////////////////////////////// ///////////////////////////////////// - auto pointerEnterHandler(void *data, - wl_pointer *pointer, + auto pointerEnterHandler(void *data, + wl_pointer *pointer, core::UInt32 serial, - wl_surface *surface, - wl_fixed_t surface_x, - wl_fixed_t surface_y) noexcept -> void { + wl_surface *surface, + wl_fixed_t surface_x, + wl_fixed_t surface_y) noexcept -> void { if (data == nullptr) return; auto *window = static_cast(data); @@ -1255,10 +1255,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerLeaveHandler(void *data, - wl_pointer *pointer, + auto pointerLeaveHandler(void *data, + wl_pointer *pointer, core::UInt32 serial, - wl_surface *surface) noexcept -> void { + wl_surface *surface) noexcept -> void { if (data == nullptr) return; auto *window = static_cast(data); @@ -1267,11 +1267,11 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerMotionHandler(void *data, - wl_pointer *pointer, + auto pointerMotionHandler(void *data, + wl_pointer *pointer, core::UInt32 time, - wl_fixed_t surface_x, - wl_fixed_t surface_y) noexcept -> void { + wl_fixed_t surface_x, + wl_fixed_t surface_y) noexcept -> void { if (data == nullptr) return; auto *window = static_cast(data); @@ -1280,8 +1280,8 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerButtonHandler(void *data, - wl_pointer *pointer, + auto pointerButtonHandler(void *data, + wl_pointer *pointer, core::UInt32 serial, core::UInt32 time, core::UInt32 button, @@ -1294,48 +1294,48 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer, + auto pointerAxisHandler([[maybe_unused]] void *data, + [[maybe_unused]] wl_pointer *pointer, [[maybe_unused]] core::UInt32 time, [[maybe_unused]] core::UInt32 axis, - [[maybe_unused]] wl_fixed_t value) noexcept -> void { + [[maybe_unused]] wl_fixed_t value) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto pointerFrameHandler([[maybe_unused]] void *data, + auto pointerFrameHandler([[maybe_unused]] void *data, [[maybe_unused]] wl_pointer *pointer) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisSourceHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer, + auto pointerAxisSourceHandler([[maybe_unused]] void *data, + [[maybe_unused]] wl_pointer *pointer, [[maybe_unused]] core::UInt32 axis_source) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisStopHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer, + auto pointerAxisStopHandler([[maybe_unused]] void *data, + [[maybe_unused]] wl_pointer *pointer, [[maybe_unused]] core::UInt32 time, [[maybe_unused]] core::UInt32 axis) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisDiscreteHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer, + auto pointerAxisDiscreteHandler([[maybe_unused]] void *data, + [[maybe_unused]] wl_pointer *pointer, [[maybe_unused]] core::UInt32 axis, - [[maybe_unused]] core::Int32 discrete) noexcept -> void { + [[maybe_unused]] core::Int32 discrete) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto keyboardKeymapHandler(void *data, + auto keyboardKeymapHandler(void *data, wl_keyboard *keyboard, core::UInt32 format, - core::Int32 fd, + core::Int32 fd, core::UInt32 size) noexcept -> void { if (data == nullptr) return; @@ -1345,11 +1345,11 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardEnterHandler(void *data, + auto keyboardEnterHandler(void *data, wl_keyboard *keyboard, core::UInt32 serial, - wl_surface *surface, - wl_array *keys) noexcept -> void { + wl_surface *surface, + wl_array *keys) noexcept -> void { if (data == nullptr) return; auto *window = static_cast(data); @@ -1358,10 +1358,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardLeaveHandler(void *data, + auto keyboardLeaveHandler(void *data, wl_keyboard *keyboard, core::UInt32 serial, - wl_surface *surface) noexcept -> void { + wl_surface *surface) noexcept -> void { if (data == nullptr) return; auto *window = static_cast(data); @@ -1370,7 +1370,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardKeyHandler(void *data, + auto keyboardKeyHandler(void *data, wl_keyboard *keyboard, core::UInt32 serial, core::UInt32 time, @@ -1384,7 +1384,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardModifiersHandler(void *data, + auto keyboardModifiersHandler(void *data, wl_keyboard *keyboard, core::UInt32 serial, core::UInt32 mods_depressed, @@ -1400,10 +1400,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardRepeatInfoHandler(void *data, + auto keyboardRepeatInfoHandler(void *data, wl_keyboard *keyboard, - core::Int32 rate, - core::Int32 delay) noexcept -> void { + core::Int32 rate, + core::Int32 delay) noexcept -> void { if (data == nullptr) return; auto *window = static_cast(data); @@ -1412,13 +1412,13 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto relativePointerRelativeMotionHandler(void *data, + auto relativePointerRelativeMotionHandler(void *data, zwp_relative_pointer_v1 *pointer, - core::UInt32 time_hi, - core::UInt32 time_lw, - wl_fixed_t dx, - wl_fixed_t dy, - wl_fixed_t dx_unaccel, + core::UInt32 time_hi, + core::UInt32 time_lw, + wl_fixed_t dx, + wl_fixed_t dy, + wl_fixed_t dx_unaccel, wl_fixed_t dy_unaccel) noexcept -> void { auto *window = static_cast(data); window->relativePointerRelativeMotion(pointer, @@ -1432,7 +1432,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto lockedPointerLockedHandler([[maybe_unused]] void *data, + auto lockedPointerLockedHandler([[maybe_unused]] void *data, [[maybe_unused]] zwp_locked_pointer_v1 *locked_pointer) noexcept -> void { } @@ -1440,7 +1440,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto lockedPointerUnlockedHandler( - [[maybe_unused]] void *data, + [[maybe_unused]] void *data, [[maybe_unused]] zwp_locked_pointer_v1 *locked_pointer) noexcept -> void { } } // namespace stormkit::wsi::linux::wayland \ No newline at end of file diff --git a/src/Wsi/linux/wayland/Log.mpp b/src/Wsi/linux/wayland/Log.mpp index 020cd1f1..7538d231 100644 --- a/src/Wsi/linux/wayland/Log.mpp +++ b/src/Wsi/linux/wayland/Log.mpp @@ -13,7 +13,6 @@ import std; import stormkit.Core; import stormkit.Log; - export namespace stormkit::wsi::linux::wayland { IN_MODULE_LOGGER("StormKit.Wsi.Linux.Wayland") } // namespace stormkit::wsi::linux::wayland diff --git a/src/Wsi/linux/wayland/WindowImpl.mpp b/src/Wsi/linux/wayland/WindowImpl.mpp index 582a9d00..40ecd4fb 100644 --- a/src/Wsi/linux/wayland/WindowImpl.mpp +++ b/src/Wsi/linux/wayland/WindowImpl.mpp @@ -9,10 +9,10 @@ module; #include #include -#include #include #include #include +#include #include @@ -101,22 +101,22 @@ namespace stormkit::wsi::linux::wayland { nullptr); struct Globals { - WLDisplayScoped display; - WLRegistryScoped registry; - WLCompositorScoped compositor; + WLDisplayScoped display; + WLRegistryScoped registry; + WLCompositorScoped compositor; std::vector outputs; - XDGShellScoped xdg_shell; + XDGShellScoped xdg_shell; XDGDecorationManagerScoped xdg_decoration_manager; WLShellScoped wayland_shell; - WLShmScoped shm; - WLSeatScoped seat; - std::vector pointers; - std::vector keyboards; - std::vector touchscreens; - WPPointerConstraintsScoped pointer_constraints; + WLShmScoped shm; + WLSeatScoped seat; + std::vector pointers; + std::vector keyboards; + std::vector touchscreens; + WPPointerConstraintsScoped pointer_constraints; WPRelativePointerManagerScoped relative_pointer_manager; core::HashMap monitors; @@ -133,13 +133,13 @@ export namespace stormkit::wsi::linux::wayland { struct KeyState { xkb_keysym_t key; - bool down; + bool down; }; struct MouseState { struct MouseButtonState { std::uint32_t button; - bool down; + bool down; }; std::array button_state; @@ -187,12 +187,12 @@ export namespace stormkit::wsi::linux::wayland { [[nodiscard]] auto mouseHidden() const noexcept -> bool; [[nodiscard]] auto fullscreen() const noexcept -> bool; - auto setKeyRepeatEnabled(bool enabled) noexcept -> void; + auto setKeyRepeatEnabled(bool enabled) noexcept -> void; [[nodiscard]] auto keyRepeatEnabled() const noexcept -> bool; auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; static auto setMousePositionOnDesktop(const core::math::Vector2U& position) noexcept -> void; @@ -203,52 +203,52 @@ export namespace stormkit::wsi::linux::wayland { auto surfaceConfigure(xdg_surface *surface, std::uint32_t serial) noexcept -> void; auto toplevelConfigure(xdg_toplevel *xdg_tl, - std::int32_t width, - std::int32_t height, - wl_array *state) noexcept -> void; + std::int32_t width, + std::int32_t height, + wl_array *state) noexcept -> void; auto toplevelClose(xdg_toplevel *xdg_tl) noexcept -> void; auto shellSurfaceConfigure(wl_shell_surface *xdg_tl, - std::uint32_t edges, - std::int32_t width, - std::int32_t height) noexcept -> void; + std::uint32_t edges, + std::int32_t width, + std::int32_t height) noexcept -> void; auto seatCapabilities(wl_seat *seat, std::uint32_t capabilities) noexcept -> void; - auto pointerEnter(wl_pointer *pointer, + auto pointerEnter(wl_pointer *pointer, std::uint32_t serial, - wl_surface *surface, - wl_fixed_t surface_x, - wl_fixed_t surface_y) noexcept -> void; + wl_surface *surface, + wl_fixed_t surface_x, + wl_fixed_t surface_y) noexcept -> void; auto pointerLeave(wl_pointer *pointer, std::uint32_t serial, wl_surface *surface) noexcept -> void; - auto pointerMotion(wl_pointer *pointer, + auto pointerMotion(wl_pointer *pointer, std::uint32_t time, - wl_fixed_t surface_x, - wl_fixed_t surface_y) noexcept -> void; - auto pointerButton(wl_pointer *pointer, + wl_fixed_t surface_x, + wl_fixed_t surface_y) noexcept -> void; + auto pointerButton(wl_pointer *pointer, std::uint32_t serial, std::uint32_t time, std::uint32_t button, std::uint32_t state) noexcept -> void; - auto keyboardKeymap(wl_keyboard *keyboard, + auto keyboardKeymap(wl_keyboard *keyboard, std::uint32_t format, - std::int32_t fd, + std::int32_t fd, std::uint32_t size) noexcept -> void; - auto keyboardEnter(wl_keyboard *keyboard, + auto keyboardEnter(wl_keyboard *keyboard, std::uint32_t serial, - wl_surface *surface, - wl_array *keys) noexcept -> void; - auto keyboardLeave(wl_keyboard *keyboard, + wl_surface *surface, + wl_array *keys) noexcept -> void; + auto keyboardLeave(wl_keyboard *keyboard, std::uint32_t serial, - wl_surface *surface) noexcept -> void; - auto keyboardKey(wl_keyboard *keyboard, + wl_surface *surface) noexcept -> void; + auto keyboardKey(wl_keyboard *keyboard, std::uint32_t serial, std::uint32_t time, std::uint32_t key, std::uint32_t state) noexcept -> void; - auto keyboardModifiers(wl_keyboard *keyboard, + auto keyboardModifiers(wl_keyboard *keyboard, std::uint32_t serial, std::uint32_t mods_depressed, std::uint32_t mods_latched, @@ -259,12 +259,12 @@ export namespace stormkit::wsi::linux::wayland { std::int32_t delay) noexcept -> void; auto relativePointerRelativeMotion(zwp_relative_pointer_v1 *pointer, - std::uint32_t time_hi, - std::uint32_t time_lw, - wl_fixed_t dx, - wl_fixed_t dy, - wl_fixed_t dx_unaccel, - wl_fixed_t dy_unaccel) noexcept -> void; + std::uint32_t time_hi, + std::uint32_t time_lw, + wl_fixed_t dx, + wl_fixed_t dy, + wl_fixed_t dx_unaccel, + wl_fixed_t dy_unaccel) noexcept -> void; private: auto createXDGShell() noexcept -> void; @@ -274,29 +274,29 @@ export namespace stormkit::wsi::linux::wayland { // Base Surface WLOutputRefScoped m_current_output; - WLSurfaceScoped m_surface; - WLShmPoolScoped m_shm_pool; + WLSurfaceScoped m_surface; + WLShmPoolScoped m_shm_pool; // Cursor WLCursorThemeScoped m_cursor_theme; - WLSurfaceScoped m_cursor_surface; - WLBufferScoped m_cursor_buffer; + WLSurfaceScoped m_cursor_surface; + WLBufferScoped m_cursor_buffer; // WL_Shell WLShellSurfaceScoped m_wlshell_surface; // XDG - XDGSurfaceScoped m_xdg_surface; + XDGSurfaceScoped m_xdg_surface; XDGTopLevelScoped m_xdg_toplevel; // Events - WLPointerRefScoped m_pointer; - std::uint32_t m_pointer_serial = 0u; + WLPointerRefScoped m_pointer; + std::uint32_t m_pointer_serial = 0u; WLKeyboardRefScoped m_keyboard; - WLTouchRefScoped m_touchscreen; + WLTouchRefScoped m_touchscreen; // WP - WPLockedPointerScoped m_locked_pointer; + WPLockedPointerScoped m_locked_pointer; WPRelativePointerScoped m_relative_pointer; // Fake Buffer @@ -304,14 +304,14 @@ export namespace stormkit::wsi::linux::wayland { // XKB common::XKBContextScoped m_xkb_context; - common::XKBKeymapScoped m_xkb_keymap; - common::XKBStateScoped m_xkb_state; + common::XKBKeymapScoped m_xkb_keymap; + common::XKBStateScoped m_xkb_state; common::XKBMods m_xkb_mods; std::string m_title; - bool m_mouse_locked = false; - bool m_fullscreen = false; + bool m_mouse_locked = false; + bool m_fullscreen = false; core::math::ExtentU m_extent; @@ -323,9 +323,9 @@ export namespace stormkit::wsi::linux::wayland { Handles m_handles; - core::math::Vector2I m_locked_mouse_position; + core::math::Vector2I m_locked_mouse_position; mutable core::math::Vector2I m_mouse_position; - core::math::ExtentU m_fullscreen_extent = {}; + core::math::ExtentU m_fullscreen_extent = {}; std::array m_keyboard_state; diff --git a/src/Wsi/linux/x11/Log.mpp b/src/Wsi/linux/x11/Log.mpp index 09edc10c..672441bb 100644 --- a/src/Wsi/linux/x11/Log.mpp +++ b/src/Wsi/linux/x11/Log.mpp @@ -13,7 +13,6 @@ import std; import stormkit.Core; import stormkit.Log; - export namespace stormkit::wsi::linux::x11 { IN_MODULE_LOGGER("StormKit.Wsi.Linux.X11") } // namespace stormkit::wsi::linux::x11 diff --git a/src/Wsi/linux/x11/WindowImpl.mpp b/src/Wsi/linux/x11/WindowImpl.mpp index 53b7122d..8563b91e 100644 --- a/src/Wsi/linux/x11/WindowImpl.mpp +++ b/src/Wsi/linux/x11/WindowImpl.mpp @@ -5,8 +5,8 @@ module; extern "C" { -#include #include +#include #include #pragma GCC diagnostic push @@ -15,11 +15,11 @@ extern "C" { #include #undef explicit #pragma GCC diagnostic pop +#include +#include #include #include #include -#include -#include } #include @@ -50,10 +50,10 @@ export namespace stormkit::wsi::linux::x11 { class WindowImpl: public ::stormkit::wsi::common::WindowImplBase { public: struct Handles { - xcb_connection_t *connection; - xcb_window_t window; + xcb_connection_t *connection; + xcb_window_t window; xcb_key_symbols_t *key_symbols; - xkb_state *state; + xkb_state *state; }; WindowImpl(); @@ -95,12 +95,12 @@ export namespace stormkit::wsi::linux::x11 { [[nodiscard]] auto mouseHidden() const noexcept -> bool; [[nodiscard]] auto fullscreen() const noexcept -> bool; - auto setKeyRepeatEnabled(bool enabled) noexcept -> void; + auto setKeyRepeatEnabled(bool enabled) noexcept -> void; [[nodiscard]] auto keyRepeatEnabled() const noexcept -> bool; auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; static auto setMousePositionOnDesktop(const core::math::Vector2U& position) noexcept -> void; @@ -112,13 +112,13 @@ export namespace stormkit::wsi::linux::x11 { auto handleKeyEvent(xcb_keycode_t keycode, bool up) noexcept -> void; - XCBConnectionScoped m_connection = nullptr; + XCBConnectionScoped m_connection = nullptr; common::XKBContextScoped m_xkb_context = nullptr; - XCBWindowScoped m_window; - XCBKeySymbolsScoped m_key_symbols; + XCBWindowScoped m_window; + XCBKeySymbolsScoped m_key_symbols; common::XKBKeymapScoped m_xkb_keymap; - common::XKBStateScoped m_xkb_state; + common::XKBStateScoped m_xkb_state; common::XKBMods m_xkb_mods; @@ -126,14 +126,14 @@ export namespace stormkit::wsi::linux::x11 { uint32_t flags = 0; uint32_t functions = 0; uint32_t decorations = 0; - int32_t input_mode = 0; + int32_t input_mode = 0; uint32_t state = 0; } m_window_hints; std::string m_title; - bool m_mouse_locked = false; - bool m_mouse_hided = false; - bool m_fullscreen = false; + bool m_mouse_locked = false; + bool m_mouse_hided = false; + bool m_fullscreen = false; core::math::ExtentU m_extent; @@ -145,7 +145,7 @@ export namespace stormkit::wsi::linux::x11 { Handles m_handles; - core::math::Vector2I m_locked_mouse_position; + core::math::Vector2I m_locked_mouse_position; mutable core::math::Vector2I m_mouse_position; }; } // namespace stormkit::wsi::linux::x11 @@ -290,7 +290,7 @@ namespace stormkit::wsi::linux::x11 { m_window.reset(xcb_generate_id(m_connection)); core::UInt32 value_list[] = { screen->white_pixel, screen->black_pixel, EVENTS }; - auto cookie = + auto cookie = xcb_create_window_checked(m_connection, XCB_COPY_FROM_PARENT, m_window, @@ -700,7 +700,7 @@ namespace stormkit::wsi::linux::x11 { auto connection = getXCBConnection(); const auto default_screen_id = 0; - auto root_window = defaultRootWindow(connection, default_screen_id); + auto root_window = defaultRootWindow(connection, default_screen_id); xcb_warp_pointer(connection, XCB_NONE, root_window, 0, 0, 0, 0, position.x, position.y); @@ -771,7 +771,7 @@ namespace stormkit::wsi::linux::x11 { ///////////////////////////////////// ///////////////////////////////////// auto WindowImpl::processEvents(xcb_generic_event_t *event) -> void { - auto *xevent = event; + auto *xevent = event; const auto response_type = xevent->response_type & ~0x80; switch (response_type) { diff --git a/src/Wsi/linux/x11/XCB.mpp b/src/Wsi/linux/x11/XCB.mpp index 8e25bb7f..b4c59085 100644 --- a/src/Wsi/linux/x11/XCB.mpp +++ b/src/Wsi/linux/x11/XCB.mpp @@ -20,7 +20,6 @@ import stormkit.Core; import :Linux.X11.Log; - #define STORMKIT_XCB_SCOPED(name, type) \ struct name##Scoped { \ name##Scoped(type *handle) noexcept; \ @@ -64,33 +63,33 @@ export namespace stormkit::wsi::linux::x11 { #undef STORMKIT_XCB_SCOPED -#define STORMKIT_XCB_SCOPED(name, type, var, global, deleter) \ - name##Scoped::name##Scoped(type *handle) noexcept : m_handle { handle } { \ - if (m_handle != nullptr) var++; \ - } \ - \ - name##Scoped::~name##Scoped() noexcept { \ - if (m_handle != nullptr) { \ - var--; \ - \ - if (var == 0) { \ - deleter(m_handle); \ - m_handle = nullptr; \ - global = nullptr; \ - } \ - } \ - } \ - \ - name##Scoped::name##Scoped(name##Scoped&& other) noexcept \ - : m_handle { std::exchange(other.m_handle, nullptr) } { \ - } \ - \ - auto name##Scoped::operator=(name##Scoped && other) noexcept -> name##Scoped& { \ - if (this == &other) return *this; \ - \ - m_handle = std::exchange(other.m_handle, nullptr); \ - \ - return *this; \ +#define STORMKIT_XCB_SCOPED(name, type, var, global, deleter) \ + name##Scoped::name##Scoped(type *handle) noexcept : m_handle { handle } { \ + if (m_handle != nullptr) var++; \ + } \ + \ + name##Scoped::~name##Scoped() noexcept { \ + if (m_handle != nullptr) { \ + var--; \ + \ + if (var == 0) { \ + deleter(m_handle); \ + m_handle = nullptr; \ + global = nullptr; \ + } \ + } \ + } \ + \ + name##Scoped::name##Scoped(name##Scoped&& other) noexcept \ + : m_handle { std::exchange(other.m_handle, nullptr) } { \ + } \ + \ + auto name##Scoped::operator=(name##Scoped&& other) noexcept -> name##Scoped& { \ + if (this == &other) return *this; \ + \ + m_handle = std::exchange(other.m_handle, nullptr); \ + \ + return *this; \ } namespace stormkit::wsi::linux::x11 { @@ -201,7 +200,7 @@ namespace stormkit::wsi::linux::x11 { using CStr = const char *; const auto *extension = CStr { nullptr }; - const auto str_error = xcb_errors_get_name_for_error(ctx, error->major_code, &extension); + const auto str_error = xcb_errors_get_name_for_error(ctx, error->major_code, &extension); return std::format("{} extension: {} major: {} minor: {}\n", str_error, diff --git a/src/Wsi/macOS/StormKitWindow.hpp b/src/Wsi/macOS/StormKitWindow.hpp index 4da320bf..90db495d 100644 --- a/src/Wsi/macOS/StormKitWindow.hpp +++ b/src/Wsi/macOS/StormKitWindow.hpp @@ -5,8 +5,8 @@ #ifndef STORMKIT_WINDOW_CONTROLLER_HPP #define STORMKIT_WINDOW_CONTROLLER_HPP -#include #include +#include #import @@ -16,11 +16,11 @@ namespace stormkit::wsi::macos { @class StormKitView; @interface StormKitWindowController: NSResponder -- (id)initWithWidth:(std::uint32_t)width - withHeight:(std::uint32_t)height - withStyle:(int)style - withTitle:(std::string)title - withRequester:(stormkit::wsi::macos::macOSWindow *)_requester; +- (id)initWithWidth:(std::uint32_t)width + withHeight:(std::uint32_t)height + withStyle:(int)style + withTitle:(std::string)title + withRequester:(stormkit::wsi::macos::macOSWindow *)_requester; - (void)dealloc; - (void)setRequester:(stormkit::wsi::macos::macOSWindow *)requester; @@ -50,10 +50,10 @@ namespace stormkit::wsi::macos { - (NSPoint)convertPoint:(NSPoint)point; @end -@interface StormKitWindow : NSWindow - - (BOOL) acceptsFirstResponder; - - (BOOL) canBecomeKeyWindow; - - (void) performClose: (id)sender; +@interface StormKitWindow: NSWindow +- (BOOL)acceptsFirstResponder; +- (BOOL)canBecomeKeyWindow; +- (void)performClose:(id)sender; @end #endif diff --git a/src/Wsi/macOS/Utils.hpp b/src/Wsi/macOS/Utils.hpp index 9b6f6704..d55adfd5 100644 --- a/src/Wsi/macOS/Utils.hpp +++ b/src/Wsi/macOS/Utils.hpp @@ -10,6 +10,6 @@ namespace stormkit::wsi::macos { auto localizedKey(char code) noexcept -> int; auto nonLocalizedKey(unsigned short code) noexcept -> int; auto usageToVirtualCode(int usage) noexcept -> int; -} // namespace storm::window::details +} // namespace stormkit::wsi::macos #endif diff --git a/src/Wsi/macOS/WindowImpl.mpp b/src/Wsi/macOS/WindowImpl.mpp index f5830c78..f7e50b19 100644 --- a/src/Wsi/macOS/WindowImpl.mpp +++ b/src/Wsi/macOS/WindowImpl.mpp @@ -14,7 +14,6 @@ import std; import stormkit.Core; - import :Types; import :Common.WindowImplBase; @@ -22,14 +21,14 @@ import :Common.WindowImplBase; export namespace stormkit::wsi::macos { class WindowImpl: public ::stormkit::wsi::common::WindowImplBase { public: - WindowImpl(WM wm) noexcept; - WindowImpl(WM wm, std::string title, const core::math::ExtentU& size, WindowStyle style); + WindowImpl(WM wm) noexcept; + WindowImpl(WM wm, std::string title, const core::math::ExtentU& size, WindowStyle style); ~WindowImpl(); - WindowImpl(const WindowImpl&) noexcept = delete; + WindowImpl(const WindowImpl&) noexcept = delete; auto operator=(const WindowImpl&) noexcept -> WindowImpl& = delete; - WindowImpl(WindowImpl&&) noexcept; + WindowImpl(WindowImpl&&) noexcept; auto operator=(WindowImpl&&) noexcept -> WindowImpl&; auto create(std::string title, const core::math::ExtentU& size, WindowStyle style) -> void; @@ -67,7 +66,7 @@ export namespace stormkit::wsi::macos { auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; static auto setMousePositionOnDesktop(WM wm, const core::math::Vector2U& position) noexcept -> void; @@ -115,50 +114,41 @@ namespace stormkit::wsi::macos { STORMKIT_FORCE_INLINE auto WindowImpl::create(std::string title, const core::math::ExtentU& size, WindowStyle style) -> void { - m_window = std::make_unique(std::move(title), - size.width, - size.height, - core::narrow(core::as(style))); + m_window = + std::make_unique(std::move(title), + size.width, + size.height, + core::narrow(core::as(style))); m_window->mouseDownEvent = [this](int button, core::Int32 x, core::Int32 y) noexcept { - WindowImplBase::mouseDownEvent(core::as(core::narrow(button)), x, y); + WindowImplBase::mouseDownEvent(core::as(core::narrow(button)), + x, + y); }; m_window->mouseUpEvent = [this](int button, core::Int32 x, core::Int32 y) noexcept { - WindowImplBase::mouseUpEvent(core::as(core::narrow(button)), x, y); + WindowImplBase::mouseUpEvent(core::as(core::narrow(button)), + x, + y); }; m_window->mouseMoveEvent = [this](core::Int32 x, core::Int32 y) noexcept { WindowImplBase::mouseMoveEvent(x, y); }; - m_window->mouseEnteredEvent = [this]() noexcept { - WindowImplBase::mouseEnteredEvent(); - }; - m_window->mouseExitedEvent = [this]() noexcept { - WindowImplBase::mouseExitedEvent(); - }; - m_window->keyDownEvent = [this](int key, char c) noexcept { + m_window->mouseEnteredEvent = [this]() noexcept { WindowImplBase::mouseEnteredEvent(); }; + m_window->mouseExitedEvent = [this]() noexcept { WindowImplBase::mouseExitedEvent(); }; + m_window->keyDownEvent = [this](int key, char c) noexcept { WindowImplBase::keyDownEvent(core::as(core::narrow(key)), c); }; m_window->keyUpEvent = [this](int key, char c) noexcept { WindowImplBase::keyUpEvent(core::as(core::narrow(key)), c); }; - m_window->closeEvent = [this]() noexcept { - WindowImplBase::closeEvent(); - }; + m_window->closeEvent = [this]() noexcept { WindowImplBase::closeEvent(); }; m_window->resizeEvent = [this](core::UInt32 width, core::UInt32 height) noexcept { WindowImplBase::resizeEvent(width, height); }; - m_window->minimizeEvent = [this]() noexcept { - WindowImplBase::minimizeEvent(); - }; - m_window->maximizeEvent = [this]() noexcept { - WindowImplBase::maximizeEvent(); - }; - m_window->lostFocusEvent = [this]() noexcept { - WindowImplBase::lostFocusEvent(); - }; - m_window->gainedFocusEvent = [this]() noexcept { - WindowImplBase::gainedFocusEvent(); - }; + m_window->minimizeEvent = [this]() noexcept { WindowImplBase::minimizeEvent(); }; + m_window->maximizeEvent = [this]() noexcept { WindowImplBase::maximizeEvent(); }; + m_window->lostFocusEvent = [this]() noexcept { WindowImplBase::lostFocusEvent(); }; + m_window->gainedFocusEvent = [this]() noexcept { WindowImplBase::gainedFocusEvent(); }; } ///////////////////////////////////// @@ -282,7 +272,7 @@ namespace stormkit::wsi::macos { return core::math::ExtentU { extent.width, extent.height }; }) | std::ranges::to(), - .handle = monitor.handle, + .handle = monitor.handle, }; }) | std::ranges::to(); diff --git a/src/Wsi/macOS/macOSWindow.hpp b/src/Wsi/macOS/macOSWindow.hpp index 51696214..91571de8 100644 --- a/src/Wsi/macOS/macOSWindow.hpp +++ b/src/Wsi/macOS/macOSWindow.hpp @@ -7,10 +7,10 @@ #include -#include #include -#include #include +#include +#include #ifdef __OBJC__ @class StormKitWindowController; @@ -19,7 +19,7 @@ using StormKitWindowControllerPtr = StormKitWindowController *; using ViewPtr = StormKitView *; #else using StormKitWindowControllerPtr = void *; -using ViewPtr = void *; +using ViewPtr = void *; #endif namespace stormkit::wsi::macos { @@ -31,24 +31,30 @@ namespace stormkit::wsi::macos { struct Monitor { enum class Flags { - None = 0, + None = 0, Primary = 1 }; - Flags flags = Flags::None; + Flags flags = Flags::None; std::string name; - struct Extent { std::uint32_t width; std::uint32_t height; }; + struct Extent { + std::uint32_t width; + std::uint32_t height; + }; std::vector extents; void *handle = nullptr; }; - macOSWindow(std::string title, std::uint32_t width, std::uint32_t height, int style) noexcept; + macOSWindow(std::string title, + std::uint32_t width, + std::uint32_t height, + int style) noexcept; ~macOSWindow(); - macOSWindow(const macOSWindow&) noexcept = delete; + macOSWindow(const macOSWindow&) noexcept = delete; auto operator=(const macOSWindow&) noexcept -> macOSWindow& = delete; macOSWindow(macOSWindow&&) noexcept; @@ -75,18 +81,18 @@ namespace stormkit::wsi::macos { [[nodiscard]] auto visible() const noexcept -> bool; - [[nodiscard]] auto macOSHandles() const noexcept -> const Handles &; + [[nodiscard]] auto macOSHandles() const noexcept -> const Handles&; [[nodiscard]] auto mouseLocked() const noexcept -> bool; [[nodiscard]] auto mouseHided() const noexcept -> bool; [[nodiscard]] auto fullscreen() const noexcept -> bool; - auto setKeyRepeatEnabled(bool enabled) noexcept -> void; + auto setKeyRepeatEnabled(bool enabled) noexcept -> void; [[nodiscard]] auto keyRepeatEnabled() const noexcept -> bool; auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(std::int32_t width, std::int32_t height) noexcept -> void; + auto setMousePosition(std::int32_t width, std::int32_t height) noexcept -> void; static auto setMousePositionOnDesktop(std::uint32_t width, std::uint32_t height) noexcept -> void; @@ -106,32 +112,31 @@ namespace stormkit::wsi::macos { std::function closeEvent; std::function resizeEvent; - std::function minimizeEvent; - std::function maximizeEvent; + std::function minimizeEvent; + std::function maximizeEvent; std::function lostFocusEvent; std::function gainedFocusEvent; private: - StormKitWindowControllerPtr m_controller; Handles m_handles; std::string m_title; - std::uint32_t m_width = 0; + std::uint32_t m_width = 0; std::uint32_t m_height = 0; - bool m_visible = false; - bool m_mouse_locked = false; - bool m_mouse_hided = false; - bool m_fullscreen = false; + bool m_visible = false; + bool m_mouse_locked = false; + bool m_mouse_hided = false; + bool m_fullscreen = false; bool m_key_repeat_enabled = false; }; auto initCocoaProcess() -> void; -} // namespace storm::window::details +} // namespace stormkit::wsi::macos //////////////////////////////////////////////////////////////////// /// IMPLEMENTATION /// @@ -171,8 +176,8 @@ namespace stormkit::wsi::macos { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto macOSWindow::keyRepeatEnabled() const noexcept -> bool { - return m_key_repeat_enabled; + return m_key_repeat_enabled; } -} +} // namespace stormkit::wsi::macos #endif diff --git a/src/Wsi/win32/Log.mpp b/src/Wsi/win32/Log.mpp index 3941566f..d6dc47b4 100644 --- a/src/Wsi/win32/Log.mpp +++ b/src/Wsi/win32/Log.mpp @@ -13,7 +13,6 @@ import std; import stormkit.Core; import stormkit.Log; - export namespace stormkit::wsi::win32 { IN_MODULE_LOGGER("StormKit.Wsi.Win32Backend") } // namespace stormkit::wsi::win32 diff --git a/src/Wsi/win32/WindowImpl.mpp b/src/Wsi/win32/WindowImpl.mpp index 15135251..62c8de3f 100644 --- a/src/Wsi/win32/WindowImpl.mpp +++ b/src/Wsi/win32/WindowImpl.mpp @@ -12,7 +12,6 @@ export module stormkit.Wsi:Win32.WindowImpl; import std; - import stormkit.Core; import :Types; @@ -69,7 +68,7 @@ export namespace stormkit::wsi::win32 { auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; static auto setMousePositionOnDesktop(WM wm, const core::math::Vector2U& position) noexcept -> void; diff --git a/tests/src/Test.mpp b/tests/src/Test.mpp index 5d18024e..8dbd7afb 100644 --- a/tests/src/Test.mpp +++ b/tests/src/Test.mpp @@ -30,8 +30,8 @@ export namespace test { }; struct TestSuite { - TestSuite(std::string&& name, - std::vector&& tests, + TestSuite(std::string && name, + std::vector && tests, const std::source_location& location = std::source_location::current()) noexcept; }; @@ -149,8 +149,8 @@ namespace test { return failed_tests == 0; } - TestSuite::TestSuite(std::string&& name, - std::vector&& tests, + TestSuite::TestSuite(std::string && name, + std::vector && tests, const std::source_location& location) noexcept { state.test_suites.emplace_back( std::make_unique(std::move(name), std::move(tests), location)); From aee9b01964ed2f8ecf5d98a90fe551c5e72c06f2 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Feb 2024 21:27:33 +0100 Subject: [PATCH 03/39] apply clang-format --- .clang-format | 2 +- examples/entities/gameoflife/src/App.cpp | 4 +- examples/entities/gameoflife/src/App.mpp | 4 +- examples/entities/gameoflife/src/Renderer.mpp | 6 +- examples/entities/gameoflife/src/Systems.cpp | 6 +- examples/entities/gameoflife/src/Systems.mpp | 8 +- include/stormkit/Core/MemoryMacro.hpp | 10 +- include/stormkit/Core/PimplImplMacro.hpp | 8 +- include/stormkit/Log/LogMacro.hpp | 20 +- .../stormkit/Core/Containers/RingBuffer.mpp | 9 +- modules/stormkit/Core/Containers/Tree.mpp | 4 +- modules/stormkit/Core/Containers/Utils.mpp | 29 +- modules/stormkit/Core/Coroutines.mpp | 48 +-- modules/stormkit/Core/Hash/Base.mpp | 4 +- modules/stormkit/Core/Meta/NamedType.mpp | 10 +- modules/stormkit/Core/String/CStrings.mpp | 8 +- modules/stormkit/Core/String/Encodings.mpp | 22 +- modules/stormkit/Core/String/Format.mpp | 2 +- modules/stormkit/Core/String/Operations.mpp | 4 +- modules/stormkit/Core/Utils/AsCast.mpp | 4 +- modules/stormkit/Core/Utils/Byte.mpp | 2 +- modules/stormkit/Core/Utils/DeferInit.mpp | 19 +- modules/stormkit/Core/Utils/Descriptors.mpp | 12 +- modules/stormkit/Core/Utils/DynamicLoader.mpp | 8 +- modules/stormkit/Core/Utils/ErrorHandling.mpp | 4 +- modules/stormkit/Core/Utils/Expected.mpp | 28 +- modules/stormkit/Core/Utils/Filesystem.mpp | 4 +- modules/stormkit/Core/Utils/Functional.mpp | 8 +- modules/stormkit/Core/Utils/Monadic.mpp | 24 +- modules/stormkit/Core/Utils/NakedRef.mpp | 14 +- modules/stormkit/Core/Utils/Numerics.mpp | 8 +- modules/stormkit/Core/Utils/Pimpl.mpp | 16 +- modules/stormkit/Core/Utils/Predicates.mpp | 2 +- modules/stormkit/Core/Utils/Singleton.mpp | 8 +- .../Engine/Renderer/BakedFrameGraph.mpp | 8 +- .../Engine/Renderer/FrameGraphBuilder.mpp | 20 +- .../stormkit/Engine/Renderer/GraphTask.mpp | 2 +- .../Engine/Renderer/GraphTaskBuilder.mpp | 4 +- modules/stormkit/Entities.mpp | 24 +- modules/stormkit/Gpu/Core/Device.mpp | 14 +- .../stormkit/Gpu/Execution/CommandBuffer.mpp | 100 ++--- .../stormkit/Gpu/Execution/Descriptors.mpp | 28 +- modules/stormkit/Gpu/Execution/Pipeline.mpp | 64 ++-- modules/stormkit/Gpu/Execution/RenderPass.mpp | 40 +- modules/stormkit/Gpu/Resource/Buffer.mpp | 22 +- modules/stormkit/Gpu/Resource/Image.mpp | 44 +-- modules/stormkit/Gpu/Resource/Shader.mpp | 30 +- modules/stormkit/Gpu/Vulkan/Utils.mpp | 24 +- modules/stormkit/Log/ConsoleLogger.mpp | 2 +- modules/stormkit/Log/FileLogger.mpp | 2 +- modules/stormkit/Log/Logger.mpp | 63 ++-- modules/stormkit/Wsi/Types.mpp | 6 +- modules/stormkit/Wsi/Window.mpp | 2 +- src/Core/DynamicLoader.cpp | 2 +- src/Core/darwin/ThreadUtils.cpp | 2 +- src/Core/darwin/ThreadUtilsImpl.h | 6 +- src/Core/darwin/ThreadUtilsImpl.m | 4 +- src/Core/posix/DynamicLoader.mpp | 4 +- src/Core/win32/DynamicLoader.mpp | 2 +- src/Core/win32/ThreadUtils.cpp | 2 +- src/Engine/Renderer/BakedFrameGraph.cpp | 6 +- src/Engine/Renderer/FrameGraphBuilder.cpp | 8 +- src/Gpu/Core/Device.cpp | 14 +- src/Gpu/Core/Instance.cpp | 4 +- src/Gpu/Core/PhysicalDevice.cpp | 2 +- src/Gpu/Execution/Pipeline.cpp | 4 +- src/Gpu/Resource/Buffer.cpp | 2 +- src/Image/HDRImage.mpp | 2 +- src/Image/Image.cpp | 24 +- src/Image/JPEGImage.mpp | 16 +- src/Image/KTXImage.mpp | 5 +- src/Image/PNGImage.mpp | 18 +- src/Image/PPMImage.mpp | 4 +- src/Image/QOIImage.mpp | 6 +- src/Image/TARGAImage.mpp | 2 +- src/Log/ConsoleLogger.cpp | 2 +- src/Log/FileLogger.cpp | 2 +- src/Log/Logger.cpp | 2 +- src/Main/linux/Main-linux.cpp | 2 +- src/Main/macOS/Main-macOS.mm | 2 +- src/Main/win32/Main-win.cpp | 2 +- src/Wsi/iOS/AppDelegate.hpp | 2 +- src/Wsi/iOS/View.h | 6 +- src/Wsi/iOS/ViewController.h | 4 +- src/Wsi/iOS/WindowImpl.hpp | 22 +- src/Wsi/iOS/iosMain.cpp | 2 +- src/Wsi/iOS/iosMain.hpp | 2 +- src/Wsi/linux/WindowImpl.mpp | 2 +- src/Wsi/linux/common/XKB.mpp | 12 +- src/Wsi/linux/wayland/Callbacks.mpp | 38 +- src/Wsi/linux/wayland/Implementation.cpp | 342 ++++++++--------- src/Wsi/linux/wayland/WindowImpl.mpp | 60 +-- src/Wsi/linux/x11/Utils.mpp | 6 +- src/Wsi/linux/x11/WindowImpl.mpp | 48 +-- src/Wsi/linux/x11/XCB.mpp | 28 +- src/Wsi/macOS/StormKitView.hpp | 42 +-- src/Wsi/macOS/StormKitView.mm | 22 +- src/Wsi/macOS/StormKitWindow.hpp | 12 +- src/Wsi/macOS/StormKitWindow.mm | 42 +-- src/Wsi/macOS/Utils.mm | 289 +++++++------- src/Wsi/macOS/WindowImpl.mpp | 2 +- src/Wsi/macOS/macOSWindow.hpp | 10 +- src/Wsi/macOS/macOSWindow.mm | 356 +++++++++--------- src/Wsi/win32/WindowImpl.mpp | 8 +- tests/src/Test.mpp | 8 +- tests/src/core/AsCast.cpp | 12 +- 106 files changed, 1199 insertions(+), 1197 deletions(-) diff --git a/.clang-format b/.clang-format index 9a621989..2c1980c1 100644 --- a/.clang-format +++ b/.clang-format @@ -70,7 +70,7 @@ NamespaceIndentation: All ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: false PenaltyBreakAssignment: '0' -PointerAlignment: Right +PointerAlignment: Left SortIncludes: 'true' SortUsingDeclarations: 'true' SpaceAfterTemplateKeyword: 'false' diff --git a/examples/entities/gameoflife/src/App.cpp b/examples/entities/gameoflife/src/App.cpp index 6cfa6864..19d2c86d 100644 --- a/examples/entities/gameoflife/src/App.cpp +++ b/examples/entities/gameoflife/src/App.cpp @@ -25,7 +25,7 @@ App::~App() { ilog("Cleaning"); } -auto App::run([[maybe_unused]] const int argc, [[maybe_unused]] const char **argv) -> core::Int32 { +auto App::run([[maybe_unused]] const int argc, [[maybe_unused]] const char** argv) -> core::Int32 { using Clock = std::chrono::high_resolution_clock; using namespace stormkit::core::literals; @@ -141,7 +141,7 @@ auto App::handleMouse(const stormkit::wsi::MouseButtonPushedEventData& event) -> const auto cells = m_entities.entitiesWithComponent(); const auto it = std::ranges::find_if(cells, [&](const auto e) { - const auto &position = m_entities.getComponent(e); + const auto& position = m_entities.getComponent(e); return position.x == x && position.y == y; }); diff --git a/examples/entities/gameoflife/src/App.mpp b/examples/entities/gameoflife/src/App.mpp index d84bf487..8fc6333f 100644 --- a/examples/entities/gameoflife/src/App.mpp +++ b/examples/entities/gameoflife/src/App.mpp @@ -31,7 +31,7 @@ export { App(); ~App() override; - auto run(const int argc, const char **argv) -> stormkit::core::Int32 override; + auto run(const int argc, const char** argv) -> stormkit::core::Int32 override; private: auto doInitWindow() -> void; @@ -51,7 +51,7 @@ export { stormkit::image::Image m_board; - UpdateBoardSystem *m_update_system = nullptr; + UpdateBoardSystem* m_update_system = nullptr; }; #ifdef STORMKIT_BUILD_MODULES diff --git a/examples/entities/gameoflife/src/Renderer.mpp b/examples/entities/gameoflife/src/Renderer.mpp index 1e9f3bca..e62950d9 100644 --- a/examples/entities/gameoflife/src/Renderer.mpp +++ b/examples/entities/gameoflife/src/Renderer.mpp @@ -38,14 +38,14 @@ export { auto doInitMeshRenderObjects() -> void; auto doInitPerFrameObjects() -> void; - const stormkit::wsi::Window *m_window = nullptr; + const stormkit::wsi::Window* m_window = nullptr; std::unique_ptr m_instance; std::unique_ptr m_device; std::unique_ptr m_surface; - stormkit::gpu::Fence *m_current_fence = nullptr; + stormkit::gpu::Fence* m_current_fence = nullptr; - const stormkit::gpu::Queue *m_queue = nullptr; + const stormkit::gpu::Queue* m_queue = nullptr; std::vector m_surface_views; std::unique_ptr m_descriptor_set_layout; diff --git a/examples/entities/gameoflife/src/Systems.cpp b/examples/entities/gameoflife/src/Systems.cpp index e03784d7..91a3537c 100644 --- a/examples/entities/gameoflife/src/Systems.cpp +++ b/examples/entities/gameoflife/src/Systems.cpp @@ -13,8 +13,8 @@ import Components; using namespace stormkit; -UpdateBoardSystem::UpdateBoardSystem(stormkit::image::Image & board, - Renderer & renderer, +UpdateBoardSystem::UpdateBoardSystem(stormkit::image::Image& board, + Renderer& renderer, entities::EntityManager& manager) : entities::System { manager, 0, { PositionComponent::TYPE } }, m_board { &board }, m_renderer { &renderer }, m_last_update { Clock::now() } { @@ -147,7 +147,7 @@ auto UpdateBoardSystem::postUpdate() -> void { using namespace stormkit::core::literals; if (m_updated) { m_updated = false; - auto & board = *m_board; + auto& board = *m_board; const auto& extent = board.extent(); for (auto i : core::range(extent.width * extent.height)) { diff --git a/examples/entities/gameoflife/src/Systems.mpp b/examples/entities/gameoflife/src/Systems.mpp index aa6b2316..7ba2fee0 100644 --- a/examples/entities/gameoflife/src/Systems.mpp +++ b/examples/entities/gameoflife/src/Systems.mpp @@ -26,8 +26,8 @@ export { class UpdateBoardSystem final: public stormkit::entities::System { public: - UpdateBoardSystem(stormkit::image::Image & board, - Renderer & renderer, + UpdateBoardSystem(stormkit::image::Image& board, + Renderer& renderer, stormkit::entities::EntityManager& manager); ~UpdateBoardSystem() override; @@ -47,8 +47,8 @@ export { auto onMessageReceived(const stormkit::entities::Message& message) -> void override {}; bool m_is_on_edit_mode = true; - stormkit::image::Image *m_board = nullptr; - Renderer *m_renderer = nullptr; + stormkit::image::Image* m_board = nullptr; + Renderer* m_renderer = nullptr; Clock::time_point m_last_update; diff --git a/include/stormkit/Core/MemoryMacro.hpp b/include/stormkit/Core/MemoryMacro.hpp index 08e9f439..be6dabbf 100644 --- a/include/stormkit/Core/MemoryMacro.hpp +++ b/include/stormkit/Core/MemoryMacro.hpp @@ -15,7 +15,7 @@ #define ALLOCATE_HELPERS(T) \ template \ - [[nodiscard]] static inline auto allocate(Args&&...args) { \ + [[nodiscard]] static inline auto allocate(Args&&... args) { \ return std::make_unique(std::forward(args)...); \ } @@ -64,7 +64,7 @@ #define STORMKIT_RAII_CAPSULE_OPAQUE(name, x, _constructor, _deleter, release_value) \ struct name##Scoped { \ template \ - name##Scoped(Args&&...args) noexcept { \ + name##Scoped(Args&&... args) noexcept { \ m_handle = _constructor(std::forward(args)...); \ } \ explicit name##Scoped(x v) noexcept { \ @@ -109,7 +109,7 @@ #define STORMKIT_RAII_CAPSULE(name, x, deleter) \ struct name##Deleter { \ - auto operator()(x *ptr) const noexcept -> void { \ + auto operator()(x* ptr) const noexcept -> void { \ if (ptr) [[likely]] \ deleter(ptr); \ } \ @@ -117,7 +117,7 @@ using name##Scoped = std::unique_ptr; #define STORMKIT_RAII_CAPSULE_PP(name, x, deleter) \ struct name##Deleter { \ - auto operator()(x *ptr) const noexcept -> void { \ + auto operator()(x* ptr) const noexcept -> void { \ if (ptr) [[likely]] \ deleter(&ptr); \ } \ @@ -129,6 +129,6 @@ noexcept(noexcept(expr))->decltype(expr) { \ return expr; \ } -#define STORMKIT_OVERLOADS_OF(name) [&](auto&&...args) STORMKIT_RETURNS(name(FWD(args)...)) +#define STORMKIT_OVERLOADS_OF(name) [&](auto&&... args) STORMKIT_RETURNS(name(FWD(args)...)) #endif \ No newline at end of file diff --git a/include/stormkit/Core/PimplImplMacro.hpp b/include/stormkit/Core/PimplImplMacro.hpp index b4c998ca..ec8331a4 100644 --- a/include/stormkit/Core/PimplImplMacro.hpp +++ b/include/stormkit/Core/PimplImplMacro.hpp @@ -15,7 +15,7 @@ Pimpl::~Pimpl() = default; \ template \ template First, class... Args> \ - Pimpl::Pimpl(First&& first, Args&&...args) { \ + Pimpl::Pimpl(First&& first, Args&&... args) { \ init(std::forward(first), std::forward(args)...); \ } \ template \ @@ -24,15 +24,15 @@ auto Pimpl::operator=(Pimpl&&) noexcept -> Pimpl& = default; \ template \ template \ - auto Pimpl::init(Args&&...args) -> void { \ + auto Pimpl::init(Args&&... args) -> void { \ m_data = std::make_unique(std::forward(args)...); \ } \ template \ - auto Pimpl::operator->() noexcept -> T * { \ + auto Pimpl::operator->() noexcept -> T* { \ return &get(); \ } \ template \ - auto Pimpl::operator->() const noexcept -> const T * { \ + auto Pimpl::operator->() const noexcept -> const T* { \ return &get(); \ } \ template \ diff --git a/include/stormkit/Log/LogMacro.hpp b/include/stormkit/Log/LogMacro.hpp index 7247adef..fb811e0d 100644 --- a/include/stormkit/Log/LogMacro.hpp +++ b/include/stormkit/Log/LogMacro.hpp @@ -13,23 +13,23 @@ #define LOGGER(module) \ NAMED_LOGGER(LOG_MODULE, module) \ template \ - auto dlog(Args&&...args)->void { \ + auto dlog(Args&&... args)->void { \ LOG_MODULE.dlog(std::forward(args)...); \ } \ template \ - auto ilog(Args&&...args)->void { \ + auto ilog(Args&&... args)->void { \ LOG_MODULE.ilog(std::forward(args)...); \ } \ template \ - auto wlog(Args&&...args)->void { \ + auto wlog(Args&&... args)->void { \ LOG_MODULE.wlog(std::forward(args)...); \ } \ template \ - auto elog(Args&&...args)->void { \ + auto elog(Args&&... args)->void { \ LOG_MODULE.elog(std::forward(args)...); \ } \ template \ - auto flog(Args&&...args)->void { \ + auto flog(Args&&... args)->void { \ LOG_MODULE.flog(std::forward(args)...); \ } @@ -39,23 +39,23 @@ #define IN_MODULE_LOGGER(module) \ IN_MODULE_NAMED_LOGGER(LOG_MODULE, module) \ template \ - auto dlog(Args&&...args)->void { \ + auto dlog(Args&&... args)->void { \ LOG_MODULE.dlog(std::forward(args)...); \ } \ template \ - auto ilog(Args&&...args)->void { \ + auto ilog(Args&&... args)->void { \ LOG_MODULE.ilog(std::forward(args)...); \ } \ template \ - auto wlog(Args&&...args)->void { \ + auto wlog(Args&&... args)->void { \ LOG_MODULE.wlog(std::forward(args)...); \ } \ template \ - auto elog(Args&&...args)->void { \ + auto elog(Args&&... args)->void { \ LOG_MODULE.elog(std::forward(args)...); \ } \ template \ - auto flog(Args&&...args)->void { \ + auto flog(Args&&... args)->void { \ LOG_MODULE.flog(std::forward(args)...); \ } diff --git a/modules/stormkit/Core/Containers/RingBuffer.mpp b/modules/stormkit/Core/Containers/RingBuffer.mpp index c216d35d..19fbb650 100644 --- a/modules/stormkit/Core/Containers/RingBuffer.mpp +++ b/modules/stormkit/Core/Containers/RingBuffer.mpp @@ -45,9 +45,8 @@ export namespace stormkit::core { -> bool; template - auto - emplace(Args&&...values) noexcept(std::is_nothrow_constructible_v) - -> void; + auto emplace(Args&&... values) noexcept( + std::is_nothrow_constructible_v) -> void; auto next() noexcept -> void; @@ -209,7 +208,7 @@ namespace stormkit::core { //////////////////////////////////////// template template - auto RingBuffer::emplace(Args&&...values) noexcept( + auto RingBuffer::emplace(Args&&... values) noexcept( std::is_nothrow_constructible_v) -> void { if (m_count == m_capacity) pop(); @@ -262,7 +261,7 @@ namespace stormkit::core { template template auto RingBuffer::getPtr(this Self& self, ExtentType pos) noexcept -> auto&& { - using OutPtr = std::conditional_t, const T *, T *>; + using OutPtr = std::conditional_t, const T*, T*>; const auto addr = std::to_address(self.m_buffer[pos * sizeof(ValueType)]); return std::launder(std::bit_cast(addr)); diff --git a/modules/stormkit/Core/Containers/Tree.mpp b/modules/stormkit/Core/Containers/Tree.mpp index 8018a717..37a00f98 100644 --- a/modules/stormkit/Core/Containers/Tree.mpp +++ b/modules/stormkit/Core/Containers/Tree.mpp @@ -69,7 +69,7 @@ export namespace stormkit::core { auto getFreeNode() -> TreeNodeIndexType; - auto insert(TreeNodeType && node, + auto insert(TreeNodeType&& node, TreeNodeIndexType parent_index, TreeNodeIndexType previous_sibling) -> TreeNodeIndexType; auto remove(TreeNodeIndexType index) -> void; @@ -244,7 +244,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - auto Tree::insert(TreeNodeType && node, + auto Tree::insert(TreeNodeType&& node, TreeNodeIndexType parent_index, TreeNodeIndexType previous_sibling) -> TreeNodeIndexType { const auto index = getFreeNode(); diff --git a/modules/stormkit/Core/Containers/Utils.mpp b/modules/stormkit/Core/Containers/Utils.mpp index 8bea3fba..fa878a24 100644 --- a/modules/stormkit/Core/Containers/Utils.mpp +++ b/modules/stormkit/Core/Containers/Utils.mpp @@ -13,26 +13,26 @@ import :Utils.Byte; export namespace stormkit::core { template - constexpr auto merge(T& output, const U&...ranges) noexcept -> void; + constexpr auto merge(T& output, const U&... ranges) noexcept -> void; template - constexpr auto concat(const T& first, const U&...others) noexcept -> std::vector>; + constexpr auto concat(const T& first, const U&... others) noexcept -> std::vector>; template - constexpr auto moveAndMerge(T& output, U&&...ranges) noexcept -> void; + constexpr auto moveAndMerge(T& output, U&&... ranges) noexcept -> void; template - constexpr auto moveAndConcat(T&& first, U&&...others) noexcept -> std::vector>; + constexpr auto moveAndConcat(T&& first, U&&... others) noexcept -> std::vector>; template requires((core::Is and ...) or (std::convertible_to and ...) or (std::constructible_from and ...)) - constexpr auto makeStaticArray(T&& first, Args&&...args) noexcept -> decltype(auto); + constexpr auto makeStaticArray(T&& first, Args&&... args) noexcept -> decltype(auto); template requires((core::Is and ...) or (std::convertible_to and ...) or (std::constructible_from and ...)) - constexpr auto makeArray(T&& first, Args&&...args) noexcept -> decltype(auto); + constexpr auto makeArray(T&& first, Args&&... args) noexcept -> decltype(auto); template constexpr auto viewAsBytes(T& data) -> decltype(auto); @@ -82,7 +82,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - constexpr auto merge(T& output, const U&...ranges) noexcept -> void { + constexpr auto merge(T& output, const U&... ranges) noexcept -> void { output.reserve(std::size(output) + (std::ranges::size(ranges) + ...)); (std::ranges::copy(ranges, std::back_inserter(output)), ...); } @@ -90,7 +90,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - constexpr auto concat(const T& first, const U&...others) noexcept -> std::vector> { + constexpr auto concat(const T& first, const U&... others) noexcept + -> std::vector> { auto output = std::vector> {}; merge(output, first, others...); @@ -100,7 +101,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - constexpr auto moveAndMerge(T& output, U&&...ranges) noexcept -> void { + constexpr auto moveAndMerge(T& output, U&&... ranges) noexcept -> void { output.reserve(std::size(output) + (std::ranges::size(ranges) + ...)); (std::ranges::move(std::forward(ranges), std::back_inserter(output)), ...); } @@ -108,7 +109,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - constexpr auto moveAndConcat(T&& first, U&&...others) noexcept -> std::vector> { + constexpr auto moveAndConcat(T&& first, U&&... others) noexcept -> std::vector> { auto output = std::vector> {}; moveAndMerge(output, std::forward(first), std::forward(others)...); @@ -120,7 +121,7 @@ namespace stormkit::core { template requires((core::Is and ...) or (std::convertible_to and ...) or (std::constructible_from and ...)) - constexpr auto makeStaticArray(T&& first, Args&&...args) noexcept -> decltype(auto) { + constexpr auto makeStaticArray(T&& first, Args&&... args) noexcept -> decltype(auto) { return std::array { std::forward(first), static_cast(std::forward(args))... }; } @@ -129,7 +130,7 @@ namespace stormkit::core { template requires((core::Is and ...) or (std::convertible_to and ...) or (std::constructible_from and ...)) - constexpr auto makeArray(T&& first, Args&&...args) noexcept -> decltype(auto) { + constexpr auto makeArray(T&& first, Args&&... args) noexcept -> decltype(auto) { return std::vector { std::forward(first), static_cast(std::forward(args))... }; } @@ -138,7 +139,7 @@ namespace stormkit::core { template constexpr auto viewAsBytes(T& data) -> decltype(auto) { using Byte = core::LikeCVType; - return std::span { std::bit_cast(std::ranges::data(data)), + return std::span { std::bit_cast(std::ranges::data(data)), std::ranges::size(data) * sizeof(T) }; } @@ -146,7 +147,7 @@ namespace stormkit::core { ///////////////////////////////////// template constexpr auto viewAs(std::span> data) -> decltype(auto) { - return std::span { std::bit_cast(std::ranges::data(data)), + return std::span { std::bit_cast(std::ranges::data(data)), std::ranges::size(data) / sizeof(T) }; } } // namespace stormkit::core diff --git a/modules/stormkit/Core/Coroutines.mpp b/modules/stormkit/Core/Coroutines.mpp index 67693244..afd220ef 100644 --- a/modules/stormkit/Core/Coroutines.mpp +++ b/modules/stormkit/Core/Coroutines.mpp @@ -29,8 +29,8 @@ namespace std { ~__manual_lifetime() {} template - _T& construct(_Args&&...__args) noexcept(std::is_nothrow_constructible_v<_T, _Args...>) { - return *::new (static_cast(std::addressof(__value_))) _T((_Args&&)__args...); + _T& construct(_Args&&... __args) noexcept(std::is_nothrow_constructible_v<_T, _Args...>) { + return *::new (static_cast(std::addressof(__value_))) _T((_Args&&)__args...); } void destruct() noexcept(std::is_nothrow_destructible_v<_T>) { __value_.~_T(); } @@ -66,7 +66,7 @@ namespace std { _T& get() const noexcept { return *__value_; } private: - _T *__value_; + _T* __value_; }; template @@ -86,7 +86,7 @@ namespace std { _T&& get() const noexcept { return static_cast<_T&&>(*__value_); } private: - _T *__value_; + _T* __value_; }; namespace ranges { @@ -111,7 +111,7 @@ namespace std { private: [[no_unique_address]] _Allocator __alloc; // \expos - _Rng && __range; // \expos + _Rng&& __range; // \expos }; template @@ -141,28 +141,28 @@ namespace std { return __offset_of_allocator(__frameSize) + sizeof(_Alloc); } - static _Alloc& __get_allocator(void *__frame, std::size_t __frameSize) noexcept { - return *reinterpret_cast<_Alloc *>(static_cast(__frame) + - __offset_of_allocator(__frameSize)); + static _Alloc& __get_allocator(void* __frame, std::size_t __frameSize) noexcept { + return *reinterpret_cast<_Alloc*>(static_cast(__frame) + + __offset_of_allocator(__frameSize)); } public: template - static void * + static void* operator new(std::size_t __frameSize, std::allocator_arg_t, _Alloc __alloc, _Args&...) { - void *__frame = __alloc.allocate(__padded_frame_size(__frameSize)); + void* __frame = __alloc.allocate(__padded_frame_size(__frameSize)); // Store allocator at end of the coroutine frame. // Assuming the allocator's move constructor is non-throwing (a requirement for // allocators) - ::new (static_cast(std::addressof(__get_allocator(__frame, __frameSize)))) + ::new (static_cast(std::addressof(__get_allocator(__frame, __frameSize)))) _Alloc(std::move(__alloc)); return __frame; } template - static void *operator new(std::size_t __frameSize, + static void* operator new(std::size_t __frameSize, _This&, std::allocator_arg_t, _Alloc __alloc, @@ -172,11 +172,11 @@ namespace std { std::move(__alloc)); } - static void operator delete(void *__ptr, std::size_t __frameSize) noexcept { + static void operator delete(void* __ptr, std::size_t __frameSize) noexcept { _Alloc& __alloc = __get_allocator(__ptr, __frameSize); _Alloc __localAlloc(std::move(__alloc)); __alloc.~Alloc(); - __localAlloc.deallocate(static_cast(__ptr), + __localAlloc.deallocate(static_cast(__ptr), __padded_frame_size(__frameSize)); } }; @@ -185,14 +185,14 @@ namespace std { requires(!__allocator_needs_to_be_stored<_Alloc>) class __promise_base_alloc<_Alloc> { public: - static void *operator new(std::size_t __size) { + static void* operator new(std::size_t __size) { _Alloc __alloc; return __alloc.allocate(__size); } - static void operator delete(void *__ptr, std::size_t __size) noexcept { + static void operator delete(void* __ptr, std::size_t __size) noexcept { _Alloc __alloc; - __alloc.deallocate(static_cast(__ptr), __size); + __alloc.deallocate(static_cast(__ptr), __size); } }; @@ -201,7 +201,7 @@ namespace std { template friend class generator; - __generator_promise_base *__root_; + __generator_promise_base* __root_; std::coroutine_handle<> __parentOrLeaf_; // Note: Using manual_lifetime here to avoid extra calls to exception_ptr // constructor/destructor in cases where it is not needed (i.e. where this @@ -241,7 +241,7 @@ namespace std { template std::coroutine_handle<> await_suspend(std::coroutine_handle<_Promise> __h) noexcept { - _Promise & __promise = __h.promise(); + _Promise& __promise = __h.promise(); __generator_promise_base& __root = *__promise.__root_; if (&__root != &__promise) { auto __parent = __promise.__parentOrLeaf_; @@ -510,7 +510,7 @@ namespace std { public: // to get around access restrictions for __yield_sequence_awaitable std::coroutine_handle<> __get_coro() noexcept { return __coro_; } - promise_type *__get_promise() noexcept { return std::addressof(__coro_.promise()); } + promise_type* __get_promise() noexcept { return std::addressof(__coro_.promise()); } private: __coroutine_handle __coro_; @@ -592,10 +592,10 @@ namespace std { private: friend generator; - explicit iterator(__promise_base *__promise, std::coroutine_handle<> __coro) noexcept + explicit iterator(__promise_base* __promise, std::coroutine_handle<> __coro) noexcept : __promise_(__promise), __coro_(__coro) {} - __promise_base *__promise_; + __promise_base* __promise_; std::coroutine_handle<> __coro_; }; @@ -620,10 +620,10 @@ namespace std { public: // to get around access restrictions for __yield_sequence_awaitable std::coroutine_handle<> __get_coro() noexcept { return __coro_; } - __promise_base *__get_promise() noexcept { return __promise_; } + __promise_base* __get_promise() noexcept { return __promise_; } private: - __promise_base *__promise_; + __promise_base* __promise_; std::coroutine_handle<> __coro_; bool __started_ = false; }; diff --git a/modules/stormkit/Core/Hash/Base.mpp b/modules/stormkit/Core/Hash/Base.mpp index 04140748..35a89f24 100644 --- a/modules/stormkit/Core/Hash/Base.mpp +++ b/modules/stormkit/Core/Hash/Base.mpp @@ -23,7 +23,7 @@ export namespace stormkit::core { constexpr auto hashCombine(HashValue auto& hash, std::ranges::range auto&& range) noexcept; template - constexpr auto hashCombine(HashValue auto& hash, Args&&...args) noexcept; + constexpr auto hashCombine(HashValue auto& hash, Args&&... args) noexcept; } // namespace stormkit::core //////////////////////////////////////////////////////////////////// @@ -51,7 +51,7 @@ namespace stormkit::core { } template - constexpr auto hashCombine(HashValue auto& hash, Args&&...args) noexcept { + constexpr auto hashCombine(HashValue auto& hash, Args&&... args) noexcept { (hashCombine(hash, std::forward(args)), ...); } } // namespace stormkit::core diff --git a/modules/stormkit/Core/Meta/NamedType.mpp b/modules/stormkit/Core/Meta/NamedType.mpp index 173de109..e287ba98 100644 --- a/modules/stormkit/Core/Meta/NamedType.mpp +++ b/modules/stormkit/Core/Meta/NamedType.mpp @@ -32,7 +32,7 @@ export { constexpr ~NamedType() noexcept(std::is_nothrow_destructible_v); template - constexpr explicit(sizeof...(Args) == 1) NamedType(Args&&...args) noexcept( + constexpr explicit(sizeof...(Args) == 1) NamedType(Args&&... args) noexcept( std::is_nothrow_constructible_v) : m_value { std::forward(args)... } {} @@ -61,7 +61,7 @@ export { concept IsNamedType = std::derived_from; template - constexpr auto makeNamed(Args&&...args) noexcept -> T; + constexpr auto makeNamed(Args&&... args) noexcept -> T; struct PreIncrementable { constexpr auto operator++(this auto&& self) -> decltype(auto); @@ -166,7 +166,7 @@ export { struct Callable { template - constexpr auto operator()(this auto&& self, Args&&...args) -> decltype(auto); + constexpr auto operator()(this auto&& self, Args&&... args) -> decltype(auto); }; struct MethodCallable { @@ -261,7 +261,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - constexpr auto makeNamed(Args&&...args) noexcept -> decltype(auto) { + constexpr auto makeNamed(Args&&... args) noexcept -> decltype(auto) { return T { std::forward(args)... }; } @@ -479,7 +479,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - constexpr auto Callable::operator()(this auto&& self, Args&&...args) -> decltype(auto) { + constexpr auto Callable::operator()(this auto&& self, Args&&... args) -> decltype(auto) { return std::forward(self).get()(std::forward(args)...); } diff --git a/modules/stormkit/Core/String/CStrings.mpp b/modules/stormkit/Core/String/CStrings.mpp index bc42493c..1863bcd1 100644 --- a/modules/stormkit/Core/String/CStrings.mpp +++ b/modules/stormkit/Core/String/CStrings.mpp @@ -5,8 +5,8 @@ export module stormkit.Core:String.CString; export namespace stormkit::core { - using CZString = const char *; - using ZString = char *; - using CWZString = const wchar_t *; - using WZString = wchar_t *; + using CZString = const char*; + using ZString = char*; + using CWZString = const wchar_t*; + using WZString = wchar_t*; } // namespace stormkit::core \ No newline at end of file diff --git a/modules/stormkit/Core/String/Encodings.mpp b/modules/stormkit/Core/String/Encodings.mpp index 71fcb2bc..2d55da3b 100644 --- a/modules/stormkit/Core/String/Encodings.mpp +++ b/modules/stormkit/Core/String/Encodings.mpp @@ -49,13 +49,13 @@ namespace stormkit::core { auto len = 0ull; auto input_it = std::data(input); - while ((len = std::mbrtoc16(std::bit_cast(std::data(output)), + while ((len = std::mbrtoc16(std::bit_cast(std::data(output)), input_it, MB_CUR_MAX, &state)) > 0ull) input_it += len; #else - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #endif return output; @@ -70,9 +70,9 @@ namespace stormkit::core { output.resize(std::size(input)); for (const auto& c : input) - std::c16rtomb(std::bit_cast(std::data(output)), c, &state); + std::c16rtomb(std::bit_cast(std::data(output)), c, &state); #else - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #endif return output; @@ -89,15 +89,15 @@ namespace stormkit::core { [[maybe_unused]] auto input_it = std::data(input); [[maybe_unused]] auto i = 0; #if defined(STORMKIT_COMPILER_MSVC) - while ((len = std::mbrtoc16(std::bit_cast(std::data(output)) + i++, + while ((len = std::mbrtoc16(std::bit_cast(std::data(output)) + i++, input_it, MB_CUR_MAX, &state)) > 0u) input_it += len; #elif defined(STORMKIT_COMPILER_CLANG) - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #else - while ((len = std::mbrtoc8(std::bit_cast(std::data(output)) + i++, + while ((len = std::mbrtoc8(std::bit_cast(std::data(output)) + i++, input_it, MB_CUR_MAX, &state)) > 0ull) @@ -117,7 +117,7 @@ namespace stormkit::core { #if defined(STORMKIT_COMPILER_MSVC) for (const auto& c : input) std::c16rtomb(std::data(output), core::as(c), &state); #elif defined(STORMKIT_COMPILER_CLANG) - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #else for (const auto& c : input) std::c8rtomb(std::data(output), core::narrow(c), &state); #endif @@ -136,12 +136,12 @@ namespace stormkit::core { auto bytes = toByteSpan(output); std::ranges::copy(asByteView(input), std::ranges::begin(bytes)); #elif defined(STORMKIT_COMPILER_CLANG) - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #else auto len = 0ull; auto input_it = std::data(input); auto i = 0; - while ((len = std::mbrtoc8(std::bit_cast(std::data(output)) + i++, + while ((len = std::mbrtoc8(std::bit_cast(std::data(output)) + i++, input_it, MB_CUR_MAX, &state)) > 0ull) @@ -164,7 +164,7 @@ namespace stormkit::core { auto bytes = toByteSpan(output); std::ranges::copy(asByteView(input), std::ranges::begin(bytes)); #elif defined(STORMKIT_COMPILER_CLANG) - output = std::bit_cast(std::data(input)); + output = std::bit_cast(std::data(input)); #else for (const auto& c : input) std::c8rtomb(std::data(output), c, &state); #endif diff --git a/modules/stormkit/Core/String/Format.mpp b/modules/stormkit/Core/String/Format.mpp index e857f220..52471c5f 100644 --- a/modules/stormkit/Core/String/Format.mpp +++ b/modules/stormkit/Core/String/Format.mpp @@ -66,7 +66,7 @@ namespace std { template template auto formatter::format(const stormkit::core::Secondf& data, - FormatContext & ctx) const + FormatContext& ctx) const -> decltype(ctx.out()) { return formatter::format(data.count(), ctx); } diff --git a/modules/stormkit/Core/String/Operations.mpp b/modules/stormkit/Core/String/Operations.mpp index ac4a6ebb..9c57d48c 100644 --- a/modules/stormkit/Core/String/Operations.mpp +++ b/modules/stormkit/Core/String/Operations.mpp @@ -18,7 +18,7 @@ export namespace stormkit::core { [[nodiscard]] auto toString(auto&& value) noexcept -> std::string; - [[nodiscard]] auto toCZString(std::string_view value) noexcept -> const char *; + [[nodiscard]] auto toCZString(std::string_view value) noexcept -> const char*; template struct ConstexprString { @@ -92,7 +92,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - inline auto toCZString(std::string_view value) noexcept -> const char * { + inline auto toCZString(std::string_view value) noexcept -> const char* { return std::data(value); } } // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/AsCast.mpp b/modules/stormkit/Core/Utils/AsCast.mpp index 87339c5d..794a1665 100644 --- a/modules/stormkit/Core/Utils/AsCast.mpp +++ b/modules/stormkit/Core/Utils/AsCast.mpp @@ -145,9 +145,9 @@ namespace stormkit::core { requires(IsPolymorphic> and Is>) STORMKIT_FORCE_INLINE constexpr auto is(From&& value) noexcept -> bool { if constexpr (IsLValueReference and not IsPointer>) - return dynamic_cast(&std::forward(value)) != nullptr; + return dynamic_cast(&std::forward(value)) != nullptr; else - return dynamic_cast(std::to_address(std::forward(value))) != nullptr; + return dynamic_cast(std::to_address(std::forward(value))) != nullptr; } ///////////////////////////////////// diff --git a/modules/stormkit/Core/Utils/Byte.mpp b/modules/stormkit/Core/Utils/Byte.mpp index ceecb23d..1cda4d22 100644 --- a/modules/stormkit/Core/Utils/Byte.mpp +++ b/modules/stormkit/Core/Utils/Byte.mpp @@ -78,7 +78,7 @@ namespace stormkit::core { return sizeof(ValueType); }(); - return std::span { std::bit_cast(ptr), size * byte_count }; + return std::span { std::bit_cast(ptr), size * byte_count }; } ///////////////////////////////////// diff --git a/modules/stormkit/Core/Utils/DeferInit.mpp b/modules/stormkit/Core/Utils/DeferInit.mpp index 0bc27075..7da683c9 100644 --- a/modules/stormkit/Core/Utils/DeferInit.mpp +++ b/modules/stormkit/Core/Utils/DeferInit.mpp @@ -24,12 +24,11 @@ export namespace stormkit::core { -> DeferInit&; template - auto - construct(Args&&...args) noexcept(noexcept(std::is_nothrow_constructible_v)) - -> void; + auto construct(Args&&... args) noexcept( + noexcept(std::is_nothrow_constructible_v)) -> void; template - auto constructWithNarrowing(Args&&...args) noexcept( + auto constructWithNarrowing(Args&&... args) noexcept( noexcept(std::is_nothrow_constructible_v)) -> void; auto operator=(T&& value) noexcept(noexcept(std::is_nothrow_move_constructible_v)) @@ -39,7 +38,7 @@ export namespace stormkit::core { [[nodiscard]] constexpr auto operator->(this auto&& self) noexcept -> decltype(auto); [[nodiscard]] constexpr auto operator*(this auto&& self) noexcept -> decltype(auto); - [[nodiscard]] constexpr operator T &() noexcept; + [[nodiscard]] constexpr operator T&() noexcept; [[nodiscard]] constexpr operator const T &() const noexcept; [[nodiscard]] auto initialized() const noexcept -> bool; @@ -105,7 +104,7 @@ namespace stormkit::core { //////////////////////////////////////// template template - auto DeferInit::construct(Args&&...args) noexcept( + auto DeferInit::construct(Args&&... args) noexcept( noexcept(std::is_nothrow_constructible_v)) -> void { reset(); @@ -118,7 +117,7 @@ namespace stormkit::core { //////////////////////////////////////// template template - auto DeferInit::constructWithNarrowing(Args&&...args) noexcept( + auto DeferInit::constructWithNarrowing(Args&&... args) noexcept( noexcept(std::is_nothrow_constructible_v)) -> void { reset(); @@ -164,7 +163,7 @@ namespace stormkit::core { using U = LikeCVType; - return *std::launder(std::bit_cast(std::data(self.m_data))); + return *std::launder(std::bit_cast(std::data(self.m_data))); } ///////////////////////////////////// @@ -175,7 +174,7 @@ namespace stormkit::core { using U = LikeCVType; - return std::launder(std::bit_cast(std::data(self.m_data))); + return std::launder(std::bit_cast(std::data(self.m_data))); } ///////////////////////////////////// @@ -188,7 +187,7 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - constexpr DeferInit::operator T &() noexcept { + constexpr DeferInit::operator T&() noexcept { return get(); } diff --git a/modules/stormkit/Core/Utils/Descriptors.mpp b/modules/stormkit/Core/Utils/Descriptors.mpp index 988d2227..fc6bd7c5 100644 --- a/modules/stormkit/Core/Utils/Descriptors.mpp +++ b/modules/stormkit/Core/Utils/Descriptors.mpp @@ -13,20 +13,20 @@ export module stormkit.Core:Utils.Descriptors; import std; export namespace stormkit::core { - [[nodiscard]] auto getSTDErr() noexcept -> std::FILE *; - [[nodiscard]] auto getSTDOut() noexcept -> std::FILE *; + [[nodiscard]] auto getSTDErr() noexcept -> std::FILE*; + [[nodiscard]] auto getSTDOut() noexcept -> std::FILE*; } // namespace stormkit::core namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto getSTDErr() noexcept -> std::FILE * { - return std::bit_cast(stderr); + STORMKIT_FORCE_INLINE auto getSTDErr() noexcept -> std::FILE* { + return std::bit_cast(stderr); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto getSTDOut() noexcept -> std::FILE * { - return std::bit_cast(stdout); + STORMKIT_FORCE_INLINE auto getSTDOut() noexcept -> std::FILE* { + return std::bit_cast(stdout); } } // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/DynamicLoader.mpp b/modules/stormkit/Core/Utils/DynamicLoader.mpp index 44e9c760..717a7f37 100644 --- a/modules/stormkit/Core/Utils/DynamicLoader.mpp +++ b/modules/stormkit/Core/Utils/DynamicLoader.mpp @@ -42,7 +42,7 @@ export namespace stormkit::core { -> Expected>; template - [[nodiscard]] auto cFunc(std::string_view name) const noexcept -> Expected; + [[nodiscard]] auto cFunc(std::string_view name) const noexcept -> Expected; [[nodiscard]] auto filepath() const noexcept -> const std::filesystem::path&; @@ -52,7 +52,7 @@ export namespace stormkit::core { DynamicLoader() noexcept; auto doLoad(std::filesystem::path filepath) -> Expected; - auto doGetFunc(std::string_view name) const -> Expected; + auto doGetFunc(std::string_view name) const -> Expected; std::filesystem::path m_filepath; @@ -95,11 +95,11 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - auto DynamicLoader::cFunc(std::string_view name) const noexcept -> Expected { + auto DynamicLoader::cFunc(std::string_view name) const noexcept -> Expected { expects(not std::empty(name)); return doGetFunc(name).transform( - [](auto&& value) { return std::bit_cast(value); }); + [](auto&& value) { return std::bit_cast(value); }); } ///////////////////////////////////// diff --git a/modules/stormkit/Core/Utils/ErrorHandling.mpp b/modules/stormkit/Core/Utils/ErrorHandling.mpp index 937dece8..8f2350c8 100644 --- a/modules/stormkit/Core/Utils/ErrorHandling.mpp +++ b/modules/stormkit/Core/Utils/ErrorHandling.mpp @@ -18,7 +18,7 @@ import :Utils.Descriptors; export namespace stormkit::core { template [[nodiscard]] constexpr auto - expectsWithMessage(std::string && message, + expectsWithMessage(std::string&& message, std::source_location location = std::source_location::current()) noexcept -> decltype(auto); // optional overload @@ -28,7 +28,7 @@ export namespace stormkit::core { -> decltype(auto); // optional overload [[nodiscard]] constexpr auto - expectsWithMessage(std::string && message, + expectsWithMessage(std::string&& message, std::source_location location = std::source_location::current()) noexcept -> decltype(auto); diff --git a/modules/stormkit/Core/Utils/Expected.mpp b/modules/stormkit/Core/Utils/Expected.mpp index 214e4a57..4f812f2a 100644 --- a/modules/stormkit/Core/Utils/Expected.mpp +++ b/modules/stormkit/Core/Utils/Expected.mpp @@ -21,7 +21,7 @@ export namespace stormkit::core { template [[nodiscard]] constexpr auto - either(T && optional, + either(T&& optional, std::invocable::value_type> auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto); @@ -30,10 +30,10 @@ export namespace stormkit::core { export namespace stormkit::core::monadic { struct Anything { template - operator T &(this auto& self) noexcept; + operator T&(this auto& self) noexcept; template - operator T &&(this auto&& self) noexcept; + operator T&&(this auto&& self) noexcept; }; template @@ -51,12 +51,12 @@ export namespace stormkit::core::monadic { [[nodiscard]] constexpr auto map(auto&& first, auto&& second) noexcept -> decltype(auto); - [[nodiscard]] constexpr auto either(std::regular_invocable auto&&...visitors) noexcept - -> decltype(auto); + [[nodiscard]] constexpr auto + either(std::regular_invocable auto&&... visitors) noexcept -> decltype(auto); template [[nodiscard]] constexpr auto either(IsUnaryPredicate auto&& predicate, - std::invocable auto && true_, + std::invocable auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto); [[nodiscard]] constexpr auto clone() noexcept -> decltype(auto); @@ -65,7 +65,7 @@ export namespace stormkit::core::monadic { [[nodiscard]] constexpr auto init() noexcept -> decltype(auto); template - [[nodiscard]] constexpr auto init(Args&&...args) noexcept -> decltype(auto); + [[nodiscard]] constexpr auto init(Args&&... args) noexcept -> decltype(auto); } // namespace stormkit::core::monadic //////////////////////////////////////////////////////////////////// @@ -86,7 +86,7 @@ namespace stormkit::core { ///////////////////////////////////// template STORMKIT_FORCE_INLINE constexpr auto - either(T && optional, + either(T&& optional, std::invocable::value_type> auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto) { if (optional != std::nullopt) return true_(*std::forward(optional)); @@ -158,7 +158,7 @@ namespace stormkit::core::monadic { -> decltype(auto) { return [first = std::forward(first), second = std::forward(second)]( - auto&&...args) noexcept -> decltype(auto) { + auto&&... args) noexcept -> decltype(auto) { return second(first(std::forward(args)...)); }; } @@ -167,8 +167,8 @@ namespace stormkit::core::monadic { ///////////////////////////////////// template STORMKIT_FORCE_INLINE constexpr auto either(IsUnaryPredicate auto&& predicate, - std::invocable auto && true_, - std::invocable auto && false_) noexcept + std::invocable auto&& true_, + std::invocable auto&& false_) noexcept -> decltype(auto) { [predicate = std::move(predicate), true_ = std::move(true_), false_ = std::move(false_)]( auto&& elem) noexcept -> decltype(auto) { @@ -180,7 +180,7 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE constexpr auto - either(std::regular_invocable auto&&...visitors) noexcept -> decltype(auto) { + either(std::regular_invocable auto&&... visitors) noexcept -> decltype(auto) { return [... visitors = std::forward(visitors)](auto&& variant) mutable noexcept { return std::visit(core::Overloaded { std::forward(visitors)... }, @@ -201,7 +201,7 @@ namespace stormkit::core::monadic { ///////////////////////////////////// template STORMKIT_FORCE_INLINE constexpr auto init() noexcept -> decltype(auto) { - return [](Args&&...args) noexcept( + return [](Args&&... args) noexcept( noexcept(std::is_nothrow_constructible_v)) -> decltype(auto) { return T { std::forward(args)... }; }; @@ -210,7 +210,7 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE constexpr auto init(Args&&...args) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto init(Args&&... args) noexcept -> decltype(auto) { return [... args = std::forward(args)]() mutable noexcept( noexcept(std::is_nothrow_constructible_v)) -> decltype(auto) { return T { std::forward(args)... }; diff --git a/modules/stormkit/Core/Utils/Filesystem.mpp b/modules/stormkit/Core/Utils/Filesystem.mpp index 3197af49..fb651115 100644 --- a/modules/stormkit/Core/Utils/Filesystem.mpp +++ b/modules/stormkit/Core/Utils/Filesystem.mpp @@ -56,13 +56,13 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// inline auto read(std::istream& stream, std::span output) noexcept -> void { - stream.read(std::bit_cast(std::data(output)), std::size(output)); + stream.read(std::bit_cast(std::data(output)), std::size(output)); } //////////////////////////////////////// //////////////////////////////////////// inline auto write(std::ostream& stream, std::span data) noexcept -> void { - stream.write(std::bit_cast(std::data(data)), std::size(data)); + stream.write(std::bit_cast(std::data(data)), std::size(data)); } //////////////////////////////////////// diff --git a/modules/stormkit/Core/Utils/Functional.mpp b/modules/stormkit/Core/Utils/Functional.mpp index 46bcf43b..269a1893 100644 --- a/modules/stormkit/Core/Utils/Functional.mpp +++ b/modules/stormkit/Core/Utils/Functional.mpp @@ -19,7 +19,7 @@ export namespace stormkit::core { template [[nodiscard]] constexpr auto - either(T && optional, + either(T&& optional, std::invocable::value_type> auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto); @@ -28,7 +28,7 @@ export namespace stormkit::core { template // requires(std::invocable) - [[nodiscard]] constexpr auto toUnary(Func&& func, Args&&...args) noexcept -> decltype(auto); + [[nodiscard]] constexpr auto toUnary(Func&& func, Args&&... args) noexcept -> decltype(auto); } // namespace stormkit::core //////////////////////////////////////////////////////////////////// @@ -49,7 +49,7 @@ namespace stormkit::core { ///////////////////////////////////// template STORMKIT_FORCE_INLINE constexpr auto - either(T && optional, + either(T&& optional, std::invocable::value_type> auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto) { if (optional != std::nullopt) return true_(*std::forward(optional)); @@ -67,7 +67,7 @@ namespace stormkit::core { ///////////////////////////////////// template // requires(std::invocable) - STORMKIT_FORCE_INLINE constexpr auto toUnary(Func&& func, Args&&...args) noexcept + STORMKIT_FORCE_INLINE constexpr auto toUnary(Func&& func, Args&&... args) noexcept -> decltype(auto) { return [_func = std::forward(func), ... _args = std::forward(args)]( auto&& first) noexcept(noexcept(func(first, std::forward(args)...))) { diff --git a/modules/stormkit/Core/Utils/Monadic.mpp b/modules/stormkit/Core/Utils/Monadic.mpp index 5b1398fa..fff20192 100644 --- a/modules/stormkit/Core/Utils/Monadic.mpp +++ b/modules/stormkit/Core/Utils/Monadic.mpp @@ -18,10 +18,10 @@ import :Utils.Functional; export namespace stormkit::core::monadic { struct Anything { template - operator T &(this auto& self) noexcept; + operator T&(this auto& self) noexcept; template - operator T &&(this auto&& self) noexcept; + operator T&&(this auto&& self) noexcept; }; template @@ -39,12 +39,12 @@ export namespace stormkit::core::monadic { [[nodiscard]] constexpr auto map(auto&& first, auto&& second) noexcept -> decltype(auto); - [[nodiscard]] constexpr auto either(std::regular_invocable auto&&...visitors) noexcept - -> decltype(auto); + [[nodiscard]] constexpr auto + either(std::regular_invocable auto&&... visitors) noexcept -> decltype(auto); template [[nodiscard]] constexpr auto either(IsUnaryPredicate auto&& predicate, - std::invocable auto && true_, + std::invocable auto&& true_, std::invocable auto&& false_) noexcept -> decltype(auto); [[nodiscard]] constexpr auto isEqual() noexcept -> decltype(auto); @@ -55,7 +55,7 @@ export namespace stormkit::core::monadic { [[nodiscard]] constexpr auto init() noexcept -> decltype(auto); template - [[nodiscard]] constexpr auto init(Args&&...args) noexcept -> decltype(auto); + [[nodiscard]] constexpr auto init(Args&&... args) noexcept -> decltype(auto); } // namespace stormkit::core::monadic //////////////////////////////////////////////////////////////////// @@ -125,7 +125,7 @@ namespace stormkit::core::monadic { -> decltype(auto) { return [first = std::forward(first), second = std::forward(second)]( - auto&&...args) noexcept -> decltype(auto) { + auto&&... args) noexcept -> decltype(auto) { return second(first(std::forward(args)...)); }; } @@ -134,8 +134,8 @@ namespace stormkit::core::monadic { ///////////////////////////////////// template STORMKIT_FORCE_INLINE constexpr auto either(IsUnaryPredicate auto&& predicate, - std::invocable auto && true_, - std::invocable auto && false_) noexcept + std::invocable auto&& true_, + std::invocable auto&& false_) noexcept -> decltype(auto) { [predicate = std::move(predicate), true_ = std::move(true_), false_ = std::move(false_)]( auto&& elem) noexcept -> decltype(auto) { @@ -155,7 +155,7 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE constexpr auto - either(std::regular_invocable auto&&...visitors) noexcept -> decltype(auto) { + either(std::regular_invocable auto&&... visitors) noexcept -> decltype(auto) { return [... visitors = std::forward(visitors)](auto&& variant) mutable noexcept { return std::visit(core::Overloaded { std::forward(visitors)... }, @@ -176,7 +176,7 @@ namespace stormkit::core::monadic { ///////////////////////////////////// template STORMKIT_FORCE_INLINE constexpr auto init() noexcept -> decltype(auto) { - return [](Args&&...args) noexcept( + return [](Args&&... args) noexcept( noexcept(std::is_nothrow_constructible_v)) -> decltype(auto) { return T { std::forward(args)... }; }; @@ -185,7 +185,7 @@ namespace stormkit::core::monadic { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE constexpr auto init(Args&&...args) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto init(Args&&... args) noexcept -> decltype(auto) { return [... args = std::forward(args)]() mutable noexcept( noexcept(std::is_nothrow_constructible_v)) -> decltype(auto) { return T { std::forward(args)... }; diff --git a/modules/stormkit/Core/Utils/NakedRef.mpp b/modules/stormkit/Core/Utils/NakedRef.mpp index 3c1ff50d..565b4dbf 100644 --- a/modules/stormkit/Core/Utils/NakedRef.mpp +++ b/modules/stormkit/Core/Utils/NakedRef.mpp @@ -17,7 +17,7 @@ export namespace stormkit::core { using UnderlyingType = T; using underlying_type = UnderlyingType; - using PointerType = UnderlyingType *; + using PointerType = UnderlyingType*; using pointer_type = PointerType; using ReferenceType = UnderlyingType&; @@ -37,7 +37,7 @@ export namespace stormkit::core { [[nodiscard]] constexpr auto operator->(this auto&& self) noexcept -> decltype(auto); [[nodiscard]] constexpr auto operator*(this auto&& self) noexcept -> decltype(auto); - [[nodiscard]] constexpr operator T &(this auto&& self) noexcept; + [[nodiscard]] constexpr operator T&(this auto&& self) noexcept; private: PointerType m_value; @@ -54,11 +54,11 @@ export namespace stormkit::core { template requires((IsLValueReference or IsPointer) && ...) - constexpr auto makeNakedRefArray(Args&&...args); + constexpr auto makeNakedRefArray(Args&&... args); template requires((IsLValueReference or IsPointer) && ...) - constexpr auto makeNakedRefVector(Args&&...args); + constexpr auto makeNakedRefVector(Args&&... args); } // namespace stormkit::core //////////////////////////////////////////////////////////////////// @@ -128,7 +128,7 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - constexpr NakedRef::operator T &(this auto&& self) noexcept { + constexpr NakedRef::operator T&(this auto&& self) noexcept { return std::forward(self).get(); } @@ -150,7 +150,7 @@ namespace stormkit::core { ///////////////////////////////////// template requires((IsLValueReference or IsPointer) && ...) - constexpr auto makeNakedRefArray(Args&&...args) { + constexpr auto makeNakedRefArray(Args&&... args) { return std::array { (makeNakedRef(std::forward(args)), ...) }; } @@ -158,7 +158,7 @@ namespace stormkit::core { ///////////////////////////////////// template requires((IsLValueReference or IsPointer) && ...) - constexpr auto makeNakedRefVector(Args&&...args) { + constexpr auto makeNakedRefVector(Args&&... args) { return std::vector { (makeNakedRef(std::forward(args)), ...) }; } } // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/Numerics.mpp b/modules/stormkit/Core/Utils/Numerics.mpp index dcfc40a7..af55818a 100644 --- a/modules/stormkit/Core/Utils/Numerics.mpp +++ b/modules/stormkit/Core/Utils/Numerics.mpp @@ -89,10 +89,10 @@ export namespace stormkit::core { [[nodiscard]] constexpr auto range(IsNumericsRangePure auto&& range) noexcept; template - [[nodiscard]] constexpr auto multiRange(const Args&...args) noexcept; + [[nodiscard]] constexpr auto multiRange(const Args&... args) noexcept; template - [[nodiscard]] constexpr auto multiRange(Args&&...args) noexcept; + [[nodiscard]] constexpr auto multiRange(Args&&... args) noexcept; } // namespace stormkit::core //////////////////////////////////////////////////////////////////// @@ -293,14 +293,14 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE constexpr auto multiRange(const Args&...args) noexcept { + STORMKIT_FORCE_INLINE constexpr auto multiRange(const Args&... args) noexcept { return rangeImplementation(NumericsRange { .begin = 0, .end = args }...); } ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE constexpr auto multiRange(Args&&...args) noexcept { + STORMKIT_FORCE_INLINE constexpr auto multiRange(Args&&... args) noexcept { return rangeImplementation(std::forward(args)...); } } // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/Pimpl.mpp b/modules/stormkit/Core/Utils/Pimpl.mpp index fa03711d..8e72cc4c 100644 --- a/modules/stormkit/Core/Utils/Pimpl.mpp +++ b/modules/stormkit/Core/Utils/Pimpl.mpp @@ -18,16 +18,16 @@ export namespace stormkit::core { ~Pimpl(); template First, class... Args> - explicit(sizeof...(Args) == 0) Pimpl(First&& first, Args&&...args); + explicit(sizeof...(Args) == 0) Pimpl(First&& first, Args&&... args); Pimpl(Pimpl&&) noexcept; auto operator=(Pimpl&&) noexcept -> Pimpl&; template - auto init(Args&&...args) -> void; + auto init(Args&&... args) -> void; - auto operator->() noexcept -> T *; - auto operator->() const noexcept -> const T *; + auto operator->() noexcept -> T*; + auto operator->() const noexcept -> const T*; auto operator*() noexcept -> T&; auto operator*() const noexcept -> const T&; @@ -63,7 +63,7 @@ namespace stormkit::core { ///////////////////////////////////// template template First, class... Args> - Pimpl::Pimpl(First&& first, Args&&...args) { + Pimpl::Pimpl(First&& first, Args&&... args) { init(std::forward(first), std::forward(args)...); } @@ -81,21 +81,21 @@ namespace stormkit::core { ///////////////////////////////////// template template - auto Pimpl::init(Args&&...args) -> void { + auto Pimpl::init(Args&&... args) -> void { m_data = std::make_unique(std::forward(args)...); } ///////////////////////////////////// ///////////////////////////////////// template - auto Pimpl::operator->() noexcept -> T * { + auto Pimpl::operator->() noexcept -> T* { return &get(); } ///////////////////////////////////// ///////////////////////////////////// template - auto Pimpl::operator->() const noexcept -> const T * { + auto Pimpl::operator->() const noexcept -> const T* { return &get(); } diff --git a/modules/stormkit/Core/Utils/Predicates.mpp b/modules/stormkit/Core/Utils/Predicates.mpp index 8bae2ee1..43ac8ca2 100644 --- a/modules/stormkit/Core/Utils/Predicates.mpp +++ b/modules/stormkit/Core/Utils/Predicates.mpp @@ -36,7 +36,7 @@ namespace stormkit::core::predicates { //////////////////////////////////////// //////////////////////////////////////// constexpr auto wrap(std::invocable auto&& func) noexcept { - return [func = std::forward(func)](auto&&...args) { + return [func = std::forward(func)](auto&&... args) { return func(std::forward(args)...); }; } diff --git a/modules/stormkit/Core/Utils/Singleton.mpp b/modules/stormkit/Core/Utils/Singleton.mpp index 22611d24..883d9e78 100644 --- a/modules/stormkit/Core/Utils/Singleton.mpp +++ b/modules/stormkit/Core/Utils/Singleton.mpp @@ -11,12 +11,12 @@ export namespace stormkit::core { class Singleton { public: template - static auto instance(Args&&...args) noexcept(std::is_nothrow_constructible_v) -> T&; + static auto instance(Args&&... args) noexcept(std::is_nothrow_constructible_v) -> T&; Singleton(Singleton&&) = delete; Singleton(const Singleton&) = delete; - auto operator=(Singleton&&) -> Singleton & = delete; + auto operator=(Singleton&&) -> Singleton& = delete; auto operator=(const Singleton&) -> Singleton& = delete; protected: @@ -39,8 +39,8 @@ namespace stormkit::core { ///////////////////////////////////// template template - auto Singleton::instance(Args&&...args) noexcept(std::is_nothrow_constructible_v) -> T& { - auto lambdas = [](Args&&...args) mutable { + auto Singleton::instance(Args&&... args) noexcept(std::is_nothrow_constructible_v) -> T& { + auto lambdas = [](Args&&... args) mutable { m_instance = std::make_unique(std::forward(args)...); }; diff --git a/modules/stormkit/Engine/Renderer/BakedFrameGraph.mpp b/modules/stormkit/Engine/Renderer/BakedFrameGraph.mpp index f03168c2..1f9d3d8f 100644 --- a/modules/stormkit/Engine/Renderer/BakedFrameGraph.mpp +++ b/modules/stormkit/Engine/Renderer/BakedFrameGraph.mpp @@ -46,8 +46,8 @@ export namespace stormkit::engine { struct Frame {}; BakedFrameGraph(const FrameGraphBuilder& builder, - Data && data, - BakedFrameGraph *old = nullptr); + Data&& data, + BakedFrameGraph* old = nullptr); ~BakedFrameGraph(); BakedFrameGraph(const BakedFrameGraph&) = delete; @@ -61,9 +61,9 @@ export namespace stormkit::engine { auto setBackbuffer(gpu::ImageView& backbuffer) -> void; private: - const FrameGraphBuilder *m_builder = nullptr; + const FrameGraphBuilder* m_builder = nullptr; - gpu::ImageView *m_backbuffer = nullptr; + gpu::ImageView* m_backbuffer = nullptr; Data m_data; diff --git a/modules/stormkit/Engine/Renderer/FrameGraphBuilder.mpp b/modules/stormkit/Engine/Renderer/FrameGraphBuilder.mpp index 93337f9a..b6ada807 100644 --- a/modules/stormkit/Engine/Renderer/FrameGraphBuilder.mpp +++ b/modules/stormkit/Engine/Renderer/FrameGraphBuilder.mpp @@ -52,9 +52,9 @@ export namespace stormkit::engine { auto reset() noexcept -> void; auto bake() -> void; - auto createFrameGraph(const gpu::Device& device, BakedFrameGraph *old = nullptr) + auto createFrameGraph(const gpu::Device& device, BakedFrameGraph* old = nullptr) -> BakedFrameGraph; - auto allocateFrameGraph(const gpu::Device& device, BakedFrameGraph *old = nullptr) + auto allocateFrameGraph(const gpu::Device& device, BakedFrameGraph* old = nullptr) -> std::unique_ptr; auto hasTask(GraphID id) const noexcept -> bool; @@ -125,7 +125,7 @@ export namespace stormkit::engine { auto buildBufferPhysicalDescriptions(const GraphTask& task) noexcept -> std::vector; auto buildRenderPassPhysicalDescription( - const GraphTask & task, + const GraphTask& task, core::HashMap& layouts) noexcept -> RenderPassData; auto allocatePhysicalResources(const gpu::Device& device) -> BakedFrameGraph::Data; @@ -193,12 +193,12 @@ namespace stormkit::engine { auto& task = m_tasks.emplace_back(id, std::move(name), type, cull_imune); m_datas.emplace_back(std::vector { sizeof(TaskData) }); - task.onSetup = [setup = std::move(setup)](core::Byte & data, + task.onSetup = [setup = std::move(setup)](core::Byte& data, GraphTaskBuilder& builder) noexcept { setup(core::as(data), builder); }; task.onExecute = [execute = std::move( - execute)](const core::Byte & data, + execute)](const core::Byte& data, std::optional> renderpass, gpu::CommandBuffer& cmb) noexcept { execute(core::as(data), std::move(renderpass), cmb); @@ -213,7 +213,7 @@ namespace stormkit::engine { ///////////////////////////////////// template inline auto FrameGraphBuilder::setRetainedResource(std::string name, - Description && description, + Description&& description, const Resource& image) -> GraphResource& { auto& graph_resource = m_resources.emplace_back(std::move(name), @@ -248,7 +248,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto & self, + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto& self, std::string_view name) noexcept -> decltype(auto) { return core::as>(self.getTask(name)); @@ -264,7 +264,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto & self, + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getTask(this auto& self, std::string_view name) noexcept -> decltype(auto) { const auto it = std::ranges::find_if(self.m_tasks, [&](const auto& t) noexcept { @@ -310,7 +310,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getResource(this auto & self, + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getResource(this auto& self, std::string_view name) noexcept -> decltype(auto) { return core::as>(self.getResource(name)); @@ -326,7 +326,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getResource(this auto & self, + STORMKIT_FORCE_INLINE auto FrameGraphBuilder::getResource(this auto& self, std::string_view name) noexcept -> decltype(auto) { const auto visitor = [name](auto&& value) noexcept { return value.name() == name; }; diff --git a/modules/stormkit/Engine/Renderer/GraphTask.mpp b/modules/stormkit/Engine/Renderer/GraphTask.mpp index a0ef5048..8804d6e7 100644 --- a/modules/stormkit/Engine/Renderer/GraphTask.mpp +++ b/modules/stormkit/Engine/Renderer/GraphTask.mpp @@ -54,7 +54,7 @@ export namespace stormkit::engine { std::function onSetup; std::function> renderpass, - gpu::CommandBuffer & cmb)> + gpu::CommandBuffer& cmb)> onExecute; private: diff --git a/modules/stormkit/Engine/Renderer/GraphTaskBuilder.mpp b/modules/stormkit/Engine/Renderer/GraphTaskBuilder.mpp index f74b99d4..eb7fa5a3 100644 --- a/modules/stormkit/Engine/Renderer/GraphTaskBuilder.mpp +++ b/modules/stormkit/Engine/Renderer/GraphTaskBuilder.mpp @@ -42,7 +42,7 @@ export namespace stormkit::engine { private: core::NakedRef m_task = nullptr; - FrameGraphBuilder *m_framegraph = nullptr; + FrameGraphBuilder* m_framegraph = nullptr; }; } // namespace stormkit::engine @@ -53,7 +53,7 @@ export namespace stormkit::engine { namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE GraphTaskBuilder::GraphTaskBuilder(GraphTask & task, + STORMKIT_FORCE_INLINE GraphTaskBuilder::GraphTaskBuilder(GraphTask& task, FrameGraphBuilder& framegraph) noexcept : m_task { task }, m_framegraph { &framegraph } { } diff --git a/modules/stormkit/Entities.mpp b/modules/stormkit/Entities.mpp index 4098aaa4..685c03a2 100644 --- a/modules/stormkit/Entities.mpp +++ b/modules/stormkit/Entities.mpp @@ -46,13 +46,13 @@ export namespace stormkit::entities { template constexpr auto componentHash(std::string_view str) noexcept -> Result; - constexpr auto componentHash(const char *str, core::RangeExtent size) noexcept + constexpr auto componentHash(const char* str, core::RangeExtent size) noexcept -> Component::Type; constexpr auto componentHash(std::string_view str) noexcept -> Component::Type; namespace literals { - constexpr auto operator""_component_type(const char *str, core::RangeExtent size) + constexpr auto operator""_component_type(const char* str, core::RangeExtent size) -> Component::Type; } // namespace literals @@ -72,7 +72,7 @@ export namespace stormkit::entities { MessageBus(MessageBus&&); auto operator=(MessageBus&&) -> MessageBus&; - auto push(Message &&message) -> void; + auto push(Message&& message) -> void; [[nodiscard]] auto top() const -> const Message&; auto pop() -> void; @@ -120,7 +120,7 @@ export namespace stormkit::entities { protected: virtual auto onMessageReceived(const Message& message) -> void = 0; - EntityManager *m_manager; + EntityManager* m_manager; core::HashSet m_entities; friend class EntityManager; @@ -150,7 +150,7 @@ export namespace stormkit::entities { auto hasEntity(Entity entity) const -> bool; template - auto addComponent(Entity entity, Args&&...args) -> T&; + auto addComponent(Entity entity, Args&&... args) -> T&; template auto destroyComponent(Entity entity) -> void; @@ -177,7 +177,7 @@ export namespace stormkit::entities { -> std::vector>>; template T, typename... Args> - auto addSystem(Args&&...args) -> T&; + auto addSystem(Args&&... args) -> T&; template T> auto hasSystem() const noexcept -> bool; @@ -244,7 +244,7 @@ namespace stormkit::entities { ///////////////////////////////////// ///////////////////////////////////// - constexpr auto componentHash(const char *str, core::RangeExtent size) noexcept + constexpr auto componentHash(const char* str, core::RangeExtent size) noexcept -> Component::Type { return size == 0 ? 0xcbf29ce484222325UL : (core::narrow(str[0]) ^ @@ -261,7 +261,7 @@ namespace stormkit::entities { namespace literals { ///////////////////////////////////// ///////////////////////////////////// - constexpr auto operator""_component_type(const char *str, core::RangeExtent size) + constexpr auto operator""_component_type(const char* str, core::RangeExtent size) -> Component::Type { return stormkit::entities::componentHash(str, size); } @@ -288,7 +288,7 @@ namespace stormkit::entities { ///////////////////////////////////// ///////////////////////////////////// template - auto EntityManager::addComponent(Entity entity, Args&&...args) -> T& { + auto EntityManager::addComponent(Entity entity, Args&&... args) -> T& { static_assert(std::is_base_of::value, "T must be a Component"); static_assert(T::TYPE != Component::INVALID_TYPE, "T must have T::type defined"); @@ -359,7 +359,7 @@ namespace stormkit::entities { core::expects(self.hasEntity(entity)); const auto key = componentKeyFor(entity, T::TYPE); - return *static_cast(self.m_components.at(key).get()); + return *static_cast(self.m_components.at(key).get()); } ///////////////////////////////////// @@ -395,7 +395,7 @@ namespace stormkit::entities { ///////////////////////////////////// ///////////////////////////////////// template T, typename... Args> - auto EntityManager::addSystem(Args&&...args) -> T& { + auto EntityManager::addSystem(Args&&... args) -> T& { m_systems.emplace(std::make_unique(std::forward(args)..., *this)); auto& system = getSystem(); @@ -410,7 +410,7 @@ namespace stormkit::entities { template T> auto EntityManager::hasSystem() const noexcept -> bool { for (auto& system : m_systems) { - if (auto system_ptr = dynamic_cast(system.get()); system_ptr != nullptr) + if (auto system_ptr = dynamic_cast(system.get()); system_ptr != nullptr) return true; } diff --git a/modules/stormkit/Gpu/Core/Device.mpp b/modules/stormkit/Gpu/Core/Device.mpp index 83a1de86..4003e179 100644 --- a/modules/stormkit/Gpu/Core/Device.mpp +++ b/modules/stormkit/Gpu/Core/Device.mpp @@ -40,8 +40,8 @@ export namespace stormkit::gpu { }; Device(const PhysicalDevice& physical_device, - const Instance & instance, - const Info & info, + const Instance& instance, + const Info& info, Tag); ~Device(); @@ -52,11 +52,11 @@ export namespace stormkit::gpu { auto operator=(Device&&) noexcept -> Device&; [[nodiscard]] static auto create(const PhysicalDevice& physical_device, - const Instance & instance, + const Instance& instance, const Info& info = { true, false }) noexcept -> Device; [[nodiscard]] static auto allocate(const PhysicalDevice& physical_device, - const Instance & instance, - const Info & info = { true, false }) noexcept + const Instance& instance, + const Info& info = { true, false }) noexcept -> std::unique_ptr; auto waitIdle() const noexcept -> void; @@ -66,7 +66,7 @@ export namespace stormkit::gpu { const std::chrono::milliseconds& timeout = std::chrono::milliseconds::max()) const noexcept -> Expected; - [[nodiscard]] auto waitForFence(const Fence & fence, + [[nodiscard]] auto waitForFence(const Fence& fence, const std::chrono::milliseconds& timeout = std::chrono::milliseconds::max()) const noexcept -> Expected; @@ -137,7 +137,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - Device::waitForFence(const Fence & fence, + Device::waitForFence(const Fence& fence, const std::chrono::milliseconds& timeout) const noexcept -> Expected { return waitForFences(core::makeNakedRefArray(fence), true, timeout); diff --git a/modules/stormkit/Gpu/Execution/CommandBuffer.mpp b/modules/stormkit/Gpu/Execution/CommandBuffer.mpp index 6e7f6508..0330a2e2 100644 --- a/modules/stormkit/Gpu/Execution/CommandBuffer.mpp +++ b/modules/stormkit/Gpu/Execution/CommandBuffer.mpp @@ -40,10 +40,10 @@ export namespace stormkit::gpu { Queue(Queue&&) noexcept; auto operator=(Queue&&) noexcept -> Queue&; - [[nodiscard]] static auto create(const Device & device, + [[nodiscard]] static auto create(const Device& device, const Device::QueueEntry& entry) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device & device, + [[nodiscard]] static auto allocate(const Device& device, const Device::QueueEntry& entry) noexcept -> Expected>; @@ -81,9 +81,9 @@ export namespace stormkit::gpu { }; struct InheritanceInfo { - const RenderPass *render_pass = nullptr; + const RenderPass* render_pass = nullptr; core::UInt32 subpass = 0; - const FrameBuffer *framebuffer = nullptr; + const FrameBuffer* framebuffer = nullptr; }; class STORMKIT_API CommandBuffer: public DeviceObject, @@ -130,8 +130,8 @@ export namespace stormkit::gpu { std::optional inheritance_info = std::nullopt) -> void; auto end() -> void; - auto beginRenderPass(const RenderPass & render_pass, - const FrameBuffer & framebuffer, + auto beginRenderPass(const RenderPass& render_pass, + const FrameBuffer& framebuffer, std::span clear_values = std::array { ClearValue { ClearColor { .color = core::RGBColorDef::Silver } } }, bool secondary_commandbuffers = false) -> void; @@ -162,11 +162,11 @@ export namespace stormkit::gpu { core::UInt32 first_index = 0u, core::Int32 vertex_offset = 0, core::UInt32 first_instance = 0u) -> void; - auto drawIndirect(const Buffer & buffer, + auto drawIndirect(const Buffer& buffer, core::RangeExtent offset, core::UInt32 draw_count, core::UInt32 stride) -> void; - auto drawIndexedIndirect(const Buffer & buffer, + auto drawIndexedIndirect(const Buffer& buffer, core::RangeExtent offset, core::UInt32 draw_count, core::UInt32 stride) -> void; @@ -177,45 +177,45 @@ export namespace stormkit::gpu { core::UInt64 offset = 0, bool large_indices = false) -> void; auto - bindDescriptorSets(const Pipeline & pipeline, - const PipelineLayout & layout, + bindDescriptorSets(const Pipeline& pipeline, + const PipelineLayout& layout, std::span> descriptor_sets, std::span dynamic_offsets = {}) -> void; - auto copyBuffer(const Buffer & src, - const Buffer & dst, + auto copyBuffer(const Buffer& src, + const Buffer& dst, core::RangeExtent size, core::UInt64 src_offset = 0u, core::UInt64 dst_offset = 0u) -> void; - auto copyBufferToImage(const Buffer & src, - const Image & dst, + auto copyBufferToImage(const Buffer& src, + const Image& dst, std::span buffer_image_copies = {}) -> void; - auto copyImageToBuffer(const Image & src, - const Buffer & dst, + auto copyImageToBuffer(const Image& src, + const Buffer& dst, std::span buffer_image_copies = {}) -> void; - auto copyImage(const Image & src, - const Image & dst, + auto copyImage(const Image& src, + const Image& dst, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceLayers& src_subresource_layers, const ImageSubresourceLayers& dst_subresource_layers, - const core::math::ExtentU & extent) -> void; + const core::math::ExtentU& extent) -> void; - auto resolveImage(const Image & src, - const Image & dst, + auto resolveImage(const Image& src, + const Image& dst, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceLayers& src_subresource_layers = {}, const ImageSubresourceLayers& dst_subresource_layers = {}) -> void; - auto blitImage(const Image & src, - const Image & dst, + auto blitImage(const Image& src, + const Image& dst, ImageLayout src_layout, ImageLayout dst_layout, std::span regions, Filter filter) -> void; - auto transitionImageLayout(const Image & image, + auto transitionImageLayout(const Image& image, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceRange& subresource_range = {}) -> void; @@ -230,7 +230,7 @@ export namespace stormkit::gpu { std::span buffer_memory_barriers, std::span image_memory_barriers) -> void; - auto pushConstants(const PipelineLayout & pipeline_layout, + auto pushConstants(const PipelineLayout& pipeline_layout, ShaderStageFlag stage, std::span data, core::UInt32 offset = 0u) -> void; @@ -358,7 +358,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Queue::create(const Device & device, + STORMKIT_FORCE_INLINE auto Queue::create(const Device& device, const Device::QueueEntry& entry) noexcept -> Expected try { return Queue { device, entry, Tag {} }; @@ -366,7 +366,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Queue::allocate(const Device & device, + STORMKIT_FORCE_INLINE auto Queue::allocate(const Device& device, const Device::QueueEntry& entry) noexcept -> Expected> try { return std::make_unique(device, entry, Tag {}); @@ -420,7 +420,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - CommandBuffer::CommandBuffer(const CommandPool & command_pool, + CommandBuffer::CommandBuffer(const CommandPool& command_pool, CommandBufferLevel level, vk::raii::CommandBuffer&& command_buffer, Deleter deleter) @@ -562,8 +562,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::beginRenderPass(const RenderPass & render_pass, - const FrameBuffer & framebuffer, + CommandBuffer::beginRenderPass(const RenderPass& render_pass, + const FrameBuffer& framebuffer, std::span clear_values, bool secondary_commandbuffers) -> void { core::expects(m_state == State::Recording); @@ -760,7 +760,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::drawIndirect(const Buffer & buffer, + STORMKIT_FORCE_INLINE auto CommandBuffer::drawIndirect(const Buffer& buffer, core::RangeExtent offset, core::UInt32 draw_count, core::UInt32 stride) -> void { @@ -772,7 +772,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::drawIndexedIndirect(const Buffer & buffer, + STORMKIT_FORCE_INLINE auto CommandBuffer::drawIndexedIndirect(const Buffer& buffer, core::RangeExtent offset, core::UInt32 draw_count, core::UInt32 stride) -> void { @@ -813,8 +813,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto CommandBuffer::bindDescriptorSets( - const Pipeline & pipeline, - const PipelineLayout & layout, + const Pipeline& pipeline, + const PipelineLayout& layout, std::span> descriptor_sets, std::span dynamic_offsets) -> void { core::expects(m_state == State::Recording); @@ -835,8 +835,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::copyBuffer(const Buffer & src, - const Buffer & dst, + STORMKIT_FORCE_INLINE auto CommandBuffer::copyBuffer(const Buffer& src, + const Buffer& dst, core::RangeExtent size, core::UInt64 src_offset, core::UInt64 dst_offset) -> void { @@ -850,8 +850,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::copyBufferToImage(const Buffer & src, - const Image & dst, + CommandBuffer::copyBufferToImage(const Buffer& src, + const Image& dst, std::span buffer_image_copies) -> void { core::expects(m_state == State::Recording); @@ -891,8 +891,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::copyImageToBuffer(const Image & src, - const Buffer & dst, + CommandBuffer::copyImageToBuffer(const Image& src, + const Buffer& dst, std::span buffer_image_copies) -> void { core::expects(m_state == State::Recording); @@ -932,13 +932,13 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::copyImage(const Image & src, - const Image & dst, + CommandBuffer::copyImage(const Image& src, + const Image& dst, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceLayers& src_subresource_layers, const ImageSubresourceLayers& dst_subresource_layers, - const core::math::ExtentU & extent) -> void { + const core::math::ExtentU& extent) -> void { core::expects(m_state == State::Recording); const auto vk_src_subresource_layers = vk::ImageSubresourceLayers { @@ -970,8 +970,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::resolveImage(const Image & src, - const Image & dst, + CommandBuffer::resolveImage(const Image& src, + const Image& dst, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceLayers& src_subresource_layers, @@ -1008,8 +1008,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto CommandBuffer::blitImage(const Image & src, - const Image & dst, + STORMKIT_FORCE_INLINE auto CommandBuffer::blitImage(const Image& src, + const Image& dst, ImageLayout src_layout, ImageLayout dst_layout, std::span regions, @@ -1054,7 +1054,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - CommandBuffer::transitionImageLayout(const Image & image, + CommandBuffer::transitionImageLayout(const Image& image, ImageLayout src_layout, ImageLayout dst_layout, const ImageSubresourceRange& subresource_range) @@ -1202,7 +1202,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto CommandPool::create(const Device& device, - const Queue & queue) noexcept + const Queue& queue) noexcept -> Expected try { return CommandPool { device, queue, Tag {} }; } catch (const Result& result) { return std::unexpected(result); } @@ -1210,7 +1210,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto CommandPool::allocate(const Device& device, - const Queue & queue) noexcept + const Queue& queue) noexcept -> Expected> try { return std::make_unique(device, queue, Tag {}); } catch (const Result& result) { return std::unexpected(result); } diff --git a/modules/stormkit/Gpu/Execution/Descriptors.mpp b/modules/stormkit/Gpu/Execution/Descriptors.mpp index aa004afa..ec7e3d25 100644 --- a/modules/stormkit/Gpu/Execution/Descriptors.mpp +++ b/modules/stormkit/Gpu/Execution/Descriptors.mpp @@ -67,9 +67,9 @@ export { private: using Deleter = std::function; - DescriptorSet(const DescriptorPool & pool, + DescriptorSet(const DescriptorPool& pool, std::vector type, - vk::raii::DescriptorSet && sets, + vk::raii::DescriptorSet&& sets, Deleter deleter); std::vector m_types; @@ -93,10 +93,10 @@ export { public: static constexpr auto DEBUG_TYPE = DebugObjectType::Descriptor_Set_Layout; - DescriptorSetLayout(const Device & device, + DescriptorSetLayout(const Device& device, std::vector&& bindings, Tag); - DescriptorSetLayout(const Device & device, + DescriptorSetLayout(const Device& device, std::span bindings, Tag); ~DescriptorSetLayout(); @@ -135,7 +135,7 @@ export { core::UInt32 descriptor_count; }; - DescriptorPool(const Device & device, + DescriptorPool(const Device& device, std::span sizes, core::UInt32 max_sets, Tag); @@ -147,12 +147,12 @@ export { DescriptorPool(DescriptorPool&&) noexcept; auto operator=(DescriptorPool&&) noexcept -> DescriptorPool&; - [[nodiscard]] static auto create(const Device & device, + [[nodiscard]] static auto create(const Device& device, std::span sizes, core::UInt32 max_sets) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device & device, + [[nodiscard]] static auto allocate(const Device& device, std::span sizes, core::UInt32 max_sets) noexcept -> Expected>; @@ -217,9 +217,9 @@ export { namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE DescriptorSet::DescriptorSet(const DescriptorPool & pool, + STORMKIT_FORCE_INLINE DescriptorSet::DescriptorSet(const DescriptorPool& pool, std::vector type, - vk::raii::DescriptorSet && set, + vk::raii::DescriptorSet&& set, Deleter deleter) : DeviceObject { pool.device() }, DescriptorPoolObject { pool }, m_types { std::move(type) }, m_vk_descriptor_set { std::move(set) }, @@ -312,7 +312,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - DescriptorSetLayout::DescriptorSetLayout(const Device & device, + DescriptorSetLayout::DescriptorSetLayout(const Device& device, std::vector&& bindings, Tag) : DescriptorSetLayout { device } { @@ -322,7 +322,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - DescriptorSetLayout::DescriptorSetLayout(const Device & device, + DescriptorSetLayout::DescriptorSetLayout(const Device& device, std::span bindings, Tag) : DescriptorSetLayout { device } { @@ -373,7 +373,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE DescriptorPool::DescriptorPool(const Device & device, + STORMKIT_FORCE_INLINE DescriptorPool::DescriptorPool(const Device& device, std::span sizes, core::UInt32 max_sets, Tag) @@ -412,7 +412,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto DescriptorPool::create(const Device & device, + STORMKIT_FORCE_INLINE auto DescriptorPool::create(const Device& device, std::span extents, core::UInt32 max_sets) noexcept -> Expected try { @@ -421,7 +421,7 @@ namespace stormkit::gpu { ////////////////////////////////////p/ ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto DescriptorPool::allocate(const Device & device, + STORMKIT_FORCE_INLINE auto DescriptorPool::allocate(const Device& device, std::span extents, core::UInt32 max_sets) noexcept -> Expected> try { diff --git a/modules/stormkit/Gpu/Execution/Pipeline.mpp b/modules/stormkit/Gpu/Execution/Pipeline.mpp index dd88939c..2599e5c8 100644 --- a/modules/stormkit/Gpu/Execution/Pipeline.mpp +++ b/modules/stormkit/Gpu/Execution/Pipeline.mpp @@ -36,10 +36,10 @@ export namespace stormkit::gpu { PipelineCache(PipelineCache&&) noexcept; auto operator=(PipelineCache&&) noexcept -> PipelineCache&; - [[nodiscard]] static auto create(const Device & device, + [[nodiscard]] static auto create(const Device& device, std::filesystem::path cache_path) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device & device, + [[nodiscard]] static auto allocate(const Device& device, std::filesystem::path cache_path) noexcept -> Expected>; @@ -91,10 +91,10 @@ export namespace stormkit::gpu { PipelineLayout(PipelineLayout&&) noexcept; auto operator=(PipelineLayout&&) noexcept -> PipelineLayout&; - [[nodiscard]] static auto create(const Device & device, + [[nodiscard]] static auto create(const Device& device, const RasterPipelineLayout& layout) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device & device, + [[nodiscard]] static auto allocate(const Device& device, const RasterPipelineLayout& layout) noexcept -> Expected>; @@ -118,10 +118,10 @@ export namespace stormkit::gpu { static constexpr auto DEBUG_TYPE = DebugObjectType::Pipeline; - Pipeline(const Device & device, - const RasterPipelineState & state, - const PipelineLayout & layout, - const RenderPass & render_pass, + Pipeline(const Device& device, + const RasterPipelineState& state, + const PipelineLayout& layout, + const RenderPass& render_pass, std::optional> cache, Tag); ~Pipeline(); @@ -133,17 +133,17 @@ export namespace stormkit::gpu { auto operator=(Pipeline&&) noexcept -> Pipeline&; [[nodiscard]] static auto - create(const Device & device, - const RasterPipelineState & state, - const PipelineLayout & layout, - const RenderPass & render_pass, + create(const Device& device, + const RasterPipelineState& state, + const PipelineLayout& layout, + const RenderPass& render_pass, std::optional> cache) noexcept -> Expected; [[nodiscard]] static auto - allocate(const Device & device, - const RasterPipelineState & state, - const PipelineLayout & layout, - const RenderPass & render_pass, + allocate(const Device& device, + const RasterPipelineState& state, + const PipelineLayout& layout, + const RenderPass& render_pass, std::optional> cache) noexcept -> Expected>; @@ -202,7 +202,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PipelineCache::create(const Device & device, + STORMKIT_FORCE_INLINE auto PipelineCache::create(const Device& device, std::filesystem::path cache_path) noexcept -> Expected try { return PipelineCache { device, std::move(cache_path), Tag {} }; @@ -210,7 +210,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PipelineCache::allocate(const Device & device, + STORMKIT_FORCE_INLINE auto PipelineCache::allocate(const Device& device, std::filesystem::path cache_path) noexcept -> Expected> try { return std::make_unique(device, std::move(cache_path), Tag {}); @@ -269,7 +269,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PipelineLayout::create(const Device & device, + STORMKIT_FORCE_INLINE auto PipelineLayout::create(const Device& device, const RasterPipelineLayout& layout) noexcept -> Expected try { return PipelineLayout { device, layout, Tag {} }; @@ -277,7 +277,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PipelineLayout::allocate(const Device & device, + STORMKIT_FORCE_INLINE auto PipelineLayout::allocate(const Device& device, const RasterPipelineLayout& layout) noexcept -> Expected> try { return std::make_unique(device, layout, Tag {}); @@ -293,10 +293,10 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - Pipeline::Pipeline(const Device & device, - const RasterPipelineState & state, - const PipelineLayout & layout, - const RenderPass & render_pass, + Pipeline::Pipeline(const Device& device, + const RasterPipelineState& state, + const PipelineLayout& layout, + const RenderPass& render_pass, std::optional> cache, Tag) : DeviceObject { device }, m_state { state } { @@ -320,10 +320,10 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - Pipeline::create(const Device & device, - const RasterPipelineState & state, - const PipelineLayout & layout, - const RenderPass & render_pass, + Pipeline::create(const Device& device, + const RasterPipelineState& state, + const PipelineLayout& layout, + const RenderPass& render_pass, std::optional> cache) noexcept -> Expected try { return Pipeline { device, state, layout, render_pass, std::move(cache), Tag {} }; @@ -332,10 +332,10 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - Pipeline::allocate(const Device & device, - const RasterPipelineState & state, - const PipelineLayout & layout, - const RenderPass & render_pass, + Pipeline::allocate(const Device& device, + const RasterPipelineState& state, + const PipelineLayout& layout, + const RenderPass& render_pass, std::optional> cache) noexcept -> Expected> try { return std::make_unique(device, diff --git a/modules/stormkit/Gpu/Execution/RenderPass.mpp b/modules/stormkit/Gpu/Execution/RenderPass.mpp index b74d2d4e..a6f528a1 100644 --- a/modules/stormkit/Gpu/Execution/RenderPass.mpp +++ b/modules/stormkit/Gpu/Execution/RenderPass.mpp @@ -35,8 +35,8 @@ export { public: static constexpr auto DEBUG_TYPE = DebugObjectType::FrameBuffer; - FrameBuffer(const RenderPass & render_pass, - const core::math::ExtentU & size, + FrameBuffer(const RenderPass& render_pass, + const core::math::ExtentU& size, std::vector> attachments, Tag); ~FrameBuffer(); @@ -48,13 +48,13 @@ export { auto operator=(FrameBuffer&&) noexcept -> FrameBuffer&; [[nodiscard]] static auto - create(const RenderPass & render_pass, - const core::math::ExtentU & size, + create(const RenderPass& render_pass, + const core::math::ExtentU& size, std::vector> attachments) noexcept -> Expected; [[nodiscard]] static auto - allocate(const RenderPass & render_pass, - const core::math::ExtentU & size, + allocate(const RenderPass& render_pass, + const core::math::ExtentU& size, std::vector> attachments) noexcept -> Expected>; @@ -126,19 +126,19 @@ export { RenderPass(RenderPass&&) noexcept; auto operator=(RenderPass&&) noexcept -> RenderPass&; - [[nodiscard]] static auto create(const Device & device, + [[nodiscard]] static auto create(const Device& device, const RenderPassDescription& description) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device & device, + [[nodiscard]] static auto allocate(const Device& device, const RenderPassDescription& description) noexcept -> Expected>; [[nodiscard]] auto createFrameBuffer( - const core::math::ExtentU & size, + const core::math::ExtentU& size, std::vector> attachments) const noexcept -> Expected; [[nodiscard]] auto allocateFrameBuffer( - const core::math::ExtentU & size, + const core::math::ExtentU& size, std::vector> attachments) const noexcept -> Expected>; @@ -186,8 +186,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - FrameBuffer::FrameBuffer(const RenderPass & render_pass, - const core::math::ExtentU & extent, + FrameBuffer::FrameBuffer(const RenderPass& render_pass, + const core::math::ExtentU& extent, std::vector> attachments, Tag) : DeviceObject { render_pass.device() }, RenderPassObject { render_pass }, @@ -231,8 +231,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - FrameBuffer::create(const RenderPass & render_pass, - const core::math::ExtentU & size, + FrameBuffer::create(const RenderPass& render_pass, + const core::math::ExtentU& size, std::vector> attachments) noexcept -> Expected try { return FrameBuffer { render_pass, size, std::move(attachments), Tag {} }; @@ -241,8 +241,8 @@ namespace stormkit::gpu { ////////////////////////////////////p/ ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - FrameBuffer::allocate(const RenderPass & render_pass, - const core::math::ExtentU & size, + FrameBuffer::allocate(const RenderPass& render_pass, + const core::math::ExtentU& size, std::vector> attachments) noexcept -> Expected> try { return std::make_unique(render_pass, size, std::move(attachments), Tag {}); @@ -292,7 +292,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto RenderPass::create(const Device & device, + STORMKIT_FORCE_INLINE auto RenderPass::create(const Device& device, const RenderPassDescription& description) noexcept -> Expected try { return RenderPass { device, description, Tag {} }; @@ -301,7 +301,7 @@ namespace stormkit::gpu { ////////////////////////////////////p/ ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - RenderPass::allocate(const Device & device, + RenderPass::allocate(const Device& device, const RenderPassDescription& description) noexcept -> Expected> try { return std::make_unique(device, description, Tag {}); @@ -310,7 +310,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto RenderPass::createFrameBuffer( - const core::math::ExtentU & extent, + const core::math::ExtentU& extent, std::vector> attachments) const noexcept -> Expected { return FrameBuffer::create(*this, extent, std::move(attachments)); @@ -319,7 +319,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto RenderPass::allocateFrameBuffer( - const core::math::ExtentU & extent, + const core::math::ExtentU& extent, std::vector> attachments) const noexcept -> Expected> { return FrameBuffer::allocate(*this, extent, std::move(attachments)); diff --git a/modules/stormkit/Gpu/Resource/Buffer.mpp b/modules/stormkit/Gpu/Resource/Buffer.mpp index 1ecac90a..3e190228 100644 --- a/modules/stormkit/Gpu/Resource/Buffer.mpp +++ b/modules/stormkit/Gpu/Resource/Buffer.mpp @@ -38,11 +38,11 @@ export namespace stormkit::gpu { Buffer(Buffer&&) noexcept; auto operator=(Buffer&&) noexcept -> Buffer&; - [[nodiscard]] static auto create(const Device & device, + [[nodiscard]] static auto create(const Device& device, const CreateInfo& info, bool persistently_mapped = false) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device & device, + [[nodiscard]] static auto allocate(const Device& device, const CreateInfo& info, bool persistently_mapped = false) noexcept -> Expected>; @@ -89,7 +89,7 @@ export namespace stormkit::gpu { core::RangeExtent m_size = 0; bool m_is_persistently_mapped = false; - core::Byte *m_mapped_pointer = nullptr; + core::Byte* m_mapped_pointer = nullptr; }; struct BufferMemoryBarrier { @@ -99,7 +99,7 @@ export namespace stormkit::gpu { core::UInt32 src_queue_family_index = QUEUE_FAMILY_IGNORED; core::UInt32 dst_queue_family_index = QUEUE_FAMILY_IGNORED; - const Buffer & buffer; + const Buffer& buffer; core::RangeExtent size; core::UInt64 offset = 0; }; @@ -124,7 +124,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Buffer::create(const Device & device, + STORMKIT_FORCE_INLINE auto Buffer::create(const Device& device, const CreateInfo& info, bool persistently_mapped) noexcept -> Expected try { @@ -133,7 +133,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Buffer::allocate(const Device & device, + STORMKIT_FORCE_INLINE auto Buffer::allocate(const Device& device, const CreateInfo& info, bool persistently_mapped) noexcept -> Expected> try { @@ -164,7 +164,7 @@ namespace stormkit::gpu { if (!m_mapped_pointer) { auto _ = device().vmaAllocator().mapMemory(*m_vma_allocation, - std::bit_cast(&m_mapped_pointer)); + std::bit_cast(&m_mapped_pointer)); m_mapped_pointer += offset; } @@ -184,7 +184,7 @@ namespace stormkit::gpu { STORMKIT_FORCE_INLINE auto Buffer::mapAs(core::RangeOffset offset) noexcept -> decltype(auto) { core::expects(m_vma_allocation.operator bool()); - return std::bit_cast(map(offset)); + return std::bit_cast(map(offset)); } ///////////////////////////////////// @@ -195,7 +195,7 @@ namespace stormkit::gpu { using Byte = core::LikeCV; - return std::bit_cast(self.m_mapped_pointer); + return std::bit_cast(self.m_mapped_pointer); } ///////////////////////////////////// @@ -207,7 +207,7 @@ namespace stormkit::gpu { using Byte = core::LikeCV; - return std::span { std::bit_cast(self.m_mapped_pointer), size }; + return std::span { std::bit_cast(self.m_mapped_pointer), size }; } ///////////////////////////////////// @@ -218,7 +218,7 @@ namespace stormkit::gpu { using Type = core::LikeCV; - return std::bit_cast(self.data()); + return std::bit_cast(self.data()); } ///////////////////////////////////// diff --git a/modules/stormkit/Gpu/Resource/Image.mpp b/modules/stormkit/Gpu/Resource/Image.mpp index 0f61e2d9..d2a945e0 100644 --- a/modules/stormkit/Gpu/Resource/Image.mpp +++ b/modules/stormkit/Gpu/Resource/Image.mpp @@ -87,8 +87,8 @@ export namespace stormkit::gpu { public: static constexpr auto DEBUG_TYPE = DebugObjectType::Image_View; - ImageView(const Device & device, - const Image & image, + ImageView(const Device& device, + const Image& image, ImageViewType type, const ImageSubresourceRange& subresource_range, Tag); @@ -101,14 +101,14 @@ export namespace stormkit::gpu { auto operator=(ImageView&&) noexcept -> ImageView&; [[nodiscard]] static auto - create(const Device & device, - const Image & image, + create(const Device& device, + const Image& image, ImageViewType type = ImageViewType::T2D, const ImageSubresourceRange& subresource_range = {}) noexcept -> Expected; [[nodiscard]] static auto - allocate(const Device & device, - const Image & image, + allocate(const Device& device, + const Image& image, ImageViewType type = ImageViewType::T2D, const ImageSubresourceRange& subresource_range = {}) noexcept -> Expected>; @@ -156,7 +156,7 @@ export namespace stormkit::gpu { [[nodiscard]] static auto create(const Device& device, const CreateInfo& info) noexcept -> Expected; - [[nodiscard]] static auto allocate(const Device & device, + [[nodiscard]] static auto allocate(const Device& device, const CreateInfo& create_info) noexcept -> Expected>; @@ -173,10 +173,10 @@ export namespace stormkit::gpu { private: Image(const Device& device, const CreateInfo& info); - Image(const Device & device, + Image(const Device& device, const core::math::ExtentU& extent, PixelFormat format, - vk::Image && image, + vk::Image&& image, Tag); core::math::ExtentU m_extent = { 0, 0, 0 }; @@ -205,7 +205,7 @@ export namespace stormkit::gpu { core::UInt32 src_queue_family_index = QUEUE_FAMILY_IGNORED; core::UInt32 dst_queue_family_index = QUEUE_FAMILY_IGNORED; - const Image & image; + const Image& image; ImageSubresourceRange range; }; } // namespace stormkit::gpu @@ -254,7 +254,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Sampler::create(const Device & device, + STORMKIT_FORCE_INLINE auto Sampler::create(const Device& device, const Settings& settings) noexcept -> Expected try { return Sampler { device, settings, Tag {} }; @@ -262,7 +262,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Sampler::allocate(const Device & device, + STORMKIT_FORCE_INLINE auto Sampler::allocate(const Device& device, const Settings& settings) noexcept -> Expected> try { return std::make_unique(device, settings, Tag {}); @@ -288,8 +288,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE ImageView::ImageView(const Device & device, - const Image & image, + STORMKIT_FORCE_INLINE ImageView::ImageView(const Device& device, + const Image& image, ImageViewType type, const ImageSubresourceRange& subresource_range, Tag) @@ -336,8 +336,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - ImageView::create(const Device & device, - const Image & image, + ImageView::create(const Device& device, + const Image& image, ImageViewType type, const ImageSubresourceRange& subresource_range) noexcept -> Expected try { @@ -347,8 +347,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - ImageView::allocate(const Device & device, - const Image & image, + ImageView::allocate(const Device& device, + const Image& image, ImageViewType type, const ImageSubresourceRange& subresource_range) noexcept -> Expected> try { @@ -424,8 +424,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE Image::Image(const Device & device, - const core::math::ExtentU & extent, + STORMKIT_FORCE_INLINE Image::Image(const Device& device, + const core::math::ExtentU& extent, gpu::PixelFormat format, [[maybe_unused]] vk::Image&& image, Tag) @@ -448,7 +448,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Image::create(const Device & device, + STORMKIT_FORCE_INLINE auto Image::create(const Device& device, const CreateInfo& create_info) noexcept -> Expected try { return Image { device, create_info, Tag {} }; @@ -456,7 +456,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Image::allocate(const Device & device, + STORMKIT_FORCE_INLINE auto Image::allocate(const Device& device, const CreateInfo& create_info) noexcept -> Expected> try { return std::make_unique(device, create_info, Tag {}); diff --git a/modules/stormkit/Gpu/Resource/Shader.mpp b/modules/stormkit/Gpu/Resource/Shader.mpp index 5ebca20f..93546387 100644 --- a/modules/stormkit/Gpu/Resource/Shader.mpp +++ b/modules/stormkit/Gpu/Resource/Shader.mpp @@ -23,7 +23,7 @@ namespace stormkit::gpu { public: static constexpr auto DEBUG_TYPE = DebugObjectType::Shader_Module; - Shader(const Device & device, + Shader(const Device& device, const std::filesystem::path& filepath, ShaderStageFlag type, Tag); @@ -37,25 +37,25 @@ namespace stormkit::gpu { Shader(Shader&&) noexcept; auto operator=(Shader&&) noexcept -> Shader&; - [[nodiscard]] static auto loadFromFile(const Device & device, + [[nodiscard]] static auto loadFromFile(const Device& device, const std::filesystem::path& filepath, ShaderStageFlag type) noexcept -> Expected; - [[nodiscard]] static auto fromBytes(const Device & device, + [[nodiscard]] static auto fromBytes(const Device& device, std::span data, ShaderStageFlag type) noexcept -> Expected; - [[nodiscard]] static auto fromSpirvIDs(const Device & device, + [[nodiscard]] static auto fromSpirvIDs(const Device& device, std::span data, ShaderStageFlag type) noexcept -> Expected; - [[nodiscard]] static auto allocateAndLoadFromFile(const Device & device, + [[nodiscard]] static auto allocateAndLoadFromFile(const Device& device, const std::filesystem::path& filepath, ShaderStageFlag type) noexcept -> Expected>; - [[nodiscard]] static auto allocateFromBytes(const Device & device, + [[nodiscard]] static auto allocateFromBytes(const Device& device, std::span data, ShaderStageFlag type) noexcept -> Expected>; - [[nodiscard]] static auto allocateFromSpirvIDs(const Device & device, + [[nodiscard]] static auto allocateFromSpirvIDs(const Device& device, std::span data, ShaderStageFlag type) noexcept -> Expected>; @@ -85,7 +85,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - Shader::Shader(const Device & device, + Shader::Shader(const Device& device, const std::filesystem::path& filepath, ShaderStageFlag type, Tag) @@ -103,7 +103,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE - Shader::Shader(const Device & device, + Shader::Shader(const Device& device, std::span data, ShaderStageFlag type, Tag) @@ -135,7 +135,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Shader::loadFromFile(const Device & device, + STORMKIT_FORCE_INLINE auto Shader::loadFromFile(const Device& device, const std::filesystem::path& filepath, ShaderStageFlag type) noexcept -> Expected try { @@ -144,7 +144,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Shader::fromBytes(const Device & device, + STORMKIT_FORCE_INLINE auto Shader::fromBytes(const Device& device, std::span data, ShaderStageFlag type) noexcept -> Expected try { @@ -153,7 +153,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Shader::fromSpirvIDs(const Device & device, + STORMKIT_FORCE_INLINE auto Shader::fromSpirvIDs(const Device& device, std::span data, ShaderStageFlag type) noexcept -> Expected try { @@ -163,7 +163,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto - Shader::allocateAndLoadFromFile(const Device & device, + Shader::allocateAndLoadFromFile(const Device& device, const std::filesystem::path& filepath, ShaderStageFlag type) noexcept -> Expected> try { @@ -172,7 +172,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Shader::allocateFromBytes(const Device & device, + STORMKIT_FORCE_INLINE auto Shader::allocateFromBytes(const Device& device, std::span data, ShaderStageFlag type) noexcept -> Expected> try { @@ -181,7 +181,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Shader::allocateFromSpirvIDs(const Device & device, + STORMKIT_FORCE_INLINE auto Shader::allocateFromSpirvIDs(const Device& device, std::span data, ShaderStageFlag type) noexcept -> Expected> try { diff --git a/modules/stormkit/Gpu/Vulkan/Utils.mpp b/modules/stormkit/Gpu/Vulkan/Utils.mpp index 0bd8f48f..5cf8eeba 100644 --- a/modules/stormkit/Gpu/Vulkan/Utils.mpp +++ b/modules/stormkit/Gpu/Vulkan/Utils.mpp @@ -39,15 +39,15 @@ export namespace stormkit::gpu { using VulkanExpected = std::expected; template - requires(core::Is, vk::Result>) - auto vkCall(T& object, Func&& func, Args&&...args) noexcept -> VulkanExpected; + requires(core::Is, vk::Result>) + auto vkCall(T& object, Func&& func, Args&&... args) noexcept -> VulkanExpected; template - requires(core::Is, vk::Result>) - auto vkCall(T & object, - Func && func, + requires(core::Is, vk::Result>) + auto vkCall(T& object, + Func&& func, std::span possible_results, - Args&&...args) noexcept -> VulkanExpected; + Args&&... args) noexcept -> VulkanExpected; auto toRaiiVkHandle() noexcept -> decltype(auto); auto toVkHandle() noexcept -> decltype(auto); @@ -106,8 +106,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template - requires(core::Is, vk::Result>) - STORMKIT_FORCE_INLINE auto vkCall(T& value, Func&& func_ref, Args&&...args) noexcept + requires(core::Is, vk::Result>) + STORMKIT_FORCE_INLINE auto vkCall(T& value, Func&& func_ref, Args&&... args) noexcept -> VulkanExpected { return vkCall(value, std::forward(func_ref), @@ -118,11 +118,11 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template - requires(core::Is, vk::Result>) - STORMKIT_FORCE_INLINE auto vkCall(T & value, - Func && func_ref, + requires(core::Is, vk::Result>) + STORMKIT_FORCE_INLINE auto vkCall(T& value, + Func&& func_ref, std::span possible_results, - Args&&...args) noexcept -> VulkanExpected { + Args&&... args) noexcept -> VulkanExpected { auto func = std::mem_fn(std::forward(func_ref)); const auto result = func(value, std::forward(args)...); diff --git a/modules/stormkit/Log/ConsoleLogger.mpp b/modules/stormkit/Log/ConsoleLogger.mpp index 0e5eb1ec..494336ce 100644 --- a/modules/stormkit/Log/ConsoleLogger.mpp +++ b/modules/stormkit/Log/ConsoleLogger.mpp @@ -23,7 +23,7 @@ export namespace stormkit::log { ~ConsoleLogger() override; - auto write(Severity severity, const Module& module, const char *string) -> void override; + auto write(Severity severity, const Module& module, const char* string) -> void override; auto flush() noexcept -> void override; }; } // namespace stormkit::log diff --git a/modules/stormkit/Log/FileLogger.mpp b/modules/stormkit/Log/FileLogger.mpp index ff9b750c..b0f55ca2 100644 --- a/modules/stormkit/Log/FileLogger.mpp +++ b/modules/stormkit/Log/FileLogger.mpp @@ -28,7 +28,7 @@ export namespace stormkit::log { FileLogger(FileLogger&&); auto operator=(FileLogger&&) -> FileLogger&; - auto write(Severity severity, const Module& module, const char *string) -> void override; + auto write(Severity severity, const Module& module, const char* string) -> void override; auto flush() -> void override; private: diff --git a/modules/stormkit/Log/Logger.mpp b/modules/stormkit/Log/Logger.mpp index 59761360..a2d5ef80 100644 --- a/modules/stormkit/Log/Logger.mpp +++ b/modules/stormkit/Log/Logger.mpp @@ -25,7 +25,7 @@ export namespace stormkit::log { Logger(LogClock::time_point start, Severity log_level) noexcept; virtual ~Logger(); - virtual auto write(Severity severity, const Module& module, const char *string) -> void = 0; + virtual auto write(Severity severity, const Module& module, const char* string) -> void = 0; virtual auto flush() -> void = 0; auto setLogLevel(Severity log_level) noexcept -> void; @@ -34,35 +34,36 @@ export namespace stormkit::log { [[nodiscard]] auto logLevel() const noexcept -> const Severity&; template - [[nodiscard]] static auto createLoggerInstance(Args&&...param_args) -> T; + [[nodiscard]] static auto createLoggerInstance(Args&&... param_args) -> T; template - [[nodiscard]] static auto allocateLoggerInstance(Args&&...param_args) -> std::unique_ptr; + [[nodiscard]] static auto allocateLoggerInstance(Args&&... param_args) + -> std::unique_ptr; template static auto log(Severity severity, - const Module & module, + const Module& module, std::string_view format_string, - Args&&...param_args) -> void; + Args&&... param_args) -> void; template - static auto log(Severity severity, std::string_view format_string, Args&&...param_args) + static auto log(Severity severity, std::string_view format_string, Args&&... param_args) -> void; template - static auto dlog(Args&&...param_args) -> void; + static auto dlog(Args&&... param_args) -> void; template - static auto ilog(Args&&...param_args) -> void; + static auto ilog(Args&&... param_args) -> void; template - static auto wlog(Args&&...param_args) -> void; + static auto wlog(Args&&... param_args) -> void; template - static auto elog(Args&&...param_args) -> void; + static auto elog(Args&&... param_args) -> void; template - static auto flog(Args&&...param_args) -> void; + static auto flog(Args&&... param_args) -> void; [[nodiscard]] static auto hasLogger() noexcept -> bool; [[nodiscard]] static auto instance() noexcept -> Logger&; @@ -74,19 +75,19 @@ export namespace stormkit::log { struct Module { template - auto dlog(Args&&...args) const -> void; + auto dlog(Args&&... args) const -> void; template - auto ilog(Args&&...args) const -> void; + auto ilog(Args&&... args) const -> void; template - auto wlog(Args&&...args) const -> void; + auto wlog(Args&&... args) const -> void; template - auto elog(Args&&...args) const -> void; + auto elog(Args&&... args) const -> void; template - auto flog(Args&&...args) const -> void; + auto flog(Args&&... args) const -> void; auto flush() const -> void; @@ -123,7 +124,7 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::createLoggerInstance(Args&&...param_args) -> T { + STORMKIT_FORCE_INLINE auto Logger::createLoggerInstance(Args&&... param_args) -> T { using LogClock = std::chrono::high_resolution_clock; static_assert(std::is_base_of::value, "T must inherit Logger"); @@ -135,7 +136,7 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::allocateLoggerInstance(Args&&...param_args) + STORMKIT_FORCE_INLINE auto Logger::allocateLoggerInstance(Args&&... param_args) -> std::unique_ptr { using LogClock = std::chrono::high_resolution_clock; static_assert(std::is_base_of::value, "T must inherit Logger"); @@ -149,9 +150,9 @@ namespace stormkit::log { //////////////////////////////////////// template STORMKIT_FORCE_INLINE auto Logger::log(Severity severity, - const Module & m, + const Module& m, std::string_view format_string, - Args&&...param_args) -> void { + Args&&... param_args) -> void { core::expects(hasLogger()); const auto format = format_string; @@ -168,77 +169,77 @@ namespace stormkit::log { template STORMKIT_FORCE_INLINE auto Logger::log(Severity severity, std::string_view format_string, - Args&&...param_args) -> void { + Args&&... param_args) -> void { log(severity, Module {}, format_string, std::forward(param_args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::dlog(Args&&...param_args) -> void { + STORMKIT_FORCE_INLINE auto Logger::dlog(Args&&... param_args) -> void { log(Severity::Debug, std::forward(param_args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::ilog(Args&&...param_args) -> void { + STORMKIT_FORCE_INLINE auto Logger::ilog(Args&&... param_args) -> void { log(Severity::Info, std::forward(param_args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::wlog(Args&&...param_args) -> void { + STORMKIT_FORCE_INLINE auto Logger::wlog(Args&&... param_args) -> void { log(Severity::Warning, std::forward(param_args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::elog(Args&&...param_args) -> void { + STORMKIT_FORCE_INLINE auto Logger::elog(Args&&... param_args) -> void { log(Severity::Error, std::forward(param_args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Logger::flog(Args&&...param_args) -> void { + STORMKIT_FORCE_INLINE auto Logger::flog(Args&&... param_args) -> void { log(Severity::Fatal, std::forward(param_args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Module::dlog(Args&&...args) const -> void { + STORMKIT_FORCE_INLINE auto Module::dlog(Args&&... args) const -> void { Logger::dlog(*this, std::forward(args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Module::ilog(Args&&...args) const -> void { + STORMKIT_FORCE_INLINE auto Module::ilog(Args&&... args) const -> void { Logger::ilog(*this, std::forward(args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Module::wlog(Args&&...args) const -> void { + STORMKIT_FORCE_INLINE auto Module::wlog(Args&&... args) const -> void { Logger::wlog(*this, std::forward(args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Module::elog(Args&&...args) const -> void { + STORMKIT_FORCE_INLINE auto Module::elog(Args&&... args) const -> void { Logger::elog(*this, std::forward(args)...); } //////////////////////////////////////// //////////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Module::flog(Args&&...args) const -> void { + STORMKIT_FORCE_INLINE auto Module::flog(Args&&... args) const -> void { Logger::flog(*this, std::forward(args)...); } diff --git a/modules/stormkit/Wsi/Types.mpp b/modules/stormkit/Wsi/Types.mpp index 30fb377e..fbc66c02 100644 --- a/modules/stormkit/Wsi/Types.mpp +++ b/modules/stormkit/Wsi/Types.mpp @@ -27,7 +27,7 @@ export { Switch, }; - using NativeHandle = void *; + using NativeHandle = void*; enum class Key : core::UInt8 { A = 0, @@ -160,7 +160,7 @@ export { std::vector extents; - void *handle = nullptr; + void* handle = nullptr; [[nodiscard]] constexpr auto operator<=>(const Monitor& other) const noexcept -> std::strong_ordering; @@ -283,7 +283,7 @@ export { [[nodiscard]] constexpr auto toString(Key value) -> std::string; [[nodiscard]] constexpr auto toStringView(Key value) noexcept -> std::string_view; // - [[nodiscard]] auto toString(const Monitor &flags) -> std::string; + [[nodiscard]] auto toString(const Monitor& flags) -> std::string; [[nodiscard]] constexpr auto toString(Monitor::Flags flags) -> std::string; [[nodiscard]] constexpr auto toStringView(Monitor::Flags flags) noexcept -> std::string_view; diff --git a/modules/stormkit/Wsi/Window.mpp b/modules/stormkit/Wsi/Window.mpp index 36d9c0da..947db4dc 100644 --- a/modules/stormkit/Wsi/Window.mpp +++ b/modules/stormkit/Wsi/Window.mpp @@ -61,7 +61,7 @@ export namespace stormkit::wsi { auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; static auto setMousePositionOnDesktop(const core::math::Vector2U& position) noexcept -> void; diff --git a/src/Core/DynamicLoader.cpp b/src/Core/DynamicLoader.cpp index a542d839..cf9b3373 100644 --- a/src/Core/DynamicLoader.cpp +++ b/src/Core/DynamicLoader.cpp @@ -45,7 +45,7 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - auto DynamicLoader::doGetFunc(std::string_view name) const -> Expected { + auto DynamicLoader::doGetFunc(std::string_view name) const -> Expected { return m_impl->doGetFunc(name); } } // namespace stormkit::core diff --git a/src/Core/darwin/ThreadUtils.cpp b/src/Core/darwin/ThreadUtils.cpp index d9867cd1..f8007e6d 100644 --- a/src/Core/darwin/ThreadUtils.cpp +++ b/src/Core/darwin/ThreadUtils.cpp @@ -25,7 +25,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - auto setThreadName([[maybe_unused]] std::jthread & thread, + auto setThreadName([[maybe_unused]] std::jthread& thread, [[maybe_unused]] std::string_view name) -> void { // auto id = thread.native_handle(); // details::setThreadName(id, name); diff --git a/src/Core/darwin/ThreadUtilsImpl.h b/src/Core/darwin/ThreadUtilsImpl.h index 59029274..2f881454 100644 --- a/src/Core/darwin/ThreadUtilsImpl.h +++ b/src/Core/darwin/ThreadUtilsImpl.h @@ -1,13 +1,13 @@ #ifndef STORMKIT_CORE_THREAD_UTILS_H #define STORMKIT_CORE_THREAD_UTILS_H -#ifdef __OBJC__ +#ifdef __OBJC__ @class NSThread; #else typedef void NSThread; #endif -void setThreadName(NSThread *id, const char *name); -void setCurrentThreadName(const char *name); +void setThreadName(NSThread* id, const char* name); +void setCurrentThreadName(const char* name); #endif diff --git a/src/Core/darwin/ThreadUtilsImpl.m b/src/Core/darwin/ThreadUtilsImpl.m index 0304a00b..cedb6f36 100644 --- a/src/Core/darwin/ThreadUtilsImpl.m +++ b/src/Core/darwin/ThreadUtilsImpl.m @@ -1,12 +1,12 @@ #import "ThreadUtilsImpl.h" -#import #import +#import //////////////////////////////////////// //////////////////////////////////////// void setThreadName(NSThread *id, const char *name) { - [id setName: [NSString stringWithCString: name]]; + [id setName:[NSString stringWithCString:name]]; } //////////////////////////////////////// diff --git a/src/Core/posix/DynamicLoader.mpp b/src/Core/posix/DynamicLoader.mpp index 1d00986b..62598f28 100644 --- a/src/Core/posix/DynamicLoader.mpp +++ b/src/Core/posix/DynamicLoader.mpp @@ -74,7 +74,7 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto doGetFunc(std::string_view name) const -> Expected { + STORMKIT_FORCE_INLINE auto doGetFunc(std::string_view name) const -> Expected { core::expects(m_library_handle); auto func = ::dlsym(m_library_handle, std::data(name)); @@ -86,6 +86,6 @@ export namespace stormkit::core { } private: - void *m_library_handle = nullptr; + void* m_library_handle = nullptr; }; } // namespace stormkit::core diff --git a/src/Core/win32/DynamicLoader.mpp b/src/Core/win32/DynamicLoader.mpp index bb1b4610..edb748a6 100644 --- a/src/Core/win32/DynamicLoader.mpp +++ b/src/Core/win32/DynamicLoader.mpp @@ -75,7 +75,7 @@ export namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto doGetFunc(std::string_view name) const -> Expected { + STORMKIT_FORCE_INLINE auto doGetFunc(std::string_view name) const -> Expected { core::expects(m_library_handle); auto func = ::GetProcAddress(m_library_handle, std::data(name)); diff --git a/src/Core/win32/ThreadUtils.cpp b/src/Core/win32/ThreadUtils.cpp index 9885e2d4..822ad023 100644 --- a/src/Core/win32/ThreadUtils.cpp +++ b/src/Core/win32/ThreadUtils.cpp @@ -31,7 +31,7 @@ namespace stormkit::core { RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), - reinterpret_cast(&info)); + reinterpret_cast(&info)); } __except (EXCEPTION_EXECUTE_HANDLER) {} } } // namespace details diff --git a/src/Engine/Renderer/BakedFrameGraph.cpp b/src/Engine/Renderer/BakedFrameGraph.cpp index 6324a279..54beb915 100644 --- a/src/Engine/Renderer/BakedFrameGraph.cpp +++ b/src/Engine/Renderer/BakedFrameGraph.cpp @@ -15,9 +15,9 @@ import :Renderer.BakedFrameGraph; namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - BakedFrameGraph::BakedFrameGraph(const FrameGraphBuilder & builder, - Data && data, - [[maybe_unused]] BakedFrameGraph *old) + BakedFrameGraph::BakedFrameGraph(const FrameGraphBuilder& builder, + Data&& data, + [[maybe_unused]] BakedFrameGraph* old) : m_builder { &builder }, m_data { std::move(data) } { } diff --git a/src/Engine/Renderer/FrameGraphBuilder.cpp b/src/Engine/Renderer/FrameGraphBuilder.cpp index 38f9ca2c..0c014fd1 100644 --- a/src/Engine/Renderer/FrameGraphBuilder.cpp +++ b/src/Engine/Renderer/FrameGraphBuilder.cpp @@ -33,7 +33,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - auto FrameGraphBuilder::createFrameGraph(const gpu::Device& device, BakedFrameGraph *old) + auto FrameGraphBuilder::createFrameGraph(const gpu::Device& device, BakedFrameGraph* old) -> BakedFrameGraph { auto data = allocatePhysicalResources(device); @@ -42,7 +42,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// - auto FrameGraphBuilder::allocateFrameGraph(const gpu::Device& device, BakedFrameGraph *old) + auto FrameGraphBuilder::allocateFrameGraph(const gpu::Device& device, BakedFrameGraph* old) -> std::unique_ptr { auto data = allocatePhysicalResources(device); @@ -54,7 +54,7 @@ namespace stormkit::engine { auto FrameGraphBuilder::prepareTask(GraphTask& task) noexcept -> void { auto task_builder = GraphTaskBuilder { task, *this }; auto data = m_datas[task.dataID()]; - task.onSetup(*std::bit_cast(&data), task_builder); + task.onSetup(*std::bit_cast(&data), task_builder); } ///////////////////////////////////// @@ -209,7 +209,7 @@ namespace stormkit::engine { ///////////////////////////////////// ///////////////////////////////////// auto FrameGraphBuilder::buildRenderPassPhysicalDescription( - const GraphTask & task, + const GraphTask& task, core::HashMap& layouts) noexcept -> RenderPassData { auto to_remove = std::vector {}; diff --git a/src/Gpu/Core/Device.cpp b/src/Gpu/Core/Device.cpp index 942d0bd7..475e36eb 100644 --- a/src/Gpu/Core/Device.cpp +++ b/src/Gpu/Core/Device.cpp @@ -49,8 +49,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// Device::Device(const PhysicalDevice& physical_device, - const Instance & instance, - const Info & info, + const Instance& instance, + const Info& info, Tag) : InstanceObject { instance }, m_physical_device { &physical_device } { const auto& queue_families = m_physical_device->queueFamilies(); @@ -97,7 +97,7 @@ namespace stormkit::gpu { }(); const auto queues = [&] { - auto q = std::vector {}; + auto q = std::vector {}; q.reserve(3); if (raster_queue.id) q.push_back(&raster_queue); @@ -179,11 +179,11 @@ namespace stormkit::gpu { const auto acceleration_feature = vk::PhysicalDeviceAccelerationStructureFeaturesKHR {}; const auto rt_pipeline_feature = vk::PhysicalDeviceRayTracingPipelineFeaturesKHR {}.setPNext( - std::bit_cast(&acceleration_feature)); + std::bit_cast(&acceleration_feature)); - const auto next = [&]() -> void * { + const auto next = [&]() -> void* { if (raytracing_available and info.enable_raytracing) - return std::bit_cast(&rt_pipeline_feature); + return std::bit_cast(&rt_pipeline_feature); return nullptr; }(); @@ -225,7 +225,7 @@ namespace stormkit::gpu { ///////////////////////////////////// auto Device::waitForFences(std::span> fences, bool wait_all, - const std::chrono::milliseconds & timeout) const noexcept + const std::chrono::milliseconds& timeout) const noexcept -> Expected { const auto vk_fences = fences | std::views::transform(toVkHandle()) | std::ranges::to(); diff --git a/src/Gpu/Core/Instance.cpp b/src/Gpu/Core/Instance.cpp index 73cb7595..ca639a8c 100644 --- a/src/Gpu/Core/Instance.cpp +++ b/src/Gpu/Core/Instance.cpp @@ -62,7 +62,7 @@ namespace stormkit::gpu { auto debugCallback(vk::DebugUtilsMessageSeverityFlagsEXT severity, vk::DebugUtilsMessageTypeFlagsEXT type, const vk::DebugUtilsMessengerCallbackDataEXT& callback_data, - [[maybe_unused]] void *user_data) -> bool { + [[maybe_unused]] void* user_data) -> bool { auto message = std::format("[{}] {}", vk::to_string(severity), callback_data.pMessage); if (checkFlag(severity, vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo)) ilog(message); @@ -135,7 +135,7 @@ namespace stormkit::gpu { m_vk_context = vk::raii::Context(); const auto exts = m_vk_context->enumerateInstanceExtensionProperties(); - m_extensions = exts | std::views::transform([](auto &&extension) noexcept { + m_extensions = exts | std::views::transform([](auto&& extension) noexcept { return std::string { extension.extensionName }; }) | std::ranges::to(); diff --git a/src/Gpu/Core/PhysicalDevice.cpp b/src/Gpu/Core/PhysicalDevice.cpp index 3de5a61a..3a7a5395 100644 --- a/src/Gpu/Core/PhysicalDevice.cpp +++ b/src/Gpu/Core/PhysicalDevice.cpp @@ -29,7 +29,7 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// PhysicalDevice::PhysicalDevice(vk::raii::PhysicalDevice physical_device, - const Instance & instance) + const Instance& instance) : InstanceObject { instance }, m_vk_physical_device { std::move(physical_device) } { const auto properties = m_vk_physical_device.getProperties(); const auto features = m_vk_physical_device.getFeatures(); diff --git a/src/Gpu/Execution/Pipeline.cpp b/src/Gpu/Execution/Pipeline.cpp index 55a2cec5..fc0a8409 100644 --- a/src/Gpu/Execution/Pipeline.cpp +++ b/src/Gpu/Execution/Pipeline.cpp @@ -18,8 +18,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// auto Pipeline::doInitRasterPipeline( - const PipelineLayout & layout, - const RenderPass & render_pass, + const PipelineLayout& layout, + const RenderPass& render_pass, std::optional> pipeline_cache) noexcept -> VulkanExpected { const auto& state = core::as(m_state); diff --git a/src/Gpu/Resource/Buffer.cpp b/src/Gpu/Resource/Buffer.cpp index 3e2f04f0..f85b1e53 100644 --- a/src/Gpu/Resource/Buffer.cpp +++ b/src/Gpu/Resource/Buffer.cpp @@ -54,7 +54,7 @@ namespace stormkit::gpu { ///////////////////////////////////// auto Buffer::findMemoryType(core::UInt type_filter, vk::MemoryPropertyFlags properties, - const vk::PhysicalDeviceMemoryProperties & mem_properties, + const vk::PhysicalDeviceMemoryProperties& mem_properties, [[maybe_unused]] const vk::MemoryRequirements& mem_requirements) -> core::UInt { for (auto i : core::range(mem_properties.memoryTypeCount)) { diff --git a/src/Image/HDRImage.mpp b/src/Image/HDRImage.mpp index a52533e8..15e952db 100644 --- a/src/Image/HDRImage.mpp +++ b/src/Image/HDRImage.mpp @@ -14,7 +14,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadHDR(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveHDR(const image::Image & image, + [[nodiscard]] auto saveHDR(const image::Image& image, const std::filesystem::path& filepath) noexcept -> std::expected; diff --git a/src/Image/Image.cpp b/src/Image/Image.cpp index 0f49839b..f2169ab4 100644 --- a/src/Image/Image.cpp +++ b/src/Image/Image.cpp @@ -107,8 +107,8 @@ namespace stormkit::image { data.resize(std::size(bytes) * destination_count); if (source_count == 1u and destination_count == 2u) { - const auto input_it = std::bit_cast(std::data(data)); - auto output_it = std::bit_cast(std::data(data)); + const auto input_it = std::bit_cast(std::data(data)); + auto output_it = std::bit_cast(std::data(data)); for (auto i : core::range(std::size(bytes))) output_it[i] = core::map(input_it[i], @@ -117,8 +117,8 @@ namespace stormkit::image { BYTE_2_MIN, BYTE_2_MAX); } else if (source_count == 1u and destination_count == 4u) { - const auto input_it = std::bit_cast(std::data(data)); - auto output_it = std::bit_cast(std::data(data)); + const auto input_it = std::bit_cast(std::data(data)); + auto output_it = std::bit_cast(std::data(data)); for (auto i : core::range(std::size(bytes))) output_it[i] = core::map(input_it[i], @@ -127,8 +127,8 @@ namespace stormkit::image { BYTE_4_MIN, BYTE_4_MAX); } else if (source_count == 2u and destination_count == 1u) { - const auto input_it = std::bit_cast(std::data(data)); - auto output_it = std::bit_cast(std::data(data)); + const auto input_it = std::bit_cast(std::data(data)); + auto output_it = std::bit_cast(std::data(data)); for (auto i : core::range(std::size(bytes))) output_it[i] = core::map(input_it[i], @@ -137,8 +137,8 @@ namespace stormkit::image { BYTE_1_MIN, BYTE_1_MAX); } else if (source_count == 2u and destination_count == 4u) { - const auto input_it = std::bit_cast(std::data(data)); - auto output_it = std::bit_cast(std::data(data)); + const auto input_it = std::bit_cast(std::data(data)); + auto output_it = std::bit_cast(std::data(data)); for (auto i : core::range(std::size(bytes))) output_it[i] = core::map(input_it[i], @@ -147,8 +147,8 @@ namespace stormkit::image { BYTE_4_MIN, BYTE_4_MAX); } else if (source_count == 4u and destination_count == 1u) { - const auto input_it = std::bit_cast(std::data(data)); - auto output_it = std::bit_cast(std::data(data)); + const auto input_it = std::bit_cast(std::data(data)); + auto output_it = std::bit_cast(std::data(data)); for (auto i : core::range(std::size(bytes))) output_it[i] = core::map(input_it[i], @@ -157,8 +157,8 @@ namespace stormkit::image { BYTE_1_MIN, BYTE_1_MAX); } else if (source_count == 4u and destination_count == 2u) { - const auto input_it = std::bit_cast(std::data(data)); - auto output_it = std::bit_cast(std::data(data)); + const auto input_it = std::bit_cast(std::data(data)); + auto output_it = std::bit_cast(std::data(data)); for (auto i : core::range(std::size(bytes))) output_it[i] = core::map(input_it[i], diff --git a/src/Image/JPEGImage.mpp b/src/Image/JPEGImage.mpp index 1c9849d1..100a788c 100644 --- a/src/Image/JPEGImage.mpp +++ b/src/Image/JPEGImage.mpp @@ -26,7 +26,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadJPG(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveJPG(const image::Image & image, + [[nodiscard]] auto saveJPG(const image::Image& image, const std::filesystem::path& filepath) noexcept -> std::expected; @@ -49,10 +49,10 @@ namespace stormkit::image::details { ///////////////////////////////////// ///////////////////////////////////// - auto error_callback(jpeg_common_struct *st) noexcept -> void { + auto error_callback(jpeg_common_struct* st) noexcept -> void { core::expects(st != nullptr); - auto error_data = reinterpret_cast(st->client_data); + auto error_data = reinterpret_cast(st->client_data); auto message = std::string {}; message.resize(JMSG_STR_PARM_MAX); @@ -88,7 +88,7 @@ namespace stormkit::image::details { } jpeg_mem_src(&info, - reinterpret_cast(std::data(data)), + reinterpret_cast(std::data(data)), std::size(data)); jpeg_read_header(&info, TRUE); @@ -103,7 +103,7 @@ namespace stormkit::image::details { image_memory.resize(extent.width * extent.height * extent.depth * info.out_color_components); - auto row_ptr = std::array { nullptr }; + auto row_ptr = std::array { nullptr }; while (info.output_scanline < info.output_height) { const auto index = extent.width * info.output_components * info.output_scanline; row_ptr[0] = std::data(image_memory) + index; @@ -180,7 +180,7 @@ namespace stormkit::image::details { jpeg_start_compress(&info, TRUE); - auto row_ptr = std::array { nullptr }; + auto row_ptr = std::array { nullptr }; while (info.next_scanline < info.image_height) { const auto index = info.next_scanline * 3u * info.image_width; row_ptr[0] = std::data(data) + index; @@ -208,7 +208,7 @@ namespace stormkit::image::details { ///////////////////////////////////// auto saveJPG(const image::Image& image) noexcept -> std::expected, image::Image::Error> { - using uchar_ptr = unsigned char *; + using uchar_ptr = unsigned char*; auto output_ptr = uchar_ptr { nullptr }; @@ -241,7 +241,7 @@ namespace stormkit::image::details { jpeg_start_compress(&info, TRUE); - auto row_ptr = std::array { nullptr }; + auto row_ptr = std::array { nullptr }; while (info.next_scanline < info.image_height) { const auto index = info.next_scanline * 3u * info.image_width; row_ptr[0] = std::data(data) + index; diff --git a/src/Image/KTXImage.mpp b/src/Image/KTXImage.mpp index 4fd0df92..f506bdf3 100644 --- a/src/Image/KTXImage.mpp +++ b/src/Image/KTXImage.mpp @@ -23,7 +23,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadKTX(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveKTX(const image::Image & image, + [[nodiscard]] auto saveKTX(const image::Image& image, const std::filesystem::path& filepath) noexcept -> std::expected; @@ -109,8 +109,7 @@ namespace stormkit::image::details { ///////////////////////////////////// auto loadKTX(std::span data) noexcept -> std::expected { - auto image = - gli::load_ktx(reinterpret_cast(std::data(data)), std::size(data)); + auto image = gli::load_ktx(reinterpret_cast(std::data(data)), std::size(data)); const auto faces = core::as(image.faces()); const auto layers = core::as(image.layers()); diff --git a/src/Image/PNGImage.mpp b/src/Image/PNGImage.mpp index a94ac14c..471bf41d 100644 --- a/src/Image/PNGImage.mpp +++ b/src/Image/PNGImage.mpp @@ -21,7 +21,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadPNG(std::span data) noexcept -> std::expected; - [[nodiscard]] auto savePNG(const image::Image & image, + [[nodiscard]] auto savePNG(const image::Image& image, const std::filesystem::path& filepath) noexcept -> std::expected; @@ -48,8 +48,8 @@ namespace stormkit::image::details { ///////////////////////////////////// ///////////////////////////////////// - static auto read_func(png_struct *ps, png_byte *d, png_size_t length) noexcept -> void { - auto& param = *reinterpret_cast(png_get_io_ptr(ps)); + static auto read_func(png_struct* ps, png_byte* d, png_size_t length) noexcept -> void { + auto& param = *reinterpret_cast(png_get_io_ptr(ps)); auto _d = core::asByteView(d, length); auto data = param.data.subspan(param.readed, length); @@ -61,8 +61,8 @@ namespace stormkit::image::details { ///////////////////////////////////// ///////////////////////////////////// - static auto write_func(png_struct *ps, png_byte *d, png_size_t length) -> void { - auto& param = *reinterpret_cast(png_get_io_ptr(ps)); + static auto write_func(png_struct* ps, png_byte* d, png_size_t length) -> void { + auto& param = *reinterpret_cast(png_get_io_ptr(ps)); auto _d = core::asByteView(d, length); param.data.reserve(std::size(param.data) + length); @@ -181,7 +181,7 @@ namespace stormkit::image::details { const auto row_bytes = png_get_rowbytes(png_ptr, info_ptr); image_memory.resize(extent.height * row_bytes); - auto row_pointers = std::vector { extent.height, nullptr }; + auto row_pointers = std::vector { extent.height, nullptr }; auto buff_pos = std::data(image_memory); @@ -264,11 +264,11 @@ namespace stormkit::image::details { PNG_FILTER_TYPE_DEFAULT); png_write_info(png_ptr, info_ptr); - auto rows = std::vector { data.extent.height, nullptr }; + auto rows = std::vector { data.extent.height, nullptr }; for (auto i : core::range(data.extent.height)) rows[i] = - const_cast(&data.data[i * data.extent.width * data.channel_count * - data.bytes_per_channel]); // TODO Fix this shit + const_cast(&data.data[i * data.extent.width * data.channel_count * + data.bytes_per_channel]); // TODO Fix this shit png_set_rows(png_ptr, info_ptr, reinterpret_cast(std::data(rows))); png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, nullptr); diff --git a/src/Image/PPMImage.mpp b/src/Image/PPMImage.mpp index 0402da64..e09b77c8 100644 --- a/src/Image/PPMImage.mpp +++ b/src/Image/PPMImage.mpp @@ -14,7 +14,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadPPM(std::span data) noexcept -> std::expected; - [[nodiscard]] auto savePPM(const image::Image & image, + [[nodiscard]] auto savePPM(const image::Image& image, image::Image::CodecArgs args, const std::filesystem::path& filepath) noexcept -> std::expected; @@ -42,7 +42,7 @@ namespace stormkit::image::details { ///////////////////////////////////// ///////////////////////////////////// - auto savePPM(const image::Image & image, + auto savePPM(const image::Image& image, image::Image::CodecArgs args, const std::filesystem::path& filepath) noexcept -> std::expected { diff --git a/src/Image/QOIImage.mpp b/src/Image/QOIImage.mpp index ee388d53..efb3fbbd 100644 --- a/src/Image/QOIImage.mpp +++ b/src/Image/QOIImage.mpp @@ -16,7 +16,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadQOI(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveQOI(const image::Image & image, + [[nodiscard]] auto saveQOI(const image::Image& image, const std::filesystem::path& filepath) noexcept -> std::expected; @@ -89,7 +89,7 @@ namespace stormkit::image::details { auto loadQOI([[maybe_unused]] std::span data) noexcept -> std::expected { const auto raw_header = std::span { std::data(data), SIZE_OF_HEADER }; - const auto *header = std::bit_cast(std::data(raw_header)); + const auto* header = std::bit_cast(std::data(raw_header)); const auto extent = core::math::ExtentU { core::byteSwap(header->width), core::byteSwap(header->height) }; @@ -99,7 +99,7 @@ namespace stormkit::image::details { auto pixel_cache = std::array {}; const auto chunks = - std::span { std::bit_cast(std::data(data)) + SIZE_OF_HEADER, + std::span { std::bit_cast(std::data(data)) + SIZE_OF_HEADER, std::size(data) - SIZE_OF_HEADER }; const auto output_size = extent.width * extent.height * channels; diff --git a/src/Image/TARGAImage.mpp b/src/Image/TARGAImage.mpp index 7b9ea796..fb809f5c 100644 --- a/src/Image/TARGAImage.mpp +++ b/src/Image/TARGAImage.mpp @@ -14,7 +14,7 @@ export namespace stormkit::image::details { [[nodiscard]] auto loadTGA(std::span data) noexcept -> std::expected; - [[nodiscard]] auto saveTGA(const image::Image & image, + [[nodiscard]] auto saveTGA(const image::Image& image, const std::filesystem::path& filepath) noexcept -> std::expected; diff --git a/src/Log/ConsoleLogger.cpp b/src/Log/ConsoleLogger.cpp index 7109f25b..20fbbcf2 100644 --- a/src/Log/ConsoleLogger.cpp +++ b/src/Log/ConsoleLogger.cpp @@ -36,7 +36,7 @@ namespace stormkit::log { //////////////////////////////////////// //////////////////////////////////////// - auto ConsoleLogger::write(Severity severity, const Module& m, const char *string) -> void { + auto ConsoleLogger::write(Severity severity, const Module& m, const char* string) -> void { const auto now = LogClock::now(); const auto time = std::chrono::duration_cast(now - m_start_time); diff --git a/src/Log/FileLogger.cpp b/src/Log/FileLogger.cpp index 51576801..f026fe00 100644 --- a/src/Log/FileLogger.cpp +++ b/src/Log/FileLogger.cpp @@ -67,7 +67,7 @@ namespace stormkit::log { //////////////////////////////////////// auto FileLogger::write([[maybe_unused]] Severity severity, [[maybe_unused]] const Module& m, - [[maybe_unused]] const char *string) -> void { + [[maybe_unused]] const char* string) -> void { const auto now = LogClock::now(); const auto time = std::chrono::duration_cast(now - m_start_time).count(); diff --git a/src/Log/Logger.cpp b/src/Log/Logger.cpp index 6c31b7a2..d2aa0b1f 100644 --- a/src/Log/Logger.cpp +++ b/src/Log/Logger.cpp @@ -19,7 +19,7 @@ namespace stormkit::log { #else constexpr auto DEFAULT_SEVERITY = Severity::Info | Severity::Error | Severity::Fatal; #endif - Logger *logger = nullptr; + Logger* logger = nullptr; } // namespace ///////////////////////////////////// diff --git a/src/Main/linux/Main-linux.cpp b/src/Main/linux/Main-linux.cpp index c6ead517..ab46b916 100644 --- a/src/Main/linux/Main-linux.cpp +++ b/src/Main/linux/Main-linux.cpp @@ -7,7 +7,7 @@ import stormkit.Core; extern auto userMain(std::span) -> int; -auto main(int argc, char **argv) -> int { +auto main(int argc, char** argv) -> int { auto args = std::vector {}; for (auto i : stormkit::core::range(argc)) args.emplace_back(argv[i]); diff --git a/src/Main/macOS/Main-macOS.mm b/src/Main/macOS/Main-macOS.mm index 426253c7..b41489c8 100644 --- a/src/Main/macOS/Main-macOS.mm +++ b/src/Main/macOS/Main-macOS.mm @@ -1,9 +1,9 @@ #import #import +#include #include #include -#include extern auto userMain(std::span) -> int; diff --git a/src/Main/win32/Main-win.cpp b/src/Main/win32/Main-win.cpp index 47994231..48aa6064 100644 --- a/src/Main/win32/Main-win.cpp +++ b/src/Main/win32/Main-win.cpp @@ -18,7 +18,7 @@ namespace { extern auto userMain(std::span) -> int; -auto __stdcall main(int argc, char **argv) -> int { +auto __stdcall main(int argc, char** argv) -> int { std::locale::global(std::locale { "" }); SetConsoleOutputCP(CP_UTF8); SetConsoleCP(CP_UTF8); diff --git a/src/Wsi/iOS/AppDelegate.hpp b/src/Wsi/iOS/AppDelegate.hpp index 007a4d11..241565ba 100644 --- a/src/Wsi/iOS/AppDelegate.hpp +++ b/src/Wsi/iOS/AppDelegate.hpp @@ -12,7 +12,7 @@ @interface AppDelegate: UIResponder -@property (nonatomic) storm::window::WindowImpl *window; +@property (nonatomic) storm::window::WindowImpl* window; @end diff --git a/src/Wsi/iOS/View.h b/src/Wsi/iOS/View.h index 59dd9e4f..af1f7ca1 100644 --- a/src/Wsi/iOS/View.h +++ b/src/Wsi/iOS/View.h @@ -5,11 +5,11 @@ #ifndef VIEW_H #define VIEW_H -#import +#import -@interface View : UIView +@interface View: UIView -- (id)initWithFrame: (CGRect)frame withScaleFactor: (CGFloat)factor; +- (id)initWithFrame:(CGRect)frame withScaleFactor:(CGFloat)factor; @end diff --git a/src/Wsi/iOS/ViewController.h b/src/Wsi/iOS/ViewController.h index 229dba36..a5f70b2b 100644 --- a/src/Wsi/iOS/ViewController.h +++ b/src/Wsi/iOS/ViewController.h @@ -7,8 +7,8 @@ #import -@interface ViewController : UIViewController -@property(nonatomic) BOOL hideStatusBar; +@interface ViewController: UIViewController +@property (nonatomic) BOOL hideStatusBar; @end #endif diff --git a/src/Wsi/iOS/WindowImpl.hpp b/src/Wsi/iOS/WindowImpl.hpp index 9970e55b..77ce8e3d 100644 --- a/src/Wsi/iOS/WindowImpl.hpp +++ b/src/Wsi/iOS/WindowImpl.hpp @@ -13,34 +13,34 @@ #ifdef __OBJC__ @class UIWindow; -using UIWindowPtr = UIWindow *; +using UIWindowPtr = UIWindow*; @class ViewController; -using ViewControllerPtr = ViewController *; +using ViewControllerPtr = ViewController*; @class View; -using ViewPtr = View *; +using ViewPtr = View*; #else -using UIWindowPtr = struct objc_class *; -using ViewControllerPtr = struct objc_class *; -using ViewPtr = struct objc_class *; +using UIWindowPtr = struct objc_class*; +using ViewControllerPtr = struct objc_class*; +using ViewPtr = struct objc_class*; #endif namespace storm::window { class STORMKIT_PRIVATE WindowImpl: public storm::window::AbstractWindow { public: WindowImpl() noexcept; - WindowImpl(const std::string & title, + WindowImpl(const std::string& title, const storm::window::VideoSettings& settings, storm::window::WindowStyle style) noexcept; ~WindowImpl() override; - void create(const std::string & title, + void create(const std::string& title, const storm::window::VideoSettings& settings, storm::window::WindowStyle style) noexcept override; void close() noexcept override; - bool pollEvent(storm::window::Event& event, void *native_event) noexcept override; - bool waitEvent(storm::window::Event & event, - [[maybe_unused]] void *native_event) noexcept override; + bool pollEvent(storm::window::Event& event, void* native_event) noexcept override; + bool waitEvent(storm::window::Event& event, + [[maybe_unused]] void* native_event) noexcept override; void setTitle(const std::string& title) noexcept override; void setVideoSettings(const storm::window::VideoSettings& settings) noexcept override; diff --git a/src/Wsi/iOS/iosMain.cpp b/src/Wsi/iOS/iosMain.cpp index a75db5aa..50a9d62a 100644 --- a/src/Wsi/iOS/iosMain.cpp +++ b/src/Wsi/iOS/iosMain.cpp @@ -2,7 +2,7 @@ #include -[[gnu::weak]] int iosMain(int argc, char **argv) { +[[gnu::weak]] int iosMain(int argc, char** argv) { return iosMain(); } diff --git a/src/Wsi/iOS/iosMain.hpp b/src/Wsi/iOS/iosMain.hpp index 9472046f..07611d4c 100644 --- a/src/Wsi/iOS/iosMain.hpp +++ b/src/Wsi/iOS/iosMain.hpp @@ -2,6 +2,6 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution -int iosMain(int argc, char **argv); +int iosMain(int argc, char** argv); int iosMain(); diff --git a/src/Wsi/linux/WindowImpl.mpp b/src/Wsi/linux/WindowImpl.mpp index 59da5e17..caf60030 100644 --- a/src/Wsi/linux/WindowImpl.mpp +++ b/src/Wsi/linux/WindowImpl.mpp @@ -61,7 +61,7 @@ export namespace stormkit::wsi::linux { auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; static auto setMousePositionOnDesktop(WM wm, const core::math::Vector2U& position) noexcept -> void; diff --git a/src/Wsi/linux/common/XKB.mpp b/src/Wsi/linux/common/XKB.mpp index 234b127f..13b43407 100644 --- a/src/Wsi/linux/common/XKB.mpp +++ b/src/Wsi/linux/common/XKB.mpp @@ -22,7 +22,7 @@ import :Types; #define STORMKIT_XKB_SCOPED(name, type) \ struct name##Scoped { \ name##Scoped() noexcept = default; \ - name##Scoped(type *handle) noexcept; \ + name##Scoped(type* handle) noexcept; \ ~name##Scoped() noexcept; \ \ name##Scoped(const name##Scoped&) = delete; \ @@ -31,12 +31,12 @@ import :Types; name##Scoped(name##Scoped&&) noexcept; \ auto operator=(name##Scoped&&) noexcept -> name##Scoped&; \ \ - operator type *() const noexcept { \ + operator type*() const noexcept { \ return m_handle; \ } \ \ private: \ - type *m_handle = nullptr; \ + type* m_handle = nullptr; \ } export namespace stormkit::wsi::linux::common { @@ -69,7 +69,7 @@ export namespace stormkit::wsi::linux::common { //////////////////////////////////////////////////////////////////// #define STORMKIT_XKB_SCOPED(name, type, var, global, deleter) \ - inline name##Scoped::name##Scoped(type *handle) noexcept : m_handle { handle } { \ + inline name##Scoped::name##Scoped(type* handle) noexcept : m_handle { handle } { \ if (m_handle != nullptr) var++; \ } \ \ @@ -98,7 +98,7 @@ export namespace stormkit::wsi::linux::common { } namespace stormkit::wsi::linux::common { - using XKBContextPtr = xkb_context *; + using XKBContextPtr = xkb_context*; IN_MODULE_LOGGER("StormKit.Wsi.Linux.XKB") @@ -118,7 +118,7 @@ namespace stormkit::wsi::linux::common { inline auto getXKBContext() noexcept -> XKBContextScoped { if (!xkb_context_instance) [[unlikely]] { xkb_context_instance = xkb_context_new(XKB_CONTEXT_NO_FLAGS); - dlog("New xkb context {}", std::bit_cast(xkb_context_instance)); + dlog("New xkb context {}", std::bit_cast(xkb_context_instance)); } core::ensures(xkb_context_instance); diff --git a/src/Wsi/linux/wayland/Callbacks.mpp b/src/Wsi/linux/wayland/Callbacks.mpp index 54082e46..ebbcc00f 100644 --- a/src/Wsi/linux/wayland/Callbacks.mpp +++ b/src/Wsi/linux/wayland/Callbacks.mpp @@ -21,61 +21,61 @@ import :Linux.Wayland.Log; namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto registryHandler(void *data, - wl_registry *registry, + auto registryHandler(void* data, + wl_registry* registry, core::UInt32 id, - const char *interface, + const char* interface, core::UInt32 version) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto registryRemoverHandler(void *data, wl_registry *registry, core::UInt32 id) noexcept + auto registryRemoverHandler(void* data, wl_registry* registry, core::UInt32 id) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto surfaceEnterHandler(void *data, wl_surface *surface, wl_output *output) noexcept -> void; + auto surfaceEnterHandler(void* data, wl_surface* surface, wl_output* output) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto surfaceLeaveHandler(void *data, wl_surface *surface, wl_output *output) noexcept -> void; + auto surfaceLeaveHandler(void* data, wl_surface* surface, wl_output* output) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto toplevelConfigureHandler(void *data, - xdg_toplevel *xdg_tl, + auto toplevelConfigureHandler(void* data, + xdg_toplevel* xdg_tl, core::Int32 width, core::Int32 height, - wl_array *states) noexcept -> void; + wl_array* states) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto toplevelCloseHandler(void *data, xdg_toplevel *xdg_tl) noexcept -> void; + auto toplevelCloseHandler(void* data, xdg_toplevel* xdg_tl) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto surfaceConfigureHandler(void *data, xdg_surface *surface, core::UInt32 serial) noexcept + auto surfaceConfigureHandler(void* data, xdg_surface* surface, core::UInt32 serial) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto shellPingHandler(void *data, xdg_wm_base *xdg_shell, core::UInt32 serial) noexcept -> void; + auto shellPingHandler(void* data, xdg_wm_base* xdg_shell, core::UInt32 serial) noexcept -> void; - auto shellSurfaceConfigureHandler(void *data, - wl_shell_surface *shell_surface, + auto shellSurfaceConfigureHandler(void* data, + wl_shell_surface* shell_surface, core::UInt32 edges, core::Int32 width, core::Int32 height) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto shellPingHandler(void *data, wl_shell_surface *shell_surface, core::UInt32 serial) noexcept + auto shellPingHandler(void* data, wl_shell_surface* shell_surface, core::UInt32 serial) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto relativePointerRelativeMotionHandler(void *data, - zwp_relative_pointer_v1 *pointer, + auto relativePointerRelativeMotionHandler(void* data, + zwp_relative_pointer_v1* pointer, core::UInt32 time_hi, core::UInt32 time_lw, wl_fixed_t dx, @@ -85,12 +85,12 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto lockedPointerLockedHandler(void *data, zwp_locked_pointer_v1 *locked_pointer) noexcept + auto lockedPointerLockedHandler(void* data, zwp_locked_pointer_v1* locked_pointer) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto lockedPointerUnlockedHandler(void *data, zwp_locked_pointer_v1 *locked_pointer) noexcept + auto lockedPointerUnlockedHandler(void* data, zwp_locked_pointer_v1* locked_pointer) noexcept -> void; } // namespace stormkit::wsi::linux::wayland diff --git a/src/Wsi/linux/wayland/Implementation.cpp b/src/Wsi/linux/wayland/Implementation.cpp index 4872526e..8d6fab68 100644 --- a/src/Wsi/linux/wayland/Implementation.cpp +++ b/src/Wsi/linux/wayland/Implementation.cpp @@ -29,21 +29,21 @@ import :Linux.Wayland.Log; namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto outputGeometryHandler(void *data, - wl_output *output, + auto outputGeometryHandler(void* data, + wl_output* output, core::Int32 x, core::Int32 y, core::Int32 pwidth, core::Int32 pheight, core::Int32 subpixels, - const char *make, - const char *model, + const char* make, + const char* model, core::Int32 transform) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto outputModeHandler(void *data, - wl_output *wl_output, + auto outputModeHandler(void* data, + wl_output* wl_output, core::UInt32 flags, core::Int32 width, core::Int32 height, @@ -51,49 +51,49 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto outputDoneHandler(void *data, wl_output *wl_output) noexcept -> void; + auto outputDoneHandler(void* data, wl_output* wl_output) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto outputScaleHandler(void *data, wl_output *wl_output, core::Int32 factor) noexcept -> void; + auto outputScaleHandler(void* data, wl_output* wl_output, core::Int32 factor) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto seatCapabilitiesHandler(void *data, wl_seat *seat, core::UInt32 capabilities) noexcept + auto seatCapabilitiesHandler(void* data, wl_seat* seat, core::UInt32 capabilities) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto seatNameHandler(void *data, wl_seat *seat, const char *name) noexcept -> void; + auto seatNameHandler(void* data, wl_seat* seat, const char* name) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerEnterHandler(void *data, - wl_pointer *pointer, + auto pointerEnterHandler(void* data, + wl_pointer* pointer, core::UInt32 serial, - wl_surface *surface, + wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerLeaveHandler(void *data, - wl_pointer *pointer, + auto pointerLeaveHandler(void* data, + wl_pointer* pointer, core::UInt32 serial, - wl_surface *surface) noexcept -> void; + wl_surface* surface) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerMotionHandler(void *data, - wl_pointer *pointer, + auto pointerMotionHandler(void* data, + wl_pointer* pointer, core::UInt32 time, wl_fixed_t surface_x, wl_fixed_t surface_y) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerButtonHandler(void *data, - wl_pointer *pointer, + auto pointerButtonHandler(void* data, + wl_pointer* pointer, core::UInt32 serial, core::UInt32 time, core::UInt32 button, @@ -101,63 +101,63 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisHandler(void *data, - wl_pointer *pointer, + auto pointerAxisHandler(void* data, + wl_pointer* pointer, core::UInt32 time, core::UInt32 axis, wl_fixed_t value) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerFrameHandler(void *data, wl_pointer *pointer) noexcept -> void; + auto pointerFrameHandler(void* data, wl_pointer* pointer) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisSourceHandler(void *data, - wl_pointer *pointer, + auto pointerAxisSourceHandler(void* data, + wl_pointer* pointer, core::UInt32 axis_source) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisStopHandler(void *data, - wl_pointer *pointer, + auto pointerAxisStopHandler(void* data, + wl_pointer* pointer, core::UInt32 time, core::UInt32 axis) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisDiscreteHandler(void *data, - wl_pointer *pointer, + auto pointerAxisDiscreteHandler(void* data, + wl_pointer* pointer, core::UInt32 axis, core::Int32 discrete) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto keyboardKeymapHandler(void *data, - wl_keyboard *keyboard, + auto keyboardKeymapHandler(void* data, + wl_keyboard* keyboard, core::UInt32 format, core::Int32 fd, core::UInt32 size) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto keyboardEnterHandler(void *data, - wl_keyboard *keyboard, + auto keyboardEnterHandler(void* data, + wl_keyboard* keyboard, core::UInt32 serial, - wl_surface *surface, - wl_array *keys) noexcept -> void; + wl_surface* surface, + wl_array* keys) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto keyboardLeaveHandler(void *data, - wl_keyboard *keyboard, + auto keyboardLeaveHandler(void* data, + wl_keyboard* keyboard, core::UInt32 serial, - wl_surface *surface) noexcept -> void; + wl_surface* surface) noexcept -> void; ///////////////////////////////////// ///////////////////////////////////// - auto keyboardKeyHandler(void *data, - wl_keyboard *keyboard, + auto keyboardKeyHandler(void* data, + wl_keyboard* keyboard, core::UInt32 serial, core::UInt32 time, core::UInt32 key, @@ -165,8 +165,8 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardModifiersHandler(void *data, - wl_keyboard *keyboard, + auto keyboardModifiersHandler(void* data, + wl_keyboard* keyboard, core::UInt32 serial, core::UInt32 mods_depressed, core::UInt32 mods_latcher, @@ -175,8 +175,8 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto keyboardRepeatInfoHandler(void *data, - wl_keyboard *keyboard, + auto keyboardRepeatInfoHandler(void* data, + wl_keyboard* keyboard, core::Int32 rate, core::Int32 delay) noexcept -> void; @@ -611,14 +611,14 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::surfaceOutputEnter([[maybe_unused]] wl_surface *surface, - wl_output *output) noexcept -> void { + auto WindowImpl::surfaceOutputEnter([[maybe_unused]] wl_surface* surface, + wl_output* output) noexcept -> void { m_current_output.reset(output); } ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::surfaceConfigure(xdg_surface *surface, std::uint32_t serial) noexcept -> void { + auto WindowImpl::surfaceConfigure(xdg_surface* surface, std::uint32_t serial) noexcept -> void { dlog("XDG surface configure, serial: {}", serial); xdg_surface_ack_configure(surface, serial); @@ -631,16 +631,16 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::toplevelConfigure([[maybe_unused]] xdg_toplevel *xdg_tl, + auto WindowImpl::toplevelConfigure([[maybe_unused]] xdg_toplevel* xdg_tl, std::int32_t width, std::int32_t height, - wl_array *state) noexcept -> void { + wl_array* state) noexcept -> void { dlog("XDG Shell configure: {}:{}", width, height); m_open = true; m_visible = width > 0 && height > 0; - auto data = static_cast(state->data); + auto data = static_cast(state->data); for (auto i : core::range(state->size)) { const auto state = data[i]; @@ -662,7 +662,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::toplevelClose([[maybe_unused]] xdg_toplevel *xdg_tl) noexcept -> void { + auto WindowImpl::toplevelClose([[maybe_unused]] xdg_toplevel* xdg_tl) noexcept -> void { m_open = false; m_visible = false; m_extent.width = 0; @@ -673,7 +673,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::shellSurfaceConfigure([[maybe_unused]] wl_shell_surface *xdg_tl, + auto WindowImpl::shellSurfaceConfigure([[maybe_unused]] wl_shell_surface* xdg_tl, [[maybe_unused]] std::uint32_t edges, std::int32_t width, std::int32_t height) noexcept -> void { @@ -690,16 +690,16 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::seatCapabilities([[maybe_unused]] wl_seat *seat, + auto WindowImpl::seatCapabilities([[maybe_unused]] wl_seat* seat, [[maybe_unused]] std::uint32_t capabilities) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::pointerEnter([[maybe_unused]] wl_pointer *pointer, + auto WindowImpl::pointerEnter([[maybe_unused]] wl_pointer* pointer, std::uint32_t serial, - [[maybe_unused]] wl_surface *surface, + [[maybe_unused]] wl_surface* surface, [[maybe_unused]] wl_fixed_t surface_x, [[maybe_unused]] wl_fixed_t surface_y) noexcept -> void { m_pointer_serial = serial; @@ -713,9 +713,9 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::pointerLeave([[maybe_unused]] wl_pointer *pointer, + auto WindowImpl::pointerLeave([[maybe_unused]] wl_pointer* pointer, [[maybe_unused]] std::uint32_t serial, - [[maybe_unused]] wl_surface *surface) noexcept -> void { + [[maybe_unused]] wl_surface* surface) noexcept -> void { m_pointer_serial = serial; WindowImplBase::mouseExitedEvent(); @@ -723,7 +723,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::pointerMotion([[maybe_unused]] wl_pointer *pointer, + auto WindowImpl::pointerMotion([[maybe_unused]] wl_pointer* pointer, [[maybe_unused]] std::uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) noexcept -> void { @@ -738,7 +738,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::pointerButton([[maybe_unused]] wl_pointer *pointer, + auto WindowImpl::pointerButton([[maybe_unused]] wl_pointer* pointer, [[maybe_unused]] std::uint32_t serial, [[maybe_unused]] std::uint32_t time, std::uint32_t button, @@ -746,7 +746,7 @@ namespace stormkit::wsi::linux::wayland { #define BUTTON_HANDLER(a, b) \ case a: { \ auto it = std::ranges::find_if(m_mouse_state.button_state, \ - [](const auto &s) { return s.button == a; }); \ + [](const auto& s) { return s.button == a; }); \ it->down = down; \ if (down) \ WindowImplBase::mouseDownEvent(b, \ @@ -785,13 +785,13 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardKeymap([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardKeymap([[maybe_unused]] wl_keyboard* keyboard, std::uint32_t format, std::int32_t fd, std::uint32_t size) noexcept -> void { if (format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { auto map_shm = - reinterpret_cast(mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0)); + reinterpret_cast(mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0)); updateKeymap(std::string_view { map_shm, size }); @@ -802,13 +802,13 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardEnter([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardEnter([[maybe_unused]] wl_keyboard* keyboard, [[maybe_unused]] std::uint32_t serial, - [[maybe_unused]] wl_surface *surface, - wl_array *keys) noexcept -> void { + [[maybe_unused]] wl_surface* surface, + wl_array* keys) noexcept -> void { WindowImplBase::gainedFocusEvent(); - auto data = static_cast(keys->data); + auto data = static_cast(keys->data); for (auto i : core::range(keys->size)) { const auto keycode = data[i] + 8; @@ -825,15 +825,15 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardLeave([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardLeave([[maybe_unused]] wl_keyboard* keyboard, [[maybe_unused]] std::uint32_t serial, - [[maybe_unused]] wl_surface *surface) noexcept -> void { + [[maybe_unused]] wl_surface* surface) noexcept -> void { WindowImplBase::lostFocusEvent(); } ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardKey([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardKey([[maybe_unused]] wl_keyboard* keyboard, [[maybe_unused]] std::uint32_t serial, [[maybe_unused]] std::uint32_t time, std::uint32_t key, @@ -860,7 +860,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardModifiers([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardModifiers([[maybe_unused]] wl_keyboard* keyboard, [[maybe_unused]] std::uint32_t serial, std::uint32_t mods_depressed, std::uint32_t mods_latched, @@ -877,7 +877,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::keyboardRepeatInfo([[maybe_unused]] wl_keyboard *keyboard, + auto WindowImpl::keyboardRepeatInfo([[maybe_unused]] wl_keyboard* keyboard, [[maybe_unused]] std::int32_t rate, [[maybe_unused]] std::int32_t delay) noexcept -> void { } @@ -885,7 +885,7 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// auto - WindowImpl::relativePointerRelativeMotion([[maybe_unused]] zwp_relative_pointer_v1 *pointer, + WindowImpl::relativePointerRelativeMotion([[maybe_unused]] zwp_relative_pointer_v1* pointer, [[maybe_unused]] std::uint32_t time_hi, [[maybe_unused]] std::uint32_t time_lw, [[maybe_unused]] wl_fixed_t dx, @@ -960,7 +960,7 @@ namespace stormkit::wsi::linux::wayland { auto fd = syscall(SYS_memfd_create, "buffer", 0); ftruncate(fd, buffer_size); - [[maybe_unused]] auto *data = + [[maybe_unused]] auto* data = mmap(nullptr, buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); m_shm_pool.reset(wl_shm_create_pool(globals.shm.get(), fd, buffer_size)); @@ -1042,14 +1042,14 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto registryHandler(void *data, - wl_registry *registry, + auto registryHandler(void* data, + wl_registry* registry, core::UInt32 id, - const char *interface, + const char* interface, core::UInt32 version) noexcept -> void { - auto& globals = *static_cast(data); + auto& globals = *static_cast(data); -#define BIND(n, t, v) n.reset(static_cast(wl_registry_bind(registry, id, &t##_interface, v))); +#define BIND(n, t, v) n.reset(static_cast(wl_registry_bind(registry, id, &t##_interface, v))); dlog("Wayland registry acquired {} (id: {}, version: {})", interface, id, version); @@ -1061,7 +1061,7 @@ namespace stormkit::wsi::linux::wayland { BIND(globals.compositor, wl_compositor, 3) else if (interface_name == wl_output_interface.name) { auto& output = globals.outputs.emplace_back( - static_cast(wl_registry_bind(registry, id, &wl_output_interface, 2))); + static_cast(wl_registry_bind(registry, id, &wl_output_interface, 2))); wl_output_add_listener(output.get(), &stormkit_output_listener, &globals); } else if (interface_name == xdg_wm_base_interface.name) BIND(globals.xdg_shell, xdg_wm_base, 1) @@ -1083,25 +1083,25 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto registryRemoverHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_registry *registry, + auto registryRemoverHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_registry* registry, core::UInt32 id) noexcept -> void { dlog("Wayland registry lost {}", id); } ///////////////////////////////////// ///////////////////////////////////// - auto outputGeometryHandler(void *data, - [[maybe_unused]] wl_output *output, + auto outputGeometryHandler(void* data, + [[maybe_unused]] wl_output* output, [[maybe_unused]] core::Int32 x, [[maybe_unused]] core::Int32 y, [[maybe_unused]] core::Int32 pwidth, [[maybe_unused]] core::Int32 pheight, [[maybe_unused]] core::Int32 subpixels, - const char *make, - const char *model, + const char* make, + const char* model, [[maybe_unused]] core::Int32 transform) noexcept -> void { - auto& globals = *static_cast(data); + auto& globals = *static_cast(data); auto& monitor = globals.monitors[output]; monitor.name = std::format("{} {}", make, model); @@ -1113,13 +1113,13 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto outputModeHandler(void *data, - [[maybe_unused]] wl_output *wl_output, + auto outputModeHandler(void* data, + [[maybe_unused]] wl_output* wl_output, [[maybe_unused]] core::UInt32 flags, core::Int32 width, core::Int32 height, [[maybe_unused]] core::Int32 refresh) noexcept -> void { - auto& globals = *static_cast(data); + auto& globals = *static_cast(data); auto& monitor = globals.monitors[wl_output]; monitor.extents.emplace_back(core::as(width), core::as(height)); @@ -1127,80 +1127,80 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto outputDoneHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_output *wl_output) noexcept -> void { + auto outputDoneHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_output* wl_output) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto outputScaleHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_output *wl_output, + auto outputScaleHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_output* wl_output, [[maybe_unused]] core::Int32 factor) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto surfaceEnterHandler(void *data, wl_surface *surface, wl_output *output) noexcept -> void { - auto *window = static_cast(data); + auto surfaceEnterHandler(void* data, wl_surface* surface, wl_output* output) noexcept -> void { + auto* window = static_cast(data); window->surfaceOutputEnter(surface, output); } ///////////////////////////////////// ///////////////////////////////////// - auto surfaceLeaveHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_surface *surface, - [[maybe_unused]] wl_output *output) noexcept -> void { + auto surfaceLeaveHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_surface* surface, + [[maybe_unused]] wl_output* output) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto toplevelConfigureHandler(void *data, - xdg_toplevel *xdg_tl, + auto toplevelConfigureHandler(void* data, + xdg_toplevel* xdg_tl, core::Int32 width, core::Int32 height, - wl_array *states) noexcept -> void { - auto *window = static_cast(data); + wl_array* states) noexcept -> void { + auto* window = static_cast(data); window->toplevelConfigure(xdg_tl, width, height, states); } ///////////////////////////////////// ///////////////////////////////////// - auto toplevelCloseHandler(void *data, xdg_toplevel *xdg_tl) noexcept -> void { - auto *window = static_cast(data); + auto toplevelCloseHandler(void* data, xdg_toplevel* xdg_tl) noexcept -> void { + auto* window = static_cast(data); window->toplevelClose(xdg_tl); } ///////////////////////////////////// ///////////////////////////////////// - auto surfaceConfigureHandler(void *data, xdg_surface *surface, core::UInt32 serial) noexcept + auto surfaceConfigureHandler(void* data, xdg_surface* surface, core::UInt32 serial) noexcept -> void { - auto window = static_cast(data); + auto window = static_cast(data); window->surfaceConfigure(surface, serial); } ///////////////////////////////////// ///////////////////////////////////// - auto shellPingHandler([[maybe_unused]] void *data, - xdg_wm_base *xdg_shell, + auto shellPingHandler([[maybe_unused]] void* data, + xdg_wm_base* xdg_shell, core::UInt32 serial) noexcept -> void { ilog("Ping received from shell"); xdg_wm_base_pong(xdg_shell, serial); } - auto shellSurfaceConfigureHandler(void *data, - wl_shell_surface *shell_surface, + auto shellSurfaceConfigureHandler(void* data, + wl_shell_surface* shell_surface, core::UInt32 edges, core::Int32 width, core::Int32 height) noexcept -> void { - auto *window = static_cast(data); + auto* window = static_cast(data); window->shellSurfaceConfigure(shell_surface, edges, width, height); } ///////////////////////////////////// ///////////////////////////////////// - auto shellPingHandler([[maybe_unused]] void *data, - wl_shell_surface *shell_surface, + auto shellPingHandler([[maybe_unused]] void* data, + wl_shell_surface* shell_surface, core::UInt32 serial) noexcept -> void { ilog("Ping received from shell"); @@ -1209,10 +1209,10 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto seatCapabilitiesHandler(void *data, - [[maybe_unused]] wl_seat *seat, + auto seatCapabilitiesHandler(void* data, + [[maybe_unused]] wl_seat* seat, core::UInt32 capabilities) noexcept -> void { - auto& globals = *static_cast(data); + auto& globals = *static_cast(data); if ((capabilities & WL_SEAT_CAPABILITY_KEYBOARD) > 0) { auto& keyboard = @@ -1233,69 +1233,69 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto seatNameHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_seat *seat, - const char *name) noexcept -> void { + auto seatNameHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_seat* seat, + const char* name) noexcept -> void { dlog("WL Seat found! {}", name); } ///////////////////////////////////// ///////////////////////////////////// - auto pointerEnterHandler(void *data, - wl_pointer *pointer, + auto pointerEnterHandler(void* data, + wl_pointer* pointer, core::UInt32 serial, - wl_surface *surface, + wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->pointerEnter(pointer, serial, surface, surface_x, surface_y); } ///////////////////////////////////// ///////////////////////////////////// - auto pointerLeaveHandler(void *data, - wl_pointer *pointer, + auto pointerLeaveHandler(void* data, + wl_pointer* pointer, core::UInt32 serial, - wl_surface *surface) noexcept -> void { + wl_surface* surface) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->pointerLeave(pointer, serial, surface); } ///////////////////////////////////// ///////////////////////////////////// - auto pointerMotionHandler(void *data, - wl_pointer *pointer, + auto pointerMotionHandler(void* data, + wl_pointer* pointer, core::UInt32 time, wl_fixed_t surface_x, wl_fixed_t surface_y) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->pointerMotion(pointer, time, surface_x, surface_y); } ///////////////////////////////////// ///////////////////////////////////// - auto pointerButtonHandler(void *data, - wl_pointer *pointer, + auto pointerButtonHandler(void* data, + wl_pointer* pointer, core::UInt32 serial, core::UInt32 time, core::UInt32 button, core::UInt32 state) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->pointerButton(pointer, serial, time, button, state); } ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer, + auto pointerAxisHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_pointer* pointer, [[maybe_unused]] core::UInt32 time, [[maybe_unused]] core::UInt32 axis, [[maybe_unused]] wl_fixed_t value) noexcept -> void { @@ -1303,89 +1303,89 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto pointerFrameHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer) noexcept -> void { + auto pointerFrameHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_pointer* pointer) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisSourceHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer, + auto pointerAxisSourceHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_pointer* pointer, [[maybe_unused]] core::UInt32 axis_source) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisStopHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer, + auto pointerAxisStopHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_pointer* pointer, [[maybe_unused]] core::UInt32 time, [[maybe_unused]] core::UInt32 axis) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto pointerAxisDiscreteHandler([[maybe_unused]] void *data, - [[maybe_unused]] wl_pointer *pointer, + auto pointerAxisDiscreteHandler([[maybe_unused]] void* data, + [[maybe_unused]] wl_pointer* pointer, [[maybe_unused]] core::UInt32 axis, [[maybe_unused]] core::Int32 discrete) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// - auto keyboardKeymapHandler(void *data, - wl_keyboard *keyboard, + auto keyboardKeymapHandler(void* data, + wl_keyboard* keyboard, core::UInt32 format, core::Int32 fd, core::UInt32 size) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->keyboardKeymap(keyboard, format, fd, size); } ///////////////////////////////////// ///////////////////////////////////// - auto keyboardEnterHandler(void *data, - wl_keyboard *keyboard, + auto keyboardEnterHandler(void* data, + wl_keyboard* keyboard, core::UInt32 serial, - wl_surface *surface, - wl_array *keys) noexcept -> void { + wl_surface* surface, + wl_array* keys) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->keyboardEnter(keyboard, serial, surface, keys); } ///////////////////////////////////// ///////////////////////////////////// - auto keyboardLeaveHandler(void *data, - wl_keyboard *keyboard, + auto keyboardLeaveHandler(void* data, + wl_keyboard* keyboard, core::UInt32 serial, - wl_surface *surface) noexcept -> void { + wl_surface* surface) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->keyboardLeave(keyboard, serial, surface); } ///////////////////////////////////// ///////////////////////////////////// - auto keyboardKeyHandler(void *data, - wl_keyboard *keyboard, + auto keyboardKeyHandler(void* data, + wl_keyboard* keyboard, core::UInt32 serial, core::UInt32 time, core::UInt32 key, core::UInt32 state) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->keyboardKey(keyboard, serial, time, key, state); } ///////////////////////////////////// ///////////////////////////////////// - auto keyboardModifiersHandler(void *data, - wl_keyboard *keyboard, + auto keyboardModifiersHandler(void* data, + wl_keyboard* keyboard, core::UInt32 serial, core::UInt32 mods_depressed, core::UInt32 mods_latcher, @@ -1393,34 +1393,34 @@ namespace stormkit::wsi::linux::wayland { core::UInt32 group) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window ->keyboardModifiers(keyboard, serial, mods_depressed, mods_latcher, mods_locked, group); } ///////////////////////////////////// ///////////////////////////////////// - auto keyboardRepeatInfoHandler(void *data, - wl_keyboard *keyboard, + auto keyboardRepeatInfoHandler(void* data, + wl_keyboard* keyboard, core::Int32 rate, core::Int32 delay) noexcept -> void { if (data == nullptr) return; - auto *window = static_cast(data); + auto* window = static_cast(data); window->keyboardRepeatInfo(keyboard, rate, delay); } ///////////////////////////////////// ///////////////////////////////////// - auto relativePointerRelativeMotionHandler(void *data, - zwp_relative_pointer_v1 *pointer, + auto relativePointerRelativeMotionHandler(void* data, + zwp_relative_pointer_v1* pointer, core::UInt32 time_hi, core::UInt32 time_lw, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dx_unaccel, wl_fixed_t dy_unaccel) noexcept -> void { - auto *window = static_cast(data); + auto* window = static_cast(data); window->relativePointerRelativeMotion(pointer, time_hi, time_lw, @@ -1432,15 +1432,15 @@ namespace stormkit::wsi::linux::wayland { ///////////////////////////////////// ///////////////////////////////////// - auto lockedPointerLockedHandler([[maybe_unused]] void *data, - [[maybe_unused]] zwp_locked_pointer_v1 *locked_pointer) noexcept + auto lockedPointerLockedHandler([[maybe_unused]] void* data, + [[maybe_unused]] zwp_locked_pointer_v1* locked_pointer) noexcept -> void { } ///////////////////////////////////// ///////////////////////////////////// auto lockedPointerUnlockedHandler( - [[maybe_unused]] void *data, - [[maybe_unused]] zwp_locked_pointer_v1 *locked_pointer) noexcept -> void { + [[maybe_unused]] void* data, + [[maybe_unused]] zwp_locked_pointer_v1* locked_pointer) noexcept -> void { } } // namespace stormkit::wsi::linux::wayland \ No newline at end of file diff --git a/src/Wsi/linux/wayland/WindowImpl.mpp b/src/Wsi/linux/wayland/WindowImpl.mpp index 40ecd4fb..3241e850 100644 --- a/src/Wsi/linux/wayland/WindowImpl.mpp +++ b/src/Wsi/linux/wayland/WindowImpl.mpp @@ -77,25 +77,25 @@ namespace stormkit::wsi::linux::wayland { STORMKIT_RAII_CAPSULE_OPAQUE( WLOutputRef, - wl_output *, + wl_output*, []() noexcept { return nullptr; }, [](auto) noexcept {}, nullptr); STORMKIT_RAII_CAPSULE_OPAQUE( WLPointerRef, - wl_pointer *, + wl_pointer*, []() noexcept { return nullptr; }, [](auto) noexcept {}, nullptr); STORMKIT_RAII_CAPSULE_OPAQUE( WLKeyboardRef, - wl_keyboard *, + wl_keyboard*, []() noexcept { return nullptr; }, [](auto) noexcept {}, nullptr); STORMKIT_RAII_CAPSULE_OPAQUE( WLTouchRef, - wl_touch *, + wl_touch*, []() noexcept { return nullptr; }, [](auto) noexcept {}, nullptr); @@ -119,7 +119,7 @@ namespace stormkit::wsi::linux::wayland { WPPointerConstraintsScoped pointer_constraints; WPRelativePointerManagerScoped relative_pointer_manager; - core::HashMap monitors; + core::HashMap monitors; }; } // namespace stormkit::wsi::linux::wayland @@ -127,8 +127,8 @@ export namespace stormkit::wsi::linux::wayland { class WindowImpl: public ::stormkit::wsi::common::WindowImplBase { public: struct Handles { - wl_display *display; - wl_surface *surface; + wl_display* display; + wl_surface* surface; }; struct KeyState { @@ -192,73 +192,73 @@ export namespace stormkit::wsi::linux::wayland { auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; static auto setMousePositionOnDesktop(const core::math::Vector2U& position) noexcept -> void; [[nodiscard]] static auto getMonitorSettings() -> std::vector; - auto surfaceOutputEnter(wl_surface *surface, wl_output *output) noexcept -> void; + auto surfaceOutputEnter(wl_surface* surface, wl_output* output) noexcept -> void; - auto surfaceConfigure(xdg_surface *surface, std::uint32_t serial) noexcept -> void; + auto surfaceConfigure(xdg_surface* surface, std::uint32_t serial) noexcept -> void; - auto toplevelConfigure(xdg_toplevel *xdg_tl, + auto toplevelConfigure(xdg_toplevel* xdg_tl, std::int32_t width, std::int32_t height, - wl_array *state) noexcept -> void; - auto toplevelClose(xdg_toplevel *xdg_tl) noexcept -> void; + wl_array* state) noexcept -> void; + auto toplevelClose(xdg_toplevel* xdg_tl) noexcept -> void; - auto shellSurfaceConfigure(wl_shell_surface *xdg_tl, + auto shellSurfaceConfigure(wl_shell_surface* xdg_tl, std::uint32_t edges, std::int32_t width, std::int32_t height) noexcept -> void; - auto seatCapabilities(wl_seat *seat, std::uint32_t capabilities) noexcept -> void; + auto seatCapabilities(wl_seat* seat, std::uint32_t capabilities) noexcept -> void; - auto pointerEnter(wl_pointer *pointer, + auto pointerEnter(wl_pointer* pointer, std::uint32_t serial, - wl_surface *surface, + wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) noexcept -> void; - auto pointerLeave(wl_pointer *pointer, std::uint32_t serial, wl_surface *surface) noexcept + auto pointerLeave(wl_pointer* pointer, std::uint32_t serial, wl_surface* surface) noexcept -> void; - auto pointerMotion(wl_pointer *pointer, + auto pointerMotion(wl_pointer* pointer, std::uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) noexcept -> void; - auto pointerButton(wl_pointer *pointer, + auto pointerButton(wl_pointer* pointer, std::uint32_t serial, std::uint32_t time, std::uint32_t button, std::uint32_t state) noexcept -> void; - auto keyboardKeymap(wl_keyboard *keyboard, + auto keyboardKeymap(wl_keyboard* keyboard, std::uint32_t format, std::int32_t fd, std::uint32_t size) noexcept -> void; - auto keyboardEnter(wl_keyboard *keyboard, + auto keyboardEnter(wl_keyboard* keyboard, std::uint32_t serial, - wl_surface *surface, - wl_array *keys) noexcept -> void; - auto keyboardLeave(wl_keyboard *keyboard, + wl_surface* surface, + wl_array* keys) noexcept -> void; + auto keyboardLeave(wl_keyboard* keyboard, std::uint32_t serial, - wl_surface *surface) noexcept -> void; - auto keyboardKey(wl_keyboard *keyboard, + wl_surface* surface) noexcept -> void; + auto keyboardKey(wl_keyboard* keyboard, std::uint32_t serial, std::uint32_t time, std::uint32_t key, std::uint32_t state) noexcept -> void; - auto keyboardModifiers(wl_keyboard *keyboard, + auto keyboardModifiers(wl_keyboard* keyboard, std::uint32_t serial, std::uint32_t mods_depressed, std::uint32_t mods_latched, std::uint32_t mods_locked, std::uint32_t group) noexcept -> void; - auto keyboardRepeatInfo(wl_keyboard *keyboard, + auto keyboardRepeatInfo(wl_keyboard* keyboard, std::int32_t rate, std::int32_t delay) noexcept -> void; - auto relativePointerRelativeMotion(zwp_relative_pointer_v1 *pointer, + auto relativePointerRelativeMotion(zwp_relative_pointer_v1* pointer, std::uint32_t time_hi, std::uint32_t time_lw, wl_fixed_t dx, diff --git a/src/Wsi/linux/x11/Utils.mpp b/src/Wsi/linux/x11/Utils.mpp index 80490415..57f8a3c1 100644 --- a/src/Wsi/linux/x11/Utils.mpp +++ b/src/Wsi/linux/x11/Utils.mpp @@ -21,7 +21,7 @@ import :Types; export namespace stormkit::wsi::linux::x11 { auto x11KeyToChar(xcb_keysym_t key) noexcept -> char; auto x11MouseButtonToStormMouseButton(xcb_button_t button) noexcept -> MouseButton; - auto defaultRootWindow(xcb_connection_t *connection, core::Int32 screen_id) noexcept + auto defaultRootWindow(xcb_connection_t* connection, core::Int32 screen_id) noexcept -> xcb_window_t; } // namespace stormkit::wsi::linux::x11 @@ -46,7 +46,7 @@ namespace stormkit::wsi::linux::x11 { ///////////////////////////////////// ///////////////////////////////////// - auto screen_of_display(xcb_connection_t *c, int screen) noexcept -> xcb_screen_t * { + auto screen_of_display(xcb_connection_t* c, int screen) noexcept -> xcb_screen_t* { auto iter = xcb_screen_iterator_t {}; for (iter = xcb_setup_roots_iterator(xcb_get_setup(c)); iter.rem; @@ -58,7 +58,7 @@ namespace stormkit::wsi::linux::x11 { ///////////////////////////////////// ///////////////////////////////////// - auto defaultRootWindow(xcb_connection_t *connection, int32_t screen_id) noexcept + auto defaultRootWindow(xcb_connection_t* connection, int32_t screen_id) noexcept -> xcb_window_t { auto screen = screen_of_display(connection, screen_id); diff --git a/src/Wsi/linux/x11/WindowImpl.mpp b/src/Wsi/linux/x11/WindowImpl.mpp index 8563b91e..b9966048 100644 --- a/src/Wsi/linux/x11/WindowImpl.mpp +++ b/src/Wsi/linux/x11/WindowImpl.mpp @@ -50,10 +50,10 @@ export namespace stormkit::wsi::linux::x11 { class WindowImpl: public ::stormkit::wsi::common::WindowImplBase { public: struct Handles { - xcb_connection_t *connection; + xcb_connection_t* connection; xcb_window_t window; - xcb_key_symbols_t *key_symbols; - xkb_state *state; + xcb_key_symbols_t* key_symbols; + xkb_state* state; }; WindowImpl(); @@ -100,14 +100,14 @@ export namespace stormkit::wsi::linux::x11 { auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; static auto setMousePositionOnDesktop(const core::math::Vector2U& position) noexcept -> void; [[nodiscard]] static auto getMonitorSettings() -> std::vector; private: - auto processEvents(xcb_generic_event_t *xevent) -> void; + auto processEvents(xcb_generic_event_t* xevent) -> void; auto updateKeymap() -> void; auto handleKeyEvent(xcb_keycode_t keycode, bool up) noexcept -> void; @@ -242,8 +242,8 @@ namespace stormkit::wsi::linux::x11 { constexpr auto XINPUT_MASK_MODIFIERS = core::UInt32 { XCB_INPUT_MODIFIER_MASK_ANY }; } // namespace - auto isExtEvent(xcb_generic_event_t *event, int opcode) noexcept -> bool { - return reinterpret_cast(event)->extension == opcode; + auto isExtEvent(xcb_generic_event_t* event, int opcode) noexcept -> bool { + return reinterpret_cast(event)->extension == opcode; } ///////////////////////////////////// @@ -580,7 +580,7 @@ namespace stormkit::wsi::linux::x11 { 1, m_window, XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY, - reinterpret_cast(&ev)); + reinterpret_cast(&ev)); m_fullscreen = enabled; @@ -770,23 +770,23 @@ namespace stormkit::wsi::linux::x11 { ///////////////////////////////////// ///////////////////////////////////// - auto WindowImpl::processEvents(xcb_generic_event_t *event) -> void { - auto *xevent = event; + auto WindowImpl::processEvents(xcb_generic_event_t* event) -> void { + auto* xevent = event; const auto response_type = xevent->response_type & ~0x80; switch (response_type) { case XCB_KEY_PRESS: { - auto kevent = reinterpret_cast(xevent); + auto kevent = reinterpret_cast(xevent); handleKeyEvent(kevent->detail, true); break; } case XCB_KEY_RELEASE: { - auto kevent = reinterpret_cast(xevent); + auto kevent = reinterpret_cast(xevent); handleKeyEvent(kevent->detail, false); break; } case XCB_MOTION_NOTIFY: { - auto mouse_event = reinterpret_cast(xevent); + auto mouse_event = reinterpret_cast(xevent); const auto x = core::as(mouse_event->event_x); const auto y = core::as(mouse_event->event_y); @@ -813,7 +813,7 @@ namespace stormkit::wsi::linux::x11 { break; } case XCB_BUTTON_PRESS: { - auto button_event = reinterpret_cast(xevent); + auto button_event = reinterpret_cast(xevent); auto button = button_event->detail; WindowImplBase::mouseDownEvent(x11MouseButtonToStormMouseButton(button), @@ -822,7 +822,7 @@ namespace stormkit::wsi::linux::x11 { break; } case XCB_BUTTON_RELEASE: { - auto button_event = reinterpret_cast(xevent); + auto button_event = reinterpret_cast(xevent); auto button = button_event->detail; WindowImplBase::mouseUpEvent(x11MouseButtonToStormMouseButton(button), @@ -831,7 +831,7 @@ namespace stormkit::wsi::linux::x11 { break; } case XCB_CONFIGURE_NOTIFY: { - auto configure_event = reinterpret_cast(xevent); + auto configure_event = reinterpret_cast(xevent); if ((configure_event->width != m_extent.width) || (configure_event->height != m_extent.height)) { @@ -857,13 +857,13 @@ namespace stormkit::wsi::linux::x11 { WM_DELETE_WINDOW, close_atom.error().message); - if (reinterpret_cast(xevent)->data.data32[0] == + if (reinterpret_cast(xevent)->data.data32[0] == *close_atom) WindowImplBase::closeEvent(); break; } case XCB_MAPPING_NOTIFY: { - auto mapping_notify_event = reinterpret_cast(xevent); + auto mapping_notify_event = reinterpret_cast(xevent); if (mapping_notify_event->request != XCB_MAPPING_POINTER) { xcb_refresh_keyboard_mapping(m_key_symbols.get(), mapping_notify_event); @@ -873,24 +873,24 @@ namespace stormkit::wsi::linux::x11 { } case XCB_GE_GENERIC: { if (isExtEvent(xevent, m_xi_opcode)) { - auto xievent = reinterpret_cast(xevent); + auto xievent = reinterpret_cast(xevent); switch (xievent->event_type) { case XCB_INPUT_KEY_PRESS: [[fallthrough]]; case XCB_INPUT_RAW_KEY_PRESS: { - auto xievent = reinterpret_cast(xevent); + auto xievent = reinterpret_cast(xevent); handleKeyEvent(xievent->detail, true); break; } case XCB_INPUT_KEY_RELEASE: [[fallthrough]]; case XCB_INPUT_RAW_KEY_RELEASE: { - auto xievent = reinterpret_cast(xevent); + auto xievent = reinterpret_cast(xevent); handleKeyEvent(xievent->detail, false); break; } case XCB_INPUT_BUTTON_PRESS: [[fallthrough]]; case XCB_INPUT_RAW_BUTTON_PRESS: { auto button_event = - reinterpret_cast(xevent); + reinterpret_cast(xevent); auto button = button_event->detail; WindowImplBase::mouseDownEvent(x11MouseButtonToStormMouseButton(button), @@ -901,7 +901,7 @@ namespace stormkit::wsi::linux::x11 { case XCB_INPUT_BUTTON_RELEASE: [[fallthrough]]; case XCB_INPUT_RAW_BUTTON_RELEASE: { auto button_event = - reinterpret_cast(xevent); + reinterpret_cast(xevent); auto button = button_event->detail; WindowImplBase::mouseDownEvent(x11MouseButtonToStormMouseButton(button), @@ -962,7 +962,7 @@ namespace stormkit::wsi::linux::x11 { symbol = xkb_state_key_get_one_sym(m_xkb_state.get(), keycode); xkb_state_key_get_utf8(m_xkb_state.get(), keycode, - reinterpret_cast(&character), + reinterpret_cast(&character), sizeof(char)); auto key = common::xkbKeyToStormkitKey(symbol); diff --git a/src/Wsi/linux/x11/XCB.mpp b/src/Wsi/linux/x11/XCB.mpp index b4c59085..e7cd974d 100644 --- a/src/Wsi/linux/x11/XCB.mpp +++ b/src/Wsi/linux/x11/XCB.mpp @@ -22,7 +22,7 @@ import :Linux.X11.Log; #define STORMKIT_XCB_SCOPED(name, type) \ struct name##Scoped { \ - name##Scoped(type *handle) noexcept; \ + name##Scoped(type* handle) noexcept; \ ~name##Scoped() noexcept; \ \ name##Scoped(const name##Scoped&) = delete; \ @@ -31,16 +31,16 @@ import :Linux.X11.Log; name##Scoped(name##Scoped&&) noexcept; \ auto operator=(name##Scoped&&) noexcept -> name##Scoped&; \ \ - operator type *() const noexcept { \ + operator type*() const noexcept { \ return m_handle; \ } \ \ private: \ - type *m_handle = nullptr; \ + type* m_handle = nullptr; \ } export namespace stormkit::wsi::linux::x11 { - using XCBErrorPtr = xcb_generic_error_t *; + using XCBErrorPtr = xcb_generic_error_t*; STORMKIT_XCB_SCOPED(XCBConnection, xcb_connection_t); STORMKIT_XCB_SCOPED(XCBErrorContext, xcb_errors_context_t); @@ -58,13 +58,13 @@ export namespace stormkit::wsi::linux::x11 { auto getXCBError(XCBErrorPtr error) -> std::string; auto getXIDeviceInfo(xcb_input_device_id_t device_id) - -> std::expected; + -> std::expected; } // namespace stormkit::wsi::linux::x11 #undef STORMKIT_XCB_SCOPED #define STORMKIT_XCB_SCOPED(name, type, var, global, deleter) \ - name##Scoped::name##Scoped(type *handle) noexcept : m_handle { handle } { \ + name##Scoped::name##Scoped(type* handle) noexcept : m_handle { handle } { \ if (m_handle != nullptr) var++; \ } \ \ @@ -93,9 +93,9 @@ export namespace stormkit::wsi::linux::x11 { } namespace stormkit::wsi::linux::x11 { - using XCBConnectionPtr = xcb_connection_t *; - using XCBErrorContextPtr = xcb_errors_context_t *; - using XCBErrorPtr = xcb_generic_error_t *; + using XCBConnectionPtr = xcb_connection_t*; + using XCBErrorContextPtr = xcb_errors_context_t*; + using XCBErrorPtr = xcb_generic_error_t*; STORMKIT_RAII_CAPSULE(XCBGenericError, xcb_generic_error_t, std::free) namespace { @@ -124,7 +124,7 @@ namespace stormkit::wsi::linux::x11 { inline auto getXCBConnection() noexcept -> XCBConnectionScoped { if (!xcb_connection) [[unlikely]] { xcb_connection = xcb_connect(nullptr, nullptr); - dlog("New xcb connection {}", std::bit_cast(xcb_connection)); + dlog("New xcb connection {}", std::bit_cast(xcb_connection)); } core::ensures(xcb_connection); @@ -178,7 +178,7 @@ namespace stormkit::wsi::linux::x11 { inline auto getXCBErrorContext() noexcept -> XCBErrorContextScoped { if (!xcb_error_context) [[unlikely]] { xcb_errors_context_new(getXCBConnection(), &xcb_error_context); - dlog("New xcb error context {}", std::bit_cast(xcb_error_context)); + dlog("New xcb error context {}", std::bit_cast(xcb_error_context)); } core::ensures(xcb_error_context); @@ -198,8 +198,8 @@ namespace stormkit::wsi::linux::x11 { const auto minor = xcb_errors_get_name_for_minor_code(ctx, error->major_code, error->minor_code); - using CStr = const char *; - const auto *extension = CStr { nullptr }; + using CStr = const char*; + const auto* extension = CStr { nullptr }; const auto str_error = xcb_errors_get_name_for_error(ctx, error->major_code, &extension); return std::format("{} extension: {} major: {} minor: {}\n", @@ -212,7 +212,7 @@ namespace stormkit::wsi::linux::x11 { ///////////////////////////////////// ///////////////////////////////////// inline auto getXIDeviceInfo(xcb_input_device_id_t device_id) - -> std::expected { + -> std::expected { STORMKIT_RAII_CAPSULE(Reply, xcb_input_xi_query_device_reply_t, std::free) auto connection = getXCBConnection(); diff --git a/src/Wsi/macOS/StormKitView.hpp b/src/Wsi/macOS/StormKitView.hpp index 62cad65e..a89042ae 100644 --- a/src/Wsi/macOS/StormKitView.hpp +++ b/src/Wsi/macOS/StormKitView.hpp @@ -15,37 +15,37 @@ namespace stormkit::wsi::macos { @interface StormKitView: NSView - (BOOL)acceptsFirstResponder; - (id)initWithFrame:(NSRect)frame - withRequester:(stormkit::wsi::macos::macOSWindow *)_requester - withWindow:(NSWindow *)window; + withRequester:(stormkit::wsi::macos::macOSWindow*)_requester + withWindow:(NSWindow*)window; -- (NSWindow *)myWindow; -- (void)mouseDown:(NSEvent *)event; -- (void)rightMouseDown:(NSEvent *)event; -- (void)otherMouseDown:(NSEvent *)event; -- (void)handleMouseDown:(NSEvent *)event; +- (NSWindow*)myWindow; +- (void)mouseDown:(NSEvent*)event; +- (void)rightMouseDown:(NSEvent*)event; +- (void)otherMouseDown:(NSEvent*)event; +- (void)handleMouseDown:(NSEvent*)event; -- (void)mouseUp:(NSEvent *)event; -- (void)rightMouseUp:(NSEvent *)event; -- (void)otherMouseUp:(NSEvent *)event; -- (void)handleMouseUp:(NSEvent *)event; +- (void)mouseUp:(NSEvent*)event; +- (void)rightMouseUp:(NSEvent*)event; +- (void)otherMouseUp:(NSEvent*)event; +- (void)handleMouseUp:(NSEvent*)event; -- (void)mouseMoved:(NSEvent *)event; -- (void)mouseDragged:(NSEvent *)event; -- (void)rightMouseDragged:(NSEvent *)event; -- (void)handleMouseMove:(NSEvent *)event; +- (void)mouseMoved:(NSEvent*)event; +- (void)mouseDragged:(NSEvent*)event; +- (void)rightMouseDragged:(NSEvent*)event; +- (void)handleMouseMove:(NSEvent*)event; -- (void)mouseEntered:(NSEvent *)event; -- (void)mouseExited:(NSEvent *)event; +- (void)mouseEntered:(NSEvent*)event; +- (void)mouseExited:(NSEvent*)event; -- (void)keyDown:(NSEvent *)event; -- (void)keyUp:(NSEvent *)event; +- (void)keyDown:(NSEvent*)event; +- (void)keyUp:(NSEvent*)event; - (void)updateTrackingAreas; -- (void)setRequester:(stormkit::wsi::macos::macOSWindow *)_requester; +- (void)setRequester:(stormkit::wsi::macos::macOSWindow*)_requester; - (NSPoint)relativeToGlobal:(NSPoint)point; -- (void)setNativeEventRetriever:(void *)native_event; +- (void)setNativeEventRetriever:(void*)native_event; @end #endif diff --git a/src/Wsi/macOS/StormKitView.mm b/src/Wsi/macOS/StormKitView.mm index 66241f1b..7a540401 100644 --- a/src/Wsi/macOS/StormKitView.mm +++ b/src/Wsi/macOS/StormKitView.mm @@ -39,10 +39,10 @@ - (id)initWithFrame:(NSRect)frame withWindow:(NSWindow *)window { self = [super initWithFrame:frame]; - window_handle = window; + window_handle = window; is_mouse_inside = NO; - native_event = nullptr; - requester = _requester; + native_event = nullptr; + requester = _requester; return self; } @@ -83,7 +83,9 @@ - (void)otherMouseDown:(NSEvent *)event { ///////////////////////////////////// ///////////////////////////////////// - (void)handleMouseDown:(NSEvent *)event { - requester->mouseDownEvent(mouseButton([event buttonNumber]), event.locationInWindow.x, event.locationInWindow.y); + requester->mouseDownEvent(mouseButton([event buttonNumber]), + event.locationInWindow.x, + event.locationInWindow.y); } ///////////////////////////////////// @@ -113,7 +115,9 @@ - (void)otherMouseUp:(NSEvent *)event { ///////////////////////////////////// ///////////////////////////////////// - (void)handleMouseUp:(NSEvent *)event { - requester->mouseUpEvent(mouseButton([event buttonNumber]), event.locationInWindow.x, event.locationInWindow.y); + requester->mouseUpEvent(mouseButton([event buttonNumber]), + event.locationInWindow.x, + event.locationInWindow.y); } ///////////////////////////////////// @@ -205,10 +209,8 @@ - (void)updateTrackingAreas { NSUInteger opts = (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag); - tracking_area = [[NSTrackingArea alloc] initWithRect:[self bounds] - options:opts - owner:self - userInfo:nil]; + tracking_area = + [[NSTrackingArea alloc] initWithRect:[self bounds] options:opts owner:self userInfo:nil]; [self addTrackingArea:tracking_area]; } @@ -240,7 +242,7 @@ - (NSPoint)relativeToGlobal:(NSPoint)point { ///////////////////////////////////// ///////////////////////////////////// - (CGDirectDisplayID)displayId { - auto screen = [[self window] screen]; + auto screen = [[self window] screen]; auto display_id = [[screen deviceDescription] objectForKey:@"NSScreenNumber"]; return [display_id intValue]; diff --git a/src/Wsi/macOS/StormKitWindow.hpp b/src/Wsi/macOS/StormKitWindow.hpp index 90db495d..202caac7 100644 --- a/src/Wsi/macOS/StormKitWindow.hpp +++ b/src/Wsi/macOS/StormKitWindow.hpp @@ -20,10 +20,10 @@ namespace stormkit::wsi::macos { withHeight:(std::uint32_t)height withStyle:(int)style withTitle:(std::string)title - withRequester:(stormkit::wsi::macos::macOSWindow *)_requester; + withRequester:(stormkit::wsi::macos::macOSWindow*)_requester; - (void)dealloc; -- (void)setRequester:(stormkit::wsi::macos::macOSWindow *)requester; +- (void)setRequester:(stormkit::wsi::macos::macOSWindow*)requester; - (void)close; - (BOOL)isVisible; @@ -32,17 +32,17 @@ namespace stormkit::wsi::macos { - (void)hideWindow; - (void)processEvent; -- (StormKitView *)nativeHandle; +- (StormKitView*)nativeHandle; - (NSSize)size; - (BOOL)windowShouldClose:(id)sender; - (void)windowWillClose:(id)sender; -- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize; +- (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize; -- (void)windowDidMiniaturize:(NSNotification *)notification; -- (void)windowDidDeminiaturize:(NSNotification *)notification; +- (void)windowDidMiniaturize:(NSNotification*)notification; +- (void)windowDidDeminiaturize:(NSNotification*)notification; - (void)setMousePosition:(NSPoint)point; - (void)setWindowTitle:(std::string)title; diff --git a/src/Wsi/macOS/StormKitWindow.mm b/src/Wsi/macOS/StormKitWindow.mm index 8d26c1ae..b124ad79 100644 --- a/src/Wsi/macOS/StormKitWindow.mm +++ b/src/Wsi/macOS/StormKitWindow.mm @@ -14,10 +14,10 @@ using namespace stormkit::wsi::macos; namespace { - auto fromStdString(const std::string &str) noexcept -> NSString * { - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; - } -} + auto fromStdString(const std::string &str) noexcept -> NSString * { + return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + } +} // namespace @implementation StormKitWindowController { macOSWindow *requester; @@ -28,10 +28,10 @@ @implementation StormKitWindowController { ///////////////////////////////////// ///////////////////////////////////// - (id)initWithWidth:(std::uint32_t)width - withHeight:(std::uint32_t)height - withStyle:(int)style - withTitle:(std::string)title - withRequester:(macOSWindow *)_requester { + withHeight:(std::uint32_t)height + withStyle:(int)style + withTitle:(std::string)title + withRequester:(macOSWindow *)_requester { self = [super init]; if (self) { @@ -40,27 +40,25 @@ - (id)initWithWidth:(std::uint32_t)width auto window_style = NSUInteger(); - if ((style & 0b1) == 0b1) - window_style |= NSWindowStyleMaskTitled; + if ((style & 0b1) == 0b1) window_style |= NSWindowStyleMaskTitled; - if ((style & 0b10) == 0b10) - window_style |= NSWindowStyleMaskClosable; + if ((style & 0b10) == 0b10) window_style |= NSWindowStyleMaskClosable; - if ((style & 0b100) == 0b100) - window_style |= NSWindowStyleMaskMiniaturizable; + if ((style & 0b100) == 0b100) window_style |= NSWindowStyleMaskMiniaturizable; - if ((style & 0b1000) == 0b1000) - window_style |= NSWindowStyleMaskResizable; + if ((style & 0b1000) == 0b1000) window_style |= NSWindowStyleMaskResizable; const auto rect = NSMakeRect(0, 0, width, height); - window = [[StormKitWindow alloc] initWithContentRect:rect - styleMask:window_style - backing:NSBackingStoreBuffered - defer:NO]; + window = [[StormKitWindow alloc] + initWithContentRect:rect + styleMask:window_style + backing:NSBackingStoreBuffered + defer:NO]; auto frame = [window convertRectToBacking:[[window contentView] frame]]; - view = [[StormKitView alloc] initWithFrame:frame withRequester:_requester withWindow:window]; + view = + [[StormKitView alloc] initWithFrame:frame withRequester:_requester withWindow:window]; [view setLayer:[CAMetalLayer layer]]; [view setWantsLayer:YES]; @@ -90,7 +88,7 @@ - (void)dealloc { [self close]; window = nil; - view = nil; + view = nil; } ///////////////////////////////////// diff --git a/src/Wsi/macOS/Utils.mm b/src/Wsi/macOS/Utils.mm index db0082b0..28389120 100644 --- a/src/Wsi/macOS/Utils.mm +++ b/src/Wsi/macOS/Utils.mm @@ -2,7 +2,7 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution -#include "Utils.hpp" +#include "Utils.hpp" #include #include @@ -15,122 +15,122 @@ #import namespace stormkit::wsi::macos { - enum class Key { - A = 0, - B, - C, - D, - E, - F, - G, - H, - I, - J, - K, - L, - M, - N, - O, - P, - Q, - R, - S, - T, - U, - V, - W, - X, - Y, - Z, - Num0, - Num1, - Num2, - Num3, - Num4, - Num5, - Num6, - Num7, - Num8, - Num9, - Escape, - L_Control, - L_Shift, - L_Alt, - L_System, - R_Control, - R_Shift, - R_Alt, - R_System, - Menu, - L_Bracket, - R_Bracket, - Semi_Colon, - Comma, - Period, - Quote, - Slash, - Back_Slash, - Tilde, - Equal, - Hyphen, - Space, - Enter, - Back_Space, - Tab, - Page_Up, - Page_Down, - Begin, - End, - Home, - Insert, - Delete, - Add, - Substract, - Multiply, - Divide, - Left, - Right, - Up, - Down, - Numpad0, - Numpad1, - Numpad2, - Numpad3, - Numpad4, - Numpad5, - Numpad6, - Numpad7, - Numpad8, - Numpad9, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - Pause, - KeyCount, - Unknow = std::numeric_limits::max(), - }; - - enum class MouseButton { - Left = 0, - Right, - Middle, - Button1, - Button2, - ButtonCount, - Unknow = std::numeric_limits::max(), - }; + enum class Key { + A = 0, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, + Num0, + Num1, + Num2, + Num3, + Num4, + Num5, + Num6, + Num7, + Num8, + Num9, + Escape, + L_Control, + L_Shift, + L_Alt, + L_System, + R_Control, + R_Shift, + R_Alt, + R_System, + Menu, + L_Bracket, + R_Bracket, + Semi_Colon, + Comma, + Period, + Quote, + Slash, + Back_Slash, + Tilde, + Equal, + Hyphen, + Space, + Enter, + Back_Space, + Tab, + Page_Up, + Page_Down, + Begin, + End, + Home, + Insert, + Delete, + Add, + Substract, + Multiply, + Divide, + Left, + Right, + Up, + Down, + Numpad0, + Numpad1, + Numpad2, + Numpad3, + Numpad4, + Numpad5, + Numpad6, + Numpad7, + Numpad8, + Numpad9, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + Pause, + KeyCount, + Unknow = std::numeric_limits::max(), + }; + + enum class MouseButton { + Left = 0, + Right, + Middle, + Button1, + Button2, + ButtonCount, + Unknow = std::numeric_limits::max(), + }; ///////////////////////////////////// ///////////////////////////////////// auto mouseButton(int button) noexcept -> int { @@ -140,8 +140,7 @@ auto mouseButton(int button) noexcept -> int { case 2: return static_cast(MouseButton::Middle); case 3: return static_cast(MouseButton::Button1); case 4: return static_cast(MouseButton::Button2); - default: - return static_cast(MouseButton::Unknow); + default: return static_cast(MouseButton::Unknow); } std::unreachable(); @@ -155,55 +154,55 @@ auto localizedKey(char code) noexcept -> int { switch (code) { case 'a': [[fallthrough]]; case 'A': return static_cast(Key::A); - case 'b':[[fallthrough]]; + case 'b': [[fallthrough]]; case 'B': return static_cast(Key::B); - case 'c':[[fallthrough]]; + case 'c': [[fallthrough]]; case 'C': return static_cast(Key::C); - case 'd':[[fallthrough]]; + case 'd': [[fallthrough]]; case 'D': return static_cast(Key::D); - case 'e':[[fallthrough]]; + case 'e': [[fallthrough]]; case 'E': return static_cast(Key::E); - case 'f':[[fallthrough]]; + case 'f': [[fallthrough]]; case 'F': return static_cast(Key::F); - case 'g':[[fallthrough]]; + case 'g': [[fallthrough]]; case 'G': return static_cast(Key::G); - case 'h':[[fallthrough]]; + case 'h': [[fallthrough]]; case 'H': return static_cast(Key::H); - case 'i':[[fallthrough]]; + case 'i': [[fallthrough]]; case 'I': return static_cast(Key::I); - case 'j':[[fallthrough]]; + case 'j': [[fallthrough]]; case 'J': return static_cast(Key::J); - case 'k':[[fallthrough]]; + case 'k': [[fallthrough]]; case 'K': return static_cast(Key::K); - case 'l':[[fallthrough]]; + case 'l': [[fallthrough]]; case 'L': return static_cast(Key::L); - case 'm':[[fallthrough]]; + case 'm': [[fallthrough]]; case 'M': return static_cast(Key::M); - case 'n':[[fallthrough]]; + case 'n': [[fallthrough]]; case 'N': return static_cast(Key::N); - case 'o':[[fallthrough]]; + case 'o': [[fallthrough]]; case 'O': return static_cast(Key::O); - case 'p':[[fallthrough]]; + case 'p': [[fallthrough]]; case 'P': return static_cast(Key::P); - case 'q':[[fallthrough]]; + case 'q': [[fallthrough]]; case 'Q': return static_cast(Key::Q); - case 'r':[[fallthrough]]; + case 'r': [[fallthrough]]; case 'R': return static_cast(Key::R); - case 's':[[fallthrough]]; + case 's': [[fallthrough]]; case 'S': return static_cast(Key::S); - case 't':[[fallthrough]]; + case 't': [[fallthrough]]; case 'T': return static_cast(Key::T); - case 'u':[[fallthrough]]; + case 'u': [[fallthrough]]; case 'U': return static_cast(Key::U); - case 'v':[[fallthrough]]; + case 'v': [[fallthrough]]; case 'V': return static_cast(Key::V); - case 'w':[[fallthrough]]; + case 'w': [[fallthrough]]; case 'W': return static_cast(Key::W); - case 'x':[[fallthrough]]; + case 'x': [[fallthrough]]; case 'X': return static_cast(Key::X); - case 'y':[[fallthrough]]; + case 'y': [[fallthrough]]; case 'Y': return static_cast(Key::Y); - case 'z':[[fallthrough]]; + case 'z': [[fallthrough]]; case 'Z': return static_cast(Key::Z); } @@ -563,4 +562,4 @@ auto usageToVirtualCode(int usage) noexcept -> int { return 0xff; } -} +} // namespace stormkit::wsi::macos diff --git a/src/Wsi/macOS/WindowImpl.mpp b/src/Wsi/macOS/WindowImpl.mpp index f7e50b19..c9d1d9aa 100644 --- a/src/Wsi/macOS/WindowImpl.mpp +++ b/src/Wsi/macOS/WindowImpl.mpp @@ -66,7 +66,7 @@ export namespace stormkit::wsi::macos { auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; static auto setMousePositionOnDesktop(WM wm, const core::math::Vector2U& position) noexcept -> void; diff --git a/src/Wsi/macOS/macOSWindow.hpp b/src/Wsi/macOS/macOSWindow.hpp index 91571de8..e995b591 100644 --- a/src/Wsi/macOS/macOSWindow.hpp +++ b/src/Wsi/macOS/macOSWindow.hpp @@ -14,12 +14,12 @@ #ifdef __OBJC__ @class StormKitWindowController; -using StormKitWindowControllerPtr = StormKitWindowController *; +using StormKitWindowControllerPtr = StormKitWindowController*; @class StormKitView; -using ViewPtr = StormKitView *; +using ViewPtr = StormKitView*; #else -using StormKitWindowControllerPtr = void *; -using ViewPtr = void *; +using StormKitWindowControllerPtr = void*; +using ViewPtr = void*; #endif namespace stormkit::wsi::macos { @@ -45,7 +45,7 @@ namespace stormkit::wsi::macos { std::vector extents; - void *handle = nullptr; + void* handle = nullptr; }; macOSWindow(std::string title, diff --git a/src/Wsi/macOS/macOSWindow.mm b/src/Wsi/macOS/macOSWindow.mm index 5026d368..f82df87b 100644 --- a/src/Wsi/macOS/macOSWindow.mm +++ b/src/Wsi/macOS/macOSWindow.mm @@ -10,191 +10,195 @@ #import #include +#include #include #include -#include namespace stormkit::wsi::macos { -namespace { - static auto is_process_set_as_application = false; -} - -///////////////////////////////////// -///////////////////////////////////// -macOSWindow::macOSWindow(std::string title, std::uint32_t width, std::uint32_t height, - int style) noexcept : - m_controller { nil }, - m_handles{ .view = nil }, - m_title{std::move(title)}, - m_width{width}, - m_height{height} { - initCocoaProcess(); - - m_controller = [[StormKitWindowController alloc] initWithWidth:width - withHeight:height - withStyle:static_cast(style) - withTitle:m_title - withRequester:this]; - - m_handles.view = [m_controller nativeHandle]; -} - -///////////////////////////////////// -///////////////////////////////////// -macOSWindow::~macOSWindow() { - [m_controller close]; -} - -///////////////////////////////////// -///////////////////////////////////// -macOSWindow::macOSWindow(macOSWindow &&) noexcept = default; - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::operator=(macOSWindow &&) noexcept -> macOSWindow & = default; - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::pollEvent() noexcept -> void { - [m_controller processEvent]; -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::waitEvent() noexcept -> void { - [m_controller processEvent]; -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::setTitle(std::string title) noexcept -> void { - m_title = std::move(title); - - [m_controller setWindowTitle:m_title]; -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::setExtent(std::uint32_t width, std::uint32_t height) noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::setFullscreenEnabled(bool fullscreen) noexcept -> void { - -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::lockMouse() noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::unlockMouse() noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::hideMouse() noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::unhideMouse() noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::width() const noexcept -> std::uint32_t { - auto size = [m_controller size]; - - return size.width; -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::height() const noexcept -> std::uint32_t { - auto size = [m_controller size]; - - return size.height; -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::macOSHandles() const noexcept -> const Handles & { - return m_handles; -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::setKeyRepeatEnabled([[maybe_unused]] bool enabled) noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::setVirtualKeyboardVisible([[maybe_unused]] bool visible) noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::setMousePosition([[maybe_unused]] std::int32_t x, [[maybe_unused]] std::int32_t y) noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::setMousePositionOnDesktop([[maybe_unused]] std::uint32_t x, [[maybe_unused]] std::uint32_t y) noexcept -> void { -} - -///////////////////////////////////// -///////////////////////////////////// -auto macOSWindow::getMonitorSettings() -> std::vector { - // TODO handle multiple monitors - auto display_id = CGMainDisplayID(); - auto modes = - (__bridge NSArray *)CGDisplayCopyAllDisplayModes(display_id, nullptr); - auto device_info = (__bridge NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(display_id), kIODisplayOnlyPreferredName); - - const auto mode_count = [modes count]; - - auto monitors = std::vector{}; - auto &monitor = monitors.emplace_back(); - monitor.extents.reserve(mode_count); - monitor.flags = Monitor::Flags::Primary; - monitor.handle = (void *)display_id; - - auto screen_name = @""; - auto localized_names = [device_info objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; - if ([localized_names count] > 0) [[likely]] - screen_name = [localized_names objectForKey:[[localized_names allKeys] objectAtIndex:0]]; + namespace { + static auto is_process_set_as_application = false; + } + + ///////////////////////////////////// + ///////////////////////////////////// + macOSWindow::macOSWindow(std::string title, + std::uint32_t width, + std::uint32_t height, + int style) noexcept + : m_controller { nil }, m_handles { .view = nil }, m_title { std::move(title) }, + m_width { width }, m_height { height } { + initCocoaProcess(); + + m_controller = [[StormKitWindowController alloc] + initWithWidth:width + withHeight:height + withStyle:static_cast(style) + withTitle:m_title + withRequester:this]; + + m_handles.view = [m_controller nativeHandle]; + } + + ///////////////////////////////////// + ///////////////////////////////////// + macOSWindow::~macOSWindow() { + [m_controller close]; + } + + ///////////////////////////////////// + ///////////////////////////////////// + macOSWindow::macOSWindow(macOSWindow &&) noexcept = default; + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::operator=(macOSWindow &&) noexcept -> macOSWindow & = default; + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::pollEvent() noexcept -> void { + [m_controller processEvent]; + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::waitEvent() noexcept -> void { + [m_controller processEvent]; + } - monitor.name = [screen_name UTF8String]; + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::setTitle(std::string title) noexcept -> void { + m_title = std::move(title); - for (auto i = CFIndex{0}; i < mode_count; ++i) { - auto mode = (__bridge CGDisplayModeRef)([modes objectAtIndex:i]); + [m_controller setWindowTitle:m_title]; + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::setExtent(std::uint32_t width, std::uint32_t height) noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::setFullscreenEnabled(bool fullscreen) noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::lockMouse() noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::unlockMouse() noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::hideMouse() noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::unhideMouse() noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::width() const noexcept -> std::uint32_t { + auto size = [m_controller size]; + + return size.width; + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::height() const noexcept -> std::uint32_t { + auto size = [m_controller size]; + + return size.height; + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::macOSHandles() const noexcept -> const Handles & { + return m_handles; + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::setKeyRepeatEnabled([[maybe_unused]] bool enabled) noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::setVirtualKeyboardVisible([[maybe_unused]] bool visible) noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::setMousePosition([[maybe_unused]] std::int32_t x, + [[maybe_unused]] std::int32_t y) noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::setMousePositionOnDesktop([[maybe_unused]] std::uint32_t x, + [[maybe_unused]] std::uint32_t y) noexcept -> void { + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto macOSWindow::getMonitorSettings() -> std::vector { + // TODO handle multiple monitors + auto display_id = CGMainDisplayID(); + auto modes = (__bridge NSArray *)CGDisplayCopyAllDisplayModes(display_id, nullptr); + auto device_info = (__bridge NSDictionary *) + IODisplayCreateInfoDictionary(CGDisplayIOServicePort(display_id), + kIODisplayOnlyPreferredName); + + const auto mode_count = [modes count]; + + auto monitors = std::vector {}; + auto &monitor = monitors.emplace_back(); + monitor.extents.reserve(mode_count); + monitor.flags = Monitor::Flags::Primary; + monitor.handle = (void *)display_id; + + auto screen_name = @""; + auto localized_names = + [device_info objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; + if ([localized_names count] > 0) [[likely]] + screen_name = + [localized_names objectForKey:[[localized_names allKeys] objectAtIndex:0]]; + + monitor.name = [screen_name UTF8String]; + + for (auto i = CFIndex { 0 }; i < mode_count; ++i) { + auto mode = (__bridge CGDisplayModeRef)([modes objectAtIndex:i]); + + monitor.extents.emplace_back(CGDisplayModeGetWidth(mode), CGDisplayModeGetHeight(mode)); + } + + return monitors; + } - monitor.extents.emplace_back(CGDisplayModeGetWidth(mode), CGDisplayModeGetHeight(mode)); - } + ///////////////////////////////////// + ///////////////////////////////////// + auto initCocoaProcess() -> void { + if (!is_process_set_as_application) { + [StormKitApplication sharedApplication]; - return monitors; -} - -///////////////////////////////////// -///////////////////////////////////// -auto initCocoaProcess() -> void { - if (!is_process_set_as_application) { - [StormKitApplication sharedApplication]; - - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - [NSApp activateIgnoringOtherApps:YES]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + [NSApp activateIgnoringOtherApps:YES]; - if (![[StormKitApplication sharedApplication] delegate]) - [[StormKitApplication sharedApplication] - setDelegate:[[StormKitApplicationDelegate alloc] init]]; + if (![[StormKitApplication sharedApplication] delegate]) + [[StormKitApplication sharedApplication] + setDelegate:[[StormKitApplicationDelegate alloc] init]]; - [[StormKitApplication sharedApplication] finishLaunching]; + [[StormKitApplication sharedApplication] finishLaunching]; - is_process_set_as_application = true; + is_process_set_as_application = true; + } } -} -} +} // namespace stormkit::wsi::macos diff --git a/src/Wsi/win32/WindowImpl.mpp b/src/Wsi/win32/WindowImpl.mpp index 62c8de3f..f55420b1 100644 --- a/src/Wsi/win32/WindowImpl.mpp +++ b/src/Wsi/win32/WindowImpl.mpp @@ -68,7 +68,7 @@ export namespace stormkit::wsi::win32 { auto setVirtualKeyboardVisible(bool visible) noexcept -> void; - auto setMousePosition(const core::math::Vector2I &position) noexcept -> void; + auto setMousePosition(const core::math::Vector2I& position) noexcept -> void; static auto setMousePositionOnDesktop(WM wm, const core::math::Vector2U& position) noexcept -> void; @@ -449,7 +449,7 @@ namespace stormkit::wsi::win32 { LPARAM data) -> BOOL { if (_monitor == nullptr) return TRUE; - auto& monitors = *reinterpret_cast *>(data); + auto& monitors = *reinterpret_cast*>(data); auto monitor_info = MONITORINFOEX {}; ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); @@ -494,13 +494,13 @@ namespace stormkit::wsi::win32 { auto WindowImpl::globalOnEvent(HWND handle, UINT message, WPARAM w_param, LPARAM l_param) -> LRESULT { if (message == WM_CREATE) { - auto lp_create_params = reinterpret_cast(l_param)->lpCreateParams; + auto lp_create_params = reinterpret_cast(l_param)->lpCreateParams; SetWindowLongPtrW(handle, GWLP_USERDATA, reinterpret_cast(lp_create_params)); } auto window = handle - ? reinterpret_cast(GetWindowLongPtrW(handle, GWLP_USERDATA)) + ? reinterpret_cast(GetWindowLongPtrW(handle, GWLP_USERDATA)) : nullptr; if (window) window->processEvents(message, w_param, l_param); diff --git a/tests/src/Test.mpp b/tests/src/Test.mpp index 8dbd7afb..5d18024e 100644 --- a/tests/src/Test.mpp +++ b/tests/src/Test.mpp @@ -30,8 +30,8 @@ export namespace test { }; struct TestSuite { - TestSuite(std::string && name, - std::vector && tests, + TestSuite(std::string&& name, + std::vector&& tests, const std::source_location& location = std::source_location::current()) noexcept; }; @@ -149,8 +149,8 @@ namespace test { return failed_tests == 0; } - TestSuite::TestSuite(std::string && name, - std::vector && tests, + TestSuite::TestSuite(std::string&& name, + std::vector&& tests, const std::source_location& location) noexcept { state.test_suites.emplace_back( std::make_unique(std::move(name), std::move(tests), location)); diff --git a/tests/src/core/AsCast.cpp b/tests/src/core/AsCast.cpp index 9be364f2..e7460015 100644 --- a/tests/src/core/AsCast.cpp +++ b/tests/src/core/AsCast.cpp @@ -81,9 +81,9 @@ namespace { auto bar = std::unique_ptr { std::make_unique() }; - expects((as(bar.get())->foo() == 1)); + expects((as(bar.get())->foo() == 1)); expects((as(bar.get()).foo() == 1)); - expects((as(*bar)->foo() == 1)); + expects((as(*bar)->foo() == 1)); expects((as(*bar).foo() == 1)); } }, { "AsCast.ByteAs", @@ -95,19 +95,19 @@ namespace { }; auto bar = Foo { 9, 3, 'x' }; - auto bar_byte_ptr = as(&bar); + auto bar_byte_ptr = as(&bar); expects(bar_byte_ptr != nullptr); - bar_byte_ptr = as(bar); + bar_byte_ptr = as(bar); expects(bar_byte_ptr != nullptr); - auto bar_ptr = as(bar_byte_ptr); + auto bar_ptr = as(bar_byte_ptr); expects(bar_ptr != nullptr); expects(bar_ptr->a == 9); expects(bar_ptr->b == 3); expects(bar_ptr->c == 'x'); - bar_ptr = as(*bar_byte_ptr); + bar_ptr = as(*bar_byte_ptr); expects(bar_ptr != nullptr); expects(bar_ptr->a == 9); expects(bar_ptr->b == 3); From 3e0bbd0b794dc511e7f058e5f5f18900b62914fb Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Feb 2024 22:41:28 +0100 Subject: [PATCH 04/39] include missing header for feature testing --- modules/stormkit/Core/Utils/Assert.mpp | 117 +++++++++--------- modules/stormkit/Core/Utils/ErrorHandling.mpp | 10 +- 2 files changed, 64 insertions(+), 63 deletions(-) diff --git a/modules/stormkit/Core/Utils/Assert.mpp b/modules/stormkit/Core/Utils/Assert.mpp index 2235b606..591a45bd 100644 --- a/modules/stormkit/Core/Utils/Assert.mpp +++ b/modules/stormkit/Core/Utils/Assert.mpp @@ -6,6 +6,8 @@ module; #include +#include + export module stormkit.Core:Utils.Assert; import std; @@ -33,44 +35,38 @@ export namespace stormkit::core { std::string_view message, const std::source_location& location) noexcept; - constexpr auto - assert(bool cond, - std::string_view message, - bool show_callstack = true, - const std::source_location& location = std::source_location::current()) noexcept - -> void; - - constexpr auto - assert(bool cond, - bool show_callstack = true, - const std::source_location& location = std::source_location::current()) noexcept - -> void; - - constexpr auto - expects(bool cond, - std::string_view message, - bool show_callstack = true, - const std::source_location& location = std::source_location::current()) noexcept - -> void; - - constexpr auto - expects(bool cond, - bool show_callstack = true, - const std::source_location& location = std::source_location::current()) noexcept - -> void; - - constexpr auto - ensures(bool cond, - std::string_view message, - bool show_callstack = true, - const std::source_location& location = std::source_location::current()) noexcept - -> void; - - constexpr auto - ensures(bool cond, - bool show_callstack = true, - const std::source_location& location = std::source_location::current()) noexcept - -> void; + constexpr auto assert( + bool cond, + std::string_view message, + bool show_callstack = true, + const std::source_location& location = std::source_location::current()) noexcept -> void; + + constexpr auto assert( + bool cond, + bool show_callstack = true, + const std::source_location& location = std::source_location::current()) noexcept -> void; + + constexpr auto expects( + bool cond, + std::string_view message, + bool show_callstack = true, + const std::source_location& location = std::source_location::current()) noexcept -> void; + + constexpr auto expects( + bool cond, + bool show_callstack = true, + const std::source_location& location = std::source_location::current()) noexcept -> void; + + constexpr auto ensures( + bool cond, + std::string_view message, + bool show_callstack = true, + const std::source_location& location = std::source_location::current()) noexcept -> void; + + constexpr auto ensures( + bool cond, + bool show_callstack = true, + const std::source_location& location = std::source_location::current()) noexcept -> void; } // namespace stormkit::core //////////////////////////////////////////////////////////////////// @@ -144,11 +140,11 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto assert(bool cond, - std::string_view message, - bool show_callstack, - const std::source_location& location) noexcept - -> void { + STORMKIT_FORCE_INLINE constexpr auto + assert(bool cond, + std::string_view message, + bool show_callstack, + const std::source_location& location) noexcept -> void { #ifdef STORMKIT_COMPILER_MSVC if constexpr (std::is_constant_evaluated()) { #else @@ -163,18 +159,19 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE constexpr auto - assert(bool cond, bool show_callstack, const std::source_location& location) noexcept - -> void { + assert(bool cond, + bool show_callstack, + const std::source_location& location) noexcept -> void { assert(cond, "Condition check failed", show_callstack, location); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto expects(bool cond, - std::string_view message, - bool show_callstack, - const std::source_location& location) noexcept - -> void { + STORMKIT_FORCE_INLINE constexpr auto + expects(bool cond, + std::string_view message, + bool show_callstack, + const std::source_location& location) noexcept -> void { #ifdef STORMKIT_COMPILER_MSVC if constexpr (std::is_constant_evaluated()) { #else @@ -189,18 +186,19 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE constexpr auto - expects(bool cond, bool show_callstack, const std::source_location& location) noexcept - -> void { + expects(bool cond, + bool show_callstack, + const std::source_location& location) noexcept -> void { expects(cond, "Condition check failed", show_callstack, location); } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto ensures(bool cond, - std::string_view message, - bool show_callstack, - const std::source_location& location) noexcept - -> void { + STORMKIT_FORCE_INLINE constexpr auto + ensures(bool cond, + std::string_view message, + bool show_callstack, + const std::source_location& location) noexcept -> void { #ifdef STORMKIT_COMPILER_MSVC if constexpr (std::is_constant_evaluated()) { #else @@ -215,8 +213,9 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE constexpr auto - ensures(bool cond, bool show_callstack, const std::source_location& location) noexcept - -> void { + ensures(bool cond, + bool show_callstack, + const std::source_location& location) noexcept -> void { ensures(cond, "Condition check failed", show_callstack, location); } } // namespace stormkit::core diff --git a/modules/stormkit/Core/Utils/ErrorHandling.mpp b/modules/stormkit/Core/Utils/ErrorHandling.mpp index 8f2350c8..79cb1f6c 100644 --- a/modules/stormkit/Core/Utils/ErrorHandling.mpp +++ b/modules/stormkit/Core/Utils/ErrorHandling.mpp @@ -6,6 +6,8 @@ module; #include +#include + export module stormkit.Core:Utils.ErrorHandling; import std; @@ -79,7 +81,7 @@ namespace stormkit::core { auto st = std::stacktrace::current(); std::println(stderr, "{}", std::to_string(st)); #else - std::println(stderr, "No stacktrace support"); + std::println(stderr, "No support !"); #endif std::terminate(); @@ -110,7 +112,7 @@ namespace stormkit::core { auto st = std::stacktrace::current(); std::println(stderr, "{}", std::to_string(st)); #else - std::println(stderr, "No stacktrace support"); + std::println(stderr, "No support !"); #endif std::terminate(); @@ -144,7 +146,7 @@ namespace stormkit::core { auto st = std::stacktrace::current(); std::println(stderr, "{}", std::to_string(st)); #else - std::println(stderr, "No stacktrace support"); + std::println(stderr, "No support !"); #endif std::terminate(); @@ -175,7 +177,7 @@ namespace stormkit::core { auto st = std::stacktrace::current(); std::println(stderr, "{}", std::to_string(st)); #else - std::println(stderr, "No stacktrace support"); + std::println(stderr, "No support !"); #endif std::terminate(); From 5060c85bec71fbde35c9b610f5b9a761ff17e8a0 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Feb 2024 22:42:05 +0100 Subject: [PATCH 05/39] add formatter for gpu::PhysicalDevice --- modules/stormkit/Gpu/Core/Instance.mpp | 299 ++++++++++++++----------- 1 file changed, 166 insertions(+), 133 deletions(-) diff --git a/modules/stormkit/Gpu/Core/Instance.mpp b/modules/stormkit/Gpu/Core/Instance.mpp index 59e09659..a88b843d 100644 --- a/modules/stormkit/Gpu/Core/Instance.mpp +++ b/modules/stormkit/Gpu/Core/Instance.mpp @@ -19,126 +19,159 @@ import stormkit.Gpu.Vulkan; import :Core.Types; import :Core.Device; -export namespace stormkit::gpu { - class PhysicalDevice; - - class STORMKIT_API Instance { - struct Tag {}; - - public: - static constexpr auto DEBUG_TYPE = DebugObjectType::Instance; - - Instance(std::string app_name, bool verbose, Tag); - ~Instance(); - - Instance(const Instance&) = delete; - auto operator=(const Instance&) -> Instance& = delete; - - Instance(Instance&&) noexcept; - auto operator=(Instance&&) noexcept -> Instance&; - - [[nodiscard]] static auto create(std::string app_name = "", - bool verbose = (core::STORMKIT_BUILD_TYPE == - "Debug")) noexcept -> Expected; - [[nodiscard]] static auto - allocate(std::string app_name = "", - bool verbose = (core::STORMKIT_BUILD_TYPE == "Debug")) noexcept - -> Expected>; - - [[nodiscard]] auto physicalDevices() const noexcept -> const std::vector&; - - [[nodiscard]] auto vkHandle() const noexcept -> const vk::raii::Instance&; - - // #ifdef STORMKIT_WSI_ENABLED - //[[nodiscard]] auto createWindowSurface( - // const wsi::Window& window, - // Surface::Buffering buffering = Surface::Buffering::Swapchain) const - //-> WindowSurface; - //[[nodiscard]] auto allocateWindowSurface( - // const wsi::Window& window, - // Surface::Buffering buffering = Surface::Buffering::Swapchain) const - //-> std::unique_ptr; - //[[nodiscard]] auto allocateRefCountedWindowSurface( - // const wsi::Window& window, - // Surface::Buffering buffering = Surface::Buffering::Swapchain) const - //-> std::shared_ptr; - // #endif - - //[[nodiscard]] auto createOffscreenSurface( - // const core::math::ExtentU& extent, - // Surface::Buffering buffering = Surface::Buffering::Triple) const - //-> OffscreenSurface; - //[[nodiscard]] auto allocateOffscreenSurface( - // const core::math::ExtentU& extent, - // Surface::Buffering buffering = Surface::Buffering::Triple) const - //-> std::unique_ptr; - //[[nodiscard]] auto allocateRefCountedOffscreenSurface( - // const core::math::ExtentU& extent, - // Surface::Buffering buffering = Surface::Buffering::Triple) const - //-> std::shared_ptr; - - private: - auto doInitInstance() noexcept -> VulkanExpected; - auto doInitDebugReportCallback() noexcept -> VulkanExpected; - auto doRetrievePhysicalDevices() noexcept -> VulkanExpected; - - std::string m_app_name; - bool m_validation_layers_enabled; - - core::DeferInit m_vk_context; - core::DeferInit m_vk_instance; - core::DeferInit m_vk_messenger; - - std::vector m_extensions; - std::vector m_physical_devices; - }; - - class STORMKIT_API PhysicalDevice: public InstanceObject { - public: - static constexpr auto DEBUG_TYPE = DebugObjectType::Physical_Device; - - ~PhysicalDevice(); - - PhysicalDevice(const PhysicalDevice&) = delete; - auto operator=(const PhysicalDevice&) -> PhysicalDevice& = delete; - - PhysicalDevice(PhysicalDevice&&) noexcept; - auto operator=(PhysicalDevice&&) noexcept -> PhysicalDevice&; - - [[nodiscard]] auto checkExtensionSupport(std::string_view extension) const noexcept -> bool; - [[nodiscard]] auto - checkExtensionSupport(std::span extensions) const noexcept - -> bool; - [[nodiscard]] auto - checkExtensionSupport(std::span extensions) const noexcept - -> bool; - - [[nodiscard]] auto info() const noexcept -> const PhysicalDeviceInfo&; - [[nodiscard]] auto capabilities() const noexcept -> const RenderCapabilities&; - [[nodiscard]] auto memoryProperties() const noexcept - -> const std::vector&; - - [[nodiscard]] auto queueFamilies() const noexcept -> const std::vector&; - - [[nodiscard]] auto vkHandle() const noexcept -> const vk::raii::PhysicalDevice&; - - private: - PhysicalDevice(vk::raii::PhysicalDevice physical_device, const Instance& instance); - - vk::raii::PhysicalDevice m_vk_physical_device; - - PhysicalDeviceInfo m_device_info; - RenderCapabilities m_capabilities; - std::vector m_memory_properties; - - std::vector m_queue_families; - vk::PhysicalDeviceMemoryProperties m_vk_memory_properties; - - std::vector m_extensions; - - friend class Instance; - }; -} // namespace stormkit::gpu +export { + namespace stormkit::gpu { + class PhysicalDevice; + + class STORMKIT_API Instance { + struct Tag {}; + + public: + static constexpr auto DEBUG_TYPE = DebugObjectType::Instance; + + Instance(std::string app_name, bool verbose, Tag); + ~Instance(); + + Instance(const Instance&) = delete; + auto operator=(const Instance&) -> Instance& = delete; + + Instance(Instance&&) noexcept; + auto operator=(Instance&&) noexcept -> Instance&; + + [[nodiscard]] static auto + create(std::string app_name = "", + bool verbose = (core::STORMKIT_BUILD_TYPE == + "Debug")) noexcept -> Expected; + [[nodiscard]] static auto + allocate(std::string app_name = "", + bool verbose = (core::STORMKIT_BUILD_TYPE == + "Debug")) noexcept -> Expected>; + + [[nodiscard]] auto + physicalDevices() const noexcept -> const std::vector&; + + [[nodiscard]] auto vkHandle() const noexcept -> const vk::raii::Instance&; + + // #ifdef STORMKIT_WSI_ENABLED + //[[nodiscard]] auto createWindowSurface( + // const wsi::Window& window, + // Surface::Buffering buffering = Surface::Buffering::Swapchain) const + //-> WindowSurface; + //[[nodiscard]] auto allocateWindowSurface( + // const wsi::Window& window, + // Surface::Buffering buffering = Surface::Buffering::Swapchain) const + //-> std::unique_ptr; + //[[nodiscard]] auto allocateRefCountedWindowSurface( + // const wsi::Window& window, + // Surface::Buffering buffering = Surface::Buffering::Swapchain) const + //-> std::shared_ptr; + // #endif + + //[[nodiscard]] auto createOffscreenSurface( + // const core::math::ExtentU& extent, + // Surface::Buffering buffering = Surface::Buffering::Triple) const + //-> OffscreenSurface; + //[[nodiscard]] auto allocateOffscreenSurface( + // const core::math::ExtentU& extent, + // Surface::Buffering buffering = Surface::Buffering::Triple) const + //-> std::unique_ptr; + //[[nodiscard]] auto allocateRefCountedOffscreenSurface( + // const core::math::ExtentU& extent, + // Surface::Buffering buffering = Surface::Buffering::Triple) const + //-> std::shared_ptr; + + private: + auto doInitInstance() noexcept -> VulkanExpected; + auto doInitDebugReportCallback() noexcept -> VulkanExpected; + auto doRetrievePhysicalDevices() noexcept -> VulkanExpected; + + std::string m_app_name; + bool m_validation_layers_enabled; + + core::DeferInit m_vk_context; + core::DeferInit m_vk_instance; + core::DeferInit m_vk_messenger; + + std::vector m_extensions; + std::vector m_physical_devices; + }; + + class STORMKIT_API PhysicalDevice: public InstanceObject { + public: + static constexpr auto DEBUG_TYPE = DebugObjectType::Physical_Device; + + ~PhysicalDevice(); + + PhysicalDevice(const PhysicalDevice&) = delete; + auto operator=(const PhysicalDevice&) -> PhysicalDevice& = delete; + + PhysicalDevice(PhysicalDevice&&) noexcept; + auto operator=(PhysicalDevice&&) noexcept -> PhysicalDevice&; + + [[nodiscard]] auto + checkExtensionSupport(std::string_view extension) const noexcept -> bool; + [[nodiscard]] auto checkExtensionSupport( + std::span extensions) const noexcept -> bool; + [[nodiscard]] auto checkExtensionSupport( + std::span extensions) const noexcept -> bool; + + [[nodiscard]] auto info() const noexcept -> const PhysicalDeviceInfo&; + [[nodiscard]] auto capabilities() const noexcept -> const RenderCapabilities&; + [[nodiscard]] auto + memoryProperties() const noexcept -> const std::vector&; + + [[nodiscard]] auto queueFamilies() const noexcept -> const std::vector&; + + [[nodiscard]] auto vkHandle() const noexcept -> const vk::raii::PhysicalDevice&; + + private: + PhysicalDevice(vk::raii::PhysicalDevice physical_device, const Instance& instance); + + vk::raii::PhysicalDevice m_vk_physical_device; + + PhysicalDeviceInfo m_device_info; + RenderCapabilities m_capabilities; + std::vector m_memory_properties; + + std::vector m_queue_families; + vk::PhysicalDeviceMemoryProperties m_vk_memory_properties; + + std::vector m_extensions; + + friend class Instance; + }; + + } // namespace stormkit::gpu + + namespace std { + template + struct formatter { + template + STORMKIT_FORCE_INLINE constexpr auto parse(ParseContext& ctx) -> decltype(auto) { + return ctx.begin(); + } + + template + STORMKIT_FORCE_INLINE auto format(const stormkit::gpu::PhysicalDevice& device, + FormatContext& ctx) const -> decltype(auto) { + auto&& out = ctx.out(); + const auto& info = device.info(); + return format_to( + out, + "[name: {}, vendor: {}, id: {}, vulkan: {}.{}.{}, driver version: {}.{}.{}]", + info.device_name, + info.vendor_name, + info.device_id, + info.api_major_version, + info.api_minor_version, + info.api_patch_version, + info.driver_major_version, + info.driver_minor_version, + info.driver_patch_version); + } + }; + } // namespace std +} //////////////////////////////////////////////////////////////////// /// IMPLEMENTATION /// @@ -165,14 +198,14 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Instance::operator=(Instance&& other) noexcept - -> Instance& = default; + STORMKIT_FORCE_INLINE auto + Instance::operator=(Instance&& other) noexcept -> Instance& = default; ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Instance::create(std::string app_name, - bool enable_validation) noexcept - -> Expected try { + STORMKIT_FORCE_INLINE auto + Instance::create(std::string app_name, + bool enable_validation) noexcept -> Expected try { return Instance { std::move(app_name), enable_validation, Tag {} }; } catch (Result result) { return std::unexpected(result); } @@ -186,8 +219,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Instance::physicalDevices() const noexcept - -> const std::vector& { + STORMKIT_FORCE_INLINE auto + Instance::physicalDevices() const noexcept -> const std::vector& { return m_physical_devices; } @@ -256,8 +289,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PhysicalDevice::capabilities() const noexcept - -> const RenderCapabilities& { + STORMKIT_FORCE_INLINE auto + PhysicalDevice::capabilities() const noexcept -> const RenderCapabilities& { return m_capabilities; } @@ -270,15 +303,15 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PhysicalDevice::queueFamilies() const noexcept - -> const std::vector& { + STORMKIT_FORCE_INLINE auto + PhysicalDevice::queueFamilies() const noexcept -> const std::vector& { return m_queue_families; } ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto PhysicalDevice::vkHandle() const noexcept - -> const vk::raii::PhysicalDevice& { + STORMKIT_FORCE_INLINE auto + PhysicalDevice::vkHandle() const noexcept -> const vk::raii::PhysicalDevice& { return m_vk_physical_device; } } // namespace stormkit::gpu From 4f4b67f9508d0ea6e832b3b31b5d795ef4db90cd Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Feb 2024 23:39:40 +0100 Subject: [PATCH 06/39] use std::ranges support of std::format --- modules/stormkit/Core/Utils/Assert.mpp | 2 +- src/Gpu/Core/Device.cpp | 11 +++-------- src/Gpu/Core/Instance.cpp | 4 +--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/modules/stormkit/Core/Utils/Assert.mpp b/modules/stormkit/Core/Utils/Assert.mpp index 591a45bd..dec1c220 100644 --- a/modules/stormkit/Core/Utils/Assert.mpp +++ b/modules/stormkit/Core/Utils/Assert.mpp @@ -115,7 +115,7 @@ namespace stormkit::core { auto st = std::stacktrace::current(); std::println(stderr, "{}", std::to_string(st)); #else - std::println(stderr, "No stacktrace support"); + std::println(stderr, "No support !"); #endif } diff --git a/src/Gpu/Core/Device.cpp b/src/Gpu/Core/Device.cpp index 475e36eb..452c37b1 100644 --- a/src/Gpu/Core/Device.cpp +++ b/src/Gpu/Core/Device.cpp @@ -131,10 +131,9 @@ namespace stormkit::gpu { const auto device_extensions = m_physical_device->vkHandle().enumerateDeviceExtensionProperties(); - device_logger.dlog("Device extensions -----------"); - for (const auto& ext : device_extensions) - device_logger.dlog("{}", std::string_view { ext.extensionName }); - device_logger.dlog("-------------------------------"); + device_logger.dlog("Device extensions: {}", device_extensions | std::views::transform([](auto&& ext) { + return std::string_view { ext.extensionName }; + })); const auto swapchain_available = [&] { for (const auto& ext : SWAPCHAIN_EXTENSIONS) { @@ -145,8 +144,6 @@ namespace stormkit::gpu { } } - device_logger.ilog("Swapchain supported !"); - return true; }(); @@ -159,8 +156,6 @@ namespace stormkit::gpu { } } - device_logger.ilog("Raytracing supported !"); - return true; }(); diff --git a/src/Gpu/Core/Instance.cpp b/src/Gpu/Core/Instance.cpp index ca639a8c..e0421692 100644 --- a/src/Gpu/Core/Instance.cpp +++ b/src/Gpu/Core/Instance.cpp @@ -140,9 +140,7 @@ namespace stormkit::gpu { }) | std::ranges::to(); - dlog("Instance extensions -----------"); - for (auto&& str : m_extensions) dlog(" {}", str); - dlog("-------------------------------"); + dlog("Instance extensions: {}", m_extensions); const auto validation_layers = [this]() noexcept { auto output = std::vector {}; From 0f459846fc8f6faf87d9c8c931b31253d4d12c3f Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 4 Feb 2024 23:40:01 +0100 Subject: [PATCH 07/39] fix constructors of gpu::Device --- modules/stormkit/Gpu/Core/Device.mpp | 74 +++++++++++++++++----------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/modules/stormkit/Gpu/Core/Device.mpp b/modules/stormkit/Gpu/Core/Device.mpp index 4003e179..eb2cab78 100644 --- a/modules/stormkit/Gpu/Core/Device.mpp +++ b/modules/stormkit/Gpu/Core/Device.mpp @@ -53,26 +53,27 @@ export namespace stormkit::gpu { [[nodiscard]] static auto create(const PhysicalDevice& physical_device, const Instance& instance, - const Info& info = { true, false }) noexcept -> Device; + const Info& info = { true, + false }) noexcept -> Expected; [[nodiscard]] static auto allocate(const PhysicalDevice& physical_device, const Instance& instance, const Info& info = { true, false }) noexcept - -> std::unique_ptr; + -> Expected>; auto waitIdle() const noexcept -> void; - [[nodiscard]] auto waitForFences(std::span> fences, - bool wait_all = true, - const std::chrono::milliseconds& timeout = - std::chrono::milliseconds::max()) const noexcept - -> Expected; - [[nodiscard]] auto waitForFence(const Fence& fence, - const std::chrono::milliseconds& timeout = - std::chrono::milliseconds::max()) const noexcept - -> Expected; - - auto resetFences(std::span> fences) const noexcept - -> void; + [[nodiscard]] auto + waitForFences(std::span> fences, + bool wait_all = true, + const std::chrono::milliseconds& timeout = + std::chrono::milliseconds::max()) const noexcept -> Expected; + [[nodiscard]] auto + waitForFence(const Fence& fence, + const std::chrono::milliseconds& timeout = + std::chrono::milliseconds::max()) const noexcept -> Expected; + + auto + resetFences(std::span> fences) const noexcept -> void; auto resetFence(const Fence& fence) const noexcept -> void; [[nodiscard]] auto rasterQueueEntry() const noexcept -> const QueueEntry&; @@ -92,8 +93,9 @@ export namespace stormkit::gpu { template auto setObjectName(const T& object, std::string_view name) const -> void; - auto setObjectName(core::UInt64 object, DebugObjectType type, std::string_view name) const - -> void; + auto setObjectName(core::UInt64 object, + DebugObjectType type, + std::string_view name) const -> void; private: core::NakedRef m_physical_device; @@ -128,6 +130,23 @@ namespace stormkit::gpu { ///////////////////////////////////// STORMKIT_FORCE_INLINE auto Device::operator=(Device&& other) noexcept -> Device& = default; + ///////////////////////////////////// + ///////////////////////////////////// + STORMKIT_FORCE_INLINE auto Device::create(const PhysicalDevice& physical_device, + const Instance& instance, + const Info& info) noexcept -> Expected try { + return Device { physical_device, instance, info, Tag {} }; + } catch (Result result) { return std::unexpected(result); } + + ///////////////////////////////////// + ///////////////////////////////////// + STORMKIT_FORCE_INLINE auto + Device::allocate(const PhysicalDevice& physical_device, + const Instance& instance, + const Info& info) noexcept -> Expected> try { + return std::make_unique(physical_device, instance, info, Tag {}); + } catch (Result result) { return std::unexpected(result); } + ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE auto Device::waitIdle() const noexcept -> void { @@ -136,10 +155,9 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto - Device::waitForFence(const Fence& fence, - const std::chrono::milliseconds& timeout) const noexcept - -> Expected { + STORMKIT_FORCE_INLINE auto Device::waitForFence( + const Fence& fence, + const std::chrono::milliseconds& timeout) const noexcept -> Expected { return waitForFences(core::makeNakedRefArray(fence), true, timeout); } @@ -157,8 +175,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Device::asyncTransfertQueueEntry() const noexcept - -> const QueueEntry& { + STORMKIT_FORCE_INLINE auto + Device::asyncTransfertQueueEntry() const noexcept -> const QueueEntry& { core::expects(m_async_transfert_queue != std::nullopt); return *m_async_transfert_queue; @@ -166,8 +184,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Device::asyncComputeQueueEntry() const noexcept - -> const QueueEntry& { + STORMKIT_FORCE_INLINE auto + Device::asyncComputeQueueEntry() const noexcept -> const QueueEntry& { core::expects(m_async_compute_queue != std::nullopt); return *m_async_compute_queue; @@ -207,16 +225,16 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto Device::vmaFunctionTable() const noexcept - -> const vma::VulkanFunctions& { + STORMKIT_FORCE_INLINE auto + Device::vmaFunctionTable() const noexcept -> const vma::VulkanFunctions& { return m_vma_function_table; } ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto Device::setObjectName(const T& object, std::string_view name) const - -> void { + STORMKIT_FORCE_INLINE auto Device::setObjectName(const T& object, + std::string_view name) const -> void { setObjectName(std::bit_cast(*(object.vkHandle())), T::DEBUG_TYPE, name); } From 0047446e96dcccd74965db807022142009e0434a Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:26:42 +0100 Subject: [PATCH 08/39] update xmake.lua and add Stacktrace fallback --- modules/stormkit/Core/Utils.mpp | 1 + modules/stormkit/Core/Utils/Assert.mpp | 13 +-- modules/stormkit/Core/Utils/ErrorHandling.mpp | 67 ++++-------- modules/stormkit/Core/Utils/Stacktrace.mpp | 100 ++++++++++++++++++ xmake.lua | 63 +++++++---- 5 files changed, 161 insertions(+), 83 deletions(-) create mode 100644 modules/stormkit/Core/Utils/Stacktrace.mpp diff --git a/modules/stormkit/Core/Utils.mpp b/modules/stormkit/Core/Utils.mpp index aad7b525..a2b194a0 100644 --- a/modules/stormkit/Core/Utils.mpp +++ b/modules/stormkit/Core/Utils.mpp @@ -27,3 +27,4 @@ export import :Utils.Pimpl; export import :Utils.Predicates; export import :Utils.Random; export import :Utils.Singleton; +export import :Utils.Stacktrace; diff --git a/modules/stormkit/Core/Utils/Assert.mpp b/modules/stormkit/Core/Utils/Assert.mpp index dec1c220..fe0f11f0 100644 --- a/modules/stormkit/Core/Utils/Assert.mpp +++ b/modules/stormkit/Core/Utils/Assert.mpp @@ -6,13 +6,12 @@ module; #include -#include - export module stormkit.Core:Utils.Assert; import std; import :Utils.Descriptors; +import :Utils.Stacktrace; export namespace stormkit::core { enum class AssertType { @@ -109,15 +108,7 @@ namespace stormkit::core { location.function_name(), message); - if (show_callstack) { - std::println(stderr, "================= CALLSTACK ================="); -#if defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L - auto st = std::stacktrace::current(); - std::println(stderr, "{}", std::to_string(st)); -#else - std::println(stderr, "No support !"); -#endif - } + if (show_callstack) printStacktrace(); std::terminate(); } diff --git a/modules/stormkit/Core/Utils/ErrorHandling.mpp b/modules/stormkit/Core/Utils/ErrorHandling.mpp index 79cb1f6c..d9aa2c86 100644 --- a/modules/stormkit/Core/Utils/ErrorHandling.mpp +++ b/modules/stormkit/Core/Utils/ErrorHandling.mpp @@ -6,8 +6,6 @@ module; #include -#include - export module stormkit.Core:Utils.ErrorHandling; import std; @@ -16,6 +14,7 @@ import :Meta.Concepts; import :Meta.Traits; import :Utils.Descriptors; +import :Utils.Stacktrace; export namespace stormkit::core { template @@ -29,17 +28,15 @@ export namespace stormkit::core { expects(std::source_location location = std::source_location::current()) noexcept -> decltype(auto); // optional overload - [[nodiscard]] constexpr auto - expectsWithMessage(std::string&& message, - std::source_location location = std::source_location::current()) noexcept - -> decltype(auto); + [[nodiscard]] constexpr auto expectsWithMessage( + std::string&& message, + std::source_location location = std::source_location::current()) noexcept -> decltype(auto); - [[nodiscard]] constexpr auto - expects(std::source_location location = std::source_location::current()) noexcept - -> decltype(auto); + [[nodiscard]] constexpr auto expects( + std::source_location location = std::source_location::current()) noexcept -> decltype(auto); - [[nodiscard]] constexpr auto log(std::invocable auto&& logger, std::string&& message) noexcept - -> decltype(auto); + [[nodiscard]] constexpr auto log(std::invocable auto&& logger, + std::string&& message) noexcept -> decltype(auto); [[nodiscard]] constexpr auto throwError() noexcept -> decltype(auto); } // namespace stormkit::core @@ -58,8 +55,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - constexpr auto expectsWithMessage(std::string&& message, std::source_location location) noexcept - -> decltype(auto) { + constexpr auto expectsWithMessage(std::string&& message, + std::source_location location) noexcept -> decltype(auto) { return [message = std::move(message), location = std::move(location)] NORETURN_LAMBDA() -> std::optional { auto stderr = getSTDErr(); @@ -75,14 +72,7 @@ namespace stormkit::core { location.function_name(), message); - std::println(stderr, "================= CALLSTACK ================="); - -#if defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L - auto st = std::stacktrace::current(); - std::println(stderr, "{}", std::to_string(st)); -#else - std::println(stderr, "No support !"); -#endif + printStacktrace(); std::terminate(); }; @@ -106,14 +96,7 @@ namespace stormkit::core { location.function_name(), error); - std::println(stderr, "================= CALLSTACK ================="); - -#if defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L - auto st = std::stacktrace::current(); - std::println(stderr, "{}", std::to_string(st)); -#else - std::println(stderr, "No support !"); -#endif + printStacktrace(); std::terminate(); }; @@ -121,8 +104,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto expectsWithMessage(std::string&& message, std::source_location location) noexcept - -> decltype(auto) { + constexpr auto expectsWithMessage(std::string&& message, + std::source_location location) noexcept -> decltype(auto) { return [message = std::move(message), location = std::move(location)] NORETURN_LAMBDA( auto&& error) -> std::expected> { auto stderr = getSTDErr(); @@ -140,14 +123,7 @@ namespace stormkit::core { message, error); - std::println(stderr, "================= CALLSTACK ================="); - -#if defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L - auto st = std::stacktrace::current(); - std::println(stderr, "{}", std::to_string(st)); -#else - std::println(stderr, "No support !"); -#endif + printStacktrace(); std::terminate(); }; @@ -171,14 +147,7 @@ namespace stormkit::core { location.function_name(), std::forward(error)); - std::println(stderr, "================= CALLSTACK ================="); - -#if defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L - auto st = std::stacktrace::current(); - std::println(stderr, "{}", std::to_string(st)); -#else - std::println(stderr, "No support !"); -#endif + printStacktrace(); std::terminate(); }; @@ -186,8 +155,8 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// - constexpr auto log(std::invocable auto&& logger, std::string&& message) noexcept - -> decltype(auto) { + constexpr auto log(std::invocable auto&& logger, + std::string&& message) noexcept -> decltype(auto) { return [logger = std::forward, message = std::move(message)] NORETURN_LAMBDA( auto&& error) -> std::expected> { diff --git a/modules/stormkit/Core/Utils/Stacktrace.mpp b/modules/stormkit/Core/Utils/Stacktrace.mpp new file mode 100644 index 00000000..e8412d4a --- /dev/null +++ b/modules/stormkit/Core/Utils/Stacktrace.mpp @@ -0,0 +1,100 @@ +module; + +#include + +#include +#include + +#if defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L + #define STD_STACKTRACE_SUPPORTED +#else + #include + #include + #include +#endif + +export module stormkit.Core:Utils.Stacktrace; + +import std; + +export namespace stormkit::core { + auto printStacktrace(); +#if not defined(STD_STACKTRACE_SUPPORTED) + auto backtraceInit(const char* filename) noexcept -> bool; +#endif +} // namespace stormkit::core + +//////////////////////////////////////////////////////////////////// +/// IMPLEMENTATION /// +//////////////////////////////////////////////////////////////////// + +namespace stormkit::core { +#if not defined(STD_STACKTRACE_SUPPORTED) + namespace { + using BacktraceState = backtrace_state*; + auto __bt_state = BacktraceState { nullptr }; + auto __counter = 0; + + extern "C" auto bt_callback(void*, + std::uintptr_t, + const char* filename, + int line, + const char* function) noexcept -> int { + // auto status = 0; + // auto func_name = ""; + // if (function) func_name = function; + // + // const auto demangled = abi::__cxa_demangle(func_name, nullptr, nullptr, &status); + // + // if (status != 0) func_name = demangled; + // + // auto file_name = ""; + // if (filename) file_name = filename; + // + // std::println(stderr, "{}# {} at {}:{}", __counter++, func_name, file_name, line); + return 0; + } + + extern "C" auto + bt_error_callback(void* status, const char* message, int error) noexcept -> void { + if (status) *std::bit_cast(status) = false; + + std::println(stderr, "Failed to print stacktrace, reason: {} code: {}", message, error); + } + } // namespace +#endif + ///////////////////////////////////// + ///////////////////////////////////// + STORMKIT_FORCE_INLINE auto printStacktrace() { + std::println(stderr, "================= CALLSTACK ================="); +#if defined(STD_STACKTRACE_SUPPORTED) + const auto st = std::stacktrace::current(); + std::println(stderr, "{}", std::to_string(st)); +#else + backtrace_full(__bt_state, 0, bt_callback, bt_error_callback, nullptr); +#endif + } + +#if not defined(STD_STACKTRACE_SUPPORTED) + ///////////////////////////////////// + ///////////////////////////////////// + STORMKIT_FORCE_INLINE auto backtraceInit(const char* filename) noexcept -> bool { + #ifdef BACKTRACE_SUPPORTED + auto status = true; + + __bt_state = backtrace_create_state(filename, + BACKTRACE_SUPPORTS_THREADS, + bt_error_callback, + &status); + if (status) std::println("libbacktrace initialized for {}", filename); + else + std::println(stderr, "failed to initialize libbacktrace"); + + return status; + #else + std::println("libbacktrace not supported"); + return false; + #endif + } +#endif +} // namespace stormkit::core diff --git a/xmake.lua b/xmake.lua index 51c9777b..48a5cdf9 100644 --- a/xmake.lua +++ b/xmake.lua @@ -8,6 +8,10 @@ modules = { add_packages("wil") end + if get_config("toolchain") and (get_config("toolchain") == "clang" or get_config("toolchain") == "llvm") then + add_packages("libbacktrace", {public = true}) + end + set_configdir("$(buildir)/.gens/modules/stormkit/Core") add_filegroups("generated", { rootdir = "$(buildir)/.gens/modules" }) @@ -57,8 +61,8 @@ modules = { has_headers = true, deps = { "stormkit-core" }, custom = function() - add_cxflags("-Wno-main") - set_strip("debug") + add_cxflags("-Wno-main") + set_strip("debug") end }, wsi = { @@ -171,8 +175,14 @@ set_version("0.1.0", { build = "%Y%m%d%H%M" }) includes("xmake/**.lua") ---------------------------- global rules ---------------------------- -add_rules("plugin.vsxmake.autoupdate") -add_rules("plugin.compile_commands.autoupdate", { outputdir = "build", lsp = "clangd" }) +if get_config("vsxmake") then + add_rules("plugin.vsxmake.autoupdate") +end + +if get_config("compile_commands") then + add_rules("plugin.compile_commands.autoupdate", { outputdir = "build", lsp = "clangd" }) +end + add_rules( "mode.debug", "mode.release", @@ -189,28 +199,30 @@ if not is_plat("windows") or not is_plat("mingw") then end ---------------------------- global options ---------------------------- -option("enable_examples", { default = false, category = "root menu/others" }) -option("enable_applications", { default = false, category = "root menu/others" }) -option("enable_tests", { default = false, category = "root menu/others" }) +option("examples", { default = false, category = "root menu/others" }) +option("applications", { default = false, category = "root menu/others" }) +option("tests", { default = false, category = "root menu/others" }) option("sanitizers", { default = false, category = "root menu/build" }) option("mold", { default = false, category = "root menu/build" }) ---------------------------- module options ---------------------------- -option("enable_log", { default = true, category = "root menu/modules" }) -option("enable_entities", { default = true, category = "root menu/modules" }) -option("enable_image", { default = true, category = "root menu/modules" }) -option("enable_main", { default = true, category = "root menu/modules" }) -option("enable_wsi", { default = true, category = "root menu/modules" }) +option("log", { default = true, category = "root menu/modules" }) +option("entities", { default = true, category = "root menu/modules" }) +option("image", { default = true, category = "root menu/modules" }) +option("main", { default = true, category = "root menu/modules" }) +option("wsi", { default = true, category = "root menu/modules" }) option( - "enable_gpu", - { default = true, category = "root menu/modules", deps = { "enable_log", "enable_image", "enable_wsi" } } + "gpu", + { default = true, category = "root menu/modules", deps = { "log", "image", "wsi" } } ) -option("enable_engine", { +option("engine", { default = true, category = "root menu/modules", - deps = { "enable_log", "enable-entities", "enable_image", "enable_wsi", "enable_gpu" }, + deps = { "log", "entities", "image", "wsi", "gpu" }, }) +option("compile_commands", { default = false, category = "root menu/support"}) +option("vsxmake", { default = false, category = "root menu/support"}) ---------------------------- global config ---------------------------- set_allowedmodes(allowedmodes) @@ -295,22 +307,27 @@ if get_config("sanitizers") then set_policy("build.sanitizer.undefined", true) end -if has_config("enable_gpu") then +if has_config("gpu") then add_requireconfs("vulkan-headers", { override = true, system = false }) add_requireconfs("vulkan-memory-allocator", { override = true, version = "master", system = false }) - add_requireconfs("vulkan-memory-allocator-hpp", { override = true, version = "master", system = false, configs = { use_vulkanheaders = true }}) + add_requireconfs("vulkan-memory-allocator-hpp", + { override = true, version = "master", system = false, configs = { use_vulkanheaders = true } }) end -- add_defines("FROZEN_DONT_INCLUDE_STL", "ANKERL_UNORDERED_DENSE_USE_STD_IMPORT") add_requireconfs("*", { configs = { modules = true } }) +if get_config("toolchain") and (get_config("toolchain") == "clang" or get_config("toolchain") == "llvm") then + add_requires("libbacktrace") +end + ---------------------------- targets ---------------------------- for name, module in pairs(modules) do add_requires(table.join(module.packages or {}, module.public_packages or {})) local modulename = module.modulename - if name == "core" or name == "main" or get_config("enable_" .. name) then + if name == "core" or name == "main" or get_config("" .. name) then target("stormkit-" .. name, function() set_group("libraries") @@ -441,21 +458,21 @@ for name, module in pairs(modules) do add_frameworks(module.frameworks, { public = is_kind("static") }) end if is_mode("release") then - -- set_policy("build.optimization.lto", true) + -- set_policy("build.optimization.lto", true) end end) end end -if has_config("enable_examples") then +if has_config("examples") then for name, _ in pairs(modules) do local example_dir = path.join("examples", name) - if os.exists(example_dir) and has_config("enable_" .. name) then + if os.exists(example_dir) and has_config("" .. name) then includes(path.join(example_dir, "**", "xmake.lua")) end end end -if has_config("enable_tests") then +if has_config("tests") then includes("tests/xmake.lua") end From cf1b56d63d97cfc587d99f18910646755c6ce620 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:26:57 +0100 Subject: [PATCH 09/39] update packages --- xmake/frozen.lua | 1 + xmake/vmahpp.lua | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/xmake/frozen.lua b/xmake/frozen.lua index ce596330..b961fc39 100644 --- a/xmake/frozen.lua +++ b/xmake/frozen.lua @@ -1,4 +1,5 @@ package("frozen", function() + set_kind("library") set_homepage("https://github.com/serge-sans-paille/frozen") set_description("A header-only, constexpr alternative to gperf for C++14 users") set_license("Apache-2.0") diff --git a/xmake/vmahpp.lua b/xmake/vmahpp.lua index 0f4a5c28..210aa8aa 100644 --- a/xmake/vmahpp.lua +++ b/xmake/vmahpp.lua @@ -43,11 +43,12 @@ package("vulkan-memory-allocator-hpp") io.writefile("xmake.lua", format([[ add_requires("vulkan-memory-allocator master", "%s >= 1.3.275") target("vulkan-memory-allocator-hpp") - set_kind("static") + set_kind("headeronly") + add_rules("c++.moduleonly") set_languages("c++20") add_headerfiles("include/(**.hpp)") add_includedirs("include") - add_files("src/*.cppm", {public = true}) + add_files("src/*.cppm") add_packages("vulkan-memory-allocator", "%s") ]], vulkan_dep, vulkan_dep)) local configs = {} From d71076c9443438f9bdd09e0a97da3bf4fb5ae3cd Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:27:09 +0100 Subject: [PATCH 10/39] initialize libbacktrace --- src/Main/linux/Main-linux.cpp | 8 +++++++- src/Main/win32/Main-win.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Main/linux/Main-linux.cpp b/src/Main/linux/Main-linux.cpp index ab46b916..079e11bc 100644 --- a/src/Main/linux/Main-linux.cpp +++ b/src/Main/linux/Main-linux.cpp @@ -5,12 +5,18 @@ import std; import stormkit.Core; +#include + extern auto userMain(std::span) -> int; auto main(int argc, char** argv) -> int { +#if not(defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L) + stormkit::core::backtraceInit(argv[0]); +#endif + auto args = std::vector {}; for (auto i : stormkit::core::range(argc)) args.emplace_back(argv[i]); return userMain(args); -} \ No newline at end of file +} diff --git a/src/Main/win32/Main-win.cpp b/src/Main/win32/Main-win.cpp index 48aa6064..34170d4e 100644 --- a/src/Main/win32/Main-win.cpp +++ b/src/Main/win32/Main-win.cpp @@ -12,6 +12,8 @@ import std; import stormkit.Core; +#include + namespace { constexpr auto BUF_SIZE = 1024; } @@ -19,6 +21,10 @@ namespace { extern auto userMain(std::span) -> int; auto __stdcall main(int argc, char** argv) -> int { +#if not(defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L) + stormkit::core::backtraceInit(argv[0]); +#endif + std::locale::global(std::locale { "" }); SetConsoleOutputCP(CP_UTF8); SetConsoleCP(CP_UTF8); @@ -40,6 +46,11 @@ auto __stdcall main(int argc, char** argv) -> int { auto __stdcall WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) -> int { const auto argc = __argc; const auto argv = __argv; + +#if not(defined(__cpp_lib_stacktrace) and __cpp_lib_stacktrace >= 202011L) + stormkit::core::backtraceInit(argv[0]); +#endif + std::locale::global(std::locale { "" }); SetConsoleOutputCP(CP_UTF8); SetConsoleCP(CP_UTF8); From ff64eb6d5137b6ff69978cc4966c121741bf29d4 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:27:26 +0100 Subject: [PATCH 11/39] initialize render engine --- examples/engine/triangle/src/main.cpp | 2 + examples/engine/triangle/xmake.lua | 2 +- modules/stormkit/Engine/Renderer.mpp | 9 +- modules/stormkit/Gpu/Core/Device.mpp | 3 +- modules/stormkit/Gpu/Core/Instance.mpp | 25 +++ modules/stormkit/Gpu/Core/Types.mpp | 160 ++++++++++--------- src/Engine/Renderer.cpp | 206 +++++++++++++++++++++++-- 7 files changed, 316 insertions(+), 91 deletions(-) diff --git a/examples/engine/triangle/src/main.cpp b/examples/engine/triangle/src/main.cpp index ca6e2007..9ab2512c 100644 --- a/examples/engine/triangle/src/main.cpp +++ b/examples/engine/triangle/src/main.cpp @@ -19,6 +19,8 @@ import App; auto main(std::span args) -> int { using namespace stormkit; + stormkit::core::printStacktrace(); + wsi::parseArgs(args); // core::setupSignalHandler(); diff --git a/examples/engine/triangle/xmake.lua b/examples/engine/triangle/xmake.lua index e04fc6f2..65c8f2c2 100644 --- a/examples/engine/triangle/xmake.lua +++ b/examples/engine/triangle/xmake.lua @@ -1,4 +1,4 @@ -add_requires("nzsl", { configs = { toolchain = "", runtimes = "", fs_watcher = false } }) +add_requires("nzsl", { configs = { runtimes = "", fs_watcher = false } }) target("triangle") do diff --git a/modules/stormkit/Engine/Renderer.mpp b/modules/stormkit/Engine/Renderer.mpp index f1585efd..028ee98f 100644 --- a/modules/stormkit/Engine/Renderer.mpp +++ b/modules/stormkit/Engine/Renderer.mpp @@ -45,12 +45,15 @@ export { -> gpu::Expected; auto doInitInstance(std::string_view) noexcept -> gpu::Expected; auto doInitDevice() noexcept -> gpu::Expected; + auto doInitRenderSurface(std::optional>) noexcept + -> gpu::Expected; auto threadLoop(std::stop_token) noexcept -> void; - bool m_validation_layers_enabled = false; - core::DeferInit m_instance; - core::DeferInit m_device; + bool m_validation_layers_enabled = false; + core::DeferInit m_instance; + core::DeferInit m_device; + core::DeferInit m_swapchain; std::jthread m_render_thread; }; diff --git a/modules/stormkit/Gpu/Core/Device.mpp b/modules/stormkit/Gpu/Core/Device.mpp index eb2cab78..fde74a61 100644 --- a/modules/stormkit/Gpu/Core/Device.mpp +++ b/modules/stormkit/Gpu/Core/Device.mpp @@ -119,7 +119,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE Device::~Device() { - waitIdle(); + if(m_vk_device.initialized()) [[likely]] + waitIdle(); } ///////////////////////////////////// diff --git a/modules/stormkit/Gpu/Core/Instance.mpp b/modules/stormkit/Gpu/Core/Instance.mpp index a88b843d..19ae8023 100644 --- a/modules/stormkit/Gpu/Core/Instance.mpp +++ b/modules/stormkit/Gpu/Core/Instance.mpp @@ -141,6 +141,31 @@ export { friend class Instance; }; + class STORMKIT_API Swapchain { + struct Tag {}; + + public: + static constexpr auto DEBUG_TYPE = DebugObjectType::Swapchain; + + // Swapchain(const Device& device, bool signaled, Tag); + // ~Swapchain(); + // + // Swapchain(const Swapchain&) = delete; + // auto operator=(const Swapchain&) -> Swapchain& = delete; + // + // Swapchain(Swapchain&&) noexcept; + // auto operator=(Swapchain&&) noexcept -> Swapchain&; + // + // // [[nodiscard]] static auto create(const Device& device, + // // bool signaled = false) noexcept -> Expected; + // // [[nodiscard]] static auto allocate(const Device& device, bool signaled = false) noexcept + // // -> Expected>; + // // + // [[nodiscard]] auto vkHandle() const noexcept -> const vk::raii::SwapchainKHR&; + // + // private: + // core::DeferInit m_vk_swapchain; + }; } // namespace stormkit::gpu namespace std { diff --git a/modules/stormkit/Gpu/Core/Types.mpp b/modules/stormkit/Gpu/Core/Types.mpp index bbab6808..494471c4 100644 --- a/modules/stormkit/Gpu/Core/Types.mpp +++ b/modules/stormkit/Gpu/Core/Types.mpp @@ -707,6 +707,44 @@ export { core::narrow(vk::GeometryFlagBitsKHR::eNoDuplicateAnyHitInvocation) }; + enum class ColorSpace : core::UInt32 { + SRGB_NonLinear = core::narrow(vk::ColorSpaceKHR::eSrgbNonlinear), + Display_P3_NonLinear = + core::narrow(vk::ColorSpaceKHR::eDisplayP3NonlinearEXT), + // COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT = 1000104002, + // COLOR_SPACE_DISPLAY_P3_LINEAR_EXT = 1000104003, + // COLOR_SPACE_DCI_P3_NONLINEAR_EXT = 1000104004, + // COLOR_SPACE_BT709_LINEAR_EXT = 1000104005, + // COLOR_SPACE_BT709_NONLINEAR_EXT = 1000104006, + // COLOR_SPACE_BT2020_LINEAR_EXT = 1000104007, + // COLOR_SPACE_HDR10_ST2084_EXT = 1000104008, + // COLOR_SPACE_DOLBYVISION_EXT = 1000104009, + // COLOR_SPACE_HDR10_HLG_EXT = 1000104010, + // COLOR_SPACE_ADOBERGB_LINEAR_EXT = 1000104011, + // COLOR_SPACE_ADOBERGB_NONLINEAR_EXT = 1000104012, + // COLOR_SPACE_PASS_THROUGH_EXT = 1000104013, + // COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT = 1000104014, + // COLOR_SPACE_DISPLAY_NATIVE_AMD = 1000213000, + // COLORSPACE_SRGB_NONLINEAR_KHR = COLOR_SPACE_SRGB_NONLINEAR_KHR, + // COLOR_SPACE_DCI_P3_LINEAR_EXT = COLOR_SPACE_DISPLAY_P3_LINEAR_EXT, + }; + + enum class PresentMode : core::UInt32 { + Immediate = core::narrow(vk::PresentModeKHR::eImmediate), + Mailbox = core::narrow(vk::PresentModeKHR::eMailbox), + Fifo = core::narrow(vk::PresentModeKHR::eFifo), + Fifo_Relaxed = core::narrow(vk::PresentModeKHR::eFifoRelaxed), + Shared_Demand_Refresh = + core::narrow(vk::PresentModeKHR::eSharedDemandRefresh), + Shared_Continuous_Refresh = + core::narrow(vk::PresentModeKHR::eSharedContinuousRefresh), + }; + + struct SurfaceFormat { + PixelFormat format; + ColorSpace color_space; + }; + struct MemoryBarrier { AccessFlag src; AccessFlag dst; @@ -1021,15 +1059,14 @@ export { [[nodiscard]] constexpr auto isDepthFormat(PixelFormat format) noexcept -> bool; [[nodiscard]] constexpr auto getChannelCountFor(PixelFormat format) noexcept -> core::UInt8; - [[nodiscard]] constexpr auto getArraySizeByChannelFor(PixelFormat format) noexcept - -> core::UInt8; - - [[nodiscard]] auto computeMipLevel(const core::math::ExtentU& extent) noexcept - -> core::UInt32; [[nodiscard]] constexpr auto - computeUniformBufferOffsetAlignement(core::RangeExtent size, - const RenderCapabilities& capabilities) noexcept - -> core::RangeExtent; + getArraySizeByChannelFor(PixelFormat format) noexcept -> core::UInt8; + + [[nodiscard]] auto + computeMipLevel(const core::math::ExtentU& extent) noexcept -> core::UInt32; + [[nodiscard]] constexpr auto computeUniformBufferOffsetAlignement( + core::RangeExtent size, + const RenderCapabilities& capabilities) noexcept -> core::RangeExtent; [[nodiscard]] auto toString(const PhysicalDeviceInfo& data) noexcept; @@ -1037,29 +1074,24 @@ export { [[nodiscard]] constexpr auto as(From&&) noexcept -> To; template<> - [[nodiscard]] constexpr auto - as(const gpu::Viewport& viewport) noexcept - -> vk::Viewport; + [[nodiscard]] constexpr auto as( + const gpu::Viewport& viewport) noexcept -> vk::Viewport; template<> - [[nodiscard]] constexpr auto - as(const core::math::ExtentU& extent) noexcept - -> vk::Extent3D; + [[nodiscard]] constexpr auto as( + const core::math::ExtentU& extent) noexcept -> vk::Extent3D; template<> - [[nodiscard]] constexpr auto - as(const vk::Extent3D& extent) noexcept - -> core::math::ExtentU; + [[nodiscard]] constexpr auto as( + const vk::Extent3D& extent) noexcept -> core::math::ExtentU; template<> - [[nodiscard]] constexpr auto - as(const core::math::ExtentU& extent) noexcept - -> vk::Extent2D; + [[nodiscard]] constexpr auto as( + const core::math::ExtentU& extent) noexcept -> vk::Extent2D; template<> - [[nodiscard]] constexpr auto - as(const vk::Extent2D& extent) noexcept - -> core::math::ExtentU; + [[nodiscard]] constexpr auto as( + const vk::Extent2D& extent) noexcept -> core::math::ExtentU; template<> [[nodiscard]] constexpr auto as( @@ -1070,14 +1102,12 @@ export { const core::math::Vector2I& offset) noexcept -> vk::Offset2D; template<> - [[nodiscard]] constexpr auto - as(const vk::Offset3D& offset) noexcept - -> core::math::Vector3I; + [[nodiscard]] constexpr auto as( + const vk::Offset3D& offset) noexcept -> core::math::Vector3I; template<> - [[nodiscard]] constexpr auto - as(const vk::Offset2D& offset) noexcept - -> core::math::Vector2I; + [[nodiscard]] constexpr auto as( + const vk::Offset2D& offset) noexcept -> core::math::Vector2I; } // namespace stormkit::gpu FLAG_ENUM(stormkit::gpu::QueueFlag) @@ -1123,8 +1153,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto ParentRef::operator=(const ParentRef&) noexcept - -> ParentRef& = default; + STORMKIT_FORCE_INLINE auto + ParentRef::operator=(const ParentRef&) noexcept -> ParentRef& = default; ///////////////////////////////////// ///////////////////////////////////// @@ -1134,8 +1164,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template - STORMKIT_FORCE_INLINE auto ParentRef::operator=(ParentRef&&) noexcept - -> ParentRef& = default; + STORMKIT_FORCE_INLINE auto + ParentRef::operator=(ParentRef&&) noexcept -> ParentRef& = default; ///////////////////////////////////// ///////////////////////////////////// @@ -1178,8 +1208,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto getChannelCountFor(PixelFormat format) noexcept - -> core::UInt8 { + STORMKIT_FORCE_INLINE constexpr auto + getChannelCountFor(PixelFormat format) noexcept -> core::UInt8 { switch (format) { case PixelFormat::R8_SNorm: case PixelFormat::R8_UNorm: @@ -1255,8 +1285,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto getArraySizeByChannelFor(PixelFormat format) noexcept - -> core::UInt8 { + STORMKIT_FORCE_INLINE constexpr auto + getArraySizeByChannelFor(PixelFormat format) noexcept -> core::UInt8 { switch (format) { case PixelFormat::R8_SNorm: case PixelFormat::R8_UNorm: @@ -1341,8 +1371,8 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE auto computeMipLevel(const core::math::ExtentU& extent) noexcept - -> core::UInt32 { + STORMKIT_FORCE_INLINE auto + computeMipLevel(const core::math::ExtentU& extent) noexcept -> core::UInt32 { const auto as_float = core::math::ExtentF { extent }; return core::narrow(core::math::floor( @@ -1352,10 +1382,9 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// - STORMKIT_FORCE_INLINE constexpr auto - computeUniformBufferOffsetAlignement(core::RangeExtent size, - const RenderCapabilities& capabilities) noexcept - -> core::RangeExtent { + STORMKIT_FORCE_INLINE constexpr auto computeUniformBufferOffsetAlignement( + core::RangeExtent size, + const RenderCapabilities& capabilities) noexcept -> core::RangeExtent { const auto min_ubo_align = capabilities.limits.min_uniform_buffer_offset_alignment; if (min_ubo_align > 0) size = (size + min_ubo_align - 1) & ~(min_ubo_align - 1); @@ -1398,81 +1427,72 @@ namespace stormkit::gpu { ///////////////////////////////////// ///////////////////////////////////// template<> - [[nodiscard]] constexpr auto - as(const gpu::Viewport& viewport) noexcept - -> vk::Viewport { + [[nodiscard]] constexpr auto as( + const gpu::Viewport& viewport) noexcept -> vk::Viewport { return viewport.operator vk::Viewport(); } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto - as(const core::math::ExtentU& extent) noexcept - -> vk::Extent3D { + STORMKIT_FORCE_INLINE constexpr auto as( + const core::math::ExtentU& extent) noexcept -> vk::Extent3D { return vk::Extent3D { extent.width, extent.height, extent.depth }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto - as(const vk::Extent3D& extent) noexcept - -> core::math::ExtentU { + STORMKIT_FORCE_INLINE constexpr auto as( + const vk::Extent3D& extent) noexcept -> core::math::ExtentU { return { extent.width, extent.height, extent.depth }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto - as(const core::math::ExtentU& extent) noexcept - -> vk::Extent2D { + STORMKIT_FORCE_INLINE constexpr auto as( + const core::math::ExtentU& extent) noexcept -> vk::Extent2D { return vk::Extent2D { extent.width, extent.height }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto - as(const vk::Extent2D& extent) noexcept - -> core::math::ExtentU { + STORMKIT_FORCE_INLINE constexpr auto as( + const vk::Extent2D& extent) noexcept -> core::math::ExtentU { return { extent.width, extent.height }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto - as(const core::math::Vector3I& extent) noexcept - -> vk::Offset3D { + STORMKIT_FORCE_INLINE constexpr auto as( + const core::math::Vector3I& extent) noexcept -> vk::Offset3D { return vk::Offset3D { extent.x, extent.y, extent.z }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto - as(const core::math::Vector2I& extent) noexcept - -> vk::Offset2D { + STORMKIT_FORCE_INLINE constexpr auto as( + const core::math::Vector2I& extent) noexcept -> vk::Offset2D { return vk::Offset2D { extent.x, extent.y }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto - as(const vk::Offset3D& offset) noexcept - -> core::math::Vector3I { + STORMKIT_FORCE_INLINE constexpr auto as( + const vk::Offset3D& offset) noexcept -> core::math::Vector3I { return { offset.x, offset.y, offset.z }; } ///////////////////////////////////// ///////////////////////////////////// template<> - STORMKIT_FORCE_INLINE constexpr auto - as(const vk::Offset2D& offset) noexcept - -> core::math::Vector2I { + STORMKIT_FORCE_INLINE constexpr auto as( + const vk::Offset2D& offset) noexcept -> core::math::Vector2I { return { offset.x, offset.y }; } } // namespace stormkit::gpu diff --git a/src/Engine/Renderer.cpp b/src/Engine/Renderer.cpp index 5c7f4fc9..e8cacc5f 100644 --- a/src/Engine/Renderer.cpp +++ b/src/Engine/Renderer.cpp @@ -18,35 +18,209 @@ using namespace std::literals; namespace stormkit::engine { LOGGER("stormkit.Renderer") + namespace { + constexpr auto RAYTRACING_EXTENSIONS = + std::array { "gpu__ray_tracing_pipeline"sv, "gpu__acceleration_structure"sv, + "gpu__buffer_device_address"sv, "gpu__deferred_host_operations"sv, + "gpu_EXT_descriptor_indexing"sv, "gpu__spirv_1_4"sv, + "gpu__shader_float_controls"sv }; + + constexpr auto BASE_EXTENSIONS = std::array { "gpu__maintenance3"sv }; + + constexpr auto SWAPCHAIN_EXTENSIONS = std::array { "gpu__swapchain"sv }; + + ///////////////////////////////////// + ///////////////////////////////////// + auto scorePhysicalDevice(const gpu::PhysicalDevice& physical_device) -> core::UInt64 { + const auto support_raytracing = + physical_device.checkExtensionSupport(RAYTRACING_EXTENSIONS); + + auto score = core::UInt64 { 0u }; + + const auto& info = physical_device.info(); + const auto& capabilities = physical_device.capabilities(); + + if (info.type == gpu::PhysicalDeviceType::Discrete_GPU) score += 10000000u; + else if (info.type == gpu::PhysicalDeviceType::Virtual_GPU) + score += 5000000u; + else if (info.type == gpu::PhysicalDeviceType::Integrated_GPU) + score += 250000u; + + score += capabilities.limits.max_image_dimension_1D; + score += capabilities.limits.max_image_dimension_2D; + score += capabilities.limits.max_image_dimension_3D; + score += capabilities.limits.max_image_dimension_cube; + score += capabilities.limits.max_uniform_buffer_range; + score += info.api_major_version * 10000000u; + score += info.api_minor_version * 10000u; + score += info.api_patch_version * 100u; + + if (support_raytracing) score += 10000000u; + + return score; + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto pickPhysicalDevice(std::span physical_devices) noexcept + -> std::optional> { + auto ranked_devices = + std::multimap> {}; + + for (const auto& physical_device : physical_devices) { + if (not physical_device.checkExtensionSupport(BASE_EXTENSIONS)) { + dlog("Base required extensions not supported for GPU {}", physical_device); + continue; + } + if (not physical_device.checkExtensionSupport(SWAPCHAIN_EXTENSIONS)) { + dlog("Swapchain required extensions not supported for GPU {}", physical_device); + continue; + } + + const auto& info = physical_device.info(); + + dlog("Scoring for {}\n" + " device id: {:#06x}\n" + " vendor name: {}\n" + " vendor id: {}\n" + " api version: {}.{}.{}\n" + " driver version: {}.{}.{}\n" + " type: {}", + info.device_name, + info.device_id, + info.vendor_name, + info.vendor_id, + info.api_major_version, + info.api_minor_version, + info.api_patch_version, + info.driver_major_version, + info.driver_minor_version, + info.driver_patch_version, + info.type); + + const auto score = scorePhysicalDevice(physical_device); + + dlog("Score is {}", score); + + ranked_devices.emplace(score, physical_device); + } + + if (std::ranges::empty(ranked_devices)) return std::nullopt; + + return ranked_devices.rbegin()->second; + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto chooseSwapSurfaceFormat(std::span formats) noexcept + -> gpu::SurfaceFormat { + for (const auto& format : formats) { + if (format.format == gpu::PixelFormat::BGRA8_UNorm && + format.color_space == gpu::ColorSpace::SRGB_NonLinear) + return format; + } + + return formats[0]; + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto chooseSwapPresentMode(std::span present_modes) noexcept + -> gpu::PresentMode { + for (const auto& present_mode : present_modes) { + if (present_mode == gpu::PresentMode::Immediate) return present_mode; + else if (present_mode == gpu::PresentMode::Mailbox) + return present_mode; + } + + return gpu::PresentMode::Fifo; + } + + ///////////////////////////////////// + ///////////////////////////////////// + // auto + // chooseSwapExtent(const core::math::ExtentU& extent, + // const gpu::SurfaceCapabilities& capabilities) noexcept -> + // gpu::ExtentU { + // constexpr static auto int_max = std::numeric_limits::max(); + // + // if (capabilities.currentExtent.width != int_max && + // capabilities.currentExtent.height != int_max) + // return capabilities.currentExtent; + // + // auto actual_extent = extent; + // actual_extent.width = core::math::clamp(actual_extent.width, + // capabilities.minImageExtent.width, + // capabilities.maxImageExtent.width); + // actual_extent.height = core::math::clamp(actual_extent.height, + // capabilities.minImageExtent.height, + // capabilities.maxImageExtent.height); + // + // return actual_extent; + // } + // + // ///////////////////////////////////// + // ///////////////////////////////////// + // auto chooseImageCount(const gpu::SurfaceCapabilities& capabilities) noexcept + // -> core::UInt32 { + // auto image_count = capabilities.minImageCount + 1; + // return core::math::clamp(image_count, + // capabilities.minImageCount, + // capabilities.maxImageCount); + // } + } // namespace + ///////////////////////////////////// ///////////////////////////////////// - auto Renderer::doInit(std::string_view application_name, - std::optional>) noexcept + auto Renderer::doInit(std::string_view application_name, + std::optional> window) noexcept -> gpu::Expected { ilog("Initializing Renderer"); - return doInitInstance(application_name).and_then([this]() noexcept { - return doInitDevice(); - }); + return doInitInstance(application_name) + .and_then(std::bind_front(&Renderer::doInitDevice, this)) + .and_then([this, window = std::move(window)] { + return doInitRenderSurface(std::move(window)); + }); } ///////////////////////////////////// ///////////////////////////////////// auto Renderer::doInitInstance(std::string_view application_name) noexcept -> gpu::Expected { + return gpu::Instance::create(std::string { application_name }) + .transform(core::monadic::set(m_instance)); } ///////////////////////////////////// ///////////////////////////////////// auto Renderer::doInitDevice() noexcept -> gpu::Expected { + const auto& physical_devices = m_instance->physicalDevices(); + auto physical_device = + pickPhysicalDevice(physical_devices) + .or_else(core::expectsWithMessage>( + "No suitable GPU found !")) + .value(); + + ilog("Using physical device {}", *physical_device); + + return gpu::Device::create(*physical_device, *m_instance) + .transform(core::monadic::set(m_device)); + } + + ///////////////////////////////////// + ///////////////////////////////////// + auto Renderer::doInitRenderSurface(std::optional>) noexcept + -> gpu::Expected { + return {}; } ///////////////////////////////////// ///////////////////////////////////// auto Renderer::threadLoop(std::stop_token token) noexcept -> void { - // const auto create_info = vk::CommandPoolCreateInfo {}.setFlags( - // vk::CommandPoolCreateFlagBits::eTransient | - // vk::CommandPoolCreateFlagBits::eResetCommandBuffer); - // auto command_pool = vk::raii::CommandPool { m_device, create_info }; + // const auto create_info = gpu::CommandPoolCreateInfo {}.setFlags( + // gpu::CommandPoolCreateFlagBits::eTransient | + // gpu::CommandPoolCreateFlagBits::eResetCommandBuffer); + // auto command_pool = gpu::CommandPool { m_device, create_info }; // // const auto& images = m_render_surface->images(); // auto&& command_buffers = createCommandBuffers(m_device, command_pool, @@ -56,20 +230,20 @@ namespace stormkit::engine { // const auto& image = images[i]; // auto & command_buffer = command_buffers[i]; // - // command_buffer.begin(vk::CommandBufferBeginInfo {}.setFlags( - // vk::CommandBufferUsageFlagBits::eOneTimeSubmit)); + // command_buffer.begin(gpu::CommandBufferBeginInfo {}.setFlags( + // gpu::CommandBufferUsageFlagBits::eOneTimeSubmit)); // // transitionImageLayout(command_buffer, // image, - // vk::ImageLayout::eUndefined, - // vk::ImageLayout::ePresentSrcKHR); + // gpu::ImageLayout::eUndefined, + // gpu::ImageLayout::ePresentSrc); // // command_buffer.end(); // } // - // auto fence = vk::raii::Fence { m_device, - // vk::FenceCreateInfo {}.setFlags( - // vk::FenceCreateFlagBits::eSignaled) }; + // auto fence = gpu::Fence { m_device, + // gpu::FenceCreateInfo {}.setFlags( + // gpu::FenceCreateFlagBits::eSignaled) }; // // submit(m_raster_queue, command_buffers, {}, {}, *fence); // From 43c24a27cc79c42a6023db112562ef64e4dbd90a Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:27:34 +0100 Subject: [PATCH 12/39] update CI --- .github/workflows/Linux.yml | 4 ++-- .github/workflows/Windows-LLVM.yml | 10 ++++------ .github/workflows/macOS.yml | 25 +++++++++++++------------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index a16bcf44..8683bd83 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -48,8 +48,8 @@ jobs: xmake-version: branch@dev actions-cache-folder: .xmake-cache-${{ steps.cache_key.outputs.key }} - - name: Update xmake repository - run: xmake repo -vD --update + - name: Update xmake to patched xmake + run: xmake update -s https://github.com/Arthapz/xmake.git#modules - name: Retrieve dependencies hash id: dep_hash diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index ade85607..bf4fdb60 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -49,10 +49,11 @@ jobs: - name: Cache LLVM id: cache_llvm - uses: actions/cache@v3.2.2 + uses: actions/cache@v4 with: path: ${{ runner.workspace }}/StormKit/llvm/ key: ${{ matrix.os }}-llvm + save-always: true restore-keys: | ${{ matrix.os }}-llvm @@ -75,15 +76,12 @@ jobs: - name: Update xmake to patched xmake run: xmake update -s https://github.com/Arthapz/xmake.git#modules - # - name: Update xmake repository - # run: xmake repo --update - # - name: Retrieve dependencies hash id: dep_hash run: echo "hash=$(xmake l utils.ci.packageskey)" >> $env:GITHUB_OUTPUT - name: Retrieve cached xmake dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages key: ${{ matrix.os }}-LLVM-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}-${{ steps.cache_key.outputs.key }} @@ -91,7 +89,7 @@ jobs: - name: Configure & Build id: build_llvm run: | - xmake f -vD --yes -a ${{ matrix.arch }} -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --enable_examples=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm/" --runtimes="c++_shared" + xmake f -vD --yes -a ${{ matrix.arch }} -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --examples=y --tests=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm/" --runtimes="c++_shared" xmake b -vD - name: Tests diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 75b63eb5..e5fb8cc2 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -41,13 +41,21 @@ jobs: - name: Cache LLVM id: cache_llvm - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ runner.workspace }}/StormKit/llvm key: ${{ matrix.os }}-llvm + save-always: true restore-keys: | ${{ matrix.os }}-llvm + - name: Download and Uncompress LLVM + if: ${{ steps.cache_llvm.outputs.cache-hit != 'true' }} + run: | + wget 'https://github.com/Arthapz/llvm-patched/raw/main/macOS/llvm-x64.7z' + 7z x llvm-x64.7z + rm llvm-x64.7z + - name: Set xmake env run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV @@ -57,30 +65,23 @@ jobs: xmake-version: branch@dev actions-cache-folder: .xmake-cache-${{ steps.cache_key.outputs.key }} - - name: Update xmake repository - run: xmake repo -vD --update + - name: Update xmake to patched xmake + run: xmake update -s https://github.com/Arthapz/xmake.git#modules - name: Retrieve dependencies hash id: dep_hash run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT - name: Retrieve cached xmake dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages key: macOS-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}-${{ steps.cache_key.outputs.key }} - - name: Download and Uncompress LLVM - if: ${{ steps.cache_llvm.outputs.cache-hit != 'true' }} - run: | - wget 'http://86.221.35.29:1337/llvm-macos.7z' - 7z x llvm-macos.7z - rm llvm-macos.7z - - name: Configure & Build id: build run: | - xmake f -vD --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --enable_examples=y --enable_tests=y --enable_gpu=n --libc++=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm/" --ldflags="-L${{ runner.workspace }}/StormKit/llvm/lib" --shflags="-L${{ runner.workspace }}/StormKit/llvm/lib" + xmake f -vD --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --examples=y --tests=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm/" --runtimes="c++_shared" xmake b -vD - name: Tests From ff2897a2964ce51c3e0cba4c375d0ece4441d144 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:29:28 +0100 Subject: [PATCH 13/39] update CI --- .github/workflows/Linux.yml | 12 ++++++++++++ .github/workflows/Windows-LLVM.yml | 13 +++++++++++++ .github/workflows/macOS.yml | 12 ++++++++++++ 3 files changed, 37 insertions(+) diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index 8683bd83..71c06d28 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -13,6 +13,18 @@ on: - 'LICENSE' - 'README.md' + push: + branches: [develop] + paths-ignore: + - '.github/workflows/Windows-MSVC.yml' + - '.github/workflows/Linux.yml' + - '.github/workflows/macOS.yml' + - '.github/workflows/iOS.yml' + - '.github/workflows/Android.yml' + - '.gitignore' + - 'LICENSE' + - 'README.md' + jobs: build: name: ${{ matrix.os }}-x64 ( ${{ matrix.kind }}-${{ matrix.mode }} ) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index bf4fdb60..d17ae166 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -13,6 +13,19 @@ on: - 'LICENSE' - 'README.md' + push: + branches: [develop] + paths-ignore: + - '.github/workflows/Windows-MSVC.yml' + - '.github/workflows/Linux.yml' + - '.github/workflows/macOS.yml' + - '.github/workflows/iOS.yml' + - '.github/workflows/Android.yml' + - '.gitignore' + - 'LICENSE' + - 'README.md' + + jobs: build: name: ${{ matrix.os }}-LLVM-${{ matrix.arch }} ( ${{ matrix.kind }}-${{ matrix.mode }} ) diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index e5fb8cc2..c613f686 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -13,6 +13,18 @@ on: - 'LICENSE' - 'README.md' + push: + branches: [develop] + paths-ignore: + - '.github/workflows/Windows-MSVC.yml' + - '.github/workflows/Linux.yml' + - '.github/workflows/macOS.yml' + - '.github/workflows/iOS.yml' + - '.github/workflows/Android.yml' + - '.gitignore' + - 'LICENSE' + - 'README.md' + jobs: build: name: ${{ matrix.os }}-x64 ( ${{ matrix.kind }}-${{ matrix.mode }} ) From fb94eae2dfccb8521aef1564788b353e8c4fe3c5 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:31:14 +0100 Subject: [PATCH 14/39] update macOS CI --- .github/workflows/macOS.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index c613f686..e7a6d65f 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -64,7 +64,7 @@ jobs: - name: Download and Uncompress LLVM if: ${{ steps.cache_llvm.outputs.cache-hit != 'true' }} run: | - wget 'https://github.com/Arthapz/llvm-patched/raw/main/macOS/llvm-x64.7z' + wget 'https://github.com/Arthapz/llvm-patched/raw/main/macOS/llvm-x64.zip' 7z x llvm-x64.7z rm llvm-x64.7z From 2f115dfdbc2b228a2b838fbea867a95c123ed3b4 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:32:28 +0100 Subject: [PATCH 15/39] Update macOS CI --- .github/workflows/macOS.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index e7a6d65f..85064a38 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -65,8 +65,8 @@ jobs: if: ${{ steps.cache_llvm.outputs.cache-hit != 'true' }} run: | wget 'https://github.com/Arthapz/llvm-patched/raw/main/macOS/llvm-x64.zip' - 7z x llvm-x64.7z - rm llvm-x64.7z + 7z x llvm-x64.zip + rm llvm-x64.zip - name: Set xmake env run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV From 7c07f6af374625634180d38f17496e0a05405205 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 13:37:29 +0100 Subject: [PATCH 16/39] update Windows CI --- .github/workflows/Windows-LLVM.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index d17ae166..a143fd1b 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -78,7 +78,7 @@ jobs: rm llvm-x64.7z - name: Set xmake env - run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $env:GITHUB_ENV + run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Install xmake uses: xmake-io/github-action-setup-xmake@v1 @@ -91,7 +91,7 @@ jobs: - name: Retrieve dependencies hash id: dep_hash - run: echo "hash=$(xmake l utils.ci.packageskey)" >> $env:GITHUB_OUTPUT + run: echo "hash=$(xmake l utils.ci.packageskey)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - name: Retrieve cached xmake dependencies uses: actions/cache@v4 From d6835a982b675c9db960ba160404c301618948ec Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:01:49 +0100 Subject: [PATCH 17/39] update macOS CI --- .github/workflows/macOS.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 85064a38..8d9c844e 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -55,7 +55,7 @@ jobs: id: cache_llvm uses: actions/cache@v4 with: - path: ${{ runner.workspace }}/StormKit/llvm + path: ${{ runner.workspace }}/StormKit/llvm-minified key: ${{ matrix.os }}-llvm save-always: true restore-keys: | @@ -93,7 +93,7 @@ jobs: - name: Configure & Build id: build run: | - xmake f -vD --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --examples=y --tests=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm/" --runtimes="c++_shared" + xmake f -vD --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --examples=y --tests=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm-minified/" --runtimes="c++_shared" xmake b -vD - name: Tests From 037b2bbc675b2aaf6135ef323f4f9098c9b75ae4 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:18:00 +0100 Subject: [PATCH 18/39] update CI --- .github/workflows/Windows-LLVM.yml | 3 +++ .github/workflows/macOS.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index a143fd1b..53e52efd 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -89,6 +89,9 @@ jobs: - name: Update xmake to patched xmake run: xmake update -s https://github.com/Arthapz/xmake.git#modules + - name: Update xmake repository + run: xmake repo --update -vD + - name: Retrieve dependencies hash id: dep_hash run: echo "hash=$(xmake l utils.ci.packageskey)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 8d9c844e..482feb89 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -80,6 +80,9 @@ jobs: - name: Update xmake to patched xmake run: xmake update -s https://github.com/Arthapz/xmake.git#modules + - name: Update xmake repository + run: xmake repo --update -vD + - name: Retrieve dependencies hash id: dep_hash run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT From 2c0b7d1b0ac047c0ec0a5f10efb6df2583b9b688 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:24:38 +0100 Subject: [PATCH 19/39] test --- .github/workflows/Windows-LLVM.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index 53e52efd..7c682f78 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -86,8 +86,8 @@ jobs: xmake-version: "branch@dev" actions-cache-folder: .xmake-cache-${{ steps.cache_key.outputs.key }} - - name: Update xmake to patched xmake - run: xmake update -s https://github.com/Arthapz/xmake.git#modules + # - name: Update xmake to patched xmake + # run: xmake update -s https://github.com/Arthapz/xmake.git#modules - name: Update xmake repository run: xmake repo --update -vD From fe45e002fb257c3707bbb0dd109b306dd295dd61 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:29:38 +0100 Subject: [PATCH 20/39] update Windows CI --- .github/workflows/Windows-LLVM.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index 7c682f78..ced087db 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -86,8 +86,8 @@ jobs: xmake-version: "branch@dev" actions-cache-folder: .xmake-cache-${{ steps.cache_key.outputs.key }} - # - name: Update xmake to patched xmake - # run: xmake update -s https://github.com/Arthapz/xmake.git#modules + - name: Update xmake to patched xmake + run: xmake update -s github:Arthapz/xmake#modules - name: Update xmake repository run: xmake repo --update -vD From 58e2e541c671eca9bfc023e32b910ebdc001dfde Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:32:08 +0100 Subject: [PATCH 21/39] update Windows CI --- .github/workflows/Windows-LLVM.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index ced087db..f091b1a0 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -89,6 +89,9 @@ jobs: - name: Update xmake to patched xmake run: xmake update -s github:Arthapz/xmake#modules + - name: Set xmake env + run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + - name: Update xmake repository run: xmake repo --update -vD From c1b5fbcb5525cf2c3b5a9fd214899138fb0e7a20 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:39:06 +0100 Subject: [PATCH 22/39] update Windows CI --- .github/workflows/Windows-LLVM.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index f091b1a0..d722de6e 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -87,7 +87,7 @@ jobs: actions-cache-folder: .xmake-cache-${{ steps.cache_key.outputs.key }} - name: Update xmake to patched xmake - run: xmake update -s github:Arthapz/xmake#modules + run: xmake update -s --integrate github:Arthapz/xmake#modules - name: Set xmake env run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append From 44cfa3337b30e5dcdb5d41ee0835e7fc676d5dca Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:42:12 +0100 Subject: [PATCH 23/39] Update Windows CI --- .github/workflows/Windows-LLVM.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index d722de6e..8631ad08 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -89,9 +89,6 @@ jobs: - name: Update xmake to patched xmake run: xmake update -s --integrate github:Arthapz/xmake#modules - - name: Set xmake env - run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Update xmake repository run: xmake repo --update -vD From 6b38c03311797a92e4c2e6e88d70c4904e0740cc Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:43:03 +0100 Subject: [PATCH 24/39] don't install libbacktrace on windows --- xmake.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake.lua b/xmake.lua index 48a5cdf9..0e51f6e6 100644 --- a/xmake.lua +++ b/xmake.lua @@ -8,7 +8,7 @@ modules = { add_packages("wil") end - if get_config("toolchain") and (get_config("toolchain") == "clang" or get_config("toolchain") == "llvm") then + if not is_plat("windows") and get_config("toolchain") and (get_config("toolchain") == "clang" or get_config("toolchain") == "llvm") then add_packages("libbacktrace", {public = true}) end @@ -317,7 +317,7 @@ end -- add_defines("FROZEN_DONT_INCLUDE_STL", "ANKERL_UNORDERED_DENSE_USE_STD_IMPORT") add_requireconfs("*", { configs = { modules = true } }) -if get_config("toolchain") and (get_config("toolchain") == "clang" or get_config("toolchain") == "llvm") then +if not is_plat("windows") and get_config("toolchain") and (get_config("toolchain") == "clang" or get_config("toolchain") == "llvm") then add_requires("libbacktrace") end From e1e512a6e1e92e9a136c79abee7e714985276ab7 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 14:48:01 +0100 Subject: [PATCH 25/39] update CI --- .github/workflows/Windows-LLVM.yml | 10 +++++----- .github/workflows/macOS.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index 8631ad08..95a90ec0 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -90,7 +90,7 @@ jobs: run: xmake update -s --integrate github:Arthapz/xmake#modules - name: Update xmake repository - run: xmake repo --update -vD + run: xmake repo --update -v - name: Retrieve dependencies hash id: dep_hash @@ -105,17 +105,17 @@ jobs: - name: Configure & Build id: build_llvm run: | - xmake f -vD --yes -a ${{ matrix.arch }} -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --examples=y --tests=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm/" --runtimes="c++_shared" - xmake b -vD + xmake f -v --yes -a ${{ matrix.arch }} -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --examples=y --tests=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm/" --runtimes="c++_shared" + xmake b -v - name: Tests run: | cp "${{ runner.workspace }}/StormKit/llvm/lib/c++.dll" "${{ runner.workspace }}/StormKit/build/windows/${{ matrix.arch }}/${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }}/" - xmake test -vD + xmake test -v - name: Installation run: | - xmake install -vD --installdir="${{ runner.workspace }}/output" + xmake install -v --installdir="${{ runner.workspace }}/output" cp "${{ runner.workspace }}/StormKit/llvm/lib/c++.dll" "${{ runner.workspace }}/output/bin/" rmdir /s /q "StormKit" diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 482feb89..1472ca89 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -81,7 +81,7 @@ jobs: run: xmake update -s https://github.com/Arthapz/xmake.git#modules - name: Update xmake repository - run: xmake repo --update -vD + run: xmake repo --update -v - name: Retrieve dependencies hash id: dep_hash @@ -96,14 +96,14 @@ jobs: - name: Configure & Build id: build run: | - xmake f -vD --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --examples=y --tests=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm-minified/" --runtimes="c++_shared" - xmake b -vD + xmake f -v --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --examples=y --tests=y --toolchain=llvm --sdk="${{ runner.workspace }}/StormKit/llvm-minified/" --runtimes="c++_shared" + xmake b -v - name: Tests - run: DYLD_LIBRARY_PATH="${{ runner.workspace }}/StormKit/llvm/lib" xmake test -vD + run: DYLD_LIBRARY_PATH="${{ runner.workspace }}/StormKit/llvm/lib" xmake test -v - name: Installation - run: xmake install -vD --installdir="${{ runner.workspace }}/output" + run: xmake install -v --installdir="${{ runner.workspace }}/output" - name: Upload artifacts id: upload From 502570a30fc54f66f5ed1b89a7271bf8945d123f Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 15:38:37 +0100 Subject: [PATCH 26/39] Update Windows CI --- .github/workflows/Windows-LLVM.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Windows-LLVM.yml b/.github/workflows/Windows-LLVM.yml index 95a90ec0..a2f3cf97 100644 --- a/.github/workflows/Windows-LLVM.yml +++ b/.github/workflows/Windows-LLVM.yml @@ -73,9 +73,11 @@ jobs: - name: Download and Uncompress LLVM if: ${{ steps.cache_llvm.outputs.cache-hit != 'true' }} run: | - C:/msys64/usr/bin/wget 'https://github.com/Arthapz/llvm-patched/raw/main/windows/llvm-x64.7z' - 7z x llvm-x64.7z - rm llvm-x64.7z + C:/msys64/usr/bin/wget 'https://github.com/Arthapz/llvm-prebuilt/raw/main/Windows/llvm.7z.001' + C:/msys64/usr/bin/wget 'https://github.com/Arthapz/llvm-prebuilt/raw/main/Windows/llvm.7z.002' + 7z x llvm.7z.001 + rm llvm.7z.001 + rm llvm.7z.002 - name: Set xmake env run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append From ad4697ed8edfb49a8861a925bbd31366b4e2e3cd Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 15:57:53 +0100 Subject: [PATCH 27/39] update macOS CI --- .github/workflows/macOS.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 1472ca89..117dd286 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -64,9 +64,9 @@ jobs: - name: Download and Uncompress LLVM if: ${{ steps.cache_llvm.outputs.cache-hit != 'true' }} run: | - wget 'https://github.com/Arthapz/llvm-patched/raw/main/macOS/llvm-x64.zip' - 7z x llvm-x64.zip - rm llvm-x64.zip + wget 'https://github.com/Arthapz/llvm-patched/raw/main/macOS/llvm.7z.001' + 7z x llvm.7z.001 + rm llvm.7z.001 - name: Set xmake env run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV From 859287a7cf969f6f05faf29ae699a4f06eb7e43e Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 16:16:52 +0100 Subject: [PATCH 28/39] update CI --- .github/workflows/Linux.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index 71c06d28..d53dd7c2 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -76,14 +76,14 @@ jobs: - name: Configure & Build id: build run: | - xmake f -vD --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --enable_examples=y --enable_tests=y --enable_gpu=n --libc++=y --toolchain=llvm --mold=y --sdk=/opt/llvm-git/usr --ldflags="-L/opt/llvm-git/usr/lib" --shflags="-L/opt/llvm-git/usr/lib" - xmake b -vD + xmake f -v --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --examples=y --tests=y --toolchain=llvm --mold=y --runtimes="c++_shared" + xmake b -v - name: Tests - run: LD_LIBRARY_PATH="/opt/llvm-git/usr/lib" xmake test -vD + run: LD_LIBRARY_PATH="/opt/llvm-git/usr/lib" xmake test -v - name: Installation - run: xmake install -vD --installdir="${{ runner.workspace }}/output" + run: xmake install -v --installdir="${{ runner.workspace }}/output" - name: Upload artifacts id: upload From 67ee5f2777ef4a7d6fa4e276ca5f89379a55de9f Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 16:18:18 +0100 Subject: [PATCH 29/39] Update CI --- .github/workflows/macOS.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 117dd286..62fd6101 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -64,7 +64,7 @@ jobs: - name: Download and Uncompress LLVM if: ${{ steps.cache_llvm.outputs.cache-hit != 'true' }} run: | - wget 'https://github.com/Arthapz/llvm-patched/raw/main/macOS/llvm.7z.001' + wget 'https://github.com/Arthapz/llvm-prebuilt/raw/main/macOS/llvm.7z.001' 7z x llvm.7z.001 rm llvm.7z.001 From 4edea170de251f2c464e888c6266030f3bf4f2dc Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 16:22:57 +0100 Subject: [PATCH 30/39] Update CI --- .github/workflows/Linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index d53dd7c2..9ac6d2ab 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -76,7 +76,7 @@ jobs: - name: Configure & Build id: build run: | - xmake f -v --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --examples=y --tests=y --toolchain=llvm --mold=y --runtimes="c++_shared" + xmake f -v --yes -m ${{ (matrix.mode == 'release' || matrix.mode == 'debug') && matrix.mode || 'releasedbg' }} -k ${{ matrix.kind }} --sanitizers=${{ matrix.mode == 'asan' && 'y' || 'n' }} --examples=y --tests=y --toolchain=llvm --mold=y --runtimes="c++_shared" --sdk="/opt/llvm-git/usr" xmake b -v - name: Tests From 29ae1ea33a524f34e840c0417ffbe8651242b5e4 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 16:28:03 +0100 Subject: [PATCH 31/39] Update CI --- .github/workflows/Linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index 9ac6d2ab..caf159c9 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -68,7 +68,7 @@ jobs: run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT - name: Retrieve cached xmake dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages key: ${{ matrix.os }}-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}-${{ steps.cache_key.outputs.key }} From 3a7a9605b8d2f4ccf5b2da2099f1019074d48762 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 17:20:28 +0100 Subject: [PATCH 32/39] fix assert function when STORMKIT_ASSERT is not defined --- modules/stormkit/Core/Utils/Assert.mpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/stormkit/Core/Utils/Assert.mpp b/modules/stormkit/Core/Utils/Assert.mpp index fe0f11f0..3f3c01b5 100644 --- a/modules/stormkit/Core/Utils/Assert.mpp +++ b/modules/stormkit/Core/Utils/Assert.mpp @@ -6,6 +6,10 @@ module; #include +#ifndef STORMKIT_ASSERT +#define STORMKIT_ASSERT 1 +#endif + export module stormkit.Core:Utils.Assert; import std; From 9d56f2caf0d2242099641ab8acb3c1a699b92ed3 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 17:20:48 +0100 Subject: [PATCH 33/39] test --- modules/stormkit/Core/Utils/Stacktrace.mpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/stormkit/Core/Utils/Stacktrace.mpp b/modules/stormkit/Core/Utils/Stacktrace.mpp index e8412d4a..0ef8a4db 100644 --- a/modules/stormkit/Core/Utils/Stacktrace.mpp +++ b/modules/stormkit/Core/Utils/Stacktrace.mpp @@ -31,9 +31,9 @@ export namespace stormkit::core { namespace stormkit::core { #if not defined(STD_STACKTRACE_SUPPORTED) namespace { - using BacktraceState = backtrace_state*; - auto __bt_state = BacktraceState { nullptr }; - auto __counter = 0; + using BacktraceState = backtrace_state*; + auto __bt_state = BacktraceState { nullptr }; + thread_local auto __counter = 0; extern "C" auto bt_callback(void*, std::uintptr_t, @@ -86,7 +86,7 @@ namespace stormkit::core { BACKTRACE_SUPPORTS_THREADS, bt_error_callback, &status); - if (status) std::println("libbacktrace initialized for {}", filename); + if (__bt_state and status) std::println("libbacktrace initialized for {} {}", std::bit_cast(__bt_state), filename); else std::println(stderr, "failed to initialize libbacktrace"); From e871ae3cbdd284f80a08c1899183eb83438eea11 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 17:38:54 +0100 Subject: [PATCH 34/39] fix isEqual --- modules/stormkit/Core/Utils/Functional.mpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/stormkit/Core/Utils/Functional.mpp b/modules/stormkit/Core/Utils/Functional.mpp index 269a1893..09f6574c 100644 --- a/modules/stormkit/Core/Utils/Functional.mpp +++ b/modules/stormkit/Core/Utils/Functional.mpp @@ -24,6 +24,7 @@ export namespace stormkit::core { std::invocable auto&& false_) noexcept -> decltype(auto); template + requires(not IsArithmetic and not IsArithmetic) [[nodiscard]] constexpr auto isEqual(const T& a, const U& b) noexcept -> bool; template @@ -39,8 +40,9 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// STORMKIT_FORCE_INLINE constexpr auto - either(bool condition, std::invocable auto&& true_, std::invocable auto&& false_) noexcept - -> decltype(auto) { + either(bool condition, + std::invocable auto&& true_, + std::invocable auto&& false_) noexcept -> decltype(auto) { if (condition) return true_(); return false_(); } @@ -59,6 +61,7 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template + requires(not IsArithmetic and not IsArithmetic) STORMKIT_FORCE_INLINE constexpr auto isEqual(const T& a, const U& b) noexcept -> bool { return a == b; } @@ -67,8 +70,8 @@ namespace stormkit::core { ///////////////////////////////////// template // requires(std::invocable) - STORMKIT_FORCE_INLINE constexpr auto toUnary(Func&& func, Args&&... args) noexcept - -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto toUnary(Func&& func, + Args&&... args) noexcept -> decltype(auto) { return [_func = std::forward(func), ... _args = std::forward(args)]( auto&& first) noexcept(noexcept(func(first, std::forward(args)...))) { return _func(std::forward(first), std::forward(_args)...); From 3f996fdbb873255d86a5a13aad85770720f1b7ab Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 17:52:00 +0100 Subject: [PATCH 35/39] make DeferInit constexpr --- modules/stormkit/Core/Utils/DeferInit.mpp | 60 +++++++++++++---------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/modules/stormkit/Core/Utils/DeferInit.mpp b/modules/stormkit/Core/Utils/DeferInit.mpp index 7da683c9..27ecb7b2 100644 --- a/modules/stormkit/Core/Utils/DeferInit.mpp +++ b/modules/stormkit/Core/Utils/DeferInit.mpp @@ -2,6 +2,10 @@ // This file is subject to the license terms in the LICENSE file // found in the top-level of this distribution +module; + +#include + export module stormkit.Core:Utils.DeferInit; import std; @@ -13,26 +17,27 @@ export namespace stormkit::core { template class DeferInit { public: - DeferInit(); - ~DeferInit(); + constexpr DeferInit(); + constexpr ~DeferInit(); DeferInit(const DeferInit& other) = delete; auto operator=(const DeferInit& other) -> DeferInit& = delete; - DeferInit(DeferInit&& other) noexcept(noexcept(std::is_nothrow_move_constructible_v)); - auto operator=(DeferInit&& other) noexcept(noexcept(std::is_nothrow_move_assignable_v)) - -> DeferInit&; + constexpr DeferInit(DeferInit&& other) noexcept( + noexcept(std::is_nothrow_move_constructible_v)); + constexpr auto operator=(DeferInit&& other) noexcept( + noexcept(std::is_nothrow_move_assignable_v)) -> DeferInit&; template - auto construct(Args&&... args) noexcept( + constexpr auto construct(Args&&... args) noexcept( noexcept(std::is_nothrow_constructible_v)) -> void; template - auto constructWithNarrowing(Args&&... args) noexcept( + constexpr auto constructWithNarrowing(Args&&... args) noexcept( noexcept(std::is_nothrow_constructible_v)) -> void; - auto operator=(T&& value) noexcept(noexcept(std::is_nothrow_move_constructible_v)) - -> void; + constexpr auto operator=(T&& value) noexcept( + noexcept(std::is_nothrow_move_constructible_v)) -> void; [[nodiscard]] constexpr auto get(this auto&& self) noexcept -> decltype(auto); [[nodiscard]] constexpr auto operator->(this auto&& self) noexcept -> decltype(auto); @@ -41,10 +46,10 @@ export namespace stormkit::core { [[nodiscard]] constexpr operator T&() noexcept; [[nodiscard]] constexpr operator const T &() const noexcept; - [[nodiscard]] auto initialized() const noexcept -> bool; + [[nodiscard]] constexpr auto initialized() const noexcept -> bool; private: - auto reset() noexcept -> void; + constexpr auto reset() noexcept -> void; bool m_initialized = false; @@ -60,19 +65,19 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - inline DeferInit::DeferInit() = default; + STORMKIT_FORCE_INLINE constexpr DeferInit::DeferInit() = default; //////////////////////////////////////// //////////////////////////////////////// template - inline DeferInit::~DeferInit() { + STORMKIT_FORCE_INLINE constexpr DeferInit::~DeferInit() { reset(); } //////////////////////////////////////// //////////////////////////////////////// template - inline DeferInit::DeferInit(DeferInit&& other) noexcept( + STORMKIT_FORCE_INLINE constexpr DeferInit::DeferInit(DeferInit&& other) noexcept( noexcept(std::is_nothrow_move_constructible_v)) { reset(); @@ -85,7 +90,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - inline auto DeferInit::operator=(DeferInit&& other) noexcept( + STORMKIT_FORCE_INLINE constexpr auto DeferInit::operator=(DeferInit&& other) noexcept( noexcept(std::is_nothrow_move_assignable_v)) -> DeferInit& { if (&other == this) [[unlikely]] return *this; @@ -104,7 +109,7 @@ namespace stormkit::core { //////////////////////////////////////// template template - auto DeferInit::construct(Args&&... args) noexcept( + STORMKIT_FORCE_INLINE constexpr auto DeferInit::construct(Args&&... args) noexcept( noexcept(std::is_nothrow_constructible_v)) -> void { reset(); @@ -117,8 +122,8 @@ namespace stormkit::core { //////////////////////////////////////// template template - auto DeferInit::constructWithNarrowing(Args&&... args) noexcept( - noexcept(std::is_nothrow_constructible_v)) -> void { + STORMKIT_FORCE_INLINE constexpr auto DeferInit::constructWithNarrowing( + Args&&... args) noexcept(noexcept(std::is_nothrow_constructible_v)) -> void { reset(); new (std::data(m_data)) T(std::forward(args)...); @@ -129,7 +134,7 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - auto DeferInit::operator=(T&& value) noexcept( + STORMKIT_FORCE_INLINE constexpr auto DeferInit::operator=(T&& value) noexcept( noexcept(std::is_nothrow_move_constructible_v)) -> void { reset(); @@ -141,14 +146,14 @@ namespace stormkit::core { //////////////////////////////////////// //////////////////////////////////////// template - inline auto DeferInit::initialized() const noexcept -> bool { + STORMKIT_FORCE_INLINE constexpr auto DeferInit::initialized() const noexcept -> bool { return m_initialized; } ///////////////////////////////////// ///////////////////////////////////// template - auto DeferInit::reset() noexcept -> void { + STORMKIT_FORCE_INLINE constexpr auto DeferInit::reset() noexcept -> void { if (m_initialized) [[likely]] get().~T(); @@ -158,7 +163,8 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - [[nodiscard]] constexpr auto DeferInit::get(this auto&& self) noexcept -> decltype(auto) { + [[nodiscard]] STORMKIT_FORCE_INLINE constexpr auto + DeferInit::get(this auto&& self) noexcept -> decltype(auto) { core::expects(self.m_initialized); using U = LikeCVType; @@ -169,7 +175,8 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - constexpr auto DeferInit::operator->(this auto&& self) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto + DeferInit::operator->(this auto&& self) noexcept -> decltype(auto) { core::expects(self.m_initialized); using U = LikeCVType; @@ -180,21 +187,22 @@ namespace stormkit::core { ///////////////////////////////////// ///////////////////////////////////// template - constexpr auto DeferInit::operator*(this auto&& self) noexcept -> decltype(auto) { + STORMKIT_FORCE_INLINE constexpr auto + DeferInit::operator*(this auto&& self) noexcept -> decltype(auto) { return std::forward(self).get(); } ///////////////////////////////////// ///////////////////////////////////// template - constexpr DeferInit::operator T&() noexcept { + STORMKIT_FORCE_INLINE constexpr DeferInit::operator T&() noexcept { return get(); } ///////////////////////////////////// ///////////////////////////////////// template - constexpr DeferInit::operator const T &() const noexcept { + STORMKIT_FORCE_INLINE constexpr DeferInit::operator const T &() const noexcept { return get(); } } // namespace stormkit::core From 1a4fa7792e2fa34c9cef94baa356d25f4700240c Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 18:52:10 +0100 Subject: [PATCH 36/39] add options to individually enable examples --- xmake.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/xmake.lua b/xmake.lua index 0e51f6e6..34e4097f 100644 --- a/xmake.lua +++ b/xmake.lua @@ -199,7 +199,11 @@ if not is_plat("windows") or not is_plat("mingw") then end ---------------------------- global options ---------------------------- -option("examples", { default = false, category = "root menu/others" }) +option("examples_engine", { default = false, category = "root menu/others", deps = {"examples"}, after_check = function(option) if option:dep("examples"):enabled() then option:enable(true) end end }) +option("examples_wsi", { default = false, category = "root menu/others", deps = {"examples"}, after_check = function(option) if option:dep("examples"):enabled() then option:enable(true) end end }) +option("examples_log", { default = false, category = "root menu/others", deps = {"examples"}, after_check = function(option) if option:dep("examples"):enabled() then option:enable(true) end end }) +option("examples_entities", { default = false, category = "root menu/others", deps = {"examples"}, after_check = function(option) if option:dep("examples"):enabled() then end end }) --option:enable(true) end end }) +option("examples", { default = false, category = "root menu/others", }) option("applications", { default = false, category = "root menu/others" }) option("tests", { default = false, category = "root menu/others" }) @@ -464,15 +468,15 @@ for name, module in pairs(modules) do end end -if has_config("examples") then - for name, _ in pairs(modules) do - local example_dir = path.join("examples", name) - if os.exists(example_dir) and has_config("" .. name) then - includes(path.join(example_dir, "**", "xmake.lua")) - end +for name, _ in pairs(modules) do + if get_config("examples_" .. name) then + local example_dir = path.join("examples", name) + if os.exists(example_dir) and has_config("" .. name) then + includes(path.join(example_dir, "**", "xmake.lua")) + end end end -if has_config("tests") then +if get_config("tests") then includes("tests/xmake.lua") end From 308fad82d1aefcc49b4b9f06c1594704453e7c0b Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 18:59:32 +0100 Subject: [PATCH 37/39] add auto merger action --- .github/workflows/AutoMerger.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/AutoMerger.yml diff --git a/.github/workflows/AutoMerger.yml b/.github/workflows/AutoMerger.yml new file mode 100644 index 00000000..d8989c96 --- /dev/null +++ b/.github/workflows/AutoMerger.yml @@ -0,0 +1,29 @@ +name: Automerge + +on: + workflow_dispatch: + schedule: + - cron: '@weekly' + +env: + MY_REPO: https://Arthapz:${{secrets.GITHUB_TOKEN}}@github.com/TapzCrew/StormKit.git + MY_BRANCH: develop + + MASTER_REPO: https://github.com/TapzCrew/StormKit.git + MASTER_BRANCH: main + +jobs: + merge: + runs-on: ubuntu-latest + + steps: + - name: Merge with master + run: | + git clone ${{env.MY_REPO}} -b ${{env.MY_BRANCH}} tmp + cd tmp + git config user.name "Automerge Bot" + git config user.email "arthur.laurent4@gmail.com" + git config pull.rebase false + git pull ${{env.MASTER_REPO}} ${{env.MASTER_BRANCH}} + git push + From c3d67b14105b05cf02d3b65c7113fb88e08574bc Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 19:02:38 +0100 Subject: [PATCH 38/39] fix auto merger --- .github/workflows/AutoMerger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/AutoMerger.yml b/.github/workflows/AutoMerger.yml index d8989c96..56a58970 100644 --- a/.github/workflows/AutoMerger.yml +++ b/.github/workflows/AutoMerger.yml @@ -3,7 +3,7 @@ name: Automerge on: workflow_dispatch: schedule: - - cron: '@weekly' + - cron: '0 0 * * 7' env: MY_REPO: https://Arthapz:${{secrets.GITHUB_TOKEN}}@github.com/TapzCrew/StormKit.git From 0bf37f331545a7c427cb39eb3aa81478e6014c52 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 6 Feb 2024 19:03:51 +0100 Subject: [PATCH 39/39] fix auto merger --- .github/workflows/AutoMerger.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/AutoMerger.yml b/.github/workflows/AutoMerger.yml index 56a58970..548e5aaf 100644 --- a/.github/workflows/AutoMerger.yml +++ b/.github/workflows/AutoMerger.yml @@ -1,9 +1,8 @@ name: Automerge on: - workflow_dispatch: schedule: - - cron: '0 0 * * 7' + - cron: '0 0 * * 0' env: MY_REPO: https://Arthapz:${{secrets.GITHUB_TOKEN}}@github.com/TapzCrew/StormKit.git