From 1b48aa25d351ff9803cbdafa85aa580f8b4771fe Mon Sep 17 00:00:00 2001 From: Anish Bhobe Date: Tue, 27 May 2025 18:49:40 +0200 Subject: [PATCH] East Const supremacy. --- aster/include/aster/core/buffer.h | 8 +- aster/include/aster/core/constants.h | 12 +- aster/include/aster/core/device.h | 12 +- aster/include/aster/core/global.h | 40 +++--- aster/include/aster/core/image.h | 12 +- aster/include/aster/core/image_view.h | 4 +- aster/include/aster/core/physical_device.h | 8 +- aster/include/aster/core/pipeline.h | 6 +- aster/include/aster/core/sampler.h | 4 +- aster/include/aster/core/size.h | 8 +- aster/include/aster/core/surface.h | 2 +- aster/include/aster/core/swapchain.h | 8 +- aster/include/aster/core/window.h | 2 +- aster/include/aster/systems/commit_manager.h | 71 ++++++----- aster/include/aster/systems/context.h | 71 ++++++----- aster/include/aster/systems/device.h | 59 +++++---- .../include/aster/systems/pipeline_helpers.h | 11 +- aster/include/aster/systems/resource.h | 15 +-- aster/include/aster/util/freelist.h | 2 +- aster/include/aster/util/logger.h | 28 ++-- aster/src/aster/core/buffer.cpp | 21 +-- aster/src/aster/core/device.cpp | 8 +- aster/src/aster/core/global.cpp | 12 +- aster/src/aster/core/image.cpp | 24 ++-- aster/src/aster/core/instance.cpp | 18 +-- aster/src/aster/core/physical_device.cpp | 22 ++-- aster/src/aster/core/pipeline.cpp | 6 +- aster/src/aster/core/sampler.cpp | 9 +- aster/src/aster/core/surface.cpp | 2 +- aster/src/aster/core/swapchain.cpp | 10 +- aster/src/aster/core/window.cpp | 16 +-- aster/src/aster/systems/commit_manager.cpp | 28 ++-- aster/src/aster/systems/context.cpp | 63 +++++---- aster/src/aster/systems/device.cpp | 120 +++++++++--------- aster/src/aster/systems/pipeline_helpers.cpp | 30 ++--- aster/src/aster/systems/sync_server.cpp | 6 +- aster/src/aster/util/files.cpp | 8 +- aster/src/aster/util/logger.cpp | 2 +- samples/00_util/gui.cpp | 22 ++-- samples/00_util/helpers.cpp | 18 +-- samples/01_triangle/triangle.cpp | 2 +- samples/02_box/box.cpp | 8 +- samples/03_model_render/asset_loader.cpp | 34 ++--- samples/03_model_render/asset_loader.h | 20 ++- samples/03_model_render/ibl_helpers.cpp | 2 +- samples/03_model_render/light_manager.cpp | 48 +++---- samples/03_model_render/model_render.cpp | 9 +- samples/03_model_render/nodes.cpp | 30 ++--- samples/03_model_render/nodes.h | 14 +- 49 files changed, 500 insertions(+), 495 deletions(-) diff --git a/aster/include/aster/core/buffer.h b/aster/include/aster/core/buffer.h index f491ea3..18f1a51 100644 --- a/aster/include/aster/core/buffer.h +++ b/aster/include/aster/core/buffer.h @@ -26,7 +26,7 @@ struct Buffer using Flags = vk::Flags; constexpr static Flags FLAGS = {}; - const Device *m_Device = nullptr; + Device const *m_Device = nullptr; vk::Buffer m_Buffer = nullptr; VmaAllocation m_Allocation = nullptr; u8 *m_Mapped = nullptr; ///< If the buffer is host visible, it should be (and stay) mapped. @@ -50,15 +50,15 @@ struct Buffer /// Writes the data to the buffer. /// @note The buffer must be mapped. - void Write(usize offset, usize size, const void *data) const; + void Write(usize offset, usize size, void const *data) const; /// If Buffer Device Address is enabled, /// Get a pointer. - uptr GetDeviceAddress(const Device *device) const; + uptr GetDeviceAddress(Device const *device) const; // Constructors - Buffer(const Device *device, usize size, vk::BufferUsageFlags bufferUsage, VmaAllocationCreateFlags allocationFlags, + Buffer(Device const *device, usize size, vk::BufferUsageFlags bufferUsage, VmaAllocationCreateFlags allocationFlags, VmaMemoryUsage memoryUsage, cstr name); Buffer(Buffer &&other) noexcept; diff --git a/aster/include/aster/core/constants.h b/aster/include/aster/core/constants.h index b67d160..d31b8a2 100644 --- a/aster/include/aster/core/constants.h +++ b/aster/include/aster/core/constants.h @@ -32,7 +32,7 @@ using b32 = u32; using usize = size_t; using isize = intptr_t; using uptr = uintptr_t; -using cstr = const char *; +using cstr = char const *; namespace ansi_color { @@ -105,31 +105,31 @@ constexpr Version VERSION = { }; constexpr u32 -Kilobyte(const u32 in) +Kilobyte(u32 const in) { return in * 1024; } constexpr usize -Kilobyte(const usize in) +Kilobyte(usize const in) { return in * 1024; } constexpr u32 -Megabyte(const u32 in) +Megabyte(u32 const in) { return in * 1024 * 1024; } constexpr usize -Megabyte(const usize in) +Megabyte(usize const in) { return in * 1024 * 1024; } constexpr usize -Gigabyte(const usize in) +Gigabyte(usize const in) { return in * 1024 * 1024 * 1024; } diff --git a/aster/include/aster/core/device.h b/aster/include/aster/core/device.h index 8f45fb6..8e568da 100644 --- a/aster/include/aster/core/device.h +++ b/aster/include/aster/core/device.h @@ -32,7 +32,7 @@ struct Device final bool m_ValidationEnabled = true; template - void SetName(const T &object, cstr name) const; + void SetName(T const &object, cstr name) const; [[nodiscard]] vk::Queue GetQueue(u32 familyIndex, u32 queueIndex) const; [[nodiscard]] eastl::vector DumpPipelineCache() const; @@ -45,7 +45,7 @@ struct Device final return &m_Device; } - const vk::Device * + vk::Device const * operator->() const { return &m_Device; @@ -53,8 +53,8 @@ struct Device final // Ctor/Dtor Device() = default; - Device(const Instance &context, PhysicalDevice &physicalDevice, Features &enabledFeatures, - const eastl::span &queueAllocations, const eastl::span &pipelineCacheData, + Device(Instance const &context, PhysicalDevice &physicalDevice, Features &enabledFeatures, + eastl::span const &queueAllocations, eastl::span const &pipelineCacheData, NameString &&name); ~Device(); @@ -67,13 +67,13 @@ struct Device final template void -Device::SetName(const T &object, cstr name) const +Device::SetName(T const &object, cstr name) const { if (!m_ValidationEnabled || !name || !object) return; auto handle = reinterpret_cast(static_cast(object)); - const vk::DebugUtilsObjectNameInfoEXT objectNameInfo = { + vk::DebugUtilsObjectNameInfoEXT const objectNameInfo = { .objectType = object.objectType, .objectHandle = handle, .pObjectName = name, diff --git a/aster/include/aster/core/global.h b/aster/include/aster/core/global.h index 982b0a5..00dd2ae 100644 --- a/aster/include/aster/core/global.h +++ b/aster/include/aster/core/global.h @@ -5,15 +5,15 @@ #pragma once +#include "aster/util/logger.h" #include "config.h" #include "constants.h" -#include "aster/util/logger.h" #include #include -#include #include +#include // Macros that can collide with functions. #if defined(max) @@ -82,7 +82,7 @@ constexpr u32 ASTER_API_VERSION = VK_API_VERSION_1_3; } while (false) [[nodiscard]] inline bool -Failed(const vk::Result result) +Failed(vk::Result const result) { return result != vk::Result::eSuccess; } @@ -99,7 +99,7 @@ template struct eastl::hash> // NOLINT(*-dcl58-cpp) { [[nodiscard]] usize - operator()(const vk::Flags &val) + operator()(vk::Flags const &val) { return std::hash()(static_cast(val)); } @@ -107,16 +107,16 @@ struct eastl::hash> // NOLINT(*-dcl58-cpp) template [[nodiscard]] usize -HashAny(const T &val) +HashAny(T const &val) { return eastl::hash>()(val); } [[nodiscard]] inline usize -HashCombine(const usize hash0, const usize hash1) +HashCombine(usize const hash0, usize const hash1) { constexpr usize saltValue = 0x9e3779b9; - const usize tempVar = hash1 + saltValue + (hash0 << 6) + (hash0 >> 2); + usize const tempVar = hash1 + saltValue + (hash0 << 6) + (hash0 >> 2); return hash0 ^ tempVar; } @@ -139,32 +139,32 @@ struct Time Update() { ERROR_IF(std::isnan(m_Elapsed), "Time not init."); - const auto newElapsed = glfwGetTime(); + auto const newElapsed = glfwGetTime(); m_Delta = std::clamp(newElapsed - m_Elapsed, 0.0, MAX_DELTA); m_Elapsed = newElapsed; } }; [[nodiscard]] constexpr usize -ClosestMultiple(const usize val, const usize of) +ClosestMultiple(usize const val, usize const of) { return of * ((val + of - 1) / of); } [[nodiscard]] constexpr u32 -ClosestMultiple(const u32 val, const u32 of) +ClosestMultiple(u32 const val, u32 const of) { return of * ((val + of - 1) / of); } [[nodiscard]] constexpr bool -IsPowerOfTwo(const usize val) +IsPowerOfTwo(usize const val) { return val && !(val & (val - 1)); } [[nodiscard]] constexpr bool -IsPowerOfTwo(const u32 val) +IsPowerOfTwo(u32 const val) { return val && !(val & (val - 1)); } @@ -184,10 +184,10 @@ ClosestLargerPowerOfTwo(usize val) } [[nodiscard]] constexpr usize -ClosestPowerOfTwo(const usize val) +ClosestPowerOfTwo(usize const val) { - const usize largerPo2 = ClosestLargerPowerOfTwo(val); - const usize smallerPo2 = largerPo2 >> 1; + usize const largerPo2 = ClosestLargerPowerOfTwo(val); + usize const smallerPo2 = largerPo2 >> 1; return (smallerPo2 + largerPo2 <= (val << 1)) ? largerPo2 : smallerPo2; } @@ -205,10 +205,10 @@ ClosestLargerPowerOfTwo(u32 val) } [[nodiscard]] constexpr u32 -ClosestPowerOfTwo(const u32 val) +ClosestPowerOfTwo(u32 const val) { - const u32 largerPo2 = ClosestLargerPowerOfTwo(val); - const u32 smallerPo2 = largerPo2 >> 1; + u32 const largerPo2 = ClosestLargerPowerOfTwo(val); + u32 const smallerPo2 = largerPo2 >> 1; return (smallerPo2 + largerPo2 <= (val << 1)) ? largerPo2 : smallerPo2; } @@ -246,9 +246,9 @@ struct fmt::formatter> : nested_fo { auto // ReSharper disable once CppInconsistentNaming - format(const eastl::fixed_string &str, format_context &ctx) const + format(eastl::fixed_string const &str, format_context &ctx) const { - return write_padded(ctx, [this, str](auto out) { return fmt::format_to(out, "{}", nested(str.c_str())); }); + return write_padded(ctx, [this, str](auto out) { return fmt::format_to(out, "{}", nested(str.c_str())); }); } }; diff --git a/aster/include/aster/core/image.h b/aster/include/aster/core/image.h index 96fc02f..2a78aeb 100644 --- a/aster/include/aster/core/image.h +++ b/aster/include/aster/core/image.h @@ -11,25 +11,25 @@ struct StorageTexture; struct Device; [[nodiscard]] inline vk::Extent2D -ToExtent2D(const vk::Extent3D &extent) +ToExtent2D(vk::Extent3D const &extent) { return {extent.width, extent.height}; } [[nodiscard]] inline vk::Extent3D -ToExtent3D(const vk::Extent2D &extent, const u32 depth) +ToExtent3D(vk::Extent2D const &extent, u32 const depth) { return {extent.width, extent.height, depth}; } [[nodiscard]] inline vk::Offset2D -ToOffset2D(const vk::Extent3D &extent) +ToOffset2D(vk::Extent3D const &extent) { return {static_cast(extent.width), static_cast(extent.height)}; } [[nodiscard]] inline vk::Offset3D -ToOffset3D(const vk::Extent3D &extent) +ToOffset3D(vk::Extent3D const &extent) { return {static_cast(extent.width), static_cast(extent.height), static_cast(extent.depth)}; } @@ -46,7 +46,7 @@ struct Image using Flags = vk::Flags; constexpr static Flags FLAGS = {}; - const Device *m_Device = nullptr; + Device const *m_Device = nullptr; vk::Image m_Image = nullptr; VmaAllocation m_Allocation = nullptr; vk::Extent3D m_Extent; @@ -72,7 +72,7 @@ struct Image // Constructors. - explicit Image(const Device *device, vk::Image image, VmaAllocation allocation, vk::Extent3D extent, + explicit Image(Device const *device, vk::Image image, VmaAllocation allocation, vk::Extent3D extent, vk::Format format, Flags flags, u8 layerCount, u8 mipLevels); Image(Image &&other) noexcept; diff --git a/aster/include/aster/core/image_view.h b/aster/include/aster/core/image_view.h index 8c1a32f..9b46979 100644 --- a/aster/include/aster/core/image_view.h +++ b/aster/include/aster/core/image_view.h @@ -33,8 +33,8 @@ struct View return static_cast(m_Image); } - View(Ref image, const vk::ImageView view, const vk::Extent3D extent, const u8 baseLayer, const u8 layerCount, - const u8 baseMipLevel, const u8 mipLevelCount) + View(Ref image, vk::ImageView const view, vk::Extent3D const extent, u8 const baseLayer, u8 const layerCount, + u8 const baseMipLevel, u8 const mipLevelCount) : m_Image{std::move(image)} , m_View{view} , m_Extent{extent} diff --git a/aster/include/aster/core/physical_device.h b/aster/include/aster/core/physical_device.h index 4af909d..45d1f00 100644 --- a/aster/include/aster/core/physical_device.h +++ b/aster/include/aster/core/physical_device.h @@ -27,7 +27,7 @@ using QueueSupportFlags = vk::Flags; inline std::string // ReSharper disable once CppInconsistentNaming -format_as(const QueueSupportFlags &qfi) +format_as(QueueSupportFlags const &qfi) { std::stringstream sb; if (qfi & QueueSupportFlagBits::eGraphics) @@ -46,7 +46,7 @@ format_as(const QueueSupportFlags &qfi) { sb << "Present | "; } - const auto sbv = sb.view(); + auto const sbv = sb.view(); return std::string(sbv.substr(0, sbv.size() - 3)); } @@ -58,7 +58,7 @@ struct QueueFamilyInfo }; inline std::string -format_as(const QueueFamilyInfo &qfi) +format_as(QueueFamilyInfo const &qfi) { return fmt::format("Queue {}: Count={} Support={}", qfi.m_Index, qfi.m_Count, qfi.m_Support); } @@ -88,5 +88,5 @@ struct PhysicalDevice final class PhysicalDevices : public eastl::fixed_vector { public: - PhysicalDevices(const Surface &surface, const Instance &context); + PhysicalDevices(Surface const &surface, Instance const &context); }; \ No newline at end of file diff --git a/aster/include/aster/core/pipeline.h b/aster/include/aster/core/pipeline.h index 1c74596..a68f1be 100644 --- a/aster/include/aster/core/pipeline.h +++ b/aster/include/aster/core/pipeline.h @@ -19,14 +19,14 @@ struct Pipeline eCompute, }; - const Device *m_Device = nullptr; + Device const *m_Device = nullptr; vk::PipelineLayout m_Layout; vk::Pipeline m_Pipeline = nullptr; eastl::vector m_SetLayouts; Kind m_Kind; Pipeline() = default; - Pipeline(const Device *device, vk::PipelineLayout layout, vk::Pipeline pipeline, + Pipeline(Device const *device, vk::PipelineLayout layout, vk::Pipeline pipeline, eastl::vector &&setLayouts, Kind kind); ~Pipeline(); @@ -54,4 +54,4 @@ struct Pipeline swap(m_Kind, other.m_Kind); return *this; } -}; +}; \ No newline at end of file diff --git a/aster/include/aster/core/sampler.h b/aster/include/aster/core/sampler.h index bd3b478..4d9c97b 100644 --- a/aster/include/aster/core/sampler.h +++ b/aster/include/aster/core/sampler.h @@ -11,7 +11,7 @@ struct Device; struct Sampler final { - const Device *m_Device = nullptr; + Device const *m_Device = nullptr; vk::Sampler m_Sampler = nullptr; [[nodiscard]] bool @@ -22,7 +22,7 @@ struct Sampler final // Constructors - Sampler(const Device *device, const vk::SamplerCreateInfo &samplerCreateInfo, cstr name); + Sampler(Device const *device, vk::SamplerCreateInfo const &samplerCreateInfo, cstr name); ~Sampler(); Sampler(Sampler &&other) noexcept; diff --git a/aster/include/aster/core/size.h b/aster/include/aster/core/size.h index 8188b17..a9cf826 100644 --- a/aster/include/aster/core/size.h +++ b/aster/include/aster/core/size.h @@ -14,27 +14,27 @@ struct Size2D Size2D() = default; - Size2D(const u32 width, const u32 height) + Size2D(u32 const width, u32 const height) : m_Width{width} , m_Height{height} { } - Size2D(const vk::Extent2D extent) + Size2D(vk::Extent2D const extent) : m_Width{extent.width} , m_Height{extent.height} { } Size2D & - operator=(const vk::Extent2D other) + operator=(vk::Extent2D const other) { m_Height = other.height; m_Width = other.width; return *this; } - bool operator==(const Size2D&) const = default; + bool operator==(Size2D const &) const = default; operator vk::Extent2D() const { diff --git a/aster/include/aster/core/surface.h b/aster/include/aster/core/surface.h index bc9689f..8bf7201 100644 --- a/aster/include/aster/core/surface.h +++ b/aster/include/aster/core/surface.h @@ -18,7 +18,7 @@ struct Surface // Ctor Dtor Surface() = default; - Surface(Instance &context, const Window &window); + Surface(Instance &context, Window const &window); ~Surface(); // Move diff --git a/aster/include/aster/core/swapchain.h b/aster/include/aster/core/swapchain.h index a380d69..9008173 100644 --- a/aster/include/aster/core/swapchain.h +++ b/aster/include/aster/core/swapchain.h @@ -19,7 +19,7 @@ struct Swapchain final { using FnResizeCallback = eastl::function; - const Device *m_Device; + Device const *m_Device; vk::SwapchainKHR m_Swapchain; vk::Extent2D m_Extent; vk::Format m_Format; @@ -28,12 +28,12 @@ struct Swapchain final eastl::vector m_ResizeCallbacks; - void Create(const Surface &surface, Size2D size); + void Create(Surface const &surface, Size2D size); void RegisterResizeCallback(FnResizeCallback &&callback); // Ctor/Dtor Swapchain() = default; - Swapchain(const Surface &surface, const Device &device, Size2D size); + Swapchain(Surface const &surface, Device const &device, Size2D size); ~Swapchain(); // Move @@ -42,6 +42,6 @@ struct Swapchain final DISALLOW_COPY_AND_ASSIGN(Swapchain); - private: +private: void Cleanup(); }; \ No newline at end of file diff --git a/aster/include/aster/core/window.h b/aster/include/aster/core/window.h index e291c89..1ba7bcd 100644 --- a/aster/include/aster/core/window.h +++ b/aster/include/aster/core/window.h @@ -32,7 +32,7 @@ struct Window final } void RequestExit() const noexcept; - void SetWindowSize(const vk::Extent2D &extent) const noexcept; + void SetWindowSize(vk::Extent2D const &extent) const noexcept; void SetWindowSize(u32 width, u32 height) const noexcept; /// Actual size of the framebuffer being used for the window render. [[nodiscard]] Size2D GetSize() const; diff --git a/aster/include/aster/systems/commit_manager.h b/aster/include/aster/systems/commit_manager.h index 3f922d6..73e518f 100644 --- a/aster/include/aster/systems/commit_manager.h +++ b/aster/include/aster/systems/commit_manager.h @@ -12,11 +12,11 @@ #include "EASTL/deque.h" #include "EASTL/intrusive_hash_map.h" -#include "resource.h" #include "EASTL/vector.h" #include "aster/core/buffer.h" #include "aster/core/image_view.h" #include "aster/core/sampler.h" +#include "resource.h" namespace systems { @@ -38,14 +38,14 @@ class CommitManager void AddRef() { - const auto rc = ++m_CommitCount; + auto const rc = ++m_CommitCount; assert(rc > 0); } void Release() { - const auto rc = --m_CommitCount; + auto const rc = --m_CommitCount; assert(rc < MaxValue); } @@ -56,7 +56,7 @@ class CommitManager } bool - operator==(const Entry &other) const + operator==(Entry const &other) const { return this->mKey == other.mKey; } @@ -76,7 +76,7 @@ class CommitManager struct Hash { usize - operator()(const Handle &e) + operator()(Handle const &e) { return eastl::hash()(e.get()); } @@ -89,7 +89,7 @@ class CommitManager std::array, 4> m_ToDelete; u8 m_ToDeleteIndex = 0; - explicit HandleMapper(const u32 maxCount) + explicit HandleMapper(u32 const maxCount) : m_Data{maxCount} { // Setup freelist @@ -111,7 +111,7 @@ class CommitManager /// Returns a commit, and a bool signifying if it is a new commit. std::tuple - Create(const Handle &object) + Create(Handle const &object) { // Get-from freelist assert(!m_FreeList.Empty()); @@ -137,19 +137,19 @@ class CommitManager } Handle - GetHandle(const Resource &res) + GetHandle(Resource const &res) { return m_Data[res.m_Index].mKey; } void - AddRef(const Resource &commit) + AddRef(Resource const &commit) { m_Data.at(commit.m_Index).AddRef(); } void - Release(const Resource &commit) + Release(Resource const &commit) { auto &entry = m_Data.at(commit.m_Index); entry.Release(); @@ -173,7 +173,7 @@ class CommitManager private: u32 - GetIndex(const Entry &entry) + GetIndex(Entry const &entry) { return static_cast(&entry - m_Data.begin()); } @@ -202,9 +202,9 @@ class CommitManager vk::DescriptorImageInfo uImageInfo; vk::BufferView uBufferView; - explicit WriteInfo(const vk::DescriptorBufferInfo &info); - explicit WriteInfo(const vk::DescriptorImageInfo &info); - explicit WriteInfo(const vk::BufferView &info); + explicit WriteInfo(vk::DescriptorBufferInfo const &info); + explicit WriteInfo(vk::DescriptorImageInfo const &info); + explicit WriteInfo(vk::BufferView const &info); }; using WriteCommand = vk::WriteDescriptorSet; @@ -212,69 +212,69 @@ class CommitManager // using WriteOwner = std::variant, Handle>; public: - const Device *m_Device; + Device const *m_Device; - CommitManager(const Device *device, u32 maxBuffers, u32 maxImages, u32 maxStorageImages, + CommitManager(Device const *device, u32 maxBuffers, u32 maxImages, u32 maxStorageImages, Ref defaultSampler); ~CommitManager(); PIN_MEMORY(CommitManager); // Commit Buffer - ResId CommitBuffer(const Ref &buffer); + ResId CommitBuffer(Ref const &buffer); // Commit Storage Images ResId - CommitStorageImage(const concepts::ViewRefTo auto &image) + CommitStorageImage(concepts::ViewRefTo auto const &image) { return CommitStorageImage(CastView(image)); } - ResId CommitStorageImage(const Ref &image); + ResId CommitStorageImage(Ref const &image); // Sampled Images ResId - CommitTexture(const concepts::ViewRefTo auto &image, const Ref &sampler) + CommitTexture(concepts::ViewRefTo auto const &image, Ref const &sampler) { return CommitTexture(CastView(image), sampler); } ResId - CommitTexture(const concepts::ViewRefTo auto &image) + CommitTexture(concepts::ViewRefTo auto const &image) { return CommitTexture(CastView(image)); } - ResId CommitTexture(const Ref &handle); - ResId CommitTexture(const Ref &image, const Ref &sampler); + ResId CommitTexture(Ref const &handle); + ResId CommitTexture(Ref const &image, Ref const &sampler); void Update(); Ref - FetchHandle(const ResId &id) + FetchHandle(ResId const &id) { return m_Buffers.GetHandle(id); } Ref - FetchHandle(const ResId &id) + FetchHandle(ResId const &id) { return m_Images.GetHandle(id); } Ref - FetchHandle(const ResId &id) + FetchHandle(ResId const &id) { return m_StorageImages.GetHandle(id); } - [[nodiscard]] const vk::DescriptorSetLayout & + [[nodiscard]] vk::DescriptorSetLayout const & GetDescriptorSetLayout() const { return m_SetLayout; } - [[nodiscard]] const vk::DescriptorSet & + [[nodiscard]] vk::DescriptorSet const & GetDescriptorSet() const { return m_DescriptorSet; @@ -287,7 +287,8 @@ class CommitManager return *m_Instance; } - static bool IsInit() + static bool + IsInit() { return static_cast(m_Instance); } @@ -317,37 +318,37 @@ class CommitManager friend ResId; void - AddRef(const ResId &handle) + AddRef(ResId const &handle) { m_Buffers.AddRef(handle); } void - AddRef(const ResId &handle) + AddRef(ResId const &handle) { m_Images.AddRef(handle); } void - AddRef(const ResId &handle) + AddRef(ResId const &handle) { m_StorageImages.AddRef(handle); } void - Release(const ResId &handle) + Release(ResId const &handle) { m_Buffers.Release(handle); } void - Release(const ResId &handle) + Release(ResId const &handle) { m_Images.Release(handle); } void - Release(const ResId &handle) + Release(ResId const &handle) { m_StorageImages.Release(handle); } diff --git a/aster/include/aster/systems/context.h b/aster/include/aster/systems/context.h index ad2f6cc..fb53043 100644 --- a/aster/include/aster/systems/context.h +++ b/aster/include/aster/systems/context.h @@ -48,21 +48,21 @@ class Context friend Device; friend _internal::ContextPool; - explicit Context(_internal::ContextPool &pool, const vk::CommandBuffer cmd) + explicit Context(_internal::ContextPool &pool, vk::CommandBuffer const cmd) : m_Pool{&pool} , m_Cmd{cmd} { } /// Keep the resource alive while the command buffers are acting. - void KeepAlive(const Ref &buffer); + void KeepAlive(Ref const &buffer); /// Keep the resource alive while the command buffers are acting. - void KeepAlive(const Ref &image); + void KeepAlive(Ref const &image); /// Keep the resource alive while the command buffers are acting. - void KeepAlive(const Ref &view); + void KeepAlive(Ref const &view); public: - DEPRECATE_RAW_CALLS void Dependency(const vk::DependencyInfo &dependencyInfo); + DEPRECATE_RAW_CALLS void Dependency(vk::DependencyInfo const &dependencyInfo); void Begin(); void End(); @@ -90,24 +90,24 @@ class TransferContext : public Context friend Device; friend _internal::TransferContextPool; - explicit TransferContext(_internal::ContextPool &pool, const vk::CommandBuffer cmd) + explicit TransferContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd) : Context{pool, cmd} { } - void UploadBuffer(const Ref &buffer, usize size, const void *data); + void UploadBuffer(Ref const &buffer, usize size, void const *data); public: - void UploadTexture(const Ref &image, const eastl::span &data); + void UploadTexture(Ref const &image, eastl::span const &data); void - UploadBuffer(const Ref &buffer, const std::ranges::range auto &data) + UploadBuffer(Ref const &buffer, std::ranges::range auto const &data) { - const auto span = eastl::span{data.begin(), data.end()}; + auto const span = eastl::span{data.begin(), data.end()}; UploadBuffer(buffer, span.size_bytes(), span.data()); } - DEPRECATE_RAW_CALLS void Blit(const vk::BlitImageInfo2 &mipBlitInfo); + DEPRECATE_RAW_CALLS void Blit(vk::BlitImageInfo2 const &mipBlitInfo); TransferContext(TransferContext &&other) noexcept; TransferContext &operator=(TransferContext &&other) noexcept; @@ -123,22 +123,23 @@ class ComputeContext : public TransferContext friend Device; friend _internal::ComputeContextPool; - const Pipeline *m_PipelineInUse; + Pipeline const *m_PipelineInUse; - explicit ComputeContext(_internal::ContextPool &pool, const vk::CommandBuffer cmd) + explicit ComputeContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd) : TransferContext{pool, cmd} , m_PipelineInUse{nullptr} { } - void PushConstantBlock(usize offset, usize size, const void *data); + void PushConstantBlock(usize offset, usize size, void const *data); - void Dispatch(const Pipeline &pipeline, u32 x, u32 y, u32 z, usize size, void *data); + void Dispatch(Pipeline const &pipeline, u32 x, u32 y, u32 z, usize size, void *data); public: - void BindPipeline(const Pipeline &pipeline); + void BindPipeline(Pipeline const &pipeline); + void - PushConstantBlock(const auto &block) + PushConstantBlock(auto const &block) { if constexpr (sizeof block > 128) WARN("Vulkan only guarantees 128 bytes of Push Constants. Size of PCB is {}", sizeof block); @@ -146,7 +147,7 @@ class ComputeContext : public TransferContext } void - PushConstantBlock(const usize offset, const auto &block) + PushConstantBlock(usize const offset, auto const &block) { if (offset + sizeof block > 128) WARN("Vulkan only guarantees 128 bytes of Push Constants. Size of PCB is {}, at offset {}", sizeof block, @@ -155,7 +156,7 @@ class ComputeContext : public TransferContext } void - Dispatch(const Pipeline &pipeline, const u32 x, const u32 y, const u32 z, auto &pushConstantBlock) + Dispatch(Pipeline const &pipeline, u32 const x, u32 const y, u32 const z, auto &pushConstantBlock) { if constexpr (sizeof pushConstantBlock > 128) WARN("Vulkan only guarantees 128 bytes of Push Constants. Size of PCB is {}", sizeof pushConstantBlock); @@ -169,20 +170,20 @@ class GraphicsContext : public ComputeContext friend Device; friend _internal::GraphicsContextPool; - explicit GraphicsContext(_internal::ContextPool &pool, const vk::CommandBuffer cmd) + explicit GraphicsContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd) : ComputeContext{pool, cmd} { } public: - DEPRECATE_RAW_CALLS void SetViewport(const vk::Viewport &viewport); - void BindVertexBuffer(const Ref &vertexBuffer); - void BindIndexBuffer(const Ref &indexBuffer); + DEPRECATE_RAW_CALLS void SetViewport(vk::Viewport const &viewport); + void BindVertexBuffer(Ref const &vertexBuffer); + void BindIndexBuffer(Ref const &indexBuffer); void Draw(usize vertexCount); void DrawIndexed(usize indexCount); void DrawIndexed(usize indexCount, usize firstIndex, usize firstVertex); - DEPRECATE_RAW_CALLS void BeginRendering(const vk::RenderingInfo &renderingInfo); + DEPRECATE_RAW_CALLS void BeginRendering(vk::RenderingInfo const &renderingInfo); void EndRendering(); DEPRECATE_RAW_CALLS vk::CommandBuffer @@ -230,11 +231,11 @@ class ContextPool eastl::function m_ResetCallback; /// Keep the resource alive while the command buffers are acting. - void KeepAlive(const Ref &buffer); + void KeepAlive(Ref const &buffer); /// Keep the resource alive while the command buffers are acting. - void KeepAlive(const Ref &image); + void KeepAlive(Ref const &image); /// Keep the resource alive while the command buffers are acting. - void KeepAlive(const Ref &view); + void KeepAlive(Ref const &view); Context CreateContext(); @@ -247,7 +248,7 @@ class ContextPool ContextPool &operator=(ContextPool &&other) noexcept; bool - operator==(const ContextPool &other) const + operator==(ContextPool const &other) const { return m_Pool == other.m_Pool; } @@ -264,7 +265,7 @@ class TransferContextPool : public ContextPool TransferContextPool() = default; - TransferContextPool(Device &device, const u32 queueFamilyIndex, const ManagedBy managedBy) + TransferContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) : ContextPool{device, queueFamilyIndex, managedBy} { } @@ -283,7 +284,8 @@ class ComputeContextPool : public TransferContextPool ComputeContext CreateComputeContext(); ComputeContextPool() = default; - ComputeContextPool(Device &device, const u32 queueFamilyIndex, const ManagedBy managedBy) + + ComputeContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) : TransferContextPool{device, queueFamilyIndex, managedBy} { } @@ -302,7 +304,8 @@ class GraphicsContextPool : public ComputeContextPool GraphicsContext CreateGraphicsContext(); GraphicsContextPool() = default; - GraphicsContextPool(Device &device, const u32 queueFamilyIndex, const ManagedBy managedBy) + + GraphicsContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) : ComputeContextPool{device, queueFamilyIndex, managedBy} { } @@ -325,7 +328,7 @@ class OrderlessContextPool ContextPoolType m_Pool; bool - Contains(const ContextPool &other) const + Contains(ContextPool const &other) const { return m_Pool == other; } @@ -352,7 +355,7 @@ class OrderlessContextPool } void - Init(Device &device, const u32 queueFamilyIndex) + Init(Device &device, u32 const queueFamilyIndex) { m_Device = &device; m_QueueFamilyIndex = queueFamilyIndex; @@ -410,7 +413,7 @@ class OrderlessContextPool ReleasePool(ContextPool &pool) { auto const found = eastl::find_if(m_UsedContextPools.begin(), m_UsedContextPools.end(), - [&pool](const ContextListEntry &v) { return v.Contains(pool); }); + [&pool](ContextListEntry const &v) { return v.Contains(pool); }); auto &v = *found; ContextListType::remove(v); diff --git a/aster/include/aster/systems/device.h b/aster/include/aster/systems/device.h index 111147b..110be1b 100644 --- a/aster/include/aster/systems/device.h +++ b/aster/include/aster/systems/device.h @@ -36,7 +36,7 @@ template <> struct eastl::hash { usize - operator()(const vk::SamplerCreateInfo &createInfo) const noexcept + operator()(vk::SamplerCreateInfo const &createInfo) const noexcept { usize hash = HashAny(createInfo.flags); hash = HashCombine(hash, HashAny(createInfo.magFilter)); @@ -235,6 +235,7 @@ struct AttributeInfo { u32 m_Location; u32 m_Offset; + enum class Format { eFloat32X4, @@ -321,7 +322,7 @@ struct GraphicsPipelineCreateInfo cstr m_Name; -private: + private: friend Device; [[nodiscard]] vk::PipelineDepthStencilStateCreateInfo GetDepthStencilStateCreateInfo() const; }; @@ -338,9 +339,9 @@ struct ComputePipelineCreateInfo #pragma region Device // ---------------------------------------------------------------------------------------------------- -PhysicalDevice DefaultPhysicalDeviceSelector(const PhysicalDevices &physicalDevices); +PhysicalDevice DefaultPhysicalDeviceSelector(PhysicalDevices const &physicalDevices); -using PhysicalDeviceSelectorFn = PhysicalDevice (*)(const PhysicalDevices &); +using PhysicalDeviceSelectorFn = PhysicalDevice (*)(PhysicalDevices const &); static_assert(std::convertible_to); struct DeviceCreateInfo @@ -373,6 +374,7 @@ class Receipt : m_Opaque{opaque} { } + friend _internal::SyncServer; }; @@ -462,22 +464,22 @@ class Device final template T> [[nodiscard]] Ref - CreateTexture2D(const Texture2DCreateInfo &createInfo) + CreateTexture2D(Texture2DCreateInfo const &createInfo) { return CastImage(CreateTexture2D(createInfo)); } template T> [[nodiscard]] Ref - CreateTextureCube(const TextureCubeCreateInfo &createInfo) + CreateTextureCube(TextureCubeCreateInfo const &createInfo) { return CastImage(CreateTextureCube(createInfo)); } - [[nodiscard]] Ref CreateTexture2D(const Texture2DCreateInfo &createInfo); - [[nodiscard]] Ref CreateTextureCube(const TextureCubeCreateInfo &createInfo); - [[nodiscard]] Ref CreateAttachment(const AttachmentCreateInfo &createInfo); - [[nodiscard]] Ref CreateDepthStencilImage(const DepthStencilImageCreateInfo &createInfo); + [[nodiscard]] Ref CreateTexture2D(Texture2DCreateInfo const &createInfo); + [[nodiscard]] Ref CreateTextureCube(TextureCubeCreateInfo const &createInfo); + [[nodiscard]] Ref CreateAttachment(AttachmentCreateInfo const &createInfo); + [[nodiscard]] Ref CreateDepthStencilImage(DepthStencilImageCreateInfo const &createInfo); // // View Management @@ -485,12 +487,12 @@ class Device final template Ref - CreateView(const ViewCreateInfo &createInfo) + CreateView(ViewCreateInfo const &createInfo) { return CastView(CreateView(ViewCreateInfo(createInfo))); } - [[nodiscard]] Ref CreateView(const ViewCreateInfo &createInfo); + [[nodiscard]] Ref CreateView(ViewCreateInfo const &createInfo); // // Image - View Combined Management @@ -498,7 +500,7 @@ class Device final template T> [[nodiscard]] Ref - CreateTexture2DWithView(const Texture2DCreateInfo &createInfo) + CreateTexture2DWithView(Texture2DCreateInfo const &createInfo) { auto handle = CreateTexture2DWithView(createInfo); return CastView(handle); @@ -506,16 +508,16 @@ class Device final template T> [[nodiscard]] Ref - CreateTextureCubeWithView(const TextureCubeCreateInfo &createInfo) + CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo) { auto handle = CreateTextureCubeWithView(createInfo); return CastView(handle); } - [[nodiscard]] Ref CreateTexture2DWithView(const Texture2DCreateInfo &createInfo); - [[nodiscard]] Ref CreateTextureCubeWithView(const TextureCubeCreateInfo &createInfo); - [[nodiscard]] Ref CreateAttachmentWithView(const AttachmentCreateInfo &createInfo); - [[nodiscard]] Ref CreateDepthStencilImageWithView(const DepthStencilImageCreateInfo &createInfo); + [[nodiscard]] Ref CreateTexture2DWithView(Texture2DCreateInfo const &createInfo); + [[nodiscard]] Ref CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo); + [[nodiscard]] Ref CreateAttachmentWithView(AttachmentCreateInfo const &createInfo); + [[nodiscard]] Ref CreateDepthStencilImageWithView(DepthStencilImageCreateInfo const &createInfo); // // Sampler Management @@ -525,7 +527,7 @@ class Device final eastl::hash_map> m_HashToSamplerIdx; public: - Ref CreateSampler(const SamplerCreateInfo &createInfo); + Ref CreateSampler(SamplerCreateInfo const &createInfo); // // Pipeline @@ -538,17 +540,17 @@ class Device final PipelineCreationError CreateShaders(eastl::fixed_vector &shadersOut, - Slang::ComPtr &program, const std::span &shaders); + Slang::ComPtr &program, std::span const &shaders); systems::PipelineCreationError CreateShader(vk::PipelineShaderStageCreateInfo &shadersOut, Slang::ComPtr &program, - const ShaderInfo &shaders); + ShaderInfo const &shaders); PipelineCreationError - CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, const Slang::ComPtr &program); + CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, Slang::ComPtr const &program); public: // Pipelines, unlike the other resources, are not ref-counted. - PipelineCreationError CreatePipeline(Pipeline &pipeline, const GraphicsPipelineCreateInfo &createInfo); - PipelineCreationError CreateComputePipeline(Pipeline &pipeline, const ComputePipelineCreateInfo &createInfo); + PipelineCreationError CreatePipeline(Pipeline &pipeline, GraphicsPipelineCreateInfo const &createInfo); + PipelineCreationError CreateComputePipeline(Pipeline &pipeline, ComputePipelineCreateInfo const &createInfo); // // Frames @@ -556,6 +558,7 @@ class Device final public: Frame &GetNextFrame(); + Size2D GetSwapchainSize() const { @@ -594,13 +597,13 @@ class Device final template void - SetName(const T &object, cstr name) const + SetName(T const &object, cstr name) const { m_Device.SetName(object, name); } [[nodiscard]] vk::Queue - GetQueue(const u32 familyIndex, const u32 queueIndex) const + GetQueue(u32 const familyIndex, u32 const queueIndex) const { return m_Device.GetQueue(familyIndex, queueIndex); } @@ -634,11 +637,11 @@ class Device final // Ctor/Dtor // ---------------------------------------------------------------------------------------------------- - explicit Device(const DeviceCreateInfo &createInfo); + explicit Device(DeviceCreateInfo const &createInfo); ~Device(); PIN_MEMORY(Device); }; -} // namespace systems +} // namespace systems \ No newline at end of file diff --git a/aster/include/aster/systems/pipeline_helpers.h b/aster/include/aster/systems/pipeline_helpers.h index ff1d51b..4e8a748 100644 --- a/aster/include/aster/systems/pipeline_helpers.h +++ b/aster/include/aster/systems/pipeline_helpers.h @@ -44,11 +44,12 @@ struct PipelineLayoutBuilder [[nodiscard]] vk::PipelineLayout Build(); - [[nodiscard]] vk::DescriptorSetLayout CreateDescriptorSetLayout(const vk::DescriptorSetLayoutCreateInfo &createInfo) const; - void AddDescriptorSetForParameterBlock(slang::TypeLayoutReflection * layout); - void AddPushConstantRangeForConstantBuffer(slang::TypeLayoutReflection * layout); - void AddSubObjectRange(slang::TypeLayoutReflection * layout, i64 subObjectRangeIndex); - void AddSubObjectRanges(slang::TypeLayoutReflection * layout); + [[nodiscard]] vk::DescriptorSetLayout + CreateDescriptorSetLayout(vk::DescriptorSetLayoutCreateInfo const &createInfo) const; + void AddDescriptorSetForParameterBlock(slang::TypeLayoutReflection *layout); + void AddPushConstantRangeForConstantBuffer(slang::TypeLayoutReflection *layout); + void AddSubObjectRange(slang::TypeLayoutReflection *layout, i64 subObjectRangeIndex); + void AddSubObjectRanges(slang::TypeLayoutReflection *layout); }; struct DescriptorLayoutBuilder diff --git a/aster/include/aster/systems/resource.h b/aster/include/aster/systems/resource.h index be158ae..d59eb25 100644 --- a/aster/include/aster/systems/resource.h +++ b/aster/include/aster/systems/resource.h @@ -23,7 +23,7 @@ namespace systems template TTo, std::derived_from TFrom> static Ref -CastBuffer(const Ref &from) +CastBuffer(Ref const &from) { if constexpr (not concepts::BufferInto) assert(TTo::FLAGS & from->m_Flags); @@ -37,7 +37,7 @@ CastBuffer(const Ref &from) template TTo, std::derived_from TFrom> static Ref -CastImage(const Ref &from) +CastImage(Ref const &from) { if constexpr (not concepts::ImageInto) assert(TTo::FLAGS & from->m_Flags_); @@ -50,7 +50,7 @@ CastImage(const Ref &from) template TFrom> static Ref -CastView(const Ref> &from) +CastView(Ref> const &from) { if constexpr (not concepts::ImageInto) assert(TTo::ImageType::FLAGS & from->m_Image->m_Flags_); @@ -60,8 +60,6 @@ CastView(const Ref> &from) #pragma endregion - - /** * ResId manages the lifetime of the committed resource. * @tparam T Type of the committed resource. @@ -70,6 +68,7 @@ template class ResId { using IdType = u32; + public: constexpr static IdType INVALID = MaxValue; @@ -77,7 +76,7 @@ class ResId IdType m_Index; u32 m_Padding = 0; //< Slang DescriptorHandle are a pair of u32. TODO: Use as validation. - explicit ResId(const IdType index) + explicit ResId(IdType const index) : m_Index{index} { AddRef(); @@ -92,7 +91,7 @@ class ResId return ResId{INVALID}; } - ResId(const ResId &other) + ResId(ResId const &other) : m_Index{other.m_Index} { AddRef(); @@ -105,7 +104,7 @@ class ResId } ResId & - operator=(const ResId &other) + operator=(ResId const &other) { if (this == &other) return *this; diff --git a/aster/include/aster/util/freelist.h b/aster/include/aster/util/freelist.h index 54aed20..12d5b86 100644 --- a/aster/include/aster/util/freelist.h +++ b/aster/include/aster/util/freelist.h @@ -20,7 +20,7 @@ struct FreeList { using Value = T; using Reference = T &; - using ConstReference = const T &; + using ConstReference = T const &; using Pointer = T *; FreeListNode *m_Top; diff --git a/aster/include/aster/util/logger.h b/aster/include/aster/util/logger.h index f5f8de5..73c9a3c 100644 --- a/aster/include/aster/util/logger.h +++ b/aster/include/aster/util/logger.h @@ -29,7 +29,7 @@ struct Logger } template - constexpr static const char * + constexpr static char const * ToCstr() { if constexpr (TLogLevel == LogType::eError) @@ -45,7 +45,7 @@ struct Logger } template - constexpr static const char * + constexpr static char const * ToColorCstr() { if constexpr (TLogLevel == LogType::eError) @@ -62,7 +62,7 @@ struct Logger template void - Log(const std::string_view &message, const char *loc, u32 line) const + Log(std::string_view const &message, char const *loc, u32 line) const { if (static_cast(TLogLevel) <= m_MinimumLoggingLevel) { @@ -79,7 +79,7 @@ struct Logger template void - LogCond(const char *exprStr, const std::string_view &message, const char *loc, u32 line) const + LogCond(char const *exprStr, std::string_view const &message, char const *loc, u32 line) const { if (static_cast(TLogLevel) <= m_MinimumLoggingLevel) { @@ -103,26 +103,26 @@ extern Logger g_Logger; #define INFO(...) g_Logger.Log(fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ERROR_IF(expr, ...) \ - if (static_cast(expr)) [[unlikely]] \ + if (static_cast(expr)) [[unlikely]] \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define WARN_IF(expr, ...) \ - if (static_cast(expr)) [[unlikely]] \ + if (static_cast(expr)) [[unlikely]] \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define INFO_IF(expr, ...) \ - if (static_cast(expr)) \ + if (static_cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_ERROR(expr, ...) \ ; \ - else if (static_cast(expr)) \ + else if (static_cast(expr)) \ [[unlikely]] g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_WARN(expr, ...) \ ; \ - else if (static_cast(expr)) \ + else if (static_cast(expr)) \ [[unlikely]] g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_INFO(expr, ...) \ ; \ - else if (static_cast(expr)) \ + else if (static_cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_ERROR(...) \ @@ -139,11 +139,11 @@ extern Logger g_Logger; #define DEBUG(...) g_Logger.Log(fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define DEBUG_IF(expr, ...) \ - if (static_cast(expr)) \ + if (static_cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_DEBUG(expr, ...) \ ; \ - else if (static_cast(expr)) \ + else if (static_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 (static_cast(expr)) \ + if (static_cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_IF_VERBOSE(expr, ...) \ ; \ - else if (static_cast(expr)) \ + else if (static_cast(expr)) \ g_Logger.LogCond(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define ELSE_VERBOSE(...) \ ; \ diff --git a/aster/src/aster/core/buffer.cpp b/aster/src/aster/core/buffer.cpp index a86569f..e80446d 100644 --- a/aster/src/aster/core/buffer.cpp +++ b/aster/src/aster/core/buffer.cpp @@ -7,8 +7,8 @@ #include "core/device.h" -Buffer::Buffer(const Device *device, const usize size, const vk::BufferUsageFlags bufferUsage, - const VmaAllocationCreateFlags allocationFlags, const VmaMemoryUsage memoryUsage, const cstr name) +Buffer::Buffer(Device const *device, usize const size, vk::BufferUsageFlags const bufferUsage, + VmaAllocationCreateFlags const allocationFlags, VmaMemoryUsage const memoryUsage, cstr const name) { assert(!m_Buffer); @@ -19,7 +19,7 @@ Buffer::Buffer(const Device *device, const usize size, const vk::BufferUsageFlag .usage = bufferUsage, .sharingMode = vk::SharingMode::eExclusive, }; - const VmaAllocationCreateInfo allocationCreateInfo = { + VmaAllocationCreateInfo const allocationCreateInfo = { .flags = allocationFlags, .usage = memoryUsage, }; @@ -27,8 +27,9 @@ Buffer::Buffer(const Device *device, const usize size, const vk::BufferUsageFlag VkBuffer buffer; VmaAllocation allocation; VmaAllocationInfo allocationInfo; - auto result = static_cast(vmaCreateBuffer(device->m_Allocator, reinterpret_cast(&bufferCreateInfo), - &allocationCreateInfo, &buffer, &allocation, &allocationInfo)); + auto result = static_cast( + vmaCreateBuffer(device->m_Allocator, reinterpret_cast(&bufferCreateInfo), + &allocationCreateInfo, &buffer, &allocation, &allocationInfo)); ERROR_IF(Failed(result), "Could not allocate buffer. Cause: {}", result) THEN_ABORT(result); // vk::MemoryPropertyFlags memoryPropertyFlags; @@ -91,19 +92,19 @@ Buffer::~Buffer() } uptr -Buffer::GetDeviceAddress(const Device *device) const +Buffer::GetDeviceAddress(Device const *device) const { - const vk::BufferDeviceAddressInfo addressInfo = {.buffer = m_Buffer}; + vk::BufferDeviceAddressInfo const addressInfo = {.buffer = m_Buffer}; return device->m_Device.getBufferAddress(&addressInfo); } void -Buffer::Write(const usize offset, const usize size, const void *data) const +Buffer::Write(usize const offset, usize const size, void const *data) const { assert(IsMapped()); memcpy(m_Mapped + offset, data, size); // TODO: Debug this. - // auto result = static_cast(vmaCopyMemoryToAllocation(device->m_Allocator, &data, m_Allocation, 0, size)); - // ERROR_IF(Failed(result), "Writing to buffer failed. Cause: {}", result) THEN_ABORT(result); + // auto result = static_cast(vmaCopyMemoryToAllocation(device->m_Allocator, &data, m_Allocation, 0, + // size)); ERROR_IF(Failed(result), "Writing to buffer failed. Cause: {}", result) THEN_ABORT(result); } \ No newline at end of file diff --git a/aster/src/aster/core/device.cpp b/aster/src/aster/core/device.cpp index 558b9c8..5c8197d 100644 --- a/aster/src/aster/core/device.cpp +++ b/aster/src/aster/core/device.cpp @@ -17,8 +17,8 @@ constexpr eastl::array DEVICE_EXTENSIONS = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, }; -Device::Device(const Instance &context, PhysicalDevice &physicalDevice, Features &enabledFeatures, - const eastl::span &queueAllocations, const eastl::span &pipelineCacheData, +Device::Device(Instance const &context, PhysicalDevice &physicalDevice, Features &enabledFeatures, + eastl::span const &queueAllocations, eastl::span const &pipelineCacheData, NameString &&name) : m_Name(std::move(name)) , m_PhysicalDevice(physicalDevice.m_PhysicalDevice) @@ -74,7 +74,7 @@ Device::Device(const Instance &context, PhysicalDevice &physicalDevice, Features .vkGetDeviceProcAddr = vk::detail::defaultDispatchLoaderDynamic.vkGetDeviceProcAddr, }; - const VmaAllocatorCreateInfo allocatorCreateInfo = { + VmaAllocatorCreateInfo const allocatorCreateInfo = { .flags = VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT, .physicalDevice = m_PhysicalDevice, .device = m_Device, @@ -120,7 +120,7 @@ Device::~Device() } vk::Queue -Device::GetQueue(const u32 familyIndex, const u32 queueIndex) const +Device::GetQueue(u32 const familyIndex, u32 const queueIndex) const { vk::Queue queue; m_Device.getQueue(familyIndex, queueIndex, &queue); diff --git a/aster/src/aster/core/global.cpp b/aster/src/aster/core/global.cpp index 68e0ea3..a268f60 100644 --- a/aster/src/aster/core/global.cpp +++ b/aster/src/aster/core/global.cpp @@ -26,9 +26,9 @@ struct MemorySize { usize totalBytes = bytes + m_Bytes; m_Bytes = totalBytes % 1024; - const usize totalKb = m_Kilobytes + totalBytes / 1024; + usize const totalKb = m_Kilobytes + totalBytes / 1024; m_Kilobytes = totalKb % 1024; - const usize totalMb = m_Megabytes + totalKb / 1024; + usize const totalMb = m_Megabytes + totalKb / 1024; m_Megabytes = totalMb % 1024; m_Gigabytes += static_cast(totalMb / 1024); @@ -51,7 +51,7 @@ struct fmt::formatter template // ReSharper disable once CppInconsistentNaming constexpr auto - format(const MemorySize &mem, Context &ctx) const + format(MemorySize const &mem, Context &ctx) const { // return format_to(ctx.out(), "({}, {})", foo.a, foo.b); // --== KEY LINE ==-- if (mem.m_Gigabytes > 0) @@ -72,7 +72,7 @@ struct fmt::formatter }; void * -operator new[](size_t size, const char * /*pName*/, int flags, unsigned /*debugFlags*/, const char * /*file*/, +operator new[](size_t size, char const * /*pName*/, int flags, unsigned /*debugFlags*/, char const * /*file*/, int /*line*/) { g_TotalAlloc += size; @@ -82,8 +82,8 @@ operator new[](size_t size, const char * /*pName*/, int flags, unsigned /*debugF } void * -operator new[](size_t size, size_t /*alignment*/, size_t /*alignmentOffset*/, const char * /*pName*/, int flags, - unsigned /*debugFlags*/, const char * /*file*/, int /*line*/) +operator new[](size_t size, size_t /*alignment*/, size_t /*alignmentOffset*/, char const * /*pName*/, int flags, + unsigned /*debugFlags*/, char const * /*file*/, int /*line*/) { g_TotalAlloc += size; diff --git a/aster/src/aster/core/image.cpp b/aster/src/aster/core/image.cpp index 86d4c82..df0ec72 100644 --- a/aster/src/aster/core/image.cpp +++ b/aster/src/aster/core/image.cpp @@ -35,7 +35,7 @@ Image::~Image() } void -Image::DestroyView(const vk::ImageView imageView) const +Image::DestroyView(vk::ImageView const imageView) const { m_Device->m_Device.destroy(imageView, nullptr); } @@ -75,7 +75,8 @@ Image::DestroyView(const vk::ImageView imageView) const // // VkImage image; // VmaAllocation allocation; -// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), +// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), // &allocationCreateInfo, &image, &allocation, nullptr)); // ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result); // @@ -162,7 +163,8 @@ Image::DestroyView(const vk::ImageView imageView) const // // VkImage image; // VmaAllocation allocation; -// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), +// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), // &allocationCreateInfo, &image, &allocation, nullptr)); // ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result); // @@ -217,7 +219,8 @@ Image::DestroyView(const vk::ImageView imageView) const // // VkImage image; // VmaAllocation allocation; -// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), +// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), // &allocationCreateInfo, &image, &allocation, nullptr)); // ERROR_IF(Failed(result), "Could not allocate depth buffer. Cause: {}", result) THEN_ABORT(result); // @@ -274,7 +277,8 @@ Image::DestroyView(const vk::ImageView imageView) const // // VkImage image; // VmaAllocation allocation; -// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), +// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), // &allocationCreateInfo, &image, &allocation, nullptr)); // ERROR_IF(Failed(result), "Could not allocate depth buffer. Cause: {}", result) THEN_ABORT(result); // @@ -344,7 +348,8 @@ Image::DestroyView(const vk::ImageView imageView) const // // VkImage image; // VmaAllocation allocation; -// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), +// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), // &allocationCreateInfo, &image, &allocation, nullptr)); // ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result); // @@ -417,7 +422,8 @@ Image::DestroyView(const vk::ImageView imageView) const // // VkImage image; // VmaAllocation allocation; -// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), +// auto result = static_cast(vmaCreateImage(device->m_Allocator, reinterpret_cast(&imageCreateInfo), // &allocationCreateInfo, &image, &allocation, nullptr)); // ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result); // @@ -462,8 +468,8 @@ Image::Image(Image &&other) noexcept { } -Image::Image(const Device *device, const vk::Image image, const VmaAllocation allocation, const vk::Extent3D extent, - const vk::Format format, const Flags flags, const u8 layerCount, const u8 mipLevels) +Image::Image(Device const *device, vk::Image const image, VmaAllocation const allocation, vk::Extent3D const extent, + vk::Format const format, Flags const flags, u8 const layerCount, u8 const mipLevels) : m_Device{device} , m_Image{image} , m_Allocation{allocation} diff --git a/aster/src/aster/core/instance.cpp b/aster/src/aster/core/instance.cpp index 66ae6c4..994a771 100644 --- a/aster/src/aster/core/instance.cpp +++ b/aster/src/aster/core/instance.cpp @@ -11,9 +11,9 @@ #include VKAPI_ATTR b32 VKAPI_CALL -DebugCallback(const vk::DebugUtilsMessageSeverityFlagBitsEXT messageSeverity, - const vk::DebugUtilsMessageTypeFlagsEXT messageType, - const vk::DebugUtilsMessengerCallbackDataEXT *callbackData, [[maybe_unused]] void *userData) +DebugCallback(vk::DebugUtilsMessageSeverityFlagBitsEXT const messageSeverity, + vk::DebugUtilsMessageTypeFlagsEXT const messageType, + vk::DebugUtilsMessengerCallbackDataEXT const *callbackData, [[maybe_unused]] void *userData) { using SeverityBits = vk::DebugUtilsMessageSeverityFlagBitsEXT; using MessageTypeBits = vk::DebugUtilsMessageTypeFlagBitsEXT; @@ -33,14 +33,14 @@ DebugCallback(const vk::DebugUtilsMessageSeverityFlagBitsEXT messageSeverity, return false; } -Instance::Instance(const cstr appName, const Version version, bool enableValidation) +Instance::Instance(cstr const appName, Version const version, bool enableValidation) { INFO_IF(enableValidation, "Validation Layers enabled"); // TODO Get/Check API Version // Creating Instance - const vk::ApplicationInfo appInfo = { + vk::ApplicationInfo const appInfo = { .pApplicationName = appName, .applicationVersion = version.GetVkVersion(), .pEngineName = PROJECT_NAME, @@ -48,7 +48,7 @@ Instance::Instance(const cstr appName, const Version version, bool enableValidat .apiVersion = ASTER_API_VERSION, }; - const vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfo = { + vk::DebugUtilsMessengerCreateInfoEXT const debugUtilsMessengerCreateInfo = { .messageSeverity = vk::DebugUtilsMessageSeverityFlagBitsEXT::eError | vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo, @@ -67,12 +67,12 @@ Instance::Instance(const cstr appName, const Version version, bool enableValidat instanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); } - const vk::detail::DynamicLoader dl; + vk::detail::DynamicLoader const dl; // ReSharper disable once CppInconsistentNaming - const auto vkGetInstanceProcAddr = dl.getProcAddress("vkGetInstanceProcAddr"); + auto const vkGetInstanceProcAddr = dl.getProcAddress("vkGetInstanceProcAddr"); VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); - const auto instanceCreateInfo = vk::InstanceCreateInfo{ + auto const instanceCreateInfo = vk::InstanceCreateInfo{ .pNext = enableValidation ? &debugUtilsMessengerCreateInfo : nullptr, .pApplicationInfo = &appInfo, .enabledExtensionCount = static_cast(instanceExtensions.size()), diff --git a/aster/src/aster/core/physical_device.cpp b/aster/src/aster/core/physical_device.cpp index 03a46b3..b81da10 100644 --- a/aster/src/aster/core/physical_device.cpp +++ b/aster/src/aster/core/physical_device.cpp @@ -9,7 +9,7 @@ #include "core/surface.h" [[nodiscard]] vk::SurfaceCapabilitiesKHR -GetSurfaceCapabilities(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR surface) +GetSurfaceCapabilities(vk::PhysicalDevice const physicalDevice, vk::SurfaceKHR const surface) { vk::SurfaceCapabilitiesKHR surfaceCapabilities; @@ -21,7 +21,7 @@ GetSurfaceCapabilities(const vk::PhysicalDevice physicalDevice, const vk::Surfac } [[nodiscard]] eastl::vector -GetSurfaceFormats(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR surface) +GetSurfaceFormats(vk::PhysicalDevice const physicalDevice, vk::SurfaceKHR const surface) { // vk::Result::eIncomplete should not occur in this function. The rest are errors. Thus, abort is allowed. u32 count = 0; @@ -38,7 +38,7 @@ GetSurfaceFormats(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR } [[nodiscard]] eastl::vector -GetSurfacePresentModes(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR surface) +GetSurfacePresentModes(vk::PhysicalDevice const physicalDevice, vk::SurfaceKHR const surface) { // vk::Result::eIncomplete should not occur in this function. The rest are errors. Thus, abort is allowed. u32 count = 0; @@ -55,11 +55,11 @@ GetSurfacePresentModes(const vk::PhysicalDevice physicalDevice, const vk::Surfac } [[nodiscard]] bool -GetQueuePresentSupport(const u32 queueFamilyIndex, const vk::SurfaceKHR surface, - const vk::PhysicalDevice physicalDevice) +GetQueuePresentSupport(u32 const queueFamilyIndex, vk::SurfaceKHR const surface, + vk::PhysicalDevice const physicalDevice) { b32 supported = false; - const vk::Result result = physicalDevice.getSurfaceSupportKHR(queueFamilyIndex, surface, &supported); + vk::Result const result = physicalDevice.getSurfaceSupportKHR(queueFamilyIndex, surface, &supported); ERROR_IF(Failed(result), "Could not get queue family surface support. Cause: {}", result) THEN_ABORT(result); @@ -67,7 +67,7 @@ GetQueuePresentSupport(const u32 queueFamilyIndex, const vk::SurfaceKHR surface, } [[nodiscard]] eastl::fixed_vector -GetQueueFamilyProperties(const vk::PhysicalDevice physicalDevice) +GetQueueFamilyProperties(vk::PhysicalDevice const physicalDevice) { // Devices rarely have more than 32 queue families. Thus fixed vector u32 count = 0; @@ -81,7 +81,7 @@ GetQueueFamilyProperties(const vk::PhysicalDevice physicalDevice) // Size 384 return. [[nodiscard]] eastl::vector -GetQueueFamilies(const vk::SurfaceKHR surface, const vk::PhysicalDevice physicalDevice) +GetQueueFamilies(vk::SurfaceKHR const surface, vk::PhysicalDevice const physicalDevice) { auto queueFamilyProperties = GetQueueFamilyProperties(physicalDevice); @@ -126,7 +126,7 @@ GetQueueFamilies(const vk::SurfaceKHR surface, const vk::PhysicalDevice physical return queueFamilyInfos; } -PhysicalDevice::PhysicalDevice(const vk::SurfaceKHR surface, const vk::PhysicalDevice physicalDevice) +PhysicalDevice::PhysicalDevice(vk::SurfaceKHR const surface, vk::PhysicalDevice const physicalDevice) { physicalDevice.getProperties(&m_DeviceProperties); physicalDevice.getFeatures(&m_DeviceFeatures); @@ -139,7 +139,7 @@ PhysicalDevice::PhysicalDevice(const vk::SurfaceKHR surface, const vk::PhysicalD } eastl::fixed_vector -EnumeratePhysicalDevices(const vk::Instance instance) +EnumeratePhysicalDevices(vk::Instance const instance) { u32 count = 0; vk::Result result = instance.enumeratePhysicalDevices(&count, nullptr); @@ -154,7 +154,7 @@ EnumeratePhysicalDevices(const vk::Instance instance) return physicalDevices; } -PhysicalDevices::PhysicalDevices(const Surface &surface, const Instance &context) +PhysicalDevices::PhysicalDevices(Surface const &surface, Instance const &context) { for (auto physicalDevices = EnumeratePhysicalDevices(context.m_Instance); auto physicalDevice : physicalDevices) { diff --git a/aster/src/aster/core/pipeline.cpp b/aster/src/aster/core/pipeline.cpp index ab39e84..9bced78 100644 --- a/aster/src/aster/core/pipeline.cpp +++ b/aster/src/aster/core/pipeline.cpp @@ -7,8 +7,8 @@ #include "core/device.h" -Pipeline::Pipeline(const Device *device, const vk::PipelineLayout layout, const vk::Pipeline pipeline, - eastl::vector &&setLayouts, const Kind kind) +Pipeline::Pipeline(Device const *device, vk::PipelineLayout const layout, vk::Pipeline const pipeline, + eastl::vector &&setLayouts, Kind const kind) : m_Device{device} , m_Layout{layout} , m_Pipeline{pipeline} @@ -22,7 +22,7 @@ Pipeline::~Pipeline() if (!m_Device || !m_Pipeline) return; - for (const auto setLayout : m_SetLayouts) + for (auto const setLayout : m_SetLayouts) { m_Device->m_Device.destroy(setLayout, nullptr); } diff --git a/aster/src/aster/core/sampler.cpp b/aster/src/aster/core/sampler.cpp index 2dcc4c7..e32d6e8 100644 --- a/aster/src/aster/core/sampler.cpp +++ b/aster/src/aster/core/sampler.cpp @@ -15,10 +15,10 @@ Sampler::~Sampler() m_Device->m_Device.destroy(Take(m_Sampler), nullptr); } -Sampler::Sampler(const Device *device, const vk::SamplerCreateInfo &samplerCreateInfo, cstr name) +Sampler::Sampler(Device const *device, vk::SamplerCreateInfo const &samplerCreateInfo, cstr name) { m_Device = device; - const auto result = device->m_Device.createSampler(&samplerCreateInfo, nullptr, &m_Sampler); + auto const result = device->m_Device.createSampler(&samplerCreateInfo, nullptr, &m_Sampler); ERROR_IF(Failed(result), "Could not create a sampler {}", name ? name : "") THEN_ABORT(-1); } @@ -33,7 +33,8 @@ Sampler::operator=(Sampler &&other) noexcept return *this; } -Sampler::Sampler(Sampler &&other) noexcept: m_Device{other.m_Device} - , m_Sampler{Take(other.m_Sampler)} +Sampler::Sampler(Sampler &&other) noexcept + : m_Device{other.m_Device} + , m_Sampler{Take(other.m_Sampler)} { } \ No newline at end of file diff --git a/aster/src/aster/core/surface.cpp b/aster/src/aster/core/surface.cpp index da49170..39ba526 100644 --- a/aster/src/aster/core/surface.cpp +++ b/aster/src/aster/core/surface.cpp @@ -8,7 +8,7 @@ #include "core/instance.h" #include "core/window.h" -Surface::Surface(Instance &context, const Window &window) +Surface::Surface(Instance &context, Window const &window) : m_Context(&context) { VkSurfaceKHR surface; diff --git a/aster/src/aster/core/swapchain.cpp b/aster/src/aster/core/swapchain.cpp index 0c9d34e..4bfcfe1 100644 --- a/aster/src/aster/core/swapchain.cpp +++ b/aster/src/aster/core/swapchain.cpp @@ -11,7 +11,7 @@ [[nodiscard]] vk::Extent2D GetExtent(Size2D size, vk::SurfaceCapabilitiesKHR *surfaceCapabilities); -Swapchain::Swapchain(const Surface &surface, const Device &device, Size2D size) +Swapchain::Swapchain(Surface const &surface, Device const &device, Size2D size) : m_Device(&device) , m_Format(vk::Format::eUndefined) { @@ -50,7 +50,7 @@ Swapchain::operator=(Swapchain &&other) noexcept } void -Swapchain::Create(const Surface &surface, Size2D size) +Swapchain::Create(Surface const &surface, Size2D size) { auto surfaceCapabilities = GetSurfaceCapabilities(m_Device->m_PhysicalDevice, surface.m_Surface); m_Extent = GetExtent(size, &surfaceCapabilities); @@ -84,7 +84,7 @@ Swapchain::Create(const Surface &surface, Size2D size) } auto swapchainPresentMode = vk::PresentModeKHR::eFifo; - for (const auto presentMode : presentModes) + for (auto const presentMode : presentModes) { if (presentMode == vk::PresentModeKHR::eMailbox) { @@ -100,7 +100,7 @@ Swapchain::Create(const Surface &surface, Size2D size) // TODO: Note that different queues might need the images to be shared. - const vk::SwapchainCreateInfoKHR swapchainCreateInfo = { + vk::SwapchainCreateInfoKHR const swapchainCreateInfo = { .surface = surface.m_Surface, .minImageCount = swapchainImageCount, .imageFormat = m_Format, @@ -195,7 +195,7 @@ Swapchain::Cleanup() NameString name = "Swapchain of "; name += m_Device->m_Name; - for (const auto imageView : m_ImageViews) + for (auto const imageView : m_ImageViews) { m_Device->m_Device.destroy(imageView, nullptr); } diff --git a/aster/src/aster/core/window.cpp b/aster/src/aster/core/window.cpp index b519f78..89f7ab9 100644 --- a/aster/src/aster/core/window.cpp +++ b/aster/src/aster/core/window.cpp @@ -18,8 +18,8 @@ Window::SetupLibrary() { if (!glfwInit()) { - const char *error = nullptr; - const auto code = glfwGetError(&error); + char const *error = nullptr; + auto const code = glfwGetError(&error); ERROR("GLFW Init failed. Cause: ({}) {}", code, error) THEN_ABORT(code); } @@ -28,7 +28,7 @@ Window::SetupLibrary() } } -cstr* +cstr * Window::GetInstanceExtensions(u32 *extensionCount) { SetupLibrary(); @@ -42,13 +42,13 @@ Window::RequestExit() const noexcept } void -Window::SetWindowSize(const vk::Extent2D &extent) const noexcept +Window::SetWindowSize(vk::Extent2D const &extent) const noexcept { SetWindowSize(extent.width, extent.height); } void -Window::SetWindowSize(const u32 width, const u32 height) const noexcept +Window::SetWindowSize(u32 const width, u32 const height) const noexcept { glfwSetWindowSize(m_Window, static_cast(width), static_cast(height)); } @@ -62,7 +62,7 @@ Window::GetSize() const return {static_cast(width), static_cast(height)}; } -Window::Window(const cstr title, Size2D extent, const b8 isFullScreen) +Window::Window(cstr const title, Size2D extent, b8 const isFullScreen) { m_Name = title; @@ -83,8 +83,8 @@ Window::Window(const cstr title, Size2D extent, const b8 isFullScreen) ELSE_DEBUG("Window '{}' created with resolution '{}x{}'", m_Name, extent.m_Width, extent.m_Height); if (m_Window == nullptr) { - const char *error = nullptr; - const auto code = glfwGetError(&error); + char const *error = nullptr; + auto const code = glfwGetError(&error); ERROR("GLFW Window Creation failed. Cause: ({}) {}", code, error) THEN_ABORT(code); } diff --git a/aster/src/aster/systems/commit_manager.cpp b/aster/src/aster/systems/commit_manager.cpp index 434195e..f91c57e 100644 --- a/aster/src/aster/systems/commit_manager.cpp +++ b/aster/src/aster/systems/commit_manager.cpp @@ -14,8 +14,8 @@ using namespace systems; CommitManager *CommitManager::m_Instance = nullptr; -CommitManager::CommitManager(const Device *device, const u32 maxBuffers, const u32 maxImages, - const u32 maxStorageImages, Ref defaultSampler) +CommitManager::CommitManager(Device const *device, u32 const maxBuffers, u32 const maxImages, + u32 const maxStorageImages, Ref defaultSampler) : m_Device{device} , m_Buffers{maxBuffers} , m_Images{maxImages} @@ -39,7 +39,7 @@ CommitManager::CommitManager(const Device *device, const u32 maxBuffers, const u }, }; - const vk::DescriptorPoolCreateInfo poolCreateInfo = { + vk::DescriptorPoolCreateInfo const poolCreateInfo = { .flags = vk::DescriptorPoolCreateFlagBits::eUpdateAfterBind, .maxSets = 1, .poolSizeCount = static_cast(poolSizes.size()), @@ -80,7 +80,7 @@ CommitManager::CommitManager(const Device *device, const u32 maxBuffers, const u }; static_assert(layoutBindingFlags.size() == descriptorLayoutBindings.size()); - const vk::DescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = { + vk::DescriptorSetLayoutCreateInfo const descriptorSetLayoutCreateInfo = { .pNext = &bindingFlagsCreateInfo, .flags = vk::DescriptorSetLayoutCreateFlagBits::eUpdateAfterBindPool, .bindingCount = static_cast(descriptorLayoutBindings.size()), @@ -91,7 +91,7 @@ CommitManager::CommitManager(const Device *device, const u32 maxBuffers, const u // One descriptor is enough. Updating it at any time is safe. (Update until submit, data held when pending) // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_descriptor_indexing.html // https://github.com/KhronosGroup/Vulkan-Guide/blob/main/chapters/extensions/VK_EXT_descriptor_indexing.adoc - const vk::DescriptorSetAllocateInfo descriptorSetAllocateInfo = { + vk::DescriptorSetAllocateInfo const descriptorSetAllocateInfo = { .descriptorPool = m_DescriptorPool, .descriptorSetCount = 1, .pSetLayouts = &m_SetLayout, @@ -112,12 +112,12 @@ CommitManager::~CommitManager() #if !defined(ASTER_NDEBUG) u32 bufferCount = 0; - for (const auto &entry : m_Buffers.m_Data) + for (auto const &entry : m_Buffers.m_Data) { bufferCount += entry.m_CommitCount; } u32 imageCount = 0; - for (const auto &entry : m_Images.m_Data) + for (auto const &entry : m_Images.m_Data) { imageCount += entry.m_CommitCount; } @@ -129,7 +129,7 @@ CommitManager::~CommitManager() } ResId -CommitManager::CommitBuffer(const Ref &buffer) +CommitManager::CommitBuffer(Ref const &buffer) { auto [commit, isNew] = m_Buffers.Create(buffer); @@ -154,7 +154,7 @@ CommitManager::CommitBuffer(const Ref &buffer) } ResId -CommitManager::CommitStorageImage(const Ref &image) +CommitManager::CommitStorageImage(Ref const &image) { auto [commit, isNew] = m_StorageImages.Create(image); if (!isNew) @@ -178,13 +178,13 @@ CommitManager::CommitStorageImage(const Ref &image) } ResId -CommitManager::CommitTexture(const Ref &handle) +CommitManager::CommitTexture(Ref const &handle) { return CommitTexture(handle, m_DefaultSampler); } ResId -CommitManager::CommitTexture(const Ref &image, const Ref &sampler) +CommitManager::CommitTexture(Ref const &image, Ref const &sampler) { auto [commit, isNew] = m_Images.Create(image); if (!isNew) @@ -207,17 +207,17 @@ CommitManager::CommitTexture(const Ref &image, const Ref & return commit; } -CommitManager::WriteInfo::WriteInfo(const vk::DescriptorBufferInfo &info) +CommitManager::WriteInfo::WriteInfo(vk::DescriptorBufferInfo const &info) : uBufferInfo{info} { } -CommitManager::WriteInfo::WriteInfo(const vk::DescriptorImageInfo &info) +CommitManager::WriteInfo::WriteInfo(vk::DescriptorImageInfo const &info) : uImageInfo{info} { } -CommitManager::WriteInfo::WriteInfo(const vk::BufferView &info) +CommitManager::WriteInfo::WriteInfo(vk::BufferView const &info) : uBufferView{info} { } diff --git a/aster/src/aster/systems/context.cpp b/aster/src/aster/systems/context.cpp index b4c9a09..6c09800 100644 --- a/aster/src/aster/systems/context.cpp +++ b/aster/src/aster/systems/context.cpp @@ -9,7 +9,7 @@ #include "systems/device.h" constexpr static u32 -GetFormatSize(const vk::Format format) +GetFormatSize(vk::Format const format) { switch (format) { @@ -129,28 +129,28 @@ GetFormatSize(const vk::Format format) } void -systems::Context::KeepAlive(const Ref &buffer) +systems::Context::KeepAlive(Ref const &buffer) { assert(m_Pool); m_Pool->KeepAlive(buffer); } void -systems::Context::KeepAlive(const Ref &image) +systems::Context::KeepAlive(Ref const &image) { assert(m_Pool); m_Pool->KeepAlive(image); } void -systems::Context::KeepAlive(const Ref &view) +systems::Context::KeepAlive(Ref const &view) { assert(m_Pool); m_Pool->KeepAlive(view); } void -systems::Context::Dependency(const vk::DependencyInfo &dependencyInfo) +systems::Context::Dependency(vk::DependencyInfo const &dependencyInfo) { m_Cmd.pipelineBarrier2(&dependencyInfo); } @@ -169,9 +169,9 @@ systems::Context::Begin() // Release versions inline 'no-op'. #if !defined(ASTER_NDEBUG) void -systems::Context::BeginDebugRegion(const cstr name, const vec4 color) +systems::Context::BeginDebugRegion(cstr const name, vec4 const color) { - const vk::DebugUtilsLabelEXT label = { + vk::DebugUtilsLabelEXT const label = { .pLabelName = name, .color = std::array{color.r, color.g, color.b, color.a}, }; @@ -193,7 +193,7 @@ systems::Context::End() } void -systems::ComputeContext::Dispatch(const Pipeline &pipeline, u32 x, u32 y, u32 z, usize size, void *data) +systems::ComputeContext::Dispatch(Pipeline const &pipeline, u32 x, u32 y, u32 z, usize size, void *data) { BindPipeline(pipeline); PushConstantBlock(0, size, data); @@ -202,9 +202,9 @@ systems::ComputeContext::Dispatch(const Pipeline &pipeline, u32 x, u32 y, u32 z, } void -systems::ComputeContext::BindPipeline(const Pipeline &pipeline) +systems::ComputeContext::BindPipeline(Pipeline const &pipeline) { - vk::PipelineBindPoint bindPoint = vk::PipelineBindPoint::eGraphics; + auto bindPoint = vk::PipelineBindPoint::eGraphics; switch (pipeline.m_Kind) { case Pipeline::Kind::eGraphics: @@ -229,26 +229,26 @@ systems::ComputeContext::BindPipeline(const Pipeline &pipeline) } void -systems::GraphicsContext::SetViewport(const vk::Viewport &viewport) +systems::GraphicsContext::SetViewport(vk::Viewport const &viewport) { m_Cmd.setViewport(0, 1, &viewport); } void -systems::GraphicsContext::BindVertexBuffer(const Ref &vertexBuffer) +systems::GraphicsContext::BindVertexBuffer(Ref const &vertexBuffer) { constexpr vk::DeviceSize offset = 0; m_Cmd.bindVertexBuffers(0, 1, &vertexBuffer->m_Buffer, &offset); } void -systems::GraphicsContext::BindIndexBuffer(const Ref &indexBuffer) +systems::GraphicsContext::BindIndexBuffer(Ref const &indexBuffer) { m_Cmd.bindIndexBuffer(indexBuffer->m_Buffer, 0, vk::IndexType::eUint32); } void -systems::GraphicsContext::Draw(const usize vertexCount) +systems::GraphicsContext::Draw(usize const vertexCount) { m_Cmd.draw(static_cast(vertexCount), 1, 0, 0); } @@ -260,13 +260,13 @@ systems::GraphicsContext::DrawIndexed(usize indexCount) } void -systems::GraphicsContext::DrawIndexed(const usize indexCount, const usize firstIndex, const usize firstVertex) +systems::GraphicsContext::DrawIndexed(usize const indexCount, usize const firstIndex, usize const firstVertex) { m_Cmd.drawIndexed(static_cast(indexCount), 1, static_cast(firstIndex), static_cast(firstVertex), 0); } void -systems::GraphicsContext::BeginRendering(const vk::RenderingInfo &renderingInfo) +systems::GraphicsContext::BeginRendering(vk::RenderingInfo const &renderingInfo) { m_Cmd.beginRendering(&renderingInfo); m_Cmd.setScissor(0, 1, &renderingInfo.renderArea); @@ -279,7 +279,7 @@ systems::GraphicsContext::EndRendering() } void -systems::TransferContext::UploadTexture(const Ref &image, const eastl::span &data) +systems::TransferContext::UploadTexture(Ref const &image, eastl::span const &data) { ERROR_IF(not(image and image->IsValid()), "Invalid image"); @@ -289,10 +289,10 @@ systems::TransferContext::UploadTexture(const Ref &image, const eastl::sp ERROR_IF(expectedByteSize != data.size_bytes(), "Mismatch in data size {} vs image size {} ({}x{}x{}x{})", data.size_bytes(), expectedByteSize, w, h, d, formatSize); - const Ref stagingBuffer = m_Pool->GetDevice().CreateStagingBuffer(data.size_bytes()); + Ref const stagingBuffer = m_Pool->GetDevice().CreateStagingBuffer(data.size_bytes()); stagingBuffer->Write(0, data.size_bytes(), data.data()); - const vk::BufferImageCopy bufferImageCopy = { + vk::BufferImageCopy const bufferImageCopy = { .bufferOffset = 0, .bufferRowLength = w, .bufferImageHeight = h, @@ -314,17 +314,17 @@ systems::TransferContext::UploadTexture(const Ref &image, const eastl::sp } void -systems::TransferContext::UploadBuffer(const Ref &buffer, usize size, const void *data) +systems::TransferContext::UploadBuffer(Ref const &buffer, usize size, void const *data) { ERROR_IF(not(buffer and buffer->IsValid()), "Invalid buffer"); auto expectedByteSize = buffer->m_Size; ERROR_IF(expectedByteSize != size, "Mismatch in data size {} vs buffer size {}", size, expectedByteSize); - const Ref stagingBuffer = m_Pool->GetDevice().CreateStagingBuffer(size); + Ref const stagingBuffer = m_Pool->GetDevice().CreateStagingBuffer(size); stagingBuffer->Write(0, size, data); - const vk::BufferCopy bufferCopy = {.srcOffset = 0, .dstOffset = 0, .size = expectedByteSize}; + vk::BufferCopy const bufferCopy = {.srcOffset = 0, .dstOffset = 0, .size = expectedByteSize}; m_Cmd.copyBuffer(stagingBuffer->m_Buffer, buffer->m_Buffer, 1, &bufferCopy); @@ -333,7 +333,7 @@ systems::TransferContext::UploadBuffer(const Ref &buffer, usize size, co } void -systems::TransferContext::Blit(const vk::BlitImageInfo2 &mipBlitInfo) +systems::TransferContext::Blit(vk::BlitImageInfo2 const &mipBlitInfo) { m_Cmd.blitImage2(&mipBlitInfo); } @@ -353,7 +353,7 @@ systems::TransferContext::operator=(TransferContext &&other) noexcept } void -systems::ComputeContext::PushConstantBlock(const usize offset, const usize size, const void *data) +systems::ComputeContext::PushConstantBlock(usize const offset, usize const size, void const *data) { assert(m_PipelineInUse); @@ -368,20 +368,19 @@ systems::ComputeContext::PushConstantBlock(const usize offset, const usize size, break; } - m_Cmd.pushConstants(m_PipelineInUse->m_Layout, stage, static_cast(offset), - static_cast(size), data); + m_Cmd.pushConstants(m_PipelineInUse->m_Layout, stage, static_cast(offset), static_cast(size), data); } using namespace systems::_internal; -ContextPool::ContextPool(Device &device, const u32 queueFamilyIndex, const ManagedBy managedBy) +ContextPool::ContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) : m_Device{&device} , m_BuffersAllocated{0} , m_ExtraData{0} , m_ManagedBy{managedBy} , m_ResetCallback{} { - const vk::CommandPoolCreateInfo commandPoolCreateInfo = { + vk::CommandPoolCreateInfo const commandPoolCreateInfo = { .flags = vk::CommandPoolCreateFlagBits::eTransient, .queueFamilyIndex = queueFamilyIndex, }; @@ -430,19 +429,19 @@ ContextPool::~ContextPool() } void -ContextPool::KeepAlive(const Ref &buffer) +ContextPool::KeepAlive(Ref const &buffer) { m_OwnedBuffers.push_back(buffer); } void -ContextPool::KeepAlive(const Ref &image) +ContextPool::KeepAlive(Ref const &image) { m_OwnedImages.push_back(image); } void -ContextPool::KeepAlive(const Ref &view) +ContextPool::KeepAlive(Ref const &view) { m_OwnedImageViews.push_back(view); } @@ -457,7 +456,7 @@ ContextPool::AllocateCommandBuffer() } // Allocate New Buffer. - const vk::CommandBufferAllocateInfo allocateInfo = { + vk::CommandBufferAllocateInfo const allocateInfo = { .commandPool = m_Pool, .level = vk::CommandBufferLevel::ePrimary, .commandBufferCount = 1, diff --git a/aster/src/aster/systems/device.cpp b/aster/src/aster/systems/device.cpp index 6c43b3a..7752901 100644 --- a/aster/src/aster/systems/device.cpp +++ b/aster/src/aster/systems/device.cpp @@ -77,20 +77,20 @@ systems::GraphicsPipelineCreateInfo::GetDepthStencilStateCreateInfo() const } PhysicalDevice -systems::DefaultPhysicalDeviceSelector(const PhysicalDevices &physicalDevices) +systems::DefaultPhysicalDeviceSelector(PhysicalDevices const &physicalDevices) { for (auto &physicalDevice : physicalDevices) { - const bool hasAllRequiredQueues = - std::ranges::any_of(physicalDevice.m_QueueFamilies, [](const auto &queueFamilyProp) { + bool const hasAllRequiredQueues = + std::ranges::any_of(physicalDevice.m_QueueFamilies, [](auto const &queueFamilyProp) { return (queueFamilyProp.m_Support & REQUIRED_QUEUE_SUPPORT) == REQUIRED_QUEUE_SUPPORT; }); - const bool isNotCpu = physicalDevice.m_DeviceProperties.deviceType != vk::PhysicalDeviceType::eCpu; + bool const isNotCpu = physicalDevice.m_DeviceProperties.deviceType != vk::PhysicalDeviceType::eCpu; - const bool hasPresentMode = !physicalDevice.m_PresentModes.empty(); + bool const hasPresentMode = !physicalDevice.m_PresentModes.empty(); - const bool hasSurfaceFormat = !physicalDevice.m_SurfaceFormats.empty(); + bool const hasSurfaceFormat = !physicalDevice.m_SurfaceFormats.empty(); if (hasSurfaceFormat && hasPresentMode && isNotCpu && hasAllRequiredQueues) { @@ -107,7 +107,7 @@ systems::DefaultPhysicalDeviceSelector(const PhysicalDevices &physicalDevices) // ==================================================================================================== Ref -systems::Device::CreateStorageBuffer(const usize size, const cstr name) +systems::Device::CreateStorageBuffer(usize const size, cstr const name) { // TODO: Storage and Index buffer are set. // This is hacky and should be improved. @@ -137,7 +137,7 @@ systems::Device::CreateIndexBuffer(usize size, cstr name) } Ref -systems::Device::CreateUniformBuffer(const usize size, const cstr name) +systems::Device::CreateUniformBuffer(usize const size, cstr const name) { constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eUniformBuffer; constexpr VmaAllocationCreateFlags createFlags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | @@ -148,7 +148,7 @@ systems::Device::CreateUniformBuffer(const usize size, const cstr name) } Ref -systems::Device::CreateStagingBuffer(const usize size, const cstr name) +systems::Device::CreateStagingBuffer(usize const size, cstr const name) { constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eTransferSrc; constexpr VmaAllocationCreateFlags createFlags = @@ -158,7 +158,7 @@ systems::Device::CreateStagingBuffer(const usize size, const cstr name) } Ref -systems::Device::CreateVertexBuffer(const usize size, const cstr name) +systems::Device::CreateVertexBuffer(usize const size, cstr const name) { constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eVertexBuffer; constexpr VmaAllocationCreateFlags createFlags = @@ -172,10 +172,10 @@ systems::Device::CreateVertexBuffer(const usize size, const cstr name) #pragma region Image Management // ==================================================================================================== -vk::ImageCreateInfo ToImageCreateInfo(const systems::Texture2DCreateInfo &createInfo); -vk::ImageCreateInfo ToImageCreateInfo(const systems::TextureCubeCreateInfo &createInfo); -vk::ImageCreateInfo ToImageCreateInfo(const systems::AttachmentCreateInfo &createInfo); -vk::ImageCreateInfo ToImageCreateInfo(const systems::DepthStencilImageCreateInfo &createInfo); +vk::ImageCreateInfo ToImageCreateInfo(systems::Texture2DCreateInfo const &createInfo); +vk::ImageCreateInfo ToImageCreateInfo(systems::TextureCubeCreateInfo const &createInfo); +vk::ImageCreateInfo ToImageCreateInfo(systems::AttachmentCreateInfo const &createInfo); +vk::ImageCreateInfo ToImageCreateInfo(systems::DepthStencilImageCreateInfo const &createInfo); namespace usage_flags { @@ -189,7 +189,7 @@ constexpr vk::ImageUsageFlags DEPTH_STENCIL_ATTACHMENT = vk::ImageUsageFlagBits: } // namespace usage_flags Ref -systems::Device::CreateTexture2D(const Texture2DCreateInfo &createInfo) +systems::Device::CreateTexture2D(Texture2DCreateInfo const &createInfo) { constexpr VmaAllocationCreateInfo allocationCreateInfo = { .flags = {}, @@ -221,7 +221,7 @@ systems::Device::CreateTexture2D(const Texture2DCreateInfo &createInfo) } Ref -systems::Device::CreateTextureCube(const TextureCubeCreateInfo &createInfo) +systems::Device::CreateTextureCube(TextureCubeCreateInfo const &createInfo) { constexpr VmaAllocationCreateInfo allocationCreateInfo = { .flags = {}, @@ -253,7 +253,7 @@ systems::Device::CreateTextureCube(const TextureCubeCreateInfo &createInfo) } Ref -systems::Device::CreateAttachment(const AttachmentCreateInfo &createInfo) +systems::Device::CreateAttachment(AttachmentCreateInfo const &createInfo) { constexpr VmaAllocationCreateInfo allocationCreateInfo = { .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, @@ -280,7 +280,7 @@ systems::Device::CreateAttachment(const AttachmentCreateInfo &createInfo) } Ref -systems::Device::CreateDepthStencilImage(const DepthStencilImageCreateInfo &createInfo) +systems::Device::CreateDepthStencilImage(DepthStencilImageCreateInfo const &createInfo) { constexpr VmaAllocationCreateInfo allocationCreateInfo = { .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, @@ -307,14 +307,14 @@ systems::Device::CreateDepthStencilImage(const DepthStencilImageCreateInfo &crea } vk::ImageCreateInfo -ToImageCreateInfo(const systems::Texture2DCreateInfo &createInfo) +ToImageCreateInfo(systems::Texture2DCreateInfo const &createInfo) { auto &[format, extent, name, isSampled, isMipMapped, isStorage] = createInfo; WARN_IF(!IsPowerOfTwo(extent.width) || !IsPowerOfTwo(extent.width), "Image {2} is {0}x{1} (Non Power of Two)", extent.width, extent.height, name ? name : ""); - const u8 mipLevels = isMipMapped ? 1 + static_cast(floor(log2(eastl::max(extent.width, extent.height)))) : 1; + u8 const mipLevels = isMipMapped ? 1 + static_cast(floor(log2(eastl::max(extent.width, extent.height)))) : 1; auto usage = vk::ImageUsageFlags{}; if (isSampled) @@ -335,13 +335,13 @@ ToImageCreateInfo(const systems::Texture2DCreateInfo &createInfo) } vk::ImageCreateInfo -ToImageCreateInfo(const systems::TextureCubeCreateInfo &createInfo) +ToImageCreateInfo(systems::TextureCubeCreateInfo const &createInfo) { auto &[format, side, name, isSampled, isMipMapped, isStorage] = createInfo; WARN_IF(!IsPowerOfTwo(side), "ImageCube {1} is {0}x{0} (Non Power of Two)", side, name ? name : ""); - const u8 mipLevels = isMipMapped ? 1 + static_cast(floor(log2(side))) : 1; + u8 const mipLevels = isMipMapped ? 1 + static_cast(floor(log2(side))) : 1; auto usage = vk::ImageUsageFlags{}; if (isSampled) @@ -363,7 +363,7 @@ ToImageCreateInfo(const systems::TextureCubeCreateInfo &createInfo) } vk::ImageCreateInfo -ToImageCreateInfo(const systems::AttachmentCreateInfo &createInfo) +ToImageCreateInfo(systems::AttachmentCreateInfo const &createInfo) { auto &[format, extent, name] = createInfo; @@ -380,7 +380,7 @@ ToImageCreateInfo(const systems::AttachmentCreateInfo &createInfo) } vk::ImageCreateInfo -ToImageCreateInfo(const systems::DepthStencilImageCreateInfo &createInfo) +ToImageCreateInfo(systems::DepthStencilImageCreateInfo const &createInfo) { auto &[extent, name] = createInfo; @@ -404,17 +404,17 @@ ToImageCreateInfo(const systems::DepthStencilImageCreateInfo &createInfo) // ==================================================================================================== Ref -systems::Device::CreateView(const ViewCreateInfo &createInfo) +systems::Device::CreateView(ViewCreateInfo const &createInfo) { - const auto layerCount = createInfo.GetLayerCount(); - const auto mipCount = createInfo.GetMipLevelCount(); + auto const layerCount = createInfo.GetLayerCount(); + auto const mipCount = createInfo.GetMipLevelCount(); ERROR_IF((createInfo.m_BaseLayer + layerCount) > createInfo.m_Image->m_LayerCount, "Invalid Layer Access") THEN_ABORT(-1); ERROR_IF((createInfo.m_BaseMipLevel + mipCount) > createInfo.m_Image->m_MipLevels, "Invalid Mip Level Access") THEN_ABORT(-1); vk::ImageView view; - const auto imageViewCreateInfo = static_cast(createInfo); + auto const imageViewCreateInfo = static_cast(createInfo); auto result = m_Device->createImageView(&imageViewCreateInfo, nullptr, &view); ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", createInfo.m_Name, result) THEN_ABORT(result); @@ -432,7 +432,7 @@ systems::Device::CreateView(const ViewCreateInfo &createInfo) // ==================================================================================================== Ref -systems::Device::CreateTexture2DWithView(const Texture2DCreateInfo &createInfo) +systems::Device::CreateTexture2DWithView(Texture2DCreateInfo const &createInfo) { return CreateView({ .m_Image = CastImage(CreateTexture2D(createInfo)), @@ -443,7 +443,7 @@ systems::Device::CreateTexture2DWithView(const Texture2DCreateInfo &createInfo) } Ref -systems::Device::CreateTextureCubeWithView(const TextureCubeCreateInfo &createInfo) +systems::Device::CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo) { return CreateView({ .m_Image = CreateTextureCube(createInfo), @@ -454,7 +454,7 @@ systems::Device::CreateTextureCubeWithView(const TextureCubeCreateInfo &createIn } Ref -systems::Device::CreateAttachmentWithView(const AttachmentCreateInfo &createInfo) +systems::Device::CreateAttachmentWithView(AttachmentCreateInfo const &createInfo) { return CreateView({ .m_Image = CreateAttachment(createInfo), @@ -465,7 +465,7 @@ systems::Device::CreateAttachmentWithView(const AttachmentCreateInfo &createInfo } Ref -systems::Device::CreateDepthStencilImageWithView(const DepthStencilImageCreateInfo &createInfo) +systems::Device::CreateDepthStencilImageWithView(DepthStencilImageCreateInfo const &createInfo) { return CreateView({ .m_Image = CreateDepthStencilImage(createInfo), @@ -482,11 +482,11 @@ systems::Device::CreateDepthStencilImageWithView(const DepthStencilImageCreateIn // ==================================================================================================== Ref -systems::Device::CreateSampler(const SamplerCreateInfo &createInfo) +systems::Device::CreateSampler(SamplerCreateInfo const &createInfo) { auto vkCreateInfo = static_cast(createInfo); - if (const auto iter = m_HashToSamplerIdx.find(vkCreateInfo); + if (auto const iter = m_HashToSamplerIdx.find(vkCreateInfo); iter != m_HashToSamplerIdx.end() && !iter->second.expired()) { return iter->second.lock(); @@ -502,7 +502,7 @@ systems::Device::CreateSampler(const SamplerCreateInfo &createInfo) // ---------------------------------------------------------------------------------------------------- systems::PipelineCreationError -systems::Device::CreatePipeline(Pipeline &pipelineOut, const GraphicsPipelineCreateInfo &createInfo) +systems::Device::CreatePipeline(Pipeline &pipelineOut, GraphicsPipelineCreateInfo const &createInfo) { eastl::fixed_vector shaders; Slang::ComPtr program; @@ -641,7 +641,7 @@ systems::Device::CreatePipeline(Pipeline &pipelineOut, const GraphicsPipelineCre } systems::PipelineCreationError -systems::Device::CreateComputePipeline(Pipeline &pipelineOut, const ComputePipelineCreateInfo &createInfo) +systems::Device::CreateComputePipeline(Pipeline &pipelineOut, ComputePipelineCreateInfo const &createInfo) { eastl::fixed_vector shaders; Slang::ComPtr program; @@ -701,7 +701,7 @@ systems::Device::CreateComputePipeline(Pipeline &pipelineOut, const ComputePipel systems::PipelineCreationError systems::Device::CreateShaders( eastl::fixed_vector &shadersOut, - Slang::ComPtr &program, const std::span &shaders) + Slang::ComPtr &program, std::span const &shaders) { using Slang::ComPtr; @@ -718,7 +718,7 @@ systems::Device::CreateShaders( u32 entryPointCount = 0; - for (const auto &shaderInfo : shaders) + for (auto const &shaderInfo : shaders) { ComPtr shaderModule; shaderModule = m_SlangSession->loadModule(shaderInfo.m_ShaderFile.data(), shaderDiagnostics.writeRef()); @@ -817,7 +817,7 @@ systems::Device::CreateShaders( } WARN_IF(shaderDiagnostics, "{}", static_cast(shaderDiagnostics->getBufferPointer())); - vk::Result result = vk::Result::eSuccess; + auto result = vk::Result::eSuccess; for (u32 entryPoint = 0; entryPoint < entryPointCount; ++entryPoint) { auto &outShader = shadersOut.push_back(); @@ -840,9 +840,9 @@ systems::Device::CreateShaders( } } - const vk::ShaderModuleCreateInfo shaderModuleCreateInfo = { + vk::ShaderModuleCreateInfo const shaderModuleCreateInfo = { .codeSize = kernelCode->getBufferSize(), - .pCode = static_cast(kernelCode->getBufferPointer()), + .pCode = static_cast(kernelCode->getBufferPointer()), }; result = m_Device->createShaderModule(&shaderModuleCreateInfo, nullptr, &outShader.module); @@ -887,14 +887,14 @@ systems::PipelineCreationError PipelineLayoutBuilder::Build(vk::PipelineLayout &pipelineLayout, eastl::vector &descriptorSetLayouts) { - const vk::PipelineLayoutCreateInfo layoutCreateInfo = { + vk::PipelineLayoutCreateInfo const layoutCreateInfo = { .setLayoutCount = static_cast(m_DescriptorSetLayouts.size()), .pSetLayouts = m_DescriptorSetLayouts.data(), .pushConstantRangeCount = static_cast(m_PushConstantRanges.size()), .pPushConstantRanges = m_PushConstantRanges.data(), }; - const auto result = m_Device->m_Device->createPipelineLayout(&layoutCreateInfo, nullptr, &pipelineLayout); - for (const auto &descSet : descriptorSetLayouts) + auto const result = m_Device->m_Device->createPipelineLayout(&layoutCreateInfo, nullptr, &pipelineLayout); + for (auto const &descSet : descriptorSetLayouts) { m_Device->m_Device->destroy(descSet, nullptr); } @@ -903,7 +903,7 @@ PipelineLayoutBuilder::Build(vk::PipelineLayout &pipelineLayout, systems::PipelineCreationError systems::Device::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, - const Slang::ComPtr &program) + Slang::ComPtr const &program) { using Slang::ComPtr; @@ -936,7 +936,7 @@ systems::Device::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, #pragma endregion QueueAllocation -FindAppropriateQueueAllocation(const PhysicalDevice &physicalDevice) +FindAppropriateQueueAllocation(PhysicalDevice const &physicalDevice) { for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies) { @@ -953,7 +953,7 @@ FindAppropriateQueueAllocation(const PhysicalDevice &physicalDevice) } std::optional -FindAsyncTransferQueue(const PhysicalDevice &physicalDevice, u32 primaryQueueFamilyIndex) +FindAsyncTransferQueue(PhysicalDevice const &physicalDevice, u32 primaryQueueFamilyIndex) { for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies) { @@ -973,7 +973,7 @@ FindAsyncTransferQueue(const PhysicalDevice &physicalDevice, u32 primaryQueueFam } std::optional -FindAsyncComputeQueue(const PhysicalDevice &physicalDevice, u32 primaryQueueFamilyIndex) +FindAsyncComputeQueue(PhysicalDevice const &physicalDevice, u32 primaryQueueFamilyIndex) { for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies) { @@ -993,7 +993,7 @@ FindAsyncComputeQueue(const PhysicalDevice &physicalDevice, u32 primaryQueueFami return std::nullopt; } -systems::Device::Device(const DeviceCreateInfo &createInfo) +systems::Device::Device(DeviceCreateInfo const &createInfo) : m_Window{createInfo.m_Window} , m_SyncServer{new _internal::SyncServer{*this}} { @@ -1003,7 +1003,7 @@ systems::Device::Device(const DeviceCreateInfo &createInfo) m_Instance = Instance{createInfo.m_AppName, createInfo.m_AppVersion}; m_Surface = Surface{m_Instance, createInfo.m_Window}; - const auto physicalDevices = PhysicalDevices{m_Surface, m_Instance}; + auto const physicalDevices = PhysicalDevices{m_Surface, m_Instance}; auto physicalDevice = createInfo.m_PhysicalDeviceSelector(physicalDevices); Features features = createInfo.m_Features; @@ -1017,9 +1017,9 @@ systems::Device::Device(const DeviceCreateInfo &createInfo) m_PrimaryQueueFamily = primaryQueue.m_Family; u32 transferQueueIndex; - if (const auto asyncTransfer = FindAsyncTransferQueue(physicalDevice, m_PrimaryQueueFamily)) + if (auto const asyncTransfer = FindAsyncTransferQueue(physicalDevice, m_PrimaryQueueFamily)) { - const QueueAllocation allocation = asyncTransfer.value(); + QueueAllocation const allocation = asyncTransfer.value(); queueAllocations.push_back(allocation); m_TransferQueueFamily = allocation.m_Family; transferQueueIndex = 0; @@ -1032,9 +1032,9 @@ systems::Device::Device(const DeviceCreateInfo &createInfo) } u32 computeQueueIndex; - if (const auto asyncCompute = FindAsyncComputeQueue(physicalDevice, m_PrimaryQueueFamily)) + if (auto const asyncCompute = FindAsyncComputeQueue(physicalDevice, m_PrimaryQueueFamily)) { - const QueueAllocation allocation = asyncCompute.value(); + QueueAllocation const allocation = asyncCompute.value(); queueAllocations.push_back(allocation); m_ComputeQueueFamily = allocation.m_Family; computeQueueIndex = 0; @@ -1082,13 +1082,13 @@ systems::Device::Device(const DeviceCreateInfo &createInfo) eastl::array compilerOptions = {useOriginalEntrypointNames, bindlessSpaceIndex, scalarLayout}; slang::PreprocessorMacroDesc fancyFlag = {"_DEBUG", "1"}; - const slang::TargetDesc spirvTargetDesc = { + slang::TargetDesc const spirvTargetDesc = { .format = SLANG_SPIRV, .profile = m_GlobalSlangSession->findProfile("sm_6_6"), .compilerOptionEntries = compilerOptions.data(), .compilerOptionEntryCount = static_cast(compilerOptions.size()), }; - const slang::SessionDesc sessionDesc = { + slang::SessionDesc const sessionDesc = { .targets = &spirvTargetDesc, .targetCount = 1, .searchPaths = createInfo.m_ShaderSearchPaths.data(), @@ -1170,7 +1170,7 @@ void systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext) { vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eColorAttachmentOutput; - const vk::SubmitInfo submitInfo = { + vk::SubmitInfo const submitInfo = { .waitSemaphoreCount = 1, .pWaitSemaphores = &frame.m_ImageAcquireSem, .pWaitDstStageMask = &waitDstStage, @@ -1183,7 +1183,7 @@ systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext) ERROR_IF(Failed(result), "Command queue submit failed. Cause: {}", result) THEN_ABORT(result); - const vk::PresentInfoKHR presentInfo = { + vk::PresentInfoKHR const presentInfo = { .waitSemaphoreCount = 1, .pWaitSemaphores = &frame.m_RenderFinishSem, .swapchainCount = 1, @@ -1220,7 +1220,7 @@ systems::Device::CreateComputeContext() systems::Receipt systems::Device::Submit(Context &context) { - const auto rect = m_SyncServer->Allocate(); + auto const rect = m_SyncServer->Allocate(); auto &entry = m_SyncServer->GetEntry(rect); if (context.m_Pool->m_ManagedBy == _internal::ContextPool::ManagedBy::eDevice) @@ -1236,7 +1236,7 @@ systems::Device::Submit(Context &context) // TODO: Separate per context vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eAllCommands; - const vk::SubmitInfo submitInfo = { + vk::SubmitInfo const submitInfo = { .pNext = &timelineSubmit, .waitSemaphoreCount = 1, .pWaitSemaphores = &entry.m_Semaphore, diff --git a/aster/src/aster/systems/pipeline_helpers.cpp b/aster/src/aster/systems/pipeline_helpers.cpp index db6fdcb..a648d60 100644 --- a/aster/src/aster/systems/pipeline_helpers.cpp +++ b/aster/src/aster/systems/pipeline_helpers.cpp @@ -80,7 +80,7 @@ systems::PipelineCreationError::What() } vk::ShaderStageFlagBits -systems::SlangToVulkanShaderStage(const SlangStage stage) +systems::SlangToVulkanShaderStage(SlangStage const stage) { switch (stage) { @@ -142,7 +142,7 @@ PipelineLayoutBuilder::Build() } } - const vk::PipelineLayoutCreateInfo createInfo = { + vk::PipelineLayoutCreateInfo const createInfo = { .setLayoutCount = static_cast(filteredDescriptorSetLayouts.size()), .pSetLayouts = filteredDescriptorSetLayouts.data(), .pushConstantRangeCount = static_cast(m_PushConstants.size()), @@ -154,7 +154,7 @@ PipelineLayoutBuilder::Build() } vk::DescriptorSetLayout -PipelineLayoutBuilder::CreateDescriptorSetLayout(const vk::DescriptorSetLayoutCreateInfo &createInfo) const +PipelineLayoutBuilder::CreateDescriptorSetLayout(vk::DescriptorSetLayoutCreateInfo const &createInfo) const { vk::DescriptorSetLayout dsl; // Failure Cases are OoM errors. No recovery. @@ -173,8 +173,8 @@ PipelineLayoutBuilder::AddDescriptorSetForParameterBlock(slang::TypeLayoutReflec void PipelineLayoutBuilder::AddPushConstantRangeForConstantBuffer(slang::TypeLayoutReflection *layout) { - const auto elementTypeLayout = layout->getElementTypeLayout(); - const auto elementSize = elementTypeLayout->getSize(); + auto const elementTypeLayout = layout->getElementTypeLayout(); + auto const elementSize = elementTypeLayout->getSize(); if (elementSize == 0) return; @@ -193,13 +193,13 @@ PipelineLayoutBuilder::AddSubObjectRange(slang::TypeLayoutReflection *layout, i6 switch (layout->getBindingRangeType(bindingRangeIndex)) { case slang::BindingType::ParameterBlock: { - const auto parameterBlockTypeLayout = layout->getBindingRangeLeafTypeLayout(bindingRangeIndex); + auto const parameterBlockTypeLayout = layout->getBindingRangeLeafTypeLayout(bindingRangeIndex); AddDescriptorSetForParameterBlock(parameterBlockTypeLayout); } break; case slang::BindingType::PushConstant: { - const auto constantBufferTypeLayout = layout->getBindingRangeLeafTypeLayout(bindingRangeIndex); + auto const constantBufferTypeLayout = layout->getBindingRangeLeafTypeLayout(bindingRangeIndex); AddPushConstantRangeForConstantBuffer(constantBufferTypeLayout); } break; @@ -256,19 +256,19 @@ DescriptorLayoutBuilder::DescriptorLayoutBuilder(PipelineLayoutBuilder *pipeline } void -DescriptorLayoutBuilder::AddDescriptorRange(slang::TypeLayoutReflection *layout, const i64 relativeSetIndex, - const i64 rangeIndex) +DescriptorLayoutBuilder::AddDescriptorRange(slang::TypeLayoutReflection *layout, i64 const relativeSetIndex, + i64 const rangeIndex) { - const auto bindingType = layout->getDescriptorSetDescriptorRangeType(relativeSetIndex, rangeIndex); + auto const bindingType = layout->getDescriptorSetDescriptorRangeType(relativeSetIndex, rangeIndex); if (bindingType == slang::BindingType::PushConstant) return; - const u32 descriptorCount = + u32 const descriptorCount = static_cast(layout->getDescriptorSetDescriptorRangeDescriptorCount(relativeSetIndex, rangeIndex)); - const u32 bindingIndex = static_cast(m_LayoutBindings.size()); - const auto vkBindingType = BindingTypeToDescriptorType(bindingType); + u32 const bindingIndex = static_cast(m_LayoutBindings.size()); + auto const vkBindingType = BindingTypeToDescriptorType(bindingType); m_LayoutBindings.push_back({ .binding = bindingIndex, @@ -299,7 +299,7 @@ DescriptorLayoutBuilder::Build() if (m_LayoutBindings.empty()) return; - const auto dsl = m_PipelineLayoutBuilder->CreateDescriptorSetLayout({ + auto const dsl = m_PipelineLayoutBuilder->CreateDescriptorSetLayout({ .bindingCount = static_cast(m_LayoutBindings.size()), .pBindings = m_LayoutBindings.data(), }); @@ -309,7 +309,7 @@ DescriptorLayoutBuilder::Build() void DescriptorLayoutBuilder::AddAutomaticallyIntroducedUniformBuffer() { - const auto vulkanBindingIndex = static_cast(m_LayoutBindings.size()); + auto const vulkanBindingIndex = static_cast(m_LayoutBindings.size()); m_LayoutBindings.push_back({ .binding = vulkanBindingIndex, diff --git a/aster/src/aster/systems/sync_server.cpp b/aster/src/aster/systems/sync_server.cpp index a293566..3c2c126 100644 --- a/aster/src/aster/systems/sync_server.cpp +++ b/aster/src/aster/systems/sync_server.cpp @@ -34,7 +34,7 @@ SyncServer::Entry::Destroy(Device &device) void SyncServer::Entry::Wait(Device &device) { - const vk::SemaphoreWaitInfo waitInfo = { + vk::SemaphoreWaitInfo const waitInfo = { .semaphoreCount = 1, .pSemaphores = &m_Semaphore, .pValues = &m_CurrentPoint.m_NextValue, @@ -75,13 +75,13 @@ SyncServer::Allocate() } void -SyncServer::Free(const Receipt receipt) +SyncServer::Free(Receipt const receipt) { FreeEntry(GetEntry(receipt)); } void -SyncServer::WaitOn(const Receipt receipt) +SyncServer::WaitOn(Receipt const receipt) { auto &entry = GetEntry(receipt); entry.Wait(*m_Device); diff --git a/aster/src/aster/util/files.cpp b/aster/src/aster/util/files.cpp index 44490ec..2ba186d 100644 --- a/aster/src/aster/util/files.cpp +++ b/aster/src/aster/util/files.cpp @@ -22,7 +22,7 @@ ReadFile(std::string_view fileName) do { readCount = fread(buffer.data(), sizeof(u32), buffer.size(), filePtr); - const auto nextSize = totalRead + readCount; + auto const nextSize = totalRead + readCount; outputVec.resize(nextSize); memcpy(outputVec.data() + totalRead, buffer.data(), readCount * sizeof *buffer.data()); totalRead = nextSize; @@ -49,7 +49,7 @@ ReadFileBytes(std::string_view fileName, bool errorOnFail) do { readCount = fread(buffer.data(), sizeof(u8), buffer.size(), filePtr); - const auto nextSize = totalRead + readCount; + auto const nextSize = totalRead + readCount; outputVec.resize(nextSize); memcpy(outputVec.data() + totalRead, buffer.data(), readCount * sizeof *buffer.data()); totalRead = nextSize; @@ -61,7 +61,7 @@ ReadFileBytes(std::string_view fileName, bool errorOnFail) } bool -WriteFileBytes(std::string_view fileName, const eastl::span data) +WriteFileBytes(std::string_view fileName, eastl::span const data) { FILE *filePtr = fopen(fileName.data(), "wb"); @@ -71,7 +71,7 @@ WriteFileBytes(std::string_view fileName, const eastl::span data) return false; } - const usize written = fwrite(data.data(), sizeof(u8), data.size(), filePtr); + usize const written = fwrite(data.data(), sizeof(u8), data.size(), filePtr); (void)fclose(filePtr); diff --git a/aster/src/aster/util/logger.cpp b/aster/src/aster/util/logger.cpp index d1ccb99..8288de9 100644 --- a/aster/src/aster/util/logger.cpp +++ b/aster/src/aster/util/logger.cpp @@ -12,7 +12,7 @@ auto g_Logger = Logger(); namespace eastl { void -AssertionFailure(const char *af) +AssertionFailure(char const *af) { ERROR("{}", af); } diff --git a/samples/00_util/gui.cpp b/samples/00_util/gui.cpp index 075cebd..6dc0cb2 100644 --- a/samples/00_util/gui.cpp +++ b/samples/00_util/gui.cpp @@ -45,7 +45,7 @@ Init(systems::Device &device, Window &window) {vk::DescriptorType::eInputAttachment, 1000}, }; - const vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo = { + vk::DescriptorPoolCreateInfo const descriptorPoolCreateInfo = { .flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, .maxSets = 1000, .poolSizeCount = static_cast(poolSizes.size()), @@ -93,8 +93,8 @@ Init(systems::Device &device, Window &window) } void -Init(const Instance *context, const Device *device, const Window *window, vk::Format attachmentFormat, - const u32 imageCount, const u32 queueFamily, const vk::Queue queue) +Init(Instance const *context, Device const *device, Window const *window, vk::Format attachmentFormat, + u32 const imageCount, u32 const queueFamily, vk::Queue const queue) { g_AttachmentFormat = attachmentFormat; @@ -112,7 +112,7 @@ Init(const Instance *context, const Device *device, const Window *window, vk::Fo {vk::DescriptorType::eInputAttachment, 1000}, }; - const vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo = { + vk::DescriptorPoolCreateInfo const descriptorPoolCreateInfo = { .flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, .maxSets = 1000, .poolSizeCount = static_cast(poolSizes.size()), @@ -158,7 +158,7 @@ Init(const Instance *context, const Device *device, const Window *window, vk::Fo } void -Destroy(const systems::Device &device) +Destroy(systems::Device const &device) { ImGui_ImplVulkan_Shutdown(); ImGui_ImplGlfw_Shutdown(); @@ -168,7 +168,7 @@ Destroy(const systems::Device &device) } void -Destroy(const Device *device) +Destroy(Device const *device) { ImGui_ImplVulkan_Shutdown(); ImGui_ImplGlfw_Shutdown(); @@ -190,7 +190,7 @@ StartBuild() // because it would be confusing to have two docking targets within each others. ImGuiWindowFlags windowFlags = ImGuiWindowFlags_None | ImGuiWindowFlags_NoDocking; - const ImGuiViewport *viewport = GetMainViewport(); + ImGuiViewport const *viewport = GetMainViewport(); SetNextWindowPos(viewport->WorkPos); SetNextWindowSize(viewport->WorkSize); // SetNextWindowViewport(viewport->ID); @@ -215,7 +215,7 @@ StartBuild() // DockSpace if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable) { - const ImGuiID dockspaceId = GetID("MyDockSpace"); + ImGuiID const dockspaceId = GetID("MyDockSpace"); DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags); } } @@ -237,7 +237,7 @@ EndBuild() } void -Draw(const vk::CommandBuffer commandBuffer, const vk::Extent2D extent, const vk::ImageView view) +Draw(vk::CommandBuffer const commandBuffer, vk::Extent2D const extent, vk::ImageView const view) { // OPTICK_EVENT(); @@ -257,7 +257,7 @@ Draw(const vk::CommandBuffer commandBuffer, const vk::Extent2D extent, const vk: .clearValue = vk::ClearColorValue{0.0f, 0.0f, 0.0f, 1.0f}, }; - const vk::RenderingInfo renderingInfo = { + vk::RenderingInfo const renderingInfo = { .renderArea = {.extent = extent}, .layerCount = 1, .colorAttachmentCount = 1, @@ -290,7 +290,7 @@ Draw(systems::Frame &frame, systems::GraphicsContext &context) .clearValue = vk::ClearColorValue{0.0f, 0.0f, 0.0f, 1.0f}, }; - const vk::RenderingInfo renderingInfo = { + vk::RenderingInfo const renderingInfo = { .renderArea = {.extent = frame.m_SwapchainSize}, .layerCount = 1, .colorAttachmentCount = 1, diff --git a/samples/00_util/helpers.cpp b/samples/00_util/helpers.cpp index 244d983..5b13b06 100644 --- a/samples/00_util/helpers.cpp +++ b/samples/00_util/helpers.cpp @@ -15,24 +15,24 @@ constexpr QueueSupportFlags REQUIRED_QUEUE_SUPPORT = QueueSupportFlags{} | Queue QueueSupportFlagBits::eTransfer; bool -IsSuitableDevice(const PhysicalDevice *physicalDevice) +IsSuitableDevice(PhysicalDevice const *physicalDevice) { - const bool hasAllRequiredQueues = - std::ranges::any_of(physicalDevice->m_QueueFamilies, [](const auto &queueFamilyProp) { + bool const hasAllRequiredQueues = + std::ranges::any_of(physicalDevice->m_QueueFamilies, [](auto const &queueFamilyProp) { return (queueFamilyProp.m_Support & REQUIRED_QUEUE_SUPPORT) == REQUIRED_QUEUE_SUPPORT; }); - const bool isNotCpu = physicalDevice->m_DeviceProperties.deviceType != vk::PhysicalDeviceType::eCpu; + bool const isNotCpu = physicalDevice->m_DeviceProperties.deviceType != vk::PhysicalDeviceType::eCpu; - const bool hasPresentMode = !physicalDevice->m_PresentModes.empty(); + bool const hasPresentMode = !physicalDevice->m_PresentModes.empty(); - const bool hasSurfaceFormat = !physicalDevice->m_SurfaceFormats.empty(); + bool const hasSurfaceFormat = !physicalDevice->m_SurfaceFormats.empty(); return hasSurfaceFormat && hasPresentMode && isNotCpu && hasAllRequiredQueues; } PhysicalDevice -FindSuitableDevice(const PhysicalDevices &physicalDevices) +FindSuitableDevice(PhysicalDevices const &physicalDevices) { for (auto &physicalDevice : physicalDevices) { @@ -47,7 +47,7 @@ FindSuitableDevice(const PhysicalDevices &physicalDevices) } QueueAllocation -FindAppropriateQueueAllocation(const PhysicalDevice *physicalDevice) +FindAppropriateQueueAllocation(PhysicalDevice const *physicalDevice) { for (auto &queueFamilyInfo : physicalDevice->m_QueueFamilies) { @@ -61,4 +61,4 @@ FindAppropriateQueueAllocation(const PhysicalDevice *physicalDevice) } ERROR("No suitable queue family on the GPU.") THEN_ABORT(vk::Result::eErrorUnknown); -} +} \ No newline at end of file diff --git a/samples/01_triangle/triangle.cpp b/samples/01_triangle/triangle.cpp index bcc1522..b5ca4cc 100644 --- a/samples/01_triangle/triangle.cpp +++ b/samples/01_triangle/triangle.cpp @@ -189,4 +189,4 @@ main(int, char **) device.WaitIdle(); return 0; -} +} \ No newline at end of file diff --git a/samples/02_box/box.cpp b/samples/02_box/box.cpp index bfbf046..2f87ee8 100644 --- a/samples/02_box/box.cpp +++ b/samples/02_box/box.cpp @@ -37,7 +37,7 @@ struct ImageFile operator eastl::span() const { - return {static_cast(m_Data), GetSize()}; + return {static_cast(m_Data), GetSize()}; } ~ImageFile(); @@ -314,7 +314,7 @@ main(int, char **) eastl::fixed_vector, MAX_FRAMES_IN_FLIGHT> depthImages; - auto initDepthImages = [&depthImages, &device](const vk::Extent2D extent) { + auto initDepthImages = [&depthImages, &device](vk::Extent2D const extent) { for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) { depthImages.push_back(device.CreateDepthStencilImageWithView({.m_Extent = extent, .m_Name = "Depth"})); @@ -323,7 +323,7 @@ main(int, char **) initDepthImages(swapchainSize); - auto recreateDepthBuffers = [&depthImages, &initDepthImages](const vk::Extent2D extent) { + auto recreateDepthBuffers = [&depthImages, &initDepthImages](vk::Extent2D const extent) { depthImages.clear(); initDepthImages(extent); }; @@ -441,4 +441,4 @@ main(int, char **) device.WaitIdle(); return 0; -} +} \ No newline at end of file diff --git a/samples/03_model_render/asset_loader.cpp b/samples/03_model_render/asset_loader.cpp index 729bf57..08475da 100644 --- a/samples/03_model_render/asset_loader.cpp +++ b/samples/03_model_render/asset_loader.cpp @@ -30,7 +30,7 @@ constexpr vk::CommandBufferBeginInfo OneTimeCmdBeginInfo = {.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit}; vec4 -VectorToVec4(const std::vector &vec) +VectorToVec4(std::vector const &vec) { if (vec.empty()) { @@ -41,7 +41,7 @@ VectorToVec4(const std::vector &vec) } vec4 -VectorToVec4(const std::vector &vec, float w) +VectorToVec4(std::vector const &vec, float w) { if (vec.empty()) { @@ -52,7 +52,7 @@ VectorToVec4(const std::vector &vec, float w) } vec3 -VectorToVec3(const std::vector &vec) +VectorToVec3(std::vector const &vec) { if (vec.empty()) { @@ -161,7 +161,7 @@ AssetLoader::LoadHdrImage(cstr path, cstr name) const } void -GenerateMipMaps(systems::TransferContext &context, const Ref &texture, vk::ImageLayout initialLayout, +GenerateMipMaps(systems::TransferContext &context, Ref const &texture, vk::ImageLayout initialLayout, vk::ImageLayout finalLayout, vk::PipelineStageFlags2 prevStage, vk::PipelineStageFlags2 finalStage) { #if !defined(ASTER_NDEBUG) @@ -440,8 +440,8 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name) tinygltf::Model model; tinygltf::TinyGLTF loader; - const auto fsPath = fs::absolute(path); - const auto ext = fsPath.extension(); + auto const fsPath = fs::absolute(path); + auto const ext = fsPath.extension(); if (ext == GLTF_ASCII_FILE_EXTENSION) { std::string err; @@ -480,17 +480,17 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name) { // TODO("Something broken on load here."); auto getTextureHandle = [this, &context, &textureHandleMap, - &model](i32 index, const bool isSrgb) -> systems::ResId { + &model](i32 index, bool const isSrgb) -> systems::ResId { if (index < 0) { return systems::NullId{}; } - if (const auto iter = textureHandleMap.find(index); iter != textureHandleMap.end()) + if (auto const iter = textureHandleMap.find(index); iter != textureHandleMap.end()) { return iter->second; } - const auto &texture = model.textures[index]; + auto const &texture = model.textures[index]; auto *image = &model.images[texture.source]; auto handle = LoadImageToGpu(context, image, isSrgb, texture.name.empty() ? nullptr : texture.name.c_str()); textureHandleMap.emplace(index, handle); @@ -749,7 +749,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name) { eastl::function processNode = [&processNode, &model, &nodes, &meshPrimRanges, &meshPrimitives](i32 idx, i32 parent) -> void { - const auto *node = &model.nodes[idx]; + auto const *node = &model.nodes[idx]; auto nodeTranslation = vec3{0.0f}; auto nodeRotation = quat{1.0f, 0.0f, 0.0f, 0.0f}; @@ -772,21 +772,21 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name) { nodeMatrix = glm::make_mat4(node->matrix.data()); } - const mat4 transform = translate(mat4(1.0f), nodeTranslation) * mat4_cast(nodeRotation) * + mat4 const transform = translate(mat4(1.0f), nodeTranslation) * mat4_cast(nodeRotation) * scale(mat4(1.0f), nodeScale) * nodeMatrix; - const i32 nodeArrayIndex = static_cast(nodes.Add(transform, parent)); + i32 const nodeArrayIndex = static_cast(nodes.Add(transform, parent)); if (node->mesh >= 0) { auto [start, count] = meshPrimRanges[node->mesh]; - const auto end = start + count; + auto const end = start + count; for (usize i = start; i != end; ++i) { meshPrimitives[i].m_TransformIdx = nodeArrayIndex; } } - for (const i32 child : node->children) + for (i32 const child : node->children) { processNode(child, nodeArrayIndex); } @@ -854,7 +854,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name) } Model::Model(eastl::vector> &textureHandles, Nodes &&nodes, Ref nodeBuffer, - ModelHandles &handles, Ref indexBuffer, const eastl::vector &meshPrimitives) + ModelHandles &handles, Ref indexBuffer, eastl::vector const &meshPrimitives) : m_TextureHandles(std::move(textureHandles)) , m_Nodes(std::move(nodes)) , m_Handles(std::move(handles)) @@ -864,14 +864,14 @@ Model::Model(eastl::vector> &textureHandles, Nodes & { } -const mat4 & +mat4 const & Model::GetModelTransform() const { return m_Nodes[0]; } void -Model::SetModelTransform(const mat4 &transform) +Model::SetModelTransform(mat4 const &transform) { m_Nodes.Set(0, transform); } diff --git a/samples/03_model_render/asset_loader.h b/samples/03_model_render/asset_loader.h index f8bbfa2..78c3580 100644 --- a/samples/03_model_render/asset_loader.h +++ b/samples/03_model_render/asset_loader.h @@ -86,20 +86,19 @@ struct Model Ref m_IndexBuffer; eastl::vector m_MeshPrimitives; - [[nodiscard]] const mat4 &GetModelTransform() const; - void SetModelTransform(const mat4 &transform); + [[nodiscard]] mat4 const &GetModelTransform() const; + void SetModelTransform(mat4 const &transform); void Update(); - Model(eastl::vector> &textureHandles, - Nodes &&nodes, Ref nodeBuffer, ModelHandles &handles, Ref indexBuffer, - const eastl::vector &meshPrimitives); + Model(eastl::vector> &textureHandles, Nodes &&nodes, Ref nodeBuffer, + ModelHandles &handles, Ref indexBuffer, eastl::vector const &meshPrimitives); ~Model() = default; Model(Model &&other) noexcept = default; Model &operator=(Model &&other) noexcept = default; - Model(const Model &) = delete; - const Model &operator=(const Model &) = delete; + Model(Model const &) = delete; + Model const &operator=(Model const &) = delete; }; struct AssetLoader @@ -126,7 +125,7 @@ struct AssetLoader }; void -GenerateMipMaps(systems::TransferContext &context, const Ref &textureView, vk::ImageLayout initialLayout, +GenerateMipMaps(systems::TransferContext &context, Ref const &textureView, vk::ImageLayout initialLayout, vk::ImageLayout finalLayout, vk::PipelineStageFlags2 prevStage, vk::PipelineStageFlags2 finalStage); void @@ -135,8 +134,7 @@ GenerateMipMaps(systems::TransferContext &context, concepts::ImageRefTo vk::PipelineStageFlags2 prevStage = vk::PipelineStageFlagBits2::eAllCommands, vk::PipelineStageFlags2 finalStage = vk::PipelineStageFlagBits2::eAllCommands) { - GenerateMipMaps(context, systems::CastImage(texture), initialLayout, finalLayout, prevStage, - finalStage); + GenerateMipMaps(context, systems::CastImage(texture), initialLayout, finalLayout, prevStage, finalStage); } void @@ -147,4 +145,4 @@ GenerateMipMaps(systems::TransferContext &context, concepts::ViewRefTo { GenerateMipMaps(context, systems::CastImage(texture->m_Image), initialLayout, finalLayout, prevStage, finalStage); -} +} \ No newline at end of file diff --git a/samples/03_model_render/ibl_helpers.cpp b/samples/03_model_render/ibl_helpers.cpp index eec0a8f..b55b7c2 100644 --- a/samples/03_model_render/ibl_helpers.cpp +++ b/samples/03_model_render/ibl_helpers.cpp @@ -24,7 +24,7 @@ constexpr auto PREFILTER_ENTRY = "prefilter"; constexpr auto BRDF_LUT_ENTRY = "brdfLut"; Environment -CreateCubeFromHdrEnv(AssetLoader &assetLoader, const u32 cubeSide, systems::ResId hdrEnv) +CreateCubeFromHdrEnv(AssetLoader &assetLoader, u32 const cubeSide, systems::ResId hdrEnv) { systems::Device &device = *assetLoader.m_Device; auto *commitManager = device.m_CommitManager.get(); diff --git a/samples/03_model_render/light_manager.cpp b/samples/03_model_render/light_manager.cpp index ec29e56..4acb0f2 100644 --- a/samples/03_model_render/light_manager.cpp +++ b/samples/03_model_render/light_manager.cpp @@ -34,22 +34,22 @@ static_assert((Light::TYPE_MASK & Light::TYPE_SPOT) == Light::TYPE_SPOT); static_assert(Light::COLOR_MASK == 0xFFFFFF00); inline u32 -ToColor32(const vec4 &col) +ToColor32(vec4 const &col) { - const u32 r = static_cast(eastl::min(col.r, 1.0f) * 255.99f); - const u32 g = static_cast(eastl::min(col.g, 1.0f) * 255.99f); - const u32 b = static_cast(eastl::min(col.b, 1.0f) * 255.99f); - const u32 a = static_cast(eastl::min(col.a, 1.0f) * 255.99f); + u32 const r = static_cast(eastl::min(col.r, 1.0f) * 255.99f); + u32 const g = static_cast(eastl::min(col.g, 1.0f) * 255.99f); + u32 const b = static_cast(eastl::min(col.b, 1.0f) * 255.99f); + u32 const a = static_cast(eastl::min(col.a, 1.0f) * 255.99f); return r << 24 | g << 16 | b << 8 | a; } inline u32 -ToColor32(const vec3 &col) +ToColor32(vec3 const &col) { - const u32 r = static_cast(eastl::min(col.r, 1.0f) * 255.99f); - const u32 g = static_cast(eastl::min(col.g, 1.0f) * 255.99f); - const u32 b = static_cast(eastl::min(col.b, 1.0f) * 255.99f); + u32 const r = static_cast(eastl::min(col.r, 1.0f) * 255.99f); + u32 const g = static_cast(eastl::min(col.g, 1.0f) * 255.99f); + u32 const b = static_cast(eastl::min(col.b, 1.0f) * 255.99f); constexpr u32 a = 255; return r << 24 | g << 16 | b << 8 | a; @@ -89,9 +89,9 @@ LightManager::operator=(LightManager &&other) noexcept } LightHandle -LightManager::AddDirectional(const vec3 &direction, const vec3 &color, f32 intensity) +LightManager::AddDirectional(vec3 const &direction, vec3 const &color, f32 intensity) { - const vec3 normDirection = normalize(direction); + vec3 const normDirection = normalize(direction); if (m_DirectionalLightCount < m_MetaInfo.m_DirectionalLightMaxCount) { u16 index = 0; @@ -99,7 +99,7 @@ LightManager::AddDirectional(const vec3 &direction, const vec3 &color, f32 inten { if (light.m_Range < 0) { - const u8 gen = light.m_Color_ & Light::GEN_MASK; + u8 const gen = light.m_Color_ & Light::GEN_MASK; light.m_Color_ = (ToColor32(color) & Light::COLOR_MASK) | Light::TYPE_DIRECTIONAL | gen; light.m_Range = 1.0f; @@ -119,8 +119,8 @@ LightManager::AddDirectional(const vec3 &direction, const vec3 &color, f32 inten if (m_DirectionalLightCount == m_MetaInfo.m_DirectionalLightMaxCount && m_MetaInfo.m_DirectionalLightMaxCount == m_MetaInfo.m_PointLightOffset) { - const u16 oldPointLightOffset = m_MetaInfo.m_PointLightOffset; - const u32 pointLightMaxCount = m_MetaInfo.m_PointLightMaxCount; + u16 const oldPointLightOffset = m_MetaInfo.m_PointLightOffset; + u32 const pointLightMaxCount = m_MetaInfo.m_PointLightMaxCount; // Might cause a capacity increase, but I want to use that for my gpu buffer resize. m_Lights.push_back(); m_Lights.push_back(); @@ -146,7 +146,7 @@ LightManager::AddDirectional(const vec3 &direction, const vec3 &color, f32 inten m_Lights[m_DirectionalLightCount].m_Range = 1.0f; m_Lights[m_DirectionalLightCount].um_Direction = normDirection; m_Lights[m_DirectionalLightCount].m_Intensity = intensity; - const u16 index = m_DirectionalLightCount; + u16 const index = m_DirectionalLightCount; ++m_DirectionalLightCount; ++m_MetaInfo.m_DirectionalLightMaxCount; @@ -155,7 +155,7 @@ LightManager::AddDirectional(const vec3 &direction, const vec3 &color, f32 inten } LightHandle -LightManager::AddPoint(const vec3 &position, const vec3 &color, const f32 radius, f32 intensity) +LightManager::AddPoint(vec3 const &position, vec3 const &color, f32 const radius, f32 intensity) { assert(m_PointLightCount <= m_MetaInfo.m_PointLightMaxCount); assert(radius >= 0.0f); @@ -166,7 +166,7 @@ LightManager::AddPoint(const vec3 &position, const vec3 &color, const f32 radius { if (light->m_Range < 0) { - const u8 gen = light->m_Color_ & Light::GEN_MASK; + u8 const gen = light->m_Color_ & Light::GEN_MASK; light->m_Color_ = (ToColor32(color) & Light::COLOR_MASK) | Light::TYPE_POINT | gen; light->m_Range = radius; @@ -184,7 +184,7 @@ LightManager::AddPoint(const vec3 &position, const vec3 &color, const f32 radius } m_Lights.push_back(); - const u16 index = m_PointLightCount; + u16 const index = m_PointLightCount; Light *light = &m_Lights[index + m_MetaInfo.m_PointLightOffset]; constexpr u8 gen = 0; // New light @@ -205,7 +205,7 @@ LightManager::AddPoint(const vec3 &position, const vec3 &color, const f32 radius void LightManager::Update() { - const u16 requiredBufferCapacity = eastl::min(static_cast(m_Lights.capacity()), MAX_LIGHTS); + u16 const requiredBufferCapacity = eastl::min(static_cast(m_Lights.capacity()), MAX_LIGHTS); if ((m_GpuBufferCapacity_ & CAPACITY_MASK) < requiredBufferCapacity) { auto newBuffer = m_Device->CreateStorageBuffer(requiredBufferCapacity * sizeof m_Lights[0], "Light Buffer"); @@ -215,20 +215,20 @@ LightManager::Update() } if (m_GpuBufferCapacity_ & UPDATE_REQUIRED_BIT) { - const auto ref = m_Device->m_CommitManager->FetchHandle(m_MetaInfo.m_LightBuffer); + auto const ref = m_Device->m_CommitManager->FetchHandle(m_MetaInfo.m_LightBuffer); ref->Write(0, m_Lights.size() * sizeof m_Lights[0], m_Lights.data()); } } void -LightManager::RemoveLight(const LightHandle handle) +LightManager::RemoveLight(LightHandle const handle) { - const u8 handleGen = handle.m_Generation; + u8 const handleGen = handle.m_Generation; if (handle.m_Type == Light::TYPE_DIRECTIONAL) { Light *lightSlot = &m_Lights[handle.m_Index]; - const u8 slotGen = lightSlot->m_Color_ & Light::GEN_MASK; + u8 const slotGen = lightSlot->m_Color_ & Light::GEN_MASK; if (slotGen > handleGen) { WARN("Invalid handle gen: {} being freed. (slot gen: {})", handleGen, slotGen); @@ -243,7 +243,7 @@ LightManager::RemoveLight(const LightHandle handle) if (handle.m_Type == Light::TYPE_POINT) { Light *lightSlot = &m_Lights[handle.m_Index + m_MetaInfo.m_PointLightOffset]; - const u8 slotGen = lightSlot->m_Color_ & Light::GEN_MASK; + u8 const slotGen = lightSlot->m_Color_ & Light::GEN_MASK; if (slotGen > handleGen) { WARN("Invalid handle gen: {} being freed. (slot gen: {})", handleGen, slotGen); diff --git a/samples/03_model_render/model_render.cpp b/samples/03_model_render/model_render.cpp index 9770c68..e58f097 100644 --- a/samples/03_model_render/model_render.cpp +++ b/samples/03_model_render/model_render.cpp @@ -243,11 +243,6 @@ main(int, char **) .maxDepth = 1.0, }; - vk::Rect2D scissor = { - .offset = {0, 0}, - .extent = internalResolution, - }; - vk::ImageSubresourceRange subresourceRange = { .aspectMask = vk::ImageAspectFlagBits::eColor, .baseMipLevel = 0, @@ -356,7 +351,7 @@ main(int, char **) vec3 camPosition = cameraController.m_Camera.m_Position; vk::Extent2D inputResolution = internalResolution; - device.RegisterResizeCallback([&cameraController](vk::Extent2D extent) { + device.RegisterResizeCallback([&cameraController](vk::Extent2D const extent) { cameraController.SetAspectRatio(static_cast(extent.width) / static_cast(extent.height)); }); @@ -393,7 +388,6 @@ main(int, char **) viewport.width = static_cast(internalResolution.width); viewport.height = -static_cast(internalResolution.height); viewport.y = static_cast(internalResolution.height); - scissor.extent = internalResolution; } } } @@ -406,7 +400,6 @@ main(int, char **) viewport.width = static_cast(internalResolution.width); viewport.height = -static_cast(internalResolution.height); viewport.y = static_cast(internalResolution.height); - scissor.extent = internalResolution; } } gui::Separator(); diff --git a/samples/03_model_render/nodes.cpp b/samples/03_model_render/nodes.cpp index bef72c5..46eb5c3 100644 --- a/samples/03_model_render/nodes.cpp +++ b/samples/03_model_render/nodes.cpp @@ -6,40 +6,40 @@ #include "nodes.h" u32 -Nodes::Add(const mat4 &transform, const i32 parent) +Nodes::Add(mat4 const &transform, i32 const parent) { m_Dirty = true; - const u32 index = Count(); + u32 const index = Count(); m_Transforms.push_back(transform); m_GlobalTransforms.emplace_back(transform); - const u32 parentVal = (parent < 0 ? ROOT_BIT : parent & PARENT_MASK) | DIRTY_BIT; + u32 const parentVal = (parent < 0 ? ROOT_BIT : parent & PARENT_MASK) | DIRTY_BIT; m_Parents_.push_back(parentVal); return index; } -const mat4 & -Nodes::Get(const u32 index) const +mat4 const & +Nodes::Get(u32 const index) const { return m_Transforms[index]; } void -Nodes::Set(const u32 index, const mat4 &transform) +Nodes::Set(u32 const index, mat4 const &transform) { m_Dirty = true; m_Transforms[index] = transform; m_Parents_[index] |= DIRTY_BIT; } -const mat4 & -Nodes::operator[](const u32 index) const +mat4 const & +Nodes::operator[](u32 const index) const { return m_Transforms[index]; } mat4 & -Nodes::operator[](const u32 index) +Nodes::operator[](u32 const index) { m_Dirty = true; m_Parents_[index] |= DIRTY_BIT; @@ -58,7 +58,7 @@ Nodes::GetGlobalTransformByteSize() const return m_GlobalTransforms.size() * sizeof m_GlobalTransforms[0]; } -const Nodes::Transform * +Nodes::Transform const * Nodes::GetGlobalTransformPtr() const { return m_GlobalTransforms.data(); @@ -73,12 +73,12 @@ Nodes::Update() auto transformIter = m_Transforms.begin(); auto globalTransformIter = m_GlobalTransforms.begin(); auto parentIter = m_Parents_.begin(); - const auto parentEnd = m_Parents_.end(); + auto const parentEnd = m_Parents_.end(); while (parentIter != parentEnd) { - const bool isRoot = *parentIter & ROOT_BIT; - const bool isDirty = *parentIter & DIRTY_BIT; + bool const isRoot = *parentIter & ROOT_BIT; + bool const isDirty = *parentIter & DIRTY_BIT; if (isRoot) { @@ -90,8 +90,8 @@ Nodes::Update() } else { - const u32 parentIdx = *parentIter & PARENT_MASK; - const bool isParentDirty = m_Parents_[parentIdx] & DIRTY_BIT; + u32 const parentIdx = *parentIter & PARENT_MASK; + bool const isParentDirty = m_Parents_[parentIdx] & DIRTY_BIT; if (isDirty || isParentDirty) { // Update w.r.t parent if either local or parent transforms updated. diff --git a/samples/03_model_render/nodes.h b/samples/03_model_render/nodes.h index 613035a..b96de27 100644 --- a/samples/03_model_render/nodes.h +++ b/samples/03_model_render/nodes.h @@ -16,14 +16,14 @@ struct Nodes mat4 m_GlobalTransforms; mat4 m_NormalTransforms; - explicit Transform(const mat4 &transform) + explicit Transform(mat4 const &transform) : m_GlobalTransforms(transform) , m_NormalTransforms(transpose(inverse(mat3{transform}))) { } Transform & - operator=(const mat4 &transform) + operator=(mat4 const &transform) { m_GlobalTransforms = transform; m_NormalTransforms = transpose(inverse(mat3{transform})); @@ -41,16 +41,16 @@ struct Nodes constexpr static u32 DIRTY_BIT = 1u << 30; constexpr static u32 PARENT_MASK = ~(ROOT_BIT | DIRTY_BIT); - u32 Add(const mat4 &transform, i32 parent = -1); - [[nodiscard]] const mat4 &Get(u32 index) const; - void Set(u32 index, const mat4 &transform); + u32 Add(mat4 const &transform, i32 parent = -1); + [[nodiscard]] mat4 const &Get(u32 index) const; + void Set(u32 index, mat4 const &transform); [[nodiscard]] u32 Count() const; - [[nodiscard]] const mat4 &operator[](u32 index) const; + [[nodiscard]] mat4 const &operator[](u32 index) const; [[nodiscard]] mat4 &operator[](u32 index); [[nodiscard]] usize GetGlobalTransformByteSize() const; - [[nodiscard]] const Transform *GetGlobalTransformPtr() const; + [[nodiscard]] Transform const *GetGlobalTransformPtr() const; bool Update(); }; \ No newline at end of file