diff --git a/aster/config.h b/aster/config.h index b03eba9..54a022d 100644 --- a/aster/config.h +++ b/aster/config.h @@ -17,8 +17,6 @@ #define VMA_DYNAMIC_VULKAN_FUNCTIONS 1 #define EASTL_NO_EXCEPTIONS 1 -// ReSharper disable once CppInconsistentNaming -#define _HAS_EXCEPTIONS 0 #if defined(NDEBUG) #define USE_OPTICK (0) diff --git a/aster/constants.h b/aster/constants.h index d666735..8ee2b70 100644 --- a/aster/constants.h +++ b/aster/constants.h @@ -30,19 +30,6 @@ using usize = size_t; using p64 = intptr_t; using cstr = const char *; -constexpr usize -strlenC(const char *s) -{ - usize len = 0; - char c = '\0'; - do - { - c = s[len]; - len++; - } while (c != '\0'); - return len; -} - namespace ansi_color { constexpr auto Black = "\u001b[30m"; @@ -56,42 +43,42 @@ constexpr auto White = "\u001b[37m"; constexpr auto Reset = "\u001b[0m"; } // namespace ansi_color -template +template constexpr auto -cast(FromT &&in) +Cast(TFrom &&in) { - return static_cast(std::forward(in)); + return static_cast(std::forward(in)); } -template +template constexpr auto -recast(FromT &&in) +Recast(TFrom &&in) { - return reinterpret_cast(std::forward(in)); + return reinterpret_cast(std::forward(in)); } constexpr f32 operator""_deg(long double degrees) { - return glm::radians(cast(degrees)); + return glm::radians(Cast(degrees)); } constexpr f32 operator""_deg(unsigned long long int degrees) { - return glm::radians(cast(degrees)); + return glm::radians(Cast(degrees)); } constexpr f32 operator""_rad(long double rads) { - return cast(rads); + return Cast(rads); } constexpr f32 operator""_rad(unsigned long long int rads) { - return cast(rads); + return Cast(rads); } using glm::ivec2; diff --git a/aster/context.cpp b/aster/context.cpp index c74b503..2ce28a6 100644 --- a/aster/context.cpp +++ b/aster/context.cpp @@ -12,7 +12,8 @@ constexpr eastl::array VALIDATION_LAYERS = { }; VKAPI_ATTR b32 VKAPI_CALL -DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, +DebugCallback(const VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + const VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *callbackData, [[maybe_unused]] void *userData) { using Severity = vk::DebugUtilsMessageSeverityFlagsEXT; @@ -37,7 +38,7 @@ DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUti return false; } -Context::Context(cstr appName, Version version, bool enableValidation) +Context::Context(const cstr appName, const Version version, bool enableValidation) { INFO_IF(enableValidation, "Validation Layers enabled"); @@ -50,7 +51,7 @@ Context::Context(cstr appName, Version version, bool enableValidation) .apiVersion = ASTER_API_VERSION, }; - vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfo = { + const vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfo = { .messageSeverity = vk::DebugUtilsMessageSeverityFlagBitsEXT::eError | vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo, @@ -77,14 +78,14 @@ Context::Context(cstr appName, Version version, bool enableValidation) const auto instanceCreateInfo = vk::InstanceCreateInfo{ .pNext = enableValidation ? &debugUtilsMessengerCreateInfo : nullptr, .pApplicationInfo = &appInfo, - .enabledLayerCount = enableValidation ? cast(VALIDATION_LAYERS.size()) : 0, + .enabledLayerCount = enableValidation ? Cast(VALIDATION_LAYERS.size()) : 0, .ppEnabledLayerNames = enableValidation ? VALIDATION_LAYERS.data() : nullptr, - .enabledExtensionCount = cast(instanceExtensions.size()), + .enabledExtensionCount = Cast(instanceExtensions.size()), .ppEnabledExtensionNames = instanceExtensions.data(), }; // May throw. Irrecoverable. - vk::Result result = vk::createInstance(&instanceCreateInfo, nullptr, &m_Instance); + vk::Result result = createInstance(&instanceCreateInfo, nullptr, &m_Instance); ERROR_IF(result, "Instance creation failed. Cause: {}", result) THEN_ABORT(result) ELSE_DEBUG("Instance Created."); diff --git a/aster/device.cpp b/aster/device.cpp index 2946da2..0dc1336 100644 --- a/aster/device.cpp +++ b/aster/device.cpp @@ -41,15 +41,15 @@ Device::Device(const Context *context, PhysicalDevice *physicalDevice, } vk::DeviceCreateInfo deviceCreateInfo = { - .queueCreateInfoCount = cast(deviceQueueCreateInfos.size()), + .queueCreateInfoCount = Cast(deviceQueueCreateInfos.size()), .pQueueCreateInfos = deviceQueueCreateInfos.data(), - .enabledExtensionCount = cast(DEVICE_EXTENSIONS.size()), + .enabledExtensionCount = Cast(DEVICE_EXTENSIONS.size()), .ppEnabledExtensionNames = DEVICE_EXTENSIONS.data(), .pEnabledFeatures = enabledFeatures, }; vk::Result result = m_PhysicalDevice.createDevice(&deviceCreateInfo, nullptr, &m_Device); - ERROR_IF(failed(result), "Could not initialize Vulkan Device. Cause: {}", result) + ERROR_IF(Failed(result), "Could not initialize Vulkan Device. Cause: {}", result) THEN_ABORT(result) ELSE_DEBUG("{} ({}) Initialized.", m_Name, physicalDevice->m_DeviceProperties.deviceName.data()); @@ -66,8 +66,8 @@ Device::Device(const Context *context, PhysicalDevice *physicalDevice, .vulkanApiVersion = ASTER_API_VERSION, }; - result = cast(vmaCreateAllocator(&allocatorCreateInfo, &m_Allocator)); - ERROR_IF(failed(result), "Memory allocator creation failed. Cause: {}", result) + result = Cast(vmaCreateAllocator(&allocatorCreateInfo, &m_Allocator)); + ERROR_IF(Failed(result), "Memory allocator creation failed. Cause: {}", result) DO(m_Device.destroy(nullptr)) THEN_ABORT(result) ELSE_VERBOSE("Memory Allocator Created"); diff --git a/aster/global.h b/aster/global.h index 181bb24..ec16c06 100644 --- a/aster/global.h +++ b/aster/global.h @@ -35,72 +35,41 @@ constexpr u32 ASTER_API_VERSION = vk::ApiVersion13; #define CODE_LOC " @ " __FILE__ ":" VULKAN_HPP_STRINGIFY(__LINE__) [[nodiscard]] inline bool -failed(const vk::Result result) +Failed(const vk::Result result) { return result != vk::Result::eSuccess; } -template -concept IsVkEnum = requires(T t) { - { - std::is_enum_v - }; - { - vk::to_string(t) - } -> std::same_as; -}; - -template - requires IsVkEnum -[[nodiscard]] const char * -toCstr(const T &val) -{ - static std::string buffer; - buffer = vk::to_string(val); - return buffer.c_str(); -} - using NameString = eastl::fixed_string; -// TODO: Check why inline namespaces aren't working in MSVC 19.27.29110 -using namespace std::literals::string_literals; -using namespace std::literals::string_view_literals; - -template - requires vk::isVulkanHandleType::value -[[nodiscard]] constexpr u64 -getVkHandle(const T &vkHandle) noexcept -{ - return reinterpret_cast(cast(vkHandle)); -} - -template -struct std::hash> +template +struct std::hash> // NOLINT(*-dcl58-cpp) { [[nodiscard]] usize - operator()(const vk::Flags &val) + operator()(const vk::Flags &val) { - return std::hash()(cast(val)); + return std::hash()(Cast(val)); } }; template [[nodiscard]] usize -hashAny(const T &val) +HashAny(const T &val) { return std::hash>()(val); } [[nodiscard]] inline usize -hashCombine(const usize hash0, const usize hash1) +HashCombine(const usize hash0, const usize hash1) { constexpr usize saltValue = 0x9e3779b9; - return hash0 ^ (hash1 + saltValue + (hash0 << 6) + (hash0 >> 2)); + const usize tempVar = hash1 + saltValue + (hash0 << 6) + (hash0 >> 2); + return hash0 ^ tempVar; } struct Time { - static constexpr f64 c_MaxDelta = 0.1; + static constexpr f64 cMaxDelta = 0.1; inline static f64 m_Elapsed{Qnan}; inline static f64 m_Delta{Qnan}; @@ -118,13 +87,13 @@ struct Time { ERROR_IF(std::isnan(m_Elapsed), "Time not init."); const auto newElapsed = glfwGetTime(); - m_Delta = std::clamp(newElapsed - m_Elapsed, 0.0, c_MaxDelta); + m_Delta = std::clamp(newElapsed - m_Elapsed, 0.0, cMaxDelta); m_Elapsed = newElapsed; } }; [[nodiscard]] inline usize -closestMultiple(const usize val, const usize of) +ClosestMultiple(const usize val, const usize of) { return of * ((val + of - 1) / of); } @@ -141,12 +110,12 @@ struct fmt::formatter : nested_formatter } }; -template -struct fmt::formatter> : nested_formatter +template +struct fmt::formatter> : nested_formatter { auto // ReSharper disable once CppInconsistentNaming - format(const eastl::fixed_string &str, format_context &ctx) const + format(const eastl::fixed_string &str, format_context &ctx) const { return write_padded(ctx, [this, str](auto out) { return v10::format_to(out, "{}", nested(str.c_str())); }); } diff --git a/aster/logger.h b/aster/logger.h index 7d7689f..663c6ea 100644 --- a/aster/logger.h +++ b/aster/logger.h @@ -20,76 +20,76 @@ struct Logger eVerbose, }; - u32 m_MinimumLoggingLevel{cast(LogType::eDebug)}; + u32 m_MinimumLoggingLevel{Cast(LogType::eDebug)}; void SetMinimumLoggingLevel(LogType logType) { - m_MinimumLoggingLevel = cast(logType); + m_MinimumLoggingLevel = Cast(logType); } - template + template constexpr static const char * ToCstr() { - if constexpr (LogLevel == LogType::eError) + if constexpr (TLogLevel == LogType::eError) return "[ERROR]:"; - if constexpr (LogLevel == LogType::eWarning) + if constexpr (TLogLevel == LogType::eWarning) return "[WARN]: "; - if constexpr (LogLevel == LogType::eInfo) + if constexpr (TLogLevel == LogType::eInfo) return "[INFO]: "; - if constexpr (LogLevel == LogType::eDebug) + if constexpr (TLogLevel == LogType::eDebug) return "[DEBUG]:"; - if constexpr (LogLevel == LogType::eVerbose) + if constexpr (TLogLevel == LogType::eVerbose) return "[VERB]: "; return ""; } - template + template constexpr static const char * ToColorCstr() { - if constexpr (LogLevel == LogType::eError) + if constexpr (TLogLevel == LogType::eError) return ansi_color::Red; - if constexpr (LogLevel == LogType::eWarning) + if constexpr (TLogLevel == LogType::eWarning) return ansi_color::Yellow; - if constexpr (LogLevel == LogType::eInfo) + if constexpr (TLogLevel == LogType::eInfo) return ansi_color::Green; - if constexpr (LogLevel == LogType::eDebug) + if constexpr (TLogLevel == LogType::eDebug) return ansi_color::White; - if constexpr (LogLevel == LogType::eVerbose) + if constexpr (TLogLevel == LogType::eVerbose) return ansi_color::Blue; return ansi_color::White; } - template + template void Log(const std::string_view &message, const char *loc, u32 line) const { - if (cast(LogLevel) <= m_MinimumLoggingLevel) + if (Cast(TLogLevel) <= m_MinimumLoggingLevel) { - fmt::println("{}{} {} {} at {}:{}{}", ToColorCstr(), ToCstr(), message.data(), + fmt::println("{}{} {} {} at {}:{}{}", ToColorCstr(), ToCstr(), message.data(), ansi_color::Black, loc, line, ansi_color::Reset); } #if !defined(NDEBUG) - if constexpr (LogLevel == LogType::eError) + if constexpr (TLogLevel == LogType::eError) { debug_break(); } #endif // !defined(NDEBUG) } - template + template void LogCond(const char *exprStr, const std::string_view &message, const char *loc, u32 line) const { - if (cast(LogLevel) <= m_MinimumLoggingLevel) + if (Cast(TLogLevel) <= m_MinimumLoggingLevel) { - fmt::println("{}{} ({}) {} {} at {}:{}{}", ToColorCstr(), ToCstr(), exprStr, + fmt::println("{}{} ({}) {} {} at {}:{}{}", ToColorCstr(), ToCstr(), exprStr, message.data(), ansi_color::Black, loc, line, ansi_color::Reset); } #if !defined(NDEBUG) - if constexpr (LogLevel == LogType::eError) + if constexpr (TLogLevel == LogType::eError) { debug_break(); } @@ -105,26 +105,26 @@ extern Logger g_Logger; #define INFO(...) g_Logger.Log(fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ERROR_IF(expr, ...) \ - if (cast(expr)) [[unlikely]] \ + if (Cast(expr)) [[unlikely]] \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define WARN_IF(expr, ...) \ - if (cast(expr)) [[unlikely]] \ + if (Cast(expr)) [[unlikely]] \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define INFO_IF(expr, ...) \ - if (cast(expr)) \ + if (Cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_ERROR(expr, ...) \ ; \ - else if (cast(expr)) \ + else if (Cast(expr)) \ [[unlikely]] g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_WARN(expr, ...) \ ; \ - else if (cast(expr)) \ + else if (Cast(expr)) \ [[unlikely]] g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_INFO(expr, ...) \ ; \ - else if (cast(expr)) \ + else if (Cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_ERROR(...) \ @@ -141,11 +141,11 @@ extern Logger g_Logger; #define DEBUG(...) g_Logger.Log(fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define DEBUG_IF(expr, ...) \ - if (cast(expr)) \ + if (Cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_DEBUG(expr, ...) \ ; \ - else if (cast(expr)) \ + else if (Cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_DEBUG(...) \ ; \ @@ -174,11 +174,11 @@ extern Logger g_Logger; #define VERBOSE(...) g_Logger.Log(fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define VERBOSE_IF(expr, ...) \ - if (cast(expr)) \ + if (Cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_VERBOSE(expr, ...) \ ; \ - else if (cast(expr)) \ + else if (Cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_VERBOSE(...) \ ; \ @@ -204,5 +204,5 @@ extern Logger g_Logger; #endif // !defined(VERBOSE_LOG_DISABLED) #define DO(code) , code -#define ABORT(code) exit(cast(code)) +#define ABORT(code) exit(Cast(code)) #define THEN_ABORT(code) , ABORT(code) diff --git a/aster/physical_device.cpp b/aster/physical_device.cpp index ecb368f..1c25af3 100644 --- a/aster/physical_device.cpp +++ b/aster/physical_device.cpp @@ -14,7 +14,7 @@ GetSurfaceCapabilities(const vk::PhysicalDevice physicalDevice, const vk::Surfac vk::SurfaceCapabilitiesKHR surfaceCapabilities; vk::Result result = physicalDevice.getSurfaceCapabilitiesKHR(surface, &surfaceCapabilities); - ERROR_IF(failed(result), "Fetching surface capabilities failed. Cause: {}", result) + ERROR_IF(Failed(result), "Fetching surface capabilities failed. Cause: {}", result) THEN_ABORT(result); return surfaceCapabilities; @@ -26,12 +26,12 @@ GetSurfaceFormats(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR // vk::Result::eIncomplete should not occur in this function. The rest are errors. Thus, abort is allowed. u32 count = 0; vk::Result result = physicalDevice.getSurfaceFormatsKHR(surface, &count, nullptr); - ERROR_IF(failed(result), "Could not get surface formats. Cause: {}", result) + ERROR_IF(Failed(result), "Could not get surface formats. Cause: {}", result) THEN_ABORT(result); eastl::vector surfaceFormats(count); result = physicalDevice.getSurfaceFormatsKHR(surface, &count, surfaceFormats.data()); - ERROR_IF(failed(result), "Could not get surface formats. Cause: {}", result) + ERROR_IF(Failed(result), "Could not get surface formats. Cause: {}", result) THEN_ABORT(result); return surfaceFormats; @@ -43,23 +43,24 @@ GetSurfacePresentModes(const vk::PhysicalDevice physicalDevice, const vk::Surfac // vk::Result::eIncomplete should not occur in this function. The rest are errors. Thus, abort is allowed. u32 count = 0; vk::Result result = physicalDevice.getSurfacePresentModesKHR(surface, &count, nullptr); - ERROR_IF(failed(result), "Could not get present modes. Cause: {}", result) + ERROR_IF(Failed(result), "Could not get present modes. Cause: {}", result) THEN_ABORT(result); eastl::vector presentModes(count); result = physicalDevice.getSurfacePresentModesKHR(surface, &count, presentModes.data()); - ERROR_IF(failed(result), "Could not get present modes. Cause: {}", result) + ERROR_IF(Failed(result), "Could not get present modes. Cause: {}", result) THEN_ABORT(result); return presentModes; } [[nodiscard]] bool -GetQueuePresentSupport(const u32 queueFamilyIndex, vk::SurfaceKHR surface, const vk::PhysicalDevice physicalDevice) +GetQueuePresentSupport(const u32 queueFamilyIndex, const vk::SurfaceKHR surface, + const vk::PhysicalDevice physicalDevice) { b32 supported = false; const vk::Result result = physicalDevice.getSurfaceSupportKHR(queueFamilyIndex, surface, &supported); - ERROR_IF(failed(result), "Could not get queue family surface support. Cause: {}", result) + ERROR_IF(Failed(result), "Could not get queue family surface support. Cause: {}", result) THEN_ABORT(result); return supported; @@ -142,12 +143,12 @@ EnumeratePhysicalDevices(const vk::Instance instance) { u32 count = 0; vk::Result result = instance.enumeratePhysicalDevices(&count, nullptr); - ERROR_IF(failed(result), "Could not fetch vulkan devices. Cause: {}", result) + ERROR_IF(Failed(result), "Could not fetch vulkan devices. Cause: {}", result) THEN_ABORT(result); eastl::fixed_vector physicalDevices(count); result = instance.enumeratePhysicalDevices(&count, physicalDevices.data()); - ERROR_IF(failed(result), "Could not fetch vulkan devices. Cause: {}", result) + ERROR_IF(Failed(result), "Could not fetch vulkan devices. Cause: {}", result) THEN_ABORT(result); return physicalDevices; diff --git a/aster/swapchain.cpp b/aster/swapchain.cpp index c7336d6..d82c54c 100644 --- a/aster/swapchain.cpp +++ b/aster/swapchain.cpp @@ -46,13 +46,13 @@ Swapchain::Create(const Window *window) if (swapchainFormat == vk::Format::eUndefined) { WARN("Preferred Swapchain format not found. Falling back."); - auto surfaceFormat = surfaceFormats.front(); - swapchainFormat = surfaceFormat.format; - swapchainColorSpace = surfaceFormat.colorSpace; + auto [format, colorSpace] = surfaceFormats.front(); + swapchainFormat = format; + swapchainColorSpace = colorSpace; } vk::PresentModeKHR swapchainPresentMode = vk::PresentModeKHR::eFifo; - for (auto presentMode : presentModes) + for (const auto presentMode : presentModes) { if (presentMode == vk::PresentModeKHR::eMailbox) { @@ -68,12 +68,12 @@ Swapchain::Create(const Window *window) } else { - vk::Extent2D extent = window->GetSize(); - vk::Extent2D minExtent = surfaceCapabilities.minImageExtent; - vk::Extent2D maxExtent = surfaceCapabilities.maxImageExtent; + auto [width, height] = window->GetSize(); + auto [minWidth, minHeight] = surfaceCapabilities.minImageExtent; + auto [maxWidth, maxHeight] = surfaceCapabilities.maxImageExtent; - swapchainExtent.width = glm::clamp(extent.width, minExtent.width, maxExtent.width); - swapchainExtent.height = glm::clamp(extent.height, minExtent.height, maxExtent.height); + swapchainExtent.width = glm::clamp(width, minWidth, maxWidth); + swapchainExtent.height = glm::clamp(height, minHeight, maxHeight); } u32 swapchainImageCount = 3; @@ -103,7 +103,7 @@ Swapchain::Create(const Window *window) vk::SwapchainKHR swapchain; vk::Result result = m_Device->m_Device.createSwapchainKHR(&swapchainCreateInfo, nullptr, &swapchain); - ERROR_IF(failed(result), "Swapchain {} creation failed. Cause {}", m_Name, result) + ERROR_IF(Failed(result), "Swapchain {} creation failed. Cause {}", m_Name, result) THEN_ABORT(result) ELSE_DEBUG("Created Swapchain '{}'", m_Name); diff --git a/aster/window.cpp b/aster/window.cpp index b1a35a0..2468cbd 100644 --- a/aster/window.cpp +++ b/aster/window.cpp @@ -18,7 +18,7 @@ Window::SetWindowSize(const vk::Extent2D &extent) const noexcept void Window::SetWindowSize(const u32 width, const u32 height) const noexcept { - glfwSetWindowSize(m_Window, cast(width), cast(height)); + glfwSetWindowSize(m_Window, Cast(width), Cast(height)); } vk::Extent2D @@ -27,10 +27,10 @@ Window::GetSize() const int width; int height; glfwGetWindowSize(m_Window, &width, &height); - return {cast(width), cast(height)}; + return {Cast(width), Cast(height)}; } -Window::Window(cstr title, Context *context, vk::Extent2D extent, b8 isFullScreen) +Window::Window(const cstr title, Context *context, vk::Extent2D extent, const b8 isFullScreen) { m_Context = context; m_Name = title; @@ -44,7 +44,7 @@ Window::Window(cstr title, Context *context, vk::Extent2D extent, b8 isFullScree glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_CENTER_CURSOR, GLFW_TRUE); - m_Window = glfwCreateWindow(cast(extent.width), cast(extent.height), m_Name.c_str(), + m_Window = glfwCreateWindow(Cast(extent.width), Cast(extent.height), m_Name.c_str(), isFullScreen ? monitor : nullptr, nullptr); ERROR_IF(m_Window == nullptr, "Window creation failed") ELSE_DEBUG("Window '{}' created with resolution '{}x{}'", m_Name, extent.width, extent.height); @@ -57,15 +57,15 @@ Window::Window(cstr title, Context *context, vk::Extent2D extent, b8 isFullScree if (isFullScreen == false) { - glfwSetWindowPos(m_Window, cast(windowWidth - extent.width) / 2, - cast(windowHeight - extent.height) / 2); + glfwSetWindowPos(m_Window, Cast(windowWidth - extent.width) / 2, + Cast(windowHeight - extent.height) / 2); } glfwSetInputMode(m_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); VkSurfaceKHR surface; auto result = - cast(glfwCreateWindowSurface(cast(m_Context->m_Instance), m_Window, nullptr, &surface)); - ERROR_IF(failed(result), "Failed to create Surface with {}", result) + Cast(glfwCreateWindowSurface(Cast(m_Context->m_Instance), m_Window, nullptr, &surface)); + ERROR_IF(Failed(result), "Failed to create Surface with {}", result) THEN_ABORT(result) ELSE_DEBUG("Surface {} Created", m_Name); m_Surface = vk::SurfaceKHR(surface); diff --git a/triangle/aster.cpp b/triangle/aster.cpp index 4513902..84ae0a3 100644 --- a/triangle/aster.cpp +++ b/triangle/aster.cpp @@ -13,7 +13,7 @@ constexpr QueueSupportFlags REQUIRED_QUEUE_SUPPORT = QueueSupportFlags{} | Queue QueueSupportFlagBits::eTransfer; [[nodiscard]] bool -isSuitableDevice(const PhysicalDevice *physicalDevice) +IsSuitableDevice(const PhysicalDevice *physicalDevice) { const bool hasAllRequiredQueues = std::ranges::any_of(physicalDevice->m_QueueFamilies, [](const auto &queueFamilyProp) { @@ -30,11 +30,11 @@ isSuitableDevice(const PhysicalDevice *physicalDevice) } PhysicalDevice -findSuitableDevice(const PhysicalDevices &physicalDevices) +FindSuitableDevice(const PhysicalDevices &physicalDevices) { for (auto &physicalDevice : physicalDevices) { - if (isSuitableDevice(&physicalDevice)) + if (IsSuitableDevice(&physicalDevice)) { return physicalDevice; } @@ -45,7 +45,7 @@ findSuitableDevice(const PhysicalDevices &physicalDevices) } QueueAllocation -findAppropriateQueueAllocation(const PhysicalDevice *physicalDevice) +FindAppropriateQueueAllocation(const PhysicalDevice *physicalDevice) { for (auto &queueFamilyInfo : physicalDevice->m_QueueFamilies) { @@ -71,12 +71,12 @@ main(int, char **) Window window = {"Aster1", &context, {640, 480}}; PhysicalDevices physicalDevices = {&window, &context}; - PhysicalDevice deviceToUse = findSuitableDevice(physicalDevices); + PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices); INFO("Using {} as the primary device.", deviceToUse.m_DeviceProperties.deviceName.data()); vk::PhysicalDeviceFeatures features = {}; - QueueAllocation queueAllocation = findAppropriateQueueAllocation(&deviceToUse); + QueueAllocation queueAllocation = FindAppropriateQueueAllocation(&deviceToUse); Device device = {&context, &deviceToUse, &features, {queueAllocation}, "Primary Device"};