East Const supremacy.

This commit is contained in:
Anish Bhobe 2025-05-27 18:49:40 +02:00
parent 58edfef94d
commit 1b48aa25d3
49 changed files with 500 additions and 495 deletions

View File

@ -26,7 +26,7 @@ struct Buffer
using Flags = vk::Flags<FlagBits>; using Flags = vk::Flags<FlagBits>;
constexpr static Flags FLAGS = {}; constexpr static Flags FLAGS = {};
const Device *m_Device = nullptr; Device const *m_Device = nullptr;
vk::Buffer m_Buffer = nullptr; vk::Buffer m_Buffer = nullptr;
VmaAllocation m_Allocation = nullptr; VmaAllocation m_Allocation = nullptr;
u8 *m_Mapped = nullptr; ///< If the buffer is host visible, it should be (and stay) mapped. 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. /// Writes the data to the buffer.
/// @note The buffer must be mapped. /// @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, /// If Buffer Device Address is enabled,
/// Get a pointer. /// Get a pointer.
uptr GetDeviceAddress(const Device *device) const; uptr GetDeviceAddress(Device const *device) const;
// Constructors // 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); VmaMemoryUsage memoryUsage, cstr name);
Buffer(Buffer &&other) noexcept; Buffer(Buffer &&other) noexcept;

View File

@ -32,7 +32,7 @@ using b32 = u32;
using usize = size_t; using usize = size_t;
using isize = intptr_t; using isize = intptr_t;
using uptr = uintptr_t; using uptr = uintptr_t;
using cstr = const char *; using cstr = char const *;
namespace ansi_color namespace ansi_color
{ {
@ -105,31 +105,31 @@ constexpr Version VERSION = {
}; };
constexpr u32 constexpr u32
Kilobyte(const u32 in) Kilobyte(u32 const in)
{ {
return in * 1024; return in * 1024;
} }
constexpr usize constexpr usize
Kilobyte(const usize in) Kilobyte(usize const in)
{ {
return in * 1024; return in * 1024;
} }
constexpr u32 constexpr u32
Megabyte(const u32 in) Megabyte(u32 const in)
{ {
return in * 1024 * 1024; return in * 1024 * 1024;
} }
constexpr usize constexpr usize
Megabyte(const usize in) Megabyte(usize const in)
{ {
return in * 1024 * 1024; return in * 1024 * 1024;
} }
constexpr usize constexpr usize
Gigabyte(const usize in) Gigabyte(usize const in)
{ {
return in * 1024 * 1024 * 1024; return in * 1024 * 1024 * 1024;
} }

View File

@ -32,7 +32,7 @@ struct Device final
bool m_ValidationEnabled = true; bool m_ValidationEnabled = true;
template <concepts::VkHandle T> template <concepts::VkHandle T>
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]] vk::Queue GetQueue(u32 familyIndex, u32 queueIndex) const;
[[nodiscard]] eastl::vector<u8> DumpPipelineCache() const; [[nodiscard]] eastl::vector<u8> DumpPipelineCache() const;
@ -45,7 +45,7 @@ struct Device final
return &m_Device; return &m_Device;
} }
const vk::Device * vk::Device const *
operator->() const operator->() const
{ {
return &m_Device; return &m_Device;
@ -53,8 +53,8 @@ struct Device final
// Ctor/Dtor // Ctor/Dtor
Device() = default; Device() = default;
Device(const Instance &context, PhysicalDevice &physicalDevice, Features &enabledFeatures, Device(Instance const &context, PhysicalDevice &physicalDevice, Features &enabledFeatures,
const eastl::span<QueueAllocation> &queueAllocations, const eastl::span<u8> &pipelineCacheData, eastl::span<QueueAllocation> const &queueAllocations, eastl::span<u8> const &pipelineCacheData,
NameString &&name); NameString &&name);
~Device(); ~Device();
@ -67,13 +67,13 @@ struct Device final
template <concepts::VkHandle T> template <concepts::VkHandle T>
void void
Device::SetName(const T &object, cstr name) const Device::SetName(T const &object, cstr name) const
{ {
if (!m_ValidationEnabled || !name || !object) if (!m_ValidationEnabled || !name || !object)
return; return;
auto handle = reinterpret_cast<u64>(static_cast<typename T::NativeType>(object)); auto handle = reinterpret_cast<u64>(static_cast<typename T::NativeType>(object));
const vk::DebugUtilsObjectNameInfoEXT objectNameInfo = { vk::DebugUtilsObjectNameInfoEXT const objectNameInfo = {
.objectType = object.objectType, .objectType = object.objectType,
.objectHandle = handle, .objectHandle = handle,
.pObjectName = name, .pObjectName = name,

View File

@ -5,15 +5,15 @@
#pragma once #pragma once
#include "aster/util/logger.h"
#include "config.h" #include "config.h"
#include "constants.h" #include "constants.h"
#include "aster/util/logger.h"
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <fmt/format.h>
#include <EASTL/shared_ptr.h> #include <EASTL/shared_ptr.h>
#include <fmt/format.h>
// Macros that can collide with functions. // Macros that can collide with functions.
#if defined(max) #if defined(max)
@ -82,7 +82,7 @@ constexpr u32 ASTER_API_VERSION = VK_API_VERSION_1_3;
} while (false) } while (false)
[[nodiscard]] inline bool [[nodiscard]] inline bool
Failed(const vk::Result result) Failed(vk::Result const result)
{ {
return result != vk::Result::eSuccess; return result != vk::Result::eSuccess;
} }
@ -99,7 +99,7 @@ template <typename TFlagBits>
struct eastl::hash<vk::Flags<TFlagBits>> // NOLINT(*-dcl58-cpp) struct eastl::hash<vk::Flags<TFlagBits>> // NOLINT(*-dcl58-cpp)
{ {
[[nodiscard]] usize [[nodiscard]] usize
operator()(const vk::Flags<TFlagBits> &val) operator()(vk::Flags<TFlagBits> const &val)
{ {
return std::hash<u32>()(static_cast<u32>(val)); return std::hash<u32>()(static_cast<u32>(val));
} }
@ -107,16 +107,16 @@ struct eastl::hash<vk::Flags<TFlagBits>> // NOLINT(*-dcl58-cpp)
template <typename T> template <typename T>
[[nodiscard]] usize [[nodiscard]] usize
HashAny(const T &val) HashAny(T const &val)
{ {
return eastl::hash<std::remove_cvref_t<T>>()(val); return eastl::hash<std::remove_cvref_t<T>>()(val);
} }
[[nodiscard]] inline usize [[nodiscard]] inline usize
HashCombine(const usize hash0, const usize hash1) HashCombine(usize const hash0, usize const hash1)
{ {
constexpr usize saltValue = 0x9e3779b9; 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; return hash0 ^ tempVar;
} }
@ -139,32 +139,32 @@ struct Time
Update() Update()
{ {
ERROR_IF(std::isnan(m_Elapsed), "Time not init."); 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_Delta = std::clamp(newElapsed - m_Elapsed, 0.0, MAX_DELTA);
m_Elapsed = newElapsed; m_Elapsed = newElapsed;
} }
}; };
[[nodiscard]] constexpr usize [[nodiscard]] constexpr usize
ClosestMultiple(const usize val, const usize of) ClosestMultiple(usize const val, usize const of)
{ {
return of * ((val + of - 1) / of); return of * ((val + of - 1) / of);
} }
[[nodiscard]] constexpr u32 [[nodiscard]] constexpr u32
ClosestMultiple(const u32 val, const u32 of) ClosestMultiple(u32 const val, u32 const of)
{ {
return of * ((val + of - 1) / of); return of * ((val + of - 1) / of);
} }
[[nodiscard]] constexpr bool [[nodiscard]] constexpr bool
IsPowerOfTwo(const usize val) IsPowerOfTwo(usize const val)
{ {
return val && !(val & (val - 1)); return val && !(val & (val - 1));
} }
[[nodiscard]] constexpr bool [[nodiscard]] constexpr bool
IsPowerOfTwo(const u32 val) IsPowerOfTwo(u32 const val)
{ {
return val && !(val & (val - 1)); return val && !(val & (val - 1));
} }
@ -184,10 +184,10 @@ ClosestLargerPowerOfTwo(usize val)
} }
[[nodiscard]] constexpr usize [[nodiscard]] constexpr usize
ClosestPowerOfTwo(const usize val) ClosestPowerOfTwo(usize const val)
{ {
const usize largerPo2 = ClosestLargerPowerOfTwo(val); usize const largerPo2 = ClosestLargerPowerOfTwo(val);
const usize smallerPo2 = largerPo2 >> 1; usize const smallerPo2 = largerPo2 >> 1;
return (smallerPo2 + largerPo2 <= (val << 1)) ? largerPo2 : smallerPo2; return (smallerPo2 + largerPo2 <= (val << 1)) ? largerPo2 : smallerPo2;
} }
@ -205,10 +205,10 @@ ClosestLargerPowerOfTwo(u32 val)
} }
[[nodiscard]] constexpr u32 [[nodiscard]] constexpr u32
ClosestPowerOfTwo(const u32 val) ClosestPowerOfTwo(u32 const val)
{ {
const u32 largerPo2 = ClosestLargerPowerOfTwo(val); u32 const largerPo2 = ClosestLargerPowerOfTwo(val);
const u32 smallerPo2 = largerPo2 >> 1; u32 const smallerPo2 = largerPo2 >> 1;
return (smallerPo2 + largerPo2 <= (val << 1)) ? largerPo2 : smallerPo2; return (smallerPo2 + largerPo2 <= (val << 1)) ? largerPo2 : smallerPo2;
} }
@ -246,9 +246,9 @@ struct fmt::formatter<eastl::fixed_string<TType, TCount, TOverflow>> : nested_fo
{ {
auto auto
// ReSharper disable once CppInconsistentNaming // ReSharper disable once CppInconsistentNaming
format(const eastl::fixed_string<TType, TCount, TOverflow> &str, format_context &ctx) const format(eastl::fixed_string<TType, TCount, TOverflow> 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())); });
} }
}; };

View File

@ -11,25 +11,25 @@ struct StorageTexture;
struct Device; struct Device;
[[nodiscard]] inline vk::Extent2D [[nodiscard]] inline vk::Extent2D
ToExtent2D(const vk::Extent3D &extent) ToExtent2D(vk::Extent3D const &extent)
{ {
return {extent.width, extent.height}; return {extent.width, extent.height};
} }
[[nodiscard]] inline vk::Extent3D [[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}; return {extent.width, extent.height, depth};
} }
[[nodiscard]] inline vk::Offset2D [[nodiscard]] inline vk::Offset2D
ToOffset2D(const vk::Extent3D &extent) ToOffset2D(vk::Extent3D const &extent)
{ {
return {static_cast<i32>(extent.width), static_cast<i32>(extent.height)}; return {static_cast<i32>(extent.width), static_cast<i32>(extent.height)};
} }
[[nodiscard]] inline vk::Offset3D [[nodiscard]] inline vk::Offset3D
ToOffset3D(const vk::Extent3D &extent) ToOffset3D(vk::Extent3D const &extent)
{ {
return {static_cast<i32>(extent.width), static_cast<i32>(extent.height), static_cast<i32>(extent.depth)}; return {static_cast<i32>(extent.width), static_cast<i32>(extent.height), static_cast<i32>(extent.depth)};
} }
@ -46,7 +46,7 @@ struct Image
using Flags = vk::Flags<FlagBits>; using Flags = vk::Flags<FlagBits>;
constexpr static Flags FLAGS = {}; constexpr static Flags FLAGS = {};
const Device *m_Device = nullptr; Device const *m_Device = nullptr;
vk::Image m_Image = nullptr; vk::Image m_Image = nullptr;
VmaAllocation m_Allocation = nullptr; VmaAllocation m_Allocation = nullptr;
vk::Extent3D m_Extent; vk::Extent3D m_Extent;
@ -72,7 +72,7 @@ struct Image
// Constructors. // 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); vk::Format format, Flags flags, u8 layerCount, u8 mipLevels);
Image(Image &&other) noexcept; Image(Image &&other) noexcept;

View File

@ -33,8 +33,8 @@ struct View
return static_cast<bool>(m_Image); return static_cast<bool>(m_Image);
} }
View(Ref<Image> image, const vk::ImageView view, const vk::Extent3D extent, const u8 baseLayer, const u8 layerCount, View(Ref<Image> image, vk::ImageView const view, vk::Extent3D const extent, u8 const baseLayer, u8 const layerCount,
const u8 baseMipLevel, const u8 mipLevelCount) u8 const baseMipLevel, u8 const mipLevelCount)
: m_Image{std::move(image)} : m_Image{std::move(image)}
, m_View{view} , m_View{view}
, m_Extent{extent} , m_Extent{extent}

View File

@ -27,7 +27,7 @@ using QueueSupportFlags = vk::Flags<QueueSupportFlagBits>;
inline std::string inline std::string
// ReSharper disable once CppInconsistentNaming // ReSharper disable once CppInconsistentNaming
format_as(const QueueSupportFlags &qfi) format_as(QueueSupportFlags const &qfi)
{ {
std::stringstream sb; std::stringstream sb;
if (qfi & QueueSupportFlagBits::eGraphics) if (qfi & QueueSupportFlagBits::eGraphics)
@ -46,7 +46,7 @@ format_as(const QueueSupportFlags &qfi)
{ {
sb << "Present | "; sb << "Present | ";
} }
const auto sbv = sb.view(); auto const sbv = sb.view();
return std::string(sbv.substr(0, sbv.size() - 3)); return std::string(sbv.substr(0, sbv.size() - 3));
} }
@ -58,7 +58,7 @@ struct QueueFamilyInfo
}; };
inline std::string 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); 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<PhysicalDevice, 4> class PhysicalDevices : public eastl::fixed_vector<PhysicalDevice, 4>
{ {
public: public:
PhysicalDevices(const Surface &surface, const Instance &context); PhysicalDevices(Surface const &surface, Instance const &context);
}; };

View File

@ -19,14 +19,14 @@ struct Pipeline
eCompute, eCompute,
}; };
const Device *m_Device = nullptr; Device const *m_Device = nullptr;
vk::PipelineLayout m_Layout; vk::PipelineLayout m_Layout;
vk::Pipeline m_Pipeline = nullptr; vk::Pipeline m_Pipeline = nullptr;
eastl::vector<vk::DescriptorSetLayout> m_SetLayouts; eastl::vector<vk::DescriptorSetLayout> m_SetLayouts;
Kind m_Kind; Kind m_Kind;
Pipeline() = default; Pipeline() = default;
Pipeline(const Device *device, vk::PipelineLayout layout, vk::Pipeline pipeline, Pipeline(Device const *device, vk::PipelineLayout layout, vk::Pipeline pipeline,
eastl::vector<vk::DescriptorSetLayout> &&setLayouts, Kind kind); eastl::vector<vk::DescriptorSetLayout> &&setLayouts, Kind kind);
~Pipeline(); ~Pipeline();

View File

@ -11,7 +11,7 @@ struct Device;
struct Sampler final struct Sampler final
{ {
const Device *m_Device = nullptr; Device const *m_Device = nullptr;
vk::Sampler m_Sampler = nullptr; vk::Sampler m_Sampler = nullptr;
[[nodiscard]] bool [[nodiscard]] bool
@ -22,7 +22,7 @@ struct Sampler final
// Constructors // Constructors
Sampler(const Device *device, const vk::SamplerCreateInfo &samplerCreateInfo, cstr name); Sampler(Device const *device, vk::SamplerCreateInfo const &samplerCreateInfo, cstr name);
~Sampler(); ~Sampler();
Sampler(Sampler &&other) noexcept; Sampler(Sampler &&other) noexcept;

View File

@ -14,27 +14,27 @@ struct Size2D
Size2D() = default; Size2D() = default;
Size2D(const u32 width, const u32 height) Size2D(u32 const width, u32 const height)
: m_Width{width} : m_Width{width}
, m_Height{height} , m_Height{height}
{ {
} }
Size2D(const vk::Extent2D extent) Size2D(vk::Extent2D const extent)
: m_Width{extent.width} : m_Width{extent.width}
, m_Height{extent.height} , m_Height{extent.height}
{ {
} }
Size2D & Size2D &
operator=(const vk::Extent2D other) operator=(vk::Extent2D const other)
{ {
m_Height = other.height; m_Height = other.height;
m_Width = other.width; m_Width = other.width;
return *this; return *this;
} }
bool operator==(const Size2D&) const = default; bool operator==(Size2D const &) const = default;
operator vk::Extent2D() const operator vk::Extent2D() const
{ {

View File

@ -18,7 +18,7 @@ struct Surface
// Ctor Dtor // Ctor Dtor
Surface() = default; Surface() = default;
Surface(Instance &context, const Window &window); Surface(Instance &context, Window const &window);
~Surface(); ~Surface();
// Move // Move

View File

@ -19,7 +19,7 @@ struct Swapchain final
{ {
using FnResizeCallback = eastl::function<void(vk::Extent2D)>; using FnResizeCallback = eastl::function<void(vk::Extent2D)>;
const Device *m_Device; Device const *m_Device;
vk::SwapchainKHR m_Swapchain; vk::SwapchainKHR m_Swapchain;
vk::Extent2D m_Extent; vk::Extent2D m_Extent;
vk::Format m_Format; vk::Format m_Format;
@ -28,12 +28,12 @@ struct Swapchain final
eastl::vector<FnResizeCallback> m_ResizeCallbacks; eastl::vector<FnResizeCallback> m_ResizeCallbacks;
void Create(const Surface &surface, Size2D size); void Create(Surface const &surface, Size2D size);
void RegisterResizeCallback(FnResizeCallback &&callback); void RegisterResizeCallback(FnResizeCallback &&callback);
// Ctor/Dtor // Ctor/Dtor
Swapchain() = default; Swapchain() = default;
Swapchain(const Surface &surface, const Device &device, Size2D size); Swapchain(Surface const &surface, Device const &device, Size2D size);
~Swapchain(); ~Swapchain();
// Move // Move
@ -42,6 +42,6 @@ struct Swapchain final
DISALLOW_COPY_AND_ASSIGN(Swapchain); DISALLOW_COPY_AND_ASSIGN(Swapchain);
private: private:
void Cleanup(); void Cleanup();
}; };

View File

@ -32,7 +32,7 @@ struct Window final
} }
void RequestExit() const noexcept; 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; void SetWindowSize(u32 width, u32 height) const noexcept;
/// Actual size of the framebuffer being used for the window render. /// Actual size of the framebuffer being used for the window render.
[[nodiscard]] Size2D GetSize() const; [[nodiscard]] Size2D GetSize() const;

View File

@ -12,11 +12,11 @@
#include "EASTL/deque.h" #include "EASTL/deque.h"
#include "EASTL/intrusive_hash_map.h" #include "EASTL/intrusive_hash_map.h"
#include "resource.h"
#include "EASTL/vector.h" #include "EASTL/vector.h"
#include "aster/core/buffer.h" #include "aster/core/buffer.h"
#include "aster/core/image_view.h" #include "aster/core/image_view.h"
#include "aster/core/sampler.h" #include "aster/core/sampler.h"
#include "resource.h"
namespace systems namespace systems
{ {
@ -38,14 +38,14 @@ class CommitManager
void void
AddRef() AddRef()
{ {
const auto rc = ++m_CommitCount; auto const rc = ++m_CommitCount;
assert(rc > 0); assert(rc > 0);
} }
void void
Release() Release()
{ {
const auto rc = --m_CommitCount; auto const rc = --m_CommitCount;
assert(rc < MaxValue<u32>); assert(rc < MaxValue<u32>);
} }
@ -56,7 +56,7 @@ class CommitManager
} }
bool bool
operator==(const Entry &other) const operator==(Entry const &other) const
{ {
return this->mKey == other.mKey; return this->mKey == other.mKey;
} }
@ -76,7 +76,7 @@ class CommitManager
struct Hash struct Hash
{ {
usize usize
operator()(const Handle &e) operator()(Handle const &e)
{ {
return eastl::hash<Type *>()(e.get()); return eastl::hash<Type *>()(e.get());
} }
@ -89,7 +89,7 @@ class CommitManager
std::array<FreeList<Entry>, 4> m_ToDelete; std::array<FreeList<Entry>, 4> m_ToDelete;
u8 m_ToDeleteIndex = 0; u8 m_ToDeleteIndex = 0;
explicit HandleMapper(const u32 maxCount) explicit HandleMapper(u32 const maxCount)
: m_Data{maxCount} : m_Data{maxCount}
{ {
// Setup freelist // Setup freelist
@ -111,7 +111,7 @@ class CommitManager
/// Returns a commit, and a bool signifying if it is a new commit. /// Returns a commit, and a bool signifying if it is a new commit.
std::tuple<Resource, bool> std::tuple<Resource, bool>
Create(const Handle &object) Create(Handle const &object)
{ {
// Get-from freelist // Get-from freelist
assert(!m_FreeList.Empty()); assert(!m_FreeList.Empty());
@ -137,19 +137,19 @@ class CommitManager
} }
Handle Handle
GetHandle(const Resource &res) GetHandle(Resource const &res)
{ {
return m_Data[res.m_Index].mKey; return m_Data[res.m_Index].mKey;
} }
void void
AddRef(const Resource &commit) AddRef(Resource const &commit)
{ {
m_Data.at(commit.m_Index).AddRef(); m_Data.at(commit.m_Index).AddRef();
} }
void void
Release(const Resource &commit) Release(Resource const &commit)
{ {
auto &entry = m_Data.at(commit.m_Index); auto &entry = m_Data.at(commit.m_Index);
entry.Release(); entry.Release();
@ -173,7 +173,7 @@ class CommitManager
private: private:
u32 u32
GetIndex(const Entry &entry) GetIndex(Entry const &entry)
{ {
return static_cast<u32>(&entry - m_Data.begin()); return static_cast<u32>(&entry - m_Data.begin());
} }
@ -202,9 +202,9 @@ class CommitManager
vk::DescriptorImageInfo uImageInfo; vk::DescriptorImageInfo uImageInfo;
vk::BufferView uBufferView; vk::BufferView uBufferView;
explicit WriteInfo(const vk::DescriptorBufferInfo &info); explicit WriteInfo(vk::DescriptorBufferInfo const &info);
explicit WriteInfo(const vk::DescriptorImageInfo &info); explicit WriteInfo(vk::DescriptorImageInfo const &info);
explicit WriteInfo(const vk::BufferView &info); explicit WriteInfo(vk::BufferView const &info);
}; };
using WriteCommand = vk::WriteDescriptorSet; using WriteCommand = vk::WriteDescriptorSet;
@ -212,69 +212,69 @@ class CommitManager
// using WriteOwner = std::variant<Handle<Buffer>, Handle<Image>>; // using WriteOwner = std::variant<Handle<Buffer>, Handle<Image>>;
public: 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<Sampler> defaultSampler); Ref<Sampler> defaultSampler);
~CommitManager(); ~CommitManager();
PIN_MEMORY(CommitManager); PIN_MEMORY(CommitManager);
// Commit Buffer // Commit Buffer
ResId<Buffer> CommitBuffer(const Ref<Buffer> &buffer); ResId<Buffer> CommitBuffer(Ref<Buffer> const &buffer);
// Commit Storage Images // Commit Storage Images
ResId<StorageImageView> ResId<StorageImageView>
CommitStorageImage(const concepts::ViewRefTo<StorageImage> auto &image) CommitStorageImage(concepts::ViewRefTo<StorageImage> auto const &image)
{ {
return CommitStorageImage(CastView<StorageImageView>(image)); return CommitStorageImage(CastView<StorageImageView>(image));
} }
ResId<StorageImageView> CommitStorageImage(const Ref<StorageImageView> &image); ResId<StorageImageView> CommitStorageImage(Ref<StorageImageView> const &image);
// Sampled Images // Sampled Images
ResId<TextureView> ResId<TextureView>
CommitTexture(const concepts::ViewRefTo<Texture> auto &image, const Ref<Sampler> &sampler) CommitTexture(concepts::ViewRefTo<Texture> auto const &image, Ref<Sampler> const &sampler)
{ {
return CommitTexture(CastView<TextureView>(image), sampler); return CommitTexture(CastView<TextureView>(image), sampler);
} }
ResId<TextureView> ResId<TextureView>
CommitTexture(const concepts::ViewRefTo<Texture> auto &image) CommitTexture(concepts::ViewRefTo<Texture> auto const &image)
{ {
return CommitTexture(CastView<TextureView>(image)); return CommitTexture(CastView<TextureView>(image));
} }
ResId<TextureView> CommitTexture(const Ref<TextureView> &handle); ResId<TextureView> CommitTexture(Ref<TextureView> const &handle);
ResId<TextureView> CommitTexture(const Ref<TextureView> &image, const Ref<Sampler> &sampler); ResId<TextureView> CommitTexture(Ref<TextureView> const &image, Ref<Sampler> const &sampler);
void Update(); void Update();
Ref<Buffer> Ref<Buffer>
FetchHandle(const ResId<Buffer> &id) FetchHandle(ResId<Buffer> const &id)
{ {
return m_Buffers.GetHandle(id); return m_Buffers.GetHandle(id);
} }
Ref<TextureView> Ref<TextureView>
FetchHandle(const ResId<TextureView> &id) FetchHandle(ResId<TextureView> const &id)
{ {
return m_Images.GetHandle(id); return m_Images.GetHandle(id);
} }
Ref<StorageImageView> Ref<StorageImageView>
FetchHandle(const ResId<StorageImageView> &id) FetchHandle(ResId<StorageImageView> const &id)
{ {
return m_StorageImages.GetHandle(id); return m_StorageImages.GetHandle(id);
} }
[[nodiscard]] const vk::DescriptorSetLayout & [[nodiscard]] vk::DescriptorSetLayout const &
GetDescriptorSetLayout() const GetDescriptorSetLayout() const
{ {
return m_SetLayout; return m_SetLayout;
} }
[[nodiscard]] const vk::DescriptorSet & [[nodiscard]] vk::DescriptorSet const &
GetDescriptorSet() const GetDescriptorSet() const
{ {
return m_DescriptorSet; return m_DescriptorSet;
@ -287,7 +287,8 @@ class CommitManager
return *m_Instance; return *m_Instance;
} }
static bool IsInit() static bool
IsInit()
{ {
return static_cast<bool>(m_Instance); return static_cast<bool>(m_Instance);
} }
@ -317,37 +318,37 @@ class CommitManager
friend ResId<StorageImageView>; friend ResId<StorageImageView>;
void void
AddRef(const ResId<Buffer> &handle) AddRef(ResId<Buffer> const &handle)
{ {
m_Buffers.AddRef(handle); m_Buffers.AddRef(handle);
} }
void void
AddRef(const ResId<TextureView> &handle) AddRef(ResId<TextureView> const &handle)
{ {
m_Images.AddRef(handle); m_Images.AddRef(handle);
} }
void void
AddRef(const ResId<StorageImageView> &handle) AddRef(ResId<StorageImageView> const &handle)
{ {
m_StorageImages.AddRef(handle); m_StorageImages.AddRef(handle);
} }
void void
Release(const ResId<Buffer> &handle) Release(ResId<Buffer> const &handle)
{ {
m_Buffers.Release(handle); m_Buffers.Release(handle);
} }
void void
Release(const ResId<TextureView> &handle) Release(ResId<TextureView> const &handle)
{ {
m_Images.Release(handle); m_Images.Release(handle);
} }
void void
Release(const ResId<StorageImageView> &handle) Release(ResId<StorageImageView> const &handle)
{ {
m_StorageImages.Release(handle); m_StorageImages.Release(handle);
} }

View File

@ -48,21 +48,21 @@ class Context
friend Device; friend Device;
friend _internal::ContextPool; 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_Pool{&pool}
, m_Cmd{cmd} , m_Cmd{cmd}
{ {
} }
/// Keep the resource alive while the command buffers are acting. /// Keep the resource alive while the command buffers are acting.
void KeepAlive(const Ref<Buffer> &buffer); void KeepAlive(Ref<Buffer> const &buffer);
/// Keep the resource alive while the command buffers are acting. /// Keep the resource alive while the command buffers are acting.
void KeepAlive(const Ref<Image> &image); void KeepAlive(Ref<Image> const &image);
/// Keep the resource alive while the command buffers are acting. /// Keep the resource alive while the command buffers are acting.
void KeepAlive(const Ref<ImageView> &view); void KeepAlive(Ref<ImageView> const &view);
public: public:
DEPRECATE_RAW_CALLS void Dependency(const vk::DependencyInfo &dependencyInfo); DEPRECATE_RAW_CALLS void Dependency(vk::DependencyInfo const &dependencyInfo);
void Begin(); void Begin();
void End(); void End();
@ -90,24 +90,24 @@ class TransferContext : public Context
friend Device; friend Device;
friend _internal::TransferContextPool; friend _internal::TransferContextPool;
explicit TransferContext(_internal::ContextPool &pool, const vk::CommandBuffer cmd) explicit TransferContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd)
: Context{pool, cmd} : Context{pool, cmd}
{ {
} }
void UploadBuffer(const Ref<Buffer> &buffer, usize size, const void *data); void UploadBuffer(Ref<Buffer> const &buffer, usize size, void const *data);
public: public:
void UploadTexture(const Ref<Image> &image, const eastl::span<u8> &data); void UploadTexture(Ref<Image> const &image, eastl::span<u8> const &data);
void void
UploadBuffer(const Ref<Buffer> &buffer, const std::ranges::range auto &data) UploadBuffer(Ref<Buffer> 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()); 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(TransferContext &&other) noexcept;
TransferContext &operator=(TransferContext &&other) noexcept; TransferContext &operator=(TransferContext &&other) noexcept;
@ -123,22 +123,23 @@ class ComputeContext : public TransferContext
friend Device; friend Device;
friend _internal::ComputeContextPool; 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} : TransferContext{pool, cmd}
, m_PipelineInUse{nullptr} , 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: public:
void BindPipeline(const Pipeline &pipeline); void BindPipeline(Pipeline const &pipeline);
void void
PushConstantBlock(const auto &block) PushConstantBlock(auto const &block)
{ {
if constexpr (sizeof block > 128) if constexpr (sizeof block > 128)
WARN("Vulkan only guarantees 128 bytes of Push Constants. Size of PCB is {}", sizeof block); WARN("Vulkan only guarantees 128 bytes of Push Constants. Size of PCB is {}", sizeof block);
@ -146,7 +147,7 @@ class ComputeContext : public TransferContext
} }
void void
PushConstantBlock(const usize offset, const auto &block) PushConstantBlock(usize const offset, auto const &block)
{ {
if (offset + sizeof block > 128) if (offset + sizeof block > 128)
WARN("Vulkan only guarantees 128 bytes of Push Constants. Size of PCB is {}, at offset {}", sizeof block, 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 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) if constexpr (sizeof pushConstantBlock > 128)
WARN("Vulkan only guarantees 128 bytes of Push Constants. Size of PCB is {}", sizeof pushConstantBlock); 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 Device;
friend _internal::GraphicsContextPool; friend _internal::GraphicsContextPool;
explicit GraphicsContext(_internal::ContextPool &pool, const vk::CommandBuffer cmd) explicit GraphicsContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd)
: ComputeContext{pool, cmd} : ComputeContext{pool, cmd}
{ {
} }
public: public:
DEPRECATE_RAW_CALLS void SetViewport(const vk::Viewport &viewport); DEPRECATE_RAW_CALLS void SetViewport(vk::Viewport const &viewport);
void BindVertexBuffer(const Ref<VertexBuffer> &vertexBuffer); void BindVertexBuffer(Ref<VertexBuffer> const &vertexBuffer);
void BindIndexBuffer(const Ref<IndexBuffer> &indexBuffer); void BindIndexBuffer(Ref<IndexBuffer> const &indexBuffer);
void Draw(usize vertexCount); void Draw(usize vertexCount);
void DrawIndexed(usize indexCount); void DrawIndexed(usize indexCount);
void DrawIndexed(usize indexCount, usize firstIndex, usize firstVertex); 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(); void EndRendering();
DEPRECATE_RAW_CALLS vk::CommandBuffer DEPRECATE_RAW_CALLS vk::CommandBuffer
@ -230,11 +231,11 @@ class ContextPool
eastl::function<void(ContextPool &)> m_ResetCallback; eastl::function<void(ContextPool &)> m_ResetCallback;
/// Keep the resource alive while the command buffers are acting. /// Keep the resource alive while the command buffers are acting.
void KeepAlive(const Ref<Buffer> &buffer); void KeepAlive(Ref<Buffer> const &buffer);
/// Keep the resource alive while the command buffers are acting. /// Keep the resource alive while the command buffers are acting.
void KeepAlive(const Ref<Image> &image); void KeepAlive(Ref<Image> const &image);
/// Keep the resource alive while the command buffers are acting. /// Keep the resource alive while the command buffers are acting.
void KeepAlive(const Ref<ImageView> &view); void KeepAlive(Ref<ImageView> const &view);
Context CreateContext(); Context CreateContext();
@ -247,7 +248,7 @@ class ContextPool
ContextPool &operator=(ContextPool &&other) noexcept; ContextPool &operator=(ContextPool &&other) noexcept;
bool bool
operator==(const ContextPool &other) const operator==(ContextPool const &other) const
{ {
return m_Pool == other.m_Pool; return m_Pool == other.m_Pool;
} }
@ -264,7 +265,7 @@ class TransferContextPool : public ContextPool
TransferContextPool() = default; TransferContextPool() = default;
TransferContextPool(Device &device, const u32 queueFamilyIndex, const ManagedBy managedBy) TransferContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy)
: ContextPool{device, queueFamilyIndex, managedBy} : ContextPool{device, queueFamilyIndex, managedBy}
{ {
} }
@ -283,7 +284,8 @@ class ComputeContextPool : public TransferContextPool
ComputeContext CreateComputeContext(); ComputeContext CreateComputeContext();
ComputeContextPool() = default; ComputeContextPool() = default;
ComputeContextPool(Device &device, const u32 queueFamilyIndex, const ManagedBy managedBy)
ComputeContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy)
: TransferContextPool{device, queueFamilyIndex, managedBy} : TransferContextPool{device, queueFamilyIndex, managedBy}
{ {
} }
@ -302,7 +304,8 @@ class GraphicsContextPool : public ComputeContextPool
GraphicsContext CreateGraphicsContext(); GraphicsContext CreateGraphicsContext();
GraphicsContextPool() = default; GraphicsContextPool() = default;
GraphicsContextPool(Device &device, const u32 queueFamilyIndex, const ManagedBy managedBy)
GraphicsContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy)
: ComputeContextPool{device, queueFamilyIndex, managedBy} : ComputeContextPool{device, queueFamilyIndex, managedBy}
{ {
} }
@ -325,7 +328,7 @@ class OrderlessContextPool
ContextPoolType m_Pool; ContextPoolType m_Pool;
bool bool
Contains(const ContextPool &other) const Contains(ContextPool const &other) const
{ {
return m_Pool == other; return m_Pool == other;
} }
@ -352,7 +355,7 @@ class OrderlessContextPool
} }
void void
Init(Device &device, const u32 queueFamilyIndex) Init(Device &device, u32 const queueFamilyIndex)
{ {
m_Device = &device; m_Device = &device;
m_QueueFamilyIndex = queueFamilyIndex; m_QueueFamilyIndex = queueFamilyIndex;
@ -410,7 +413,7 @@ class OrderlessContextPool
ReleasePool(ContextPool &pool) ReleasePool(ContextPool &pool)
{ {
auto const found = eastl::find_if(m_UsedContextPools.begin(), m_UsedContextPools.end(), 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; auto &v = *found;
ContextListType::remove(v); ContextListType::remove(v);

View File

@ -36,7 +36,7 @@ template <>
struct eastl::hash<vk::SamplerCreateInfo> struct eastl::hash<vk::SamplerCreateInfo>
{ {
usize usize
operator()(const vk::SamplerCreateInfo &createInfo) const noexcept operator()(vk::SamplerCreateInfo const &createInfo) const noexcept
{ {
usize hash = HashAny(createInfo.flags); usize hash = HashAny(createInfo.flags);
hash = HashCombine(hash, HashAny(createInfo.magFilter)); hash = HashCombine(hash, HashAny(createInfo.magFilter));
@ -235,6 +235,7 @@ struct AttributeInfo
{ {
u32 m_Location; u32 m_Location;
u32 m_Offset; u32 m_Offset;
enum class Format enum class Format
{ {
eFloat32X4, eFloat32X4,
@ -321,7 +322,7 @@ struct GraphicsPipelineCreateInfo
cstr m_Name; cstr m_Name;
private: private:
friend Device; friend Device;
[[nodiscard]] vk::PipelineDepthStencilStateCreateInfo GetDepthStencilStateCreateInfo() const; [[nodiscard]] vk::PipelineDepthStencilStateCreateInfo GetDepthStencilStateCreateInfo() const;
}; };
@ -338,9 +339,9 @@ struct ComputePipelineCreateInfo
#pragma region Device #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<decltype(DefaultPhysicalDeviceSelector), PhysicalDeviceSelectorFn>); static_assert(std::convertible_to<decltype(DefaultPhysicalDeviceSelector), PhysicalDeviceSelectorFn>);
struct DeviceCreateInfo struct DeviceCreateInfo
@ -373,6 +374,7 @@ class Receipt
: m_Opaque{opaque} : m_Opaque{opaque}
{ {
} }
friend _internal::SyncServer; friend _internal::SyncServer;
}; };
@ -462,22 +464,22 @@ class Device final
template <concepts::ImageInto<Texture> T> template <concepts::ImageInto<Texture> T>
[[nodiscard]] Ref<T> [[nodiscard]] Ref<T>
CreateTexture2D(const Texture2DCreateInfo &createInfo) CreateTexture2D(Texture2DCreateInfo const &createInfo)
{ {
return CastImage<T>(CreateTexture2D(createInfo)); return CastImage<T>(CreateTexture2D(createInfo));
} }
template <concepts::ImageInto<TextureCube> T> template <concepts::ImageInto<TextureCube> T>
[[nodiscard]] Ref<T> [[nodiscard]] Ref<T>
CreateTextureCube(const TextureCubeCreateInfo &createInfo) CreateTextureCube(TextureCubeCreateInfo const &createInfo)
{ {
return CastImage<T>(CreateTextureCube(createInfo)); return CastImage<T>(CreateTextureCube(createInfo));
} }
[[nodiscard]] Ref<Image> CreateTexture2D(const Texture2DCreateInfo &createInfo); [[nodiscard]] Ref<Image> CreateTexture2D(Texture2DCreateInfo const &createInfo);
[[nodiscard]] Ref<ImageCube> CreateTextureCube(const TextureCubeCreateInfo &createInfo); [[nodiscard]] Ref<ImageCube> CreateTextureCube(TextureCubeCreateInfo const &createInfo);
[[nodiscard]] Ref<Image> CreateAttachment(const AttachmentCreateInfo &createInfo); [[nodiscard]] Ref<Image> CreateAttachment(AttachmentCreateInfo const &createInfo);
[[nodiscard]] Ref<Image> CreateDepthStencilImage(const DepthStencilImageCreateInfo &createInfo); [[nodiscard]] Ref<Image> CreateDepthStencilImage(DepthStencilImageCreateInfo const &createInfo);
// //
// View Management // View Management
@ -485,12 +487,12 @@ class Device final
template <concepts::View TImageView> template <concepts::View TImageView>
Ref<TImageView> Ref<TImageView>
CreateView(const ViewCreateInfo<typename TImageView::ImageType> &createInfo) CreateView(ViewCreateInfo<typename TImageView::ImageType> const &createInfo)
{ {
return CastView<TImageView>(CreateView(ViewCreateInfo<Image>(createInfo))); return CastView<TImageView>(CreateView(ViewCreateInfo<Image>(createInfo)));
} }
[[nodiscard]] Ref<ImageView> CreateView(const ViewCreateInfo<Image> &createInfo); [[nodiscard]] Ref<ImageView> CreateView(ViewCreateInfo<Image> const &createInfo);
// //
// Image - View Combined Management // Image - View Combined Management
@ -498,7 +500,7 @@ class Device final
template <concepts::ViewTo<Image> T> template <concepts::ViewTo<Image> T>
[[nodiscard]] Ref<T> [[nodiscard]] Ref<T>
CreateTexture2DWithView(const Texture2DCreateInfo &createInfo) CreateTexture2DWithView(Texture2DCreateInfo const &createInfo)
{ {
auto handle = CreateTexture2DWithView(createInfo); auto handle = CreateTexture2DWithView(createInfo);
return CastView<T>(handle); return CastView<T>(handle);
@ -506,16 +508,16 @@ class Device final
template <concepts::ViewTo<ImageCube> T> template <concepts::ViewTo<ImageCube> T>
[[nodiscard]] Ref<T> [[nodiscard]] Ref<T>
CreateTextureCubeWithView(const TextureCubeCreateInfo &createInfo) CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo)
{ {
auto handle = CreateTextureCubeWithView(createInfo); auto handle = CreateTextureCubeWithView(createInfo);
return CastView<T>(handle); return CastView<T>(handle);
} }
[[nodiscard]] Ref<TextureView> CreateTexture2DWithView(const Texture2DCreateInfo &createInfo); [[nodiscard]] Ref<TextureView> CreateTexture2DWithView(Texture2DCreateInfo const &createInfo);
[[nodiscard]] Ref<ImageCubeView> CreateTextureCubeWithView(const TextureCubeCreateInfo &createInfo); [[nodiscard]] Ref<ImageCubeView> CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo);
[[nodiscard]] Ref<ImageView> CreateAttachmentWithView(const AttachmentCreateInfo &createInfo); [[nodiscard]] Ref<ImageView> CreateAttachmentWithView(AttachmentCreateInfo const &createInfo);
[[nodiscard]] Ref<ImageView> CreateDepthStencilImageWithView(const DepthStencilImageCreateInfo &createInfo); [[nodiscard]] Ref<ImageView> CreateDepthStencilImageWithView(DepthStencilImageCreateInfo const &createInfo);
// //
// Sampler Management // Sampler Management
@ -525,7 +527,7 @@ class Device final
eastl::hash_map<vk::SamplerCreateInfo, WeakRef<Sampler>> m_HashToSamplerIdx; eastl::hash_map<vk::SamplerCreateInfo, WeakRef<Sampler>> m_HashToSamplerIdx;
public: public:
Ref<Sampler> CreateSampler(const SamplerCreateInfo &createInfo); Ref<Sampler> CreateSampler(SamplerCreateInfo const &createInfo);
// //
// Pipeline // Pipeline
@ -538,17 +540,17 @@ class Device final
PipelineCreationError PipelineCreationError
CreateShaders(eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> &shadersOut, CreateShaders(eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> &shadersOut,
Slang::ComPtr<slang::IComponentType> &program, const std::span<const ShaderInfo> &shaders); Slang::ComPtr<slang::IComponentType> &program, std::span<ShaderInfo const> const &shaders);
systems::PipelineCreationError systems::PipelineCreationError
CreateShader(vk::PipelineShaderStageCreateInfo &shadersOut, Slang::ComPtr<slang::IComponentType> &program, CreateShader(vk::PipelineShaderStageCreateInfo &shadersOut, Slang::ComPtr<slang::IComponentType> &program,
const ShaderInfo &shaders); ShaderInfo const &shaders);
PipelineCreationError PipelineCreationError
CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, const Slang::ComPtr<slang::IComponentType> &program); CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, Slang::ComPtr<slang::IComponentType> const &program);
public: public:
// Pipelines, unlike the other resources, are not ref-counted. // Pipelines, unlike the other resources, are not ref-counted.
PipelineCreationError CreatePipeline(Pipeline &pipeline, const GraphicsPipelineCreateInfo &createInfo); PipelineCreationError CreatePipeline(Pipeline &pipeline, GraphicsPipelineCreateInfo const &createInfo);
PipelineCreationError CreateComputePipeline(Pipeline &pipeline, const ComputePipelineCreateInfo &createInfo); PipelineCreationError CreateComputePipeline(Pipeline &pipeline, ComputePipelineCreateInfo const &createInfo);
// //
// Frames // Frames
@ -556,6 +558,7 @@ class Device final
public: public:
Frame &GetNextFrame(); Frame &GetNextFrame();
Size2D Size2D
GetSwapchainSize() const GetSwapchainSize() const
{ {
@ -594,13 +597,13 @@ class Device final
template <concepts::VkHandle T> template <concepts::VkHandle T>
void void
SetName(const T &object, cstr name) const SetName(T const &object, cstr name) const
{ {
m_Device.SetName(object, name); m_Device.SetName(object, name);
} }
[[nodiscard]] vk::Queue [[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); return m_Device.GetQueue(familyIndex, queueIndex);
} }
@ -634,7 +637,7 @@ class Device final
// Ctor/Dtor // Ctor/Dtor
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------
explicit Device(const DeviceCreateInfo &createInfo); explicit Device(DeviceCreateInfo const &createInfo);
~Device(); ~Device();

View File

@ -44,11 +44,12 @@ struct PipelineLayoutBuilder
[[nodiscard]] vk::PipelineLayout Build(); [[nodiscard]] vk::PipelineLayout Build();
[[nodiscard]] vk::DescriptorSetLayout CreateDescriptorSetLayout(const vk::DescriptorSetLayoutCreateInfo &createInfo) const; [[nodiscard]] vk::DescriptorSetLayout
void AddDescriptorSetForParameterBlock(slang::TypeLayoutReflection * layout); CreateDescriptorSetLayout(vk::DescriptorSetLayoutCreateInfo const &createInfo) const;
void AddPushConstantRangeForConstantBuffer(slang::TypeLayoutReflection * layout); void AddDescriptorSetForParameterBlock(slang::TypeLayoutReflection *layout);
void AddSubObjectRange(slang::TypeLayoutReflection * layout, i64 subObjectRangeIndex); void AddPushConstantRangeForConstantBuffer(slang::TypeLayoutReflection *layout);
void AddSubObjectRanges(slang::TypeLayoutReflection * layout); void AddSubObjectRange(slang::TypeLayoutReflection *layout, i64 subObjectRangeIndex);
void AddSubObjectRanges(slang::TypeLayoutReflection *layout);
}; };
struct DescriptorLayoutBuilder struct DescriptorLayoutBuilder

View File

@ -23,7 +23,7 @@ namespace systems
template <std::derived_from<Buffer> TTo, std::derived_from<Buffer> TFrom> template <std::derived_from<Buffer> TTo, std::derived_from<Buffer> TFrom>
static Ref<TTo> static Ref<TTo>
CastBuffer(const Ref<TFrom> &from) CastBuffer(Ref<TFrom> const &from)
{ {
if constexpr (not concepts::BufferInto<TFrom, TTo>) if constexpr (not concepts::BufferInto<TFrom, TTo>)
assert(TTo::FLAGS & from->m_Flags); assert(TTo::FLAGS & from->m_Flags);
@ -37,7 +37,7 @@ CastBuffer(const Ref<TFrom> &from)
template <std::derived_from<Image> TTo, std::derived_from<Image> TFrom> template <std::derived_from<Image> TTo, std::derived_from<Image> TFrom>
static Ref<TTo> static Ref<TTo>
CastImage(const Ref<TFrom> &from) CastImage(Ref<TFrom> const &from)
{ {
if constexpr (not concepts::ImageInto<TFrom, TTo>) if constexpr (not concepts::ImageInto<TFrom, TTo>)
assert(TTo::FLAGS & from->m_Flags_); assert(TTo::FLAGS & from->m_Flags_);
@ -50,7 +50,7 @@ CastImage(const Ref<TFrom> &from)
template <concepts::View TTo, std::derived_from<Image> TFrom> template <concepts::View TTo, std::derived_from<Image> TFrom>
static Ref<TTo> static Ref<TTo>
CastView(const Ref<View<TFrom>> &from) CastView(Ref<View<TFrom>> const &from)
{ {
if constexpr (not concepts::ImageInto<TFrom, typename TTo::ImageType>) if constexpr (not concepts::ImageInto<TFrom, typename TTo::ImageType>)
assert(TTo::ImageType::FLAGS & from->m_Image->m_Flags_); assert(TTo::ImageType::FLAGS & from->m_Image->m_Flags_);
@ -60,8 +60,6 @@ CastView(const Ref<View<TFrom>> &from)
#pragma endregion #pragma endregion
/** /**
* ResId manages the lifetime of the committed resource. * ResId manages the lifetime of the committed resource.
* @tparam T Type of the committed resource. * @tparam T Type of the committed resource.
@ -70,6 +68,7 @@ template <typename T>
class ResId class ResId
{ {
using IdType = u32; using IdType = u32;
public: public:
constexpr static IdType INVALID = MaxValue<IdType>; constexpr static IdType INVALID = MaxValue<IdType>;
@ -77,7 +76,7 @@ class ResId
IdType m_Index; IdType m_Index;
u32 m_Padding = 0; //< Slang DescriptorHandle are a pair of u32. TODO: Use as validation. 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} : m_Index{index}
{ {
AddRef(); AddRef();
@ -92,7 +91,7 @@ class ResId
return ResId{INVALID}; return ResId{INVALID};
} }
ResId(const ResId &other) ResId(ResId const &other)
: m_Index{other.m_Index} : m_Index{other.m_Index}
{ {
AddRef(); AddRef();
@ -105,7 +104,7 @@ class ResId
} }
ResId & ResId &
operator=(const ResId &other) operator=(ResId const &other)
{ {
if (this == &other) if (this == &other)
return *this; return *this;

View File

@ -20,7 +20,7 @@ struct FreeList
{ {
using Value = T; using Value = T;
using Reference = T &; using Reference = T &;
using ConstReference = const T &; using ConstReference = T const &;
using Pointer = T *; using Pointer = T *;
FreeListNode *m_Top; FreeListNode *m_Top;

View File

@ -29,7 +29,7 @@ struct Logger
} }
template <LogType TLogLevel> template <LogType TLogLevel>
constexpr static const char * constexpr static char const *
ToCstr() ToCstr()
{ {
if constexpr (TLogLevel == LogType::eError) if constexpr (TLogLevel == LogType::eError)
@ -45,7 +45,7 @@ struct Logger
} }
template <LogType TLogLevel> template <LogType TLogLevel>
constexpr static const char * constexpr static char const *
ToColorCstr() ToColorCstr()
{ {
if constexpr (TLogLevel == LogType::eError) if constexpr (TLogLevel == LogType::eError)
@ -62,7 +62,7 @@ struct Logger
template <LogType TLogLevel> template <LogType TLogLevel>
void 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<u32>(TLogLevel) <= m_MinimumLoggingLevel) if (static_cast<u32>(TLogLevel) <= m_MinimumLoggingLevel)
{ {
@ -79,7 +79,7 @@ struct Logger
template <LogType TLogLevel> template <LogType TLogLevel>
void 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<u32>(TLogLevel) <= m_MinimumLoggingLevel) if (static_cast<u32>(TLogLevel) <= m_MinimumLoggingLevel)
{ {
@ -103,26 +103,26 @@ extern Logger g_Logger;
#define INFO(...) g_Logger.Log<Logger::LogType::eInfo>(fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define INFO(...) g_Logger.Log<Logger::LogType::eInfo>(fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ERROR_IF(expr, ...) \ #define ERROR_IF(expr, ...) \
if (static_cast<bool>(expr)) [[unlikely]] \ if (static_cast<bool>(expr)) [[unlikely]] \
g_Logger.LogCond<Logger::LogType::eError>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) g_Logger.LogCond<Logger::LogType::eError>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define WARN_IF(expr, ...) \ #define WARN_IF(expr, ...) \
if (static_cast<bool>(expr)) [[unlikely]] \ if (static_cast<bool>(expr)) [[unlikely]] \
g_Logger.LogCond<Logger::LogType::eWarning>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) g_Logger.LogCond<Logger::LogType::eWarning>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define INFO_IF(expr, ...) \ #define INFO_IF(expr, ...) \
if (static_cast<bool>(expr)) \ if (static_cast<bool>(expr)) \
g_Logger.LogCond<Logger::LogType::eInfo>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) g_Logger.LogCond<Logger::LogType::eInfo>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ELSE_IF_ERROR(expr, ...) \ #define ELSE_IF_ERROR(expr, ...) \
; \ ; \
else if (static_cast<bool>(expr)) \ else if (static_cast<bool>(expr)) \
[[unlikely]] g_Logger.LogCond<Logger::LogType::eError>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) [[unlikely]] g_Logger.LogCond<Logger::LogType::eError>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ELSE_IF_WARN(expr, ...) \ #define ELSE_IF_WARN(expr, ...) \
; \ ; \
else if (static_cast<bool>(expr)) \ else if (static_cast<bool>(expr)) \
[[unlikely]] g_Logger.LogCond<Logger::LogType::eWarning>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) [[unlikely]] g_Logger.LogCond<Logger::LogType::eWarning>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ELSE_IF_INFO(expr, ...) \ #define ELSE_IF_INFO(expr, ...) \
; \ ; \
else if (static_cast<bool>(expr)) \ else if (static_cast<bool>(expr)) \
g_Logger.LogCond<Logger::LogType::eInfo>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) g_Logger.LogCond<Logger::LogType::eInfo>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ELSE_ERROR(...) \ #define ELSE_ERROR(...) \
@ -139,11 +139,11 @@ extern Logger g_Logger;
#define DEBUG(...) g_Logger.Log<Logger::LogType::eDebug>(fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define DEBUG(...) g_Logger.Log<Logger::LogType::eDebug>(fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define DEBUG_IF(expr, ...) \ #define DEBUG_IF(expr, ...) \
if (static_cast<bool>(expr)) \ if (static_cast<bool>(expr)) \
g_Logger.LogCond<Logger::LogType::eDebug>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) g_Logger.LogCond<Logger::LogType::eDebug>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ELSE_IF_DEBUG(expr, ...) \ #define ELSE_IF_DEBUG(expr, ...) \
; \ ; \
else if (static_cast<bool>(expr)) \ else if (static_cast<bool>(expr)) \
g_Logger.LogCond<Logger::LogType::eDebug>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) g_Logger.LogCond<Logger::LogType::eDebug>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ELSE_DEBUG(...) \ #define ELSE_DEBUG(...) \
; \ ; \
@ -174,11 +174,11 @@ extern Logger g_Logger;
#define VERBOSE(...) g_Logger.Log<Logger::LogType::eVerbose>(fmt::format(__VA_ARGS__), __FILE__, __LINE__) #define VERBOSE(...) g_Logger.Log<Logger::LogType::eVerbose>(fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define VERBOSE_IF(expr, ...) \ #define VERBOSE_IF(expr, ...) \
if (static_cast<bool>(expr)) \ if (static_cast<bool>(expr)) \
g_Logger.LogCond<Logger::LogType::eVerbose>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) g_Logger.LogCond<Logger::LogType::eVerbose>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ELSE_IF_VERBOSE(expr, ...) \ #define ELSE_IF_VERBOSE(expr, ...) \
; \ ; \
else if (static_cast<bool>(expr)) \ else if (static_cast<bool>(expr)) \
g_Logger.LogCond<Logger::LogType::eVerbose>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__) g_Logger.LogCond<Logger::LogType::eVerbose>(#expr, fmt::format(__VA_ARGS__), __FILE__, __LINE__)
#define ELSE_VERBOSE(...) \ #define ELSE_VERBOSE(...) \
; \ ; \

View File

@ -7,8 +7,8 @@
#include "core/device.h" #include "core/device.h"
Buffer::Buffer(const Device *device, const usize size, const vk::BufferUsageFlags bufferUsage, Buffer::Buffer(Device const *device, usize const size, vk::BufferUsageFlags const bufferUsage,
const VmaAllocationCreateFlags allocationFlags, const VmaMemoryUsage memoryUsage, const cstr name) VmaAllocationCreateFlags const allocationFlags, VmaMemoryUsage const memoryUsage, cstr const name)
{ {
assert(!m_Buffer); assert(!m_Buffer);
@ -19,7 +19,7 @@ Buffer::Buffer(const Device *device, const usize size, const vk::BufferUsageFlag
.usage = bufferUsage, .usage = bufferUsage,
.sharingMode = vk::SharingMode::eExclusive, .sharingMode = vk::SharingMode::eExclusive,
}; };
const VmaAllocationCreateInfo allocationCreateInfo = { VmaAllocationCreateInfo const allocationCreateInfo = {
.flags = allocationFlags, .flags = allocationFlags,
.usage = memoryUsage, .usage = memoryUsage,
}; };
@ -27,8 +27,9 @@ Buffer::Buffer(const Device *device, const usize size, const vk::BufferUsageFlag
VkBuffer buffer; VkBuffer buffer;
VmaAllocation allocation; VmaAllocation allocation;
VmaAllocationInfo allocationInfo; VmaAllocationInfo allocationInfo;
auto result = static_cast<vk::Result>(vmaCreateBuffer(device->m_Allocator, reinterpret_cast<VkBufferCreateInfo *>(&bufferCreateInfo), auto result = static_cast<vk::Result>(
&allocationCreateInfo, &buffer, &allocation, &allocationInfo)); vmaCreateBuffer(device->m_Allocator, reinterpret_cast<VkBufferCreateInfo *>(&bufferCreateInfo),
&allocationCreateInfo, &buffer, &allocation, &allocationInfo));
ERROR_IF(Failed(result), "Could not allocate buffer. Cause: {}", result) THEN_ABORT(result); ERROR_IF(Failed(result), "Could not allocate buffer. Cause: {}", result) THEN_ABORT(result);
// vk::MemoryPropertyFlags memoryPropertyFlags; // vk::MemoryPropertyFlags memoryPropertyFlags;
@ -91,19 +92,19 @@ Buffer::~Buffer()
} }
uptr 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); return device->m_Device.getBufferAddress(&addressInfo);
} }
void 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()); assert(IsMapped());
memcpy(m_Mapped + offset, data, size); memcpy(m_Mapped + offset, data, size);
// TODO: Debug this. // TODO: Debug this.
// auto result = static_cast<vk::Result>(vmaCopyMemoryToAllocation(device->m_Allocator, &data, m_Allocation, 0, size)); // auto result = static_cast<vk::Result>(vmaCopyMemoryToAllocation(device->m_Allocator, &data, m_Allocation, 0,
// ERROR_IF(Failed(result), "Writing to buffer failed. Cause: {}", result) THEN_ABORT(result); // size)); ERROR_IF(Failed(result), "Writing to buffer failed. Cause: {}", result) THEN_ABORT(result);
} }

View File

@ -17,8 +17,8 @@ constexpr eastl::array DEVICE_EXTENSIONS = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_EXTENSION_NAME,
}; };
Device::Device(const Instance &context, PhysicalDevice &physicalDevice, Features &enabledFeatures, Device::Device(Instance const &context, PhysicalDevice &physicalDevice, Features &enabledFeatures,
const eastl::span<QueueAllocation> &queueAllocations, const eastl::span<u8> &pipelineCacheData, eastl::span<QueueAllocation> const &queueAllocations, eastl::span<u8> const &pipelineCacheData,
NameString &&name) NameString &&name)
: m_Name(std::move(name)) : m_Name(std::move(name))
, m_PhysicalDevice(physicalDevice.m_PhysicalDevice) , m_PhysicalDevice(physicalDevice.m_PhysicalDevice)
@ -74,7 +74,7 @@ Device::Device(const Instance &context, PhysicalDevice &physicalDevice, Features
.vkGetDeviceProcAddr = vk::detail::defaultDispatchLoaderDynamic.vkGetDeviceProcAddr, .vkGetDeviceProcAddr = vk::detail::defaultDispatchLoaderDynamic.vkGetDeviceProcAddr,
}; };
const VmaAllocatorCreateInfo allocatorCreateInfo = { VmaAllocatorCreateInfo const allocatorCreateInfo = {
.flags = VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT, .flags = VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT,
.physicalDevice = m_PhysicalDevice, .physicalDevice = m_PhysicalDevice,
.device = m_Device, .device = m_Device,
@ -120,7 +120,7 @@ Device::~Device()
} }
vk::Queue vk::Queue
Device::GetQueue(const u32 familyIndex, const u32 queueIndex) const Device::GetQueue(u32 const familyIndex, u32 const queueIndex) const
{ {
vk::Queue queue; vk::Queue queue;
m_Device.getQueue(familyIndex, queueIndex, &queue); m_Device.getQueue(familyIndex, queueIndex, &queue);

View File

@ -26,9 +26,9 @@ struct MemorySize
{ {
usize totalBytes = bytes + m_Bytes; usize totalBytes = bytes + m_Bytes;
m_Bytes = totalBytes % 1024; m_Bytes = totalBytes % 1024;
const usize totalKb = m_Kilobytes + totalBytes / 1024; usize const totalKb = m_Kilobytes + totalBytes / 1024;
m_Kilobytes = totalKb % 1024; m_Kilobytes = totalKb % 1024;
const usize totalMb = m_Megabytes + totalKb / 1024; usize const totalMb = m_Megabytes + totalKb / 1024;
m_Megabytes = totalMb % 1024; m_Megabytes = totalMb % 1024;
m_Gigabytes += static_cast<u16>(totalMb / 1024); m_Gigabytes += static_cast<u16>(totalMb / 1024);
@ -51,7 +51,7 @@ struct fmt::formatter<MemorySize>
template <typename Context> template <typename Context>
// ReSharper disable once CppInconsistentNaming // ReSharper disable once CppInconsistentNaming
constexpr auto 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 ==-- // return format_to(ctx.out(), "({}, {})", foo.a, foo.b); // --== KEY LINE ==--
if (mem.m_Gigabytes > 0) if (mem.m_Gigabytes > 0)
@ -72,7 +72,7 @@ struct fmt::formatter<MemorySize>
}; };
void * 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*/) int /*line*/)
{ {
g_TotalAlloc += size; g_TotalAlloc += size;
@ -82,8 +82,8 @@ operator new[](size_t size, const char * /*pName*/, int flags, unsigned /*debugF
} }
void * void *
operator new[](size_t size, size_t /*alignment*/, size_t /*alignmentOffset*/, const char * /*pName*/, int flags, operator new[](size_t size, size_t /*alignment*/, size_t /*alignmentOffset*/, char const * /*pName*/, int flags,
unsigned /*debugFlags*/, const char * /*file*/, int /*line*/) unsigned /*debugFlags*/, char const * /*file*/, int /*line*/)
{ {
g_TotalAlloc += size; g_TotalAlloc += size;

View File

@ -35,7 +35,7 @@ Image::~Image()
} }
void void
Image::DestroyView(const vk::ImageView imageView) const Image::DestroyView(vk::ImageView const imageView) const
{ {
m_Device->m_Device.destroy(imageView, nullptr); m_Device->m_Device.destroy(imageView, nullptr);
} }
@ -75,7 +75,8 @@ Image::DestroyView(const vk::ImageView imageView) const
// //
// VkImage image; // VkImage image;
// VmaAllocation allocation; // VmaAllocation allocation;
// auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo *>(&imageCreateInfo), // auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo
// *>(&imageCreateInfo),
// &allocationCreateInfo, &image, &allocation, nullptr)); // &allocationCreateInfo, &image, &allocation, nullptr));
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result); // 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; // VkImage image;
// VmaAllocation allocation; // VmaAllocation allocation;
// auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo *>(&imageCreateInfo), // auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo
// *>(&imageCreateInfo),
// &allocationCreateInfo, &image, &allocation, nullptr)); // &allocationCreateInfo, &image, &allocation, nullptr));
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result); // 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; // VkImage image;
// VmaAllocation allocation; // VmaAllocation allocation;
// auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo *>(&imageCreateInfo), // auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo
// *>(&imageCreateInfo),
// &allocationCreateInfo, &image, &allocation, nullptr)); // &allocationCreateInfo, &image, &allocation, nullptr));
// ERROR_IF(Failed(result), "Could not allocate depth buffer. Cause: {}", result) THEN_ABORT(result); // 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; // VkImage image;
// VmaAllocation allocation; // VmaAllocation allocation;
// auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo *>(&imageCreateInfo), // auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo
// *>(&imageCreateInfo),
// &allocationCreateInfo, &image, &allocation, nullptr)); // &allocationCreateInfo, &image, &allocation, nullptr));
// ERROR_IF(Failed(result), "Could not allocate depth buffer. Cause: {}", result) THEN_ABORT(result); // 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; // VkImage image;
// VmaAllocation allocation; // VmaAllocation allocation;
// auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo *>(&imageCreateInfo), // auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo
// *>(&imageCreateInfo),
// &allocationCreateInfo, &image, &allocation, nullptr)); // &allocationCreateInfo, &image, &allocation, nullptr));
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result); // 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; // VkImage image;
// VmaAllocation allocation; // VmaAllocation allocation;
// auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo *>(&imageCreateInfo), // auto result = static_cast<vk::Result>(vmaCreateImage(device->m_Allocator, reinterpret_cast<VkImageCreateInfo
// *>(&imageCreateInfo),
// &allocationCreateInfo, &image, &allocation, nullptr)); // &allocationCreateInfo, &image, &allocation, nullptr));
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result); // 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, Image::Image(Device const *device, vk::Image const image, VmaAllocation const allocation, vk::Extent3D const extent,
const vk::Format format, const Flags flags, const u8 layerCount, const u8 mipLevels) vk::Format const format, Flags const flags, u8 const layerCount, u8 const mipLevels)
: m_Device{device} : m_Device{device}
, m_Image{image} , m_Image{image}
, m_Allocation{allocation} , m_Allocation{allocation}

View File

@ -11,9 +11,9 @@
#include <EASTL/fixed_vector.h> #include <EASTL/fixed_vector.h>
VKAPI_ATTR b32 VKAPI_CALL VKAPI_ATTR b32 VKAPI_CALL
DebugCallback(const vk::DebugUtilsMessageSeverityFlagBitsEXT messageSeverity, DebugCallback(vk::DebugUtilsMessageSeverityFlagBitsEXT const messageSeverity,
const vk::DebugUtilsMessageTypeFlagsEXT messageType, vk::DebugUtilsMessageTypeFlagsEXT const messageType,
const vk::DebugUtilsMessengerCallbackDataEXT *callbackData, [[maybe_unused]] void *userData) vk::DebugUtilsMessengerCallbackDataEXT const *callbackData, [[maybe_unused]] void *userData)
{ {
using SeverityBits = vk::DebugUtilsMessageSeverityFlagBitsEXT; using SeverityBits = vk::DebugUtilsMessageSeverityFlagBitsEXT;
using MessageTypeBits = vk::DebugUtilsMessageTypeFlagBitsEXT; using MessageTypeBits = vk::DebugUtilsMessageTypeFlagBitsEXT;
@ -33,14 +33,14 @@ DebugCallback(const vk::DebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
return false; 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"); INFO_IF(enableValidation, "Validation Layers enabled");
// TODO Get/Check API Version // TODO Get/Check API Version
// Creating Instance // Creating Instance
const vk::ApplicationInfo appInfo = { vk::ApplicationInfo const appInfo = {
.pApplicationName = appName, .pApplicationName = appName,
.applicationVersion = version.GetVkVersion(), .applicationVersion = version.GetVkVersion(),
.pEngineName = PROJECT_NAME, .pEngineName = PROJECT_NAME,
@ -48,7 +48,7 @@ Instance::Instance(const cstr appName, const Version version, bool enableValidat
.apiVersion = ASTER_API_VERSION, .apiVersion = ASTER_API_VERSION,
}; };
const vk::DebugUtilsMessengerCreateInfoEXT debugUtilsMessengerCreateInfo = { vk::DebugUtilsMessengerCreateInfoEXT const debugUtilsMessengerCreateInfo = {
.messageSeverity = vk::DebugUtilsMessageSeverityFlagBitsEXT::eError | .messageSeverity = vk::DebugUtilsMessageSeverityFlagBitsEXT::eError |
vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning |
vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo, 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); instanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
} }
const vk::detail::DynamicLoader dl; vk::detail::DynamicLoader const dl;
// ReSharper disable once CppInconsistentNaming // ReSharper disable once CppInconsistentNaming
const auto vkGetInstanceProcAddr = dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr"); auto const vkGetInstanceProcAddr = dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
const auto instanceCreateInfo = vk::InstanceCreateInfo{ auto const instanceCreateInfo = vk::InstanceCreateInfo{
.pNext = enableValidation ? &debugUtilsMessengerCreateInfo : nullptr, .pNext = enableValidation ? &debugUtilsMessengerCreateInfo : nullptr,
.pApplicationInfo = &appInfo, .pApplicationInfo = &appInfo,
.enabledExtensionCount = static_cast<u32>(instanceExtensions.size()), .enabledExtensionCount = static_cast<u32>(instanceExtensions.size()),

View File

@ -9,7 +9,7 @@
#include "core/surface.h" #include "core/surface.h"
[[nodiscard]] vk::SurfaceCapabilitiesKHR [[nodiscard]] vk::SurfaceCapabilitiesKHR
GetSurfaceCapabilities(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR surface) GetSurfaceCapabilities(vk::PhysicalDevice const physicalDevice, vk::SurfaceKHR const surface)
{ {
vk::SurfaceCapabilitiesKHR surfaceCapabilities; vk::SurfaceCapabilitiesKHR surfaceCapabilities;
@ -21,7 +21,7 @@ GetSurfaceCapabilities(const vk::PhysicalDevice physicalDevice, const vk::Surfac
} }
[[nodiscard]] eastl::vector<vk::SurfaceFormatKHR> [[nodiscard]] eastl::vector<vk::SurfaceFormatKHR>
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. // vk::Result::eIncomplete should not occur in this function. The rest are errors. Thus, abort is allowed.
u32 count = 0; u32 count = 0;
@ -38,7 +38,7 @@ GetSurfaceFormats(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR
} }
[[nodiscard]] eastl::vector<vk::PresentModeKHR> [[nodiscard]] eastl::vector<vk::PresentModeKHR>
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. // vk::Result::eIncomplete should not occur in this function. The rest are errors. Thus, abort is allowed.
u32 count = 0; u32 count = 0;
@ -55,11 +55,11 @@ GetSurfacePresentModes(const vk::PhysicalDevice physicalDevice, const vk::Surfac
} }
[[nodiscard]] bool [[nodiscard]] bool
GetQueuePresentSupport(const u32 queueFamilyIndex, const vk::SurfaceKHR surface, GetQueuePresentSupport(u32 const queueFamilyIndex, vk::SurfaceKHR const surface,
const vk::PhysicalDevice physicalDevice) vk::PhysicalDevice const physicalDevice)
{ {
b32 supported = false; 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) ERROR_IF(Failed(result), "Could not get queue family surface support. Cause: {}", result)
THEN_ABORT(result); THEN_ABORT(result);
@ -67,7 +67,7 @@ GetQueuePresentSupport(const u32 queueFamilyIndex, const vk::SurfaceKHR surface,
} }
[[nodiscard]] eastl::fixed_vector<vk::QueueFamilyProperties, 32> [[nodiscard]] eastl::fixed_vector<vk::QueueFamilyProperties, 32>
GetQueueFamilyProperties(const vk::PhysicalDevice physicalDevice) GetQueueFamilyProperties(vk::PhysicalDevice const physicalDevice)
{ {
// Devices rarely have more than 32 queue families. Thus fixed vector // Devices rarely have more than 32 queue families. Thus fixed vector
u32 count = 0; u32 count = 0;
@ -81,7 +81,7 @@ GetQueueFamilyProperties(const vk::PhysicalDevice physicalDevice)
// Size 384 return. // Size 384 return.
[[nodiscard]] eastl::vector<QueueFamilyInfo> [[nodiscard]] eastl::vector<QueueFamilyInfo>
GetQueueFamilies(const vk::SurfaceKHR surface, const vk::PhysicalDevice physicalDevice) GetQueueFamilies(vk::SurfaceKHR const surface, vk::PhysicalDevice const physicalDevice)
{ {
auto queueFamilyProperties = GetQueueFamilyProperties(physicalDevice); auto queueFamilyProperties = GetQueueFamilyProperties(physicalDevice);
@ -126,7 +126,7 @@ GetQueueFamilies(const vk::SurfaceKHR surface, const vk::PhysicalDevice physical
return queueFamilyInfos; 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.getProperties(&m_DeviceProperties);
physicalDevice.getFeatures(&m_DeviceFeatures); physicalDevice.getFeatures(&m_DeviceFeatures);
@ -139,7 +139,7 @@ PhysicalDevice::PhysicalDevice(const vk::SurfaceKHR surface, const vk::PhysicalD
} }
eastl::fixed_vector<vk::PhysicalDevice, 8> eastl::fixed_vector<vk::PhysicalDevice, 8>
EnumeratePhysicalDevices(const vk::Instance instance) EnumeratePhysicalDevices(vk::Instance const instance)
{ {
u32 count = 0; u32 count = 0;
vk::Result result = instance.enumeratePhysicalDevices(&count, nullptr); vk::Result result = instance.enumeratePhysicalDevices(&count, nullptr);
@ -154,7 +154,7 @@ EnumeratePhysicalDevices(const vk::Instance instance)
return physicalDevices; 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) for (auto physicalDevices = EnumeratePhysicalDevices(context.m_Instance); auto physicalDevice : physicalDevices)
{ {

View File

@ -7,8 +7,8 @@
#include "core/device.h" #include "core/device.h"
Pipeline::Pipeline(const Device *device, const vk::PipelineLayout layout, const vk::Pipeline pipeline, Pipeline::Pipeline(Device const *device, vk::PipelineLayout const layout, vk::Pipeline const pipeline,
eastl::vector<vk::DescriptorSetLayout> &&setLayouts, const Kind kind) eastl::vector<vk::DescriptorSetLayout> &&setLayouts, Kind const kind)
: m_Device{device} : m_Device{device}
, m_Layout{layout} , m_Layout{layout}
, m_Pipeline{pipeline} , m_Pipeline{pipeline}
@ -22,7 +22,7 @@ Pipeline::~Pipeline()
if (!m_Device || !m_Pipeline) if (!m_Device || !m_Pipeline)
return; return;
for (const auto setLayout : m_SetLayouts) for (auto const setLayout : m_SetLayouts)
{ {
m_Device->m_Device.destroy(setLayout, nullptr); m_Device->m_Device.destroy(setLayout, nullptr);
} }

View File

@ -15,10 +15,10 @@ Sampler::~Sampler()
m_Device->m_Device.destroy(Take(m_Sampler), nullptr); 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; 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 : "<unnamed>") THEN_ABORT(-1); ERROR_IF(Failed(result), "Could not create a sampler {}", name ? name : "<unnamed>") THEN_ABORT(-1);
} }
@ -33,7 +33,8 @@ Sampler::operator=(Sampler &&other) noexcept
return *this; return *this;
} }
Sampler::Sampler(Sampler &&other) noexcept: m_Device{other.m_Device} Sampler::Sampler(Sampler &&other) noexcept
, m_Sampler{Take(other.m_Sampler)} : m_Device{other.m_Device}
, m_Sampler{Take(other.m_Sampler)}
{ {
} }

View File

@ -8,7 +8,7 @@
#include "core/instance.h" #include "core/instance.h"
#include "core/window.h" #include "core/window.h"
Surface::Surface(Instance &context, const Window &window) Surface::Surface(Instance &context, Window const &window)
: m_Context(&context) : m_Context(&context)
{ {
VkSurfaceKHR surface; VkSurfaceKHR surface;

View File

@ -11,7 +11,7 @@
[[nodiscard]] vk::Extent2D GetExtent(Size2D size, vk::SurfaceCapabilitiesKHR *surfaceCapabilities); [[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_Device(&device)
, m_Format(vk::Format::eUndefined) , m_Format(vk::Format::eUndefined)
{ {
@ -50,7 +50,7 @@ Swapchain::operator=(Swapchain &&other) noexcept
} }
void 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); auto surfaceCapabilities = GetSurfaceCapabilities(m_Device->m_PhysicalDevice, surface.m_Surface);
m_Extent = GetExtent(size, &surfaceCapabilities); m_Extent = GetExtent(size, &surfaceCapabilities);
@ -84,7 +84,7 @@ Swapchain::Create(const Surface &surface, Size2D size)
} }
auto swapchainPresentMode = vk::PresentModeKHR::eFifo; auto swapchainPresentMode = vk::PresentModeKHR::eFifo;
for (const auto presentMode : presentModes) for (auto const presentMode : presentModes)
{ {
if (presentMode == vk::PresentModeKHR::eMailbox) 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. // TODO: Note that different queues might need the images to be shared.
const vk::SwapchainCreateInfoKHR swapchainCreateInfo = { vk::SwapchainCreateInfoKHR const swapchainCreateInfo = {
.surface = surface.m_Surface, .surface = surface.m_Surface,
.minImageCount = swapchainImageCount, .minImageCount = swapchainImageCount,
.imageFormat = m_Format, .imageFormat = m_Format,
@ -195,7 +195,7 @@ Swapchain::Cleanup()
NameString name = "Swapchain of "; NameString name = "Swapchain of ";
name += m_Device->m_Name; name += m_Device->m_Name;
for (const auto imageView : m_ImageViews) for (auto const imageView : m_ImageViews)
{ {
m_Device->m_Device.destroy(imageView, nullptr); m_Device->m_Device.destroy(imageView, nullptr);
} }

View File

@ -18,8 +18,8 @@ Window::SetupLibrary()
{ {
if (!glfwInit()) if (!glfwInit())
{ {
const char *error = nullptr; char const *error = nullptr;
const auto code = glfwGetError(&error); auto const code = glfwGetError(&error);
ERROR("GLFW Init failed. Cause: ({}) {}", code, error) ERROR("GLFW Init failed. Cause: ({}) {}", code, error)
THEN_ABORT(code); THEN_ABORT(code);
} }
@ -28,7 +28,7 @@ Window::SetupLibrary()
} }
} }
cstr* cstr *
Window::GetInstanceExtensions(u32 *extensionCount) Window::GetInstanceExtensions(u32 *extensionCount)
{ {
SetupLibrary(); SetupLibrary();
@ -42,13 +42,13 @@ Window::RequestExit() const noexcept
} }
void void
Window::SetWindowSize(const vk::Extent2D &extent) const noexcept Window::SetWindowSize(vk::Extent2D const &extent) const noexcept
{ {
SetWindowSize(extent.width, extent.height); SetWindowSize(extent.width, extent.height);
} }
void 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<i32>(width), static_cast<i32>(height)); glfwSetWindowSize(m_Window, static_cast<i32>(width), static_cast<i32>(height));
} }
@ -62,7 +62,7 @@ Window::GetSize() const
return {static_cast<u32>(width), static_cast<u32>(height)}; return {static_cast<u32>(width), static_cast<u32>(height)};
} }
Window::Window(const cstr title, Size2D extent, const b8 isFullScreen) Window::Window(cstr const title, Size2D extent, b8 const isFullScreen)
{ {
m_Name = title; 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); ELSE_DEBUG("Window '{}' created with resolution '{}x{}'", m_Name, extent.m_Width, extent.m_Height);
if (m_Window == nullptr) if (m_Window == nullptr)
{ {
const char *error = nullptr; char const *error = nullptr;
const auto code = glfwGetError(&error); auto const code = glfwGetError(&error);
ERROR("GLFW Window Creation failed. Cause: ({}) {}", code, error) ERROR("GLFW Window Creation failed. Cause: ({}) {}", code, error)
THEN_ABORT(code); THEN_ABORT(code);
} }

View File

@ -14,8 +14,8 @@ using namespace systems;
CommitManager *CommitManager::m_Instance = nullptr; CommitManager *CommitManager::m_Instance = nullptr;
CommitManager::CommitManager(const Device *device, const u32 maxBuffers, const u32 maxImages, CommitManager::CommitManager(Device const *device, u32 const maxBuffers, u32 const maxImages,
const u32 maxStorageImages, Ref<Sampler> defaultSampler) u32 const maxStorageImages, Ref<Sampler> defaultSampler)
: m_Device{device} : m_Device{device}
, m_Buffers{maxBuffers} , m_Buffers{maxBuffers}
, m_Images{maxImages} , 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, .flags = vk::DescriptorPoolCreateFlagBits::eUpdateAfterBind,
.maxSets = 1, .maxSets = 1,
.poolSizeCount = static_cast<u32>(poolSizes.size()), .poolSizeCount = static_cast<u32>(poolSizes.size()),
@ -80,7 +80,7 @@ CommitManager::CommitManager(const Device *device, const u32 maxBuffers, const u
}; };
static_assert(layoutBindingFlags.size() == descriptorLayoutBindings.size()); static_assert(layoutBindingFlags.size() == descriptorLayoutBindings.size());
const vk::DescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = { vk::DescriptorSetLayoutCreateInfo const descriptorSetLayoutCreateInfo = {
.pNext = &bindingFlagsCreateInfo, .pNext = &bindingFlagsCreateInfo,
.flags = vk::DescriptorSetLayoutCreateFlagBits::eUpdateAfterBindPool, .flags = vk::DescriptorSetLayoutCreateFlagBits::eUpdateAfterBindPool,
.bindingCount = static_cast<u32>(descriptorLayoutBindings.size()), .bindingCount = static_cast<u32>(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) // 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://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 // 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, .descriptorPool = m_DescriptorPool,
.descriptorSetCount = 1, .descriptorSetCount = 1,
.pSetLayouts = &m_SetLayout, .pSetLayouts = &m_SetLayout,
@ -112,12 +112,12 @@ CommitManager::~CommitManager()
#if !defined(ASTER_NDEBUG) #if !defined(ASTER_NDEBUG)
u32 bufferCount = 0; u32 bufferCount = 0;
for (const auto &entry : m_Buffers.m_Data) for (auto const &entry : m_Buffers.m_Data)
{ {
bufferCount += entry.m_CommitCount; bufferCount += entry.m_CommitCount;
} }
u32 imageCount = 0; u32 imageCount = 0;
for (const auto &entry : m_Images.m_Data) for (auto const &entry : m_Images.m_Data)
{ {
imageCount += entry.m_CommitCount; imageCount += entry.m_CommitCount;
} }
@ -129,7 +129,7 @@ CommitManager::~CommitManager()
} }
ResId<Buffer> ResId<Buffer>
CommitManager::CommitBuffer(const Ref<Buffer> &buffer) CommitManager::CommitBuffer(Ref<Buffer> const &buffer)
{ {
auto [commit, isNew] = m_Buffers.Create(buffer); auto [commit, isNew] = m_Buffers.Create(buffer);
@ -154,7 +154,7 @@ CommitManager::CommitBuffer(const Ref<Buffer> &buffer)
} }
ResId<StorageImageView> ResId<StorageImageView>
CommitManager::CommitStorageImage(const Ref<StorageImageView> &image) CommitManager::CommitStorageImage(Ref<StorageImageView> const &image)
{ {
auto [commit, isNew] = m_StorageImages.Create(image); auto [commit, isNew] = m_StorageImages.Create(image);
if (!isNew) if (!isNew)
@ -178,13 +178,13 @@ CommitManager::CommitStorageImage(const Ref<StorageImageView> &image)
} }
ResId<TextureView> ResId<TextureView>
CommitManager::CommitTexture(const Ref<TextureView> &handle) CommitManager::CommitTexture(Ref<TextureView> const &handle)
{ {
return CommitTexture(handle, m_DefaultSampler); return CommitTexture(handle, m_DefaultSampler);
} }
ResId<TextureView> ResId<TextureView>
CommitManager::CommitTexture(const Ref<TextureView> &image, const Ref<Sampler> &sampler) CommitManager::CommitTexture(Ref<TextureView> const &image, Ref<Sampler> const &sampler)
{ {
auto [commit, isNew] = m_Images.Create(image); auto [commit, isNew] = m_Images.Create(image);
if (!isNew) if (!isNew)
@ -207,17 +207,17 @@ CommitManager::CommitTexture(const Ref<TextureView> &image, const Ref<Sampler> &
return commit; return commit;
} }
CommitManager::WriteInfo::WriteInfo(const vk::DescriptorBufferInfo &info) CommitManager::WriteInfo::WriteInfo(vk::DescriptorBufferInfo const &info)
: uBufferInfo{info} : uBufferInfo{info}
{ {
} }
CommitManager::WriteInfo::WriteInfo(const vk::DescriptorImageInfo &info) CommitManager::WriteInfo::WriteInfo(vk::DescriptorImageInfo const &info)
: uImageInfo{info} : uImageInfo{info}
{ {
} }
CommitManager::WriteInfo::WriteInfo(const vk::BufferView &info) CommitManager::WriteInfo::WriteInfo(vk::BufferView const &info)
: uBufferView{info} : uBufferView{info}
{ {
} }

View File

@ -9,7 +9,7 @@
#include "systems/device.h" #include "systems/device.h"
constexpr static u32 constexpr static u32
GetFormatSize(const vk::Format format) GetFormatSize(vk::Format const format)
{ {
switch (format) switch (format)
{ {
@ -129,28 +129,28 @@ GetFormatSize(const vk::Format format)
} }
void void
systems::Context::KeepAlive(const Ref<Buffer> &buffer) systems::Context::KeepAlive(Ref<Buffer> const &buffer)
{ {
assert(m_Pool); assert(m_Pool);
m_Pool->KeepAlive(buffer); m_Pool->KeepAlive(buffer);
} }
void void
systems::Context::KeepAlive(const Ref<Image> &image) systems::Context::KeepAlive(Ref<Image> const &image)
{ {
assert(m_Pool); assert(m_Pool);
m_Pool->KeepAlive(image); m_Pool->KeepAlive(image);
} }
void void
systems::Context::KeepAlive(const Ref<ImageView> &view) systems::Context::KeepAlive(Ref<ImageView> const &view)
{ {
assert(m_Pool); assert(m_Pool);
m_Pool->KeepAlive(view); m_Pool->KeepAlive(view);
} }
void void
systems::Context::Dependency(const vk::DependencyInfo &dependencyInfo) systems::Context::Dependency(vk::DependencyInfo const &dependencyInfo)
{ {
m_Cmd.pipelineBarrier2(&dependencyInfo); m_Cmd.pipelineBarrier2(&dependencyInfo);
} }
@ -169,9 +169,9 @@ systems::Context::Begin()
// Release versions inline 'no-op'. // Release versions inline 'no-op'.
#if !defined(ASTER_NDEBUG) #if !defined(ASTER_NDEBUG)
void 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, .pLabelName = name,
.color = std::array{color.r, color.g, color.b, color.a}, .color = std::array{color.r, color.g, color.b, color.a},
}; };
@ -193,7 +193,7 @@ systems::Context::End()
} }
void 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); BindPipeline(pipeline);
PushConstantBlock(0, size, data); PushConstantBlock(0, size, data);
@ -202,9 +202,9 @@ systems::ComputeContext::Dispatch(const Pipeline &pipeline, u32 x, u32 y, u32 z,
} }
void 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) switch (pipeline.m_Kind)
{ {
case Pipeline::Kind::eGraphics: case Pipeline::Kind::eGraphics:
@ -229,26 +229,26 @@ systems::ComputeContext::BindPipeline(const Pipeline &pipeline)
} }
void void
systems::GraphicsContext::SetViewport(const vk::Viewport &viewport) systems::GraphicsContext::SetViewport(vk::Viewport const &viewport)
{ {
m_Cmd.setViewport(0, 1, &viewport); m_Cmd.setViewport(0, 1, &viewport);
} }
void void
systems::GraphicsContext::BindVertexBuffer(const Ref<VertexBuffer> &vertexBuffer) systems::GraphicsContext::BindVertexBuffer(Ref<VertexBuffer> const &vertexBuffer)
{ {
constexpr vk::DeviceSize offset = 0; constexpr vk::DeviceSize offset = 0;
m_Cmd.bindVertexBuffers(0, 1, &vertexBuffer->m_Buffer, &offset); m_Cmd.bindVertexBuffers(0, 1, &vertexBuffer->m_Buffer, &offset);
} }
void void
systems::GraphicsContext::BindIndexBuffer(const Ref<IndexBuffer> &indexBuffer) systems::GraphicsContext::BindIndexBuffer(Ref<IndexBuffer> const &indexBuffer)
{ {
m_Cmd.bindIndexBuffer(indexBuffer->m_Buffer, 0, vk::IndexType::eUint32); m_Cmd.bindIndexBuffer(indexBuffer->m_Buffer, 0, vk::IndexType::eUint32);
} }
void void
systems::GraphicsContext::Draw(const usize vertexCount) systems::GraphicsContext::Draw(usize const vertexCount)
{ {
m_Cmd.draw(static_cast<u32>(vertexCount), 1, 0, 0); m_Cmd.draw(static_cast<u32>(vertexCount), 1, 0, 0);
} }
@ -260,13 +260,13 @@ systems::GraphicsContext::DrawIndexed(usize indexCount)
} }
void 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<u32>(indexCount), 1, static_cast<u32>(firstIndex), static_cast<i32>(firstVertex), 0); m_Cmd.drawIndexed(static_cast<u32>(indexCount), 1, static_cast<u32>(firstIndex), static_cast<i32>(firstVertex), 0);
} }
void void
systems::GraphicsContext::BeginRendering(const vk::RenderingInfo &renderingInfo) systems::GraphicsContext::BeginRendering(vk::RenderingInfo const &renderingInfo)
{ {
m_Cmd.beginRendering(&renderingInfo); m_Cmd.beginRendering(&renderingInfo);
m_Cmd.setScissor(0, 1, &renderingInfo.renderArea); m_Cmd.setScissor(0, 1, &renderingInfo.renderArea);
@ -279,7 +279,7 @@ systems::GraphicsContext::EndRendering()
} }
void void
systems::TransferContext::UploadTexture(const Ref<Image> &image, const eastl::span<u8> &data) systems::TransferContext::UploadTexture(Ref<Image> const &image, eastl::span<u8> const &data)
{ {
ERROR_IF(not(image and image->IsValid()), "Invalid image"); ERROR_IF(not(image and image->IsValid()), "Invalid image");
@ -289,10 +289,10 @@ systems::TransferContext::UploadTexture(const Ref<Image> &image, const eastl::sp
ERROR_IF(expectedByteSize != data.size_bytes(), "Mismatch in data size {} vs image size {} ({}x{}x{}x{})", ERROR_IF(expectedByteSize != data.size_bytes(), "Mismatch in data size {} vs image size {} ({}x{}x{}x{})",
data.size_bytes(), expectedByteSize, w, h, d, formatSize); data.size_bytes(), expectedByteSize, w, h, d, formatSize);
const Ref<StagingBuffer> stagingBuffer = m_Pool->GetDevice().CreateStagingBuffer(data.size_bytes()); Ref<StagingBuffer> const stagingBuffer = m_Pool->GetDevice().CreateStagingBuffer(data.size_bytes());
stagingBuffer->Write(0, data.size_bytes(), data.data()); stagingBuffer->Write(0, data.size_bytes(), data.data());
const vk::BufferImageCopy bufferImageCopy = { vk::BufferImageCopy const bufferImageCopy = {
.bufferOffset = 0, .bufferOffset = 0,
.bufferRowLength = w, .bufferRowLength = w,
.bufferImageHeight = h, .bufferImageHeight = h,
@ -314,17 +314,17 @@ systems::TransferContext::UploadTexture(const Ref<Image> &image, const eastl::sp
} }
void void
systems::TransferContext::UploadBuffer(const Ref<Buffer> &buffer, usize size, const void *data) systems::TransferContext::UploadBuffer(Ref<Buffer> const &buffer, usize size, void const *data)
{ {
ERROR_IF(not(buffer and buffer->IsValid()), "Invalid buffer"); ERROR_IF(not(buffer and buffer->IsValid()), "Invalid buffer");
auto expectedByteSize = buffer->m_Size; auto expectedByteSize = buffer->m_Size;
ERROR_IF(expectedByteSize != size, "Mismatch in data size {} vs buffer size {}", size, expectedByteSize); ERROR_IF(expectedByteSize != size, "Mismatch in data size {} vs buffer size {}", size, expectedByteSize);
const Ref<StagingBuffer> stagingBuffer = m_Pool->GetDevice().CreateStagingBuffer(size); Ref<StagingBuffer> const stagingBuffer = m_Pool->GetDevice().CreateStagingBuffer(size);
stagingBuffer->Write(0, size, data); 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); m_Cmd.copyBuffer(stagingBuffer->m_Buffer, buffer->m_Buffer, 1, &bufferCopy);
@ -333,7 +333,7 @@ systems::TransferContext::UploadBuffer(const Ref<Buffer> &buffer, usize size, co
} }
void void
systems::TransferContext::Blit(const vk::BlitImageInfo2 &mipBlitInfo) systems::TransferContext::Blit(vk::BlitImageInfo2 const &mipBlitInfo)
{ {
m_Cmd.blitImage2(&mipBlitInfo); m_Cmd.blitImage2(&mipBlitInfo);
} }
@ -353,7 +353,7 @@ systems::TransferContext::operator=(TransferContext &&other) noexcept
} }
void 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); assert(m_PipelineInUse);
@ -368,20 +368,19 @@ systems::ComputeContext::PushConstantBlock(const usize offset, const usize size,
break; break;
} }
m_Cmd.pushConstants(m_PipelineInUse->m_Layout, stage, static_cast<u32>(offset), m_Cmd.pushConstants(m_PipelineInUse->m_Layout, stage, static_cast<u32>(offset), static_cast<u32>(size), data);
static_cast<u32>(size), data);
} }
using namespace systems::_internal; 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_Device{&device}
, m_BuffersAllocated{0} , m_BuffersAllocated{0}
, m_ExtraData{0} , m_ExtraData{0}
, m_ManagedBy{managedBy} , m_ManagedBy{managedBy}
, m_ResetCallback{} , m_ResetCallback{}
{ {
const vk::CommandPoolCreateInfo commandPoolCreateInfo = { vk::CommandPoolCreateInfo const commandPoolCreateInfo = {
.flags = vk::CommandPoolCreateFlagBits::eTransient, .flags = vk::CommandPoolCreateFlagBits::eTransient,
.queueFamilyIndex = queueFamilyIndex, .queueFamilyIndex = queueFamilyIndex,
}; };
@ -430,19 +429,19 @@ ContextPool::~ContextPool()
} }
void void
ContextPool::KeepAlive(const Ref<Buffer> &buffer) ContextPool::KeepAlive(Ref<Buffer> const &buffer)
{ {
m_OwnedBuffers.push_back(buffer); m_OwnedBuffers.push_back(buffer);
} }
void void
ContextPool::KeepAlive(const Ref<Image> &image) ContextPool::KeepAlive(Ref<Image> const &image)
{ {
m_OwnedImages.push_back(image); m_OwnedImages.push_back(image);
} }
void void
ContextPool::KeepAlive(const Ref<ImageView> &view) ContextPool::KeepAlive(Ref<ImageView> const &view)
{ {
m_OwnedImageViews.push_back(view); m_OwnedImageViews.push_back(view);
} }
@ -457,7 +456,7 @@ ContextPool::AllocateCommandBuffer()
} }
// Allocate New Buffer. // Allocate New Buffer.
const vk::CommandBufferAllocateInfo allocateInfo = { vk::CommandBufferAllocateInfo const allocateInfo = {
.commandPool = m_Pool, .commandPool = m_Pool,
.level = vk::CommandBufferLevel::ePrimary, .level = vk::CommandBufferLevel::ePrimary,
.commandBufferCount = 1, .commandBufferCount = 1,

View File

@ -77,20 +77,20 @@ systems::GraphicsPipelineCreateInfo::GetDepthStencilStateCreateInfo() const
} }
PhysicalDevice PhysicalDevice
systems::DefaultPhysicalDeviceSelector(const PhysicalDevices &physicalDevices) systems::DefaultPhysicalDeviceSelector(PhysicalDevices const &physicalDevices)
{ {
for (auto &physicalDevice : physicalDevices) for (auto &physicalDevice : physicalDevices)
{ {
const bool hasAllRequiredQueues = bool const hasAllRequiredQueues =
std::ranges::any_of(physicalDevice.m_QueueFamilies, [](const auto &queueFamilyProp) { std::ranges::any_of(physicalDevice.m_QueueFamilies, [](auto const &queueFamilyProp) {
return (queueFamilyProp.m_Support & REQUIRED_QUEUE_SUPPORT) == REQUIRED_QUEUE_SUPPORT; 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) if (hasSurfaceFormat && hasPresentMode && isNotCpu && hasAllRequiredQueues)
{ {
@ -107,7 +107,7 @@ systems::DefaultPhysicalDeviceSelector(const PhysicalDevices &physicalDevices)
// ==================================================================================================== // ====================================================================================================
Ref<StorageBuffer> Ref<StorageBuffer>
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. // TODO: Storage and Index buffer are set.
// This is hacky and should be improved. // This is hacky and should be improved.
@ -137,7 +137,7 @@ systems::Device::CreateIndexBuffer(usize size, cstr name)
} }
Ref<UniformBuffer> Ref<UniformBuffer>
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 vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eUniformBuffer;
constexpr VmaAllocationCreateFlags createFlags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | 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<StagingBuffer> Ref<StagingBuffer>
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 vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eTransferSrc;
constexpr VmaAllocationCreateFlags createFlags = constexpr VmaAllocationCreateFlags createFlags =
@ -158,7 +158,7 @@ systems::Device::CreateStagingBuffer(const usize size, const cstr name)
} }
Ref<VertexBuffer> Ref<VertexBuffer>
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 vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eVertexBuffer;
constexpr VmaAllocationCreateFlags createFlags = constexpr VmaAllocationCreateFlags createFlags =
@ -172,10 +172,10 @@ systems::Device::CreateVertexBuffer(const usize size, const cstr name)
#pragma region Image Management #pragma region Image Management
// ==================================================================================================== // ====================================================================================================
vk::ImageCreateInfo ToImageCreateInfo(const systems::Texture2DCreateInfo &createInfo); vk::ImageCreateInfo ToImageCreateInfo(systems::Texture2DCreateInfo const &createInfo);
vk::ImageCreateInfo ToImageCreateInfo(const systems::TextureCubeCreateInfo &createInfo); vk::ImageCreateInfo ToImageCreateInfo(systems::TextureCubeCreateInfo const &createInfo);
vk::ImageCreateInfo ToImageCreateInfo(const systems::AttachmentCreateInfo &createInfo); vk::ImageCreateInfo ToImageCreateInfo(systems::AttachmentCreateInfo const &createInfo);
vk::ImageCreateInfo ToImageCreateInfo(const systems::DepthStencilImageCreateInfo &createInfo); vk::ImageCreateInfo ToImageCreateInfo(systems::DepthStencilImageCreateInfo const &createInfo);
namespace usage_flags namespace usage_flags
{ {
@ -189,7 +189,7 @@ constexpr vk::ImageUsageFlags DEPTH_STENCIL_ATTACHMENT = vk::ImageUsageFlagBits:
} // namespace usage_flags } // namespace usage_flags
Ref<Image> Ref<Image>
systems::Device::CreateTexture2D(const Texture2DCreateInfo &createInfo) systems::Device::CreateTexture2D(Texture2DCreateInfo const &createInfo)
{ {
constexpr VmaAllocationCreateInfo allocationCreateInfo = { constexpr VmaAllocationCreateInfo allocationCreateInfo = {
.flags = {}, .flags = {},
@ -221,7 +221,7 @@ systems::Device::CreateTexture2D(const Texture2DCreateInfo &createInfo)
} }
Ref<ImageCube> Ref<ImageCube>
systems::Device::CreateTextureCube(const TextureCubeCreateInfo &createInfo) systems::Device::CreateTextureCube(TextureCubeCreateInfo const &createInfo)
{ {
constexpr VmaAllocationCreateInfo allocationCreateInfo = { constexpr VmaAllocationCreateInfo allocationCreateInfo = {
.flags = {}, .flags = {},
@ -253,7 +253,7 @@ systems::Device::CreateTextureCube(const TextureCubeCreateInfo &createInfo)
} }
Ref<Image> Ref<Image>
systems::Device::CreateAttachment(const AttachmentCreateInfo &createInfo) systems::Device::CreateAttachment(AttachmentCreateInfo const &createInfo)
{ {
constexpr VmaAllocationCreateInfo allocationCreateInfo = { constexpr VmaAllocationCreateInfo allocationCreateInfo = {
.flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
@ -280,7 +280,7 @@ systems::Device::CreateAttachment(const AttachmentCreateInfo &createInfo)
} }
Ref<Image> Ref<Image>
systems::Device::CreateDepthStencilImage(const DepthStencilImageCreateInfo &createInfo) systems::Device::CreateDepthStencilImage(DepthStencilImageCreateInfo const &createInfo)
{ {
constexpr VmaAllocationCreateInfo allocationCreateInfo = { constexpr VmaAllocationCreateInfo allocationCreateInfo = {
.flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
@ -307,14 +307,14 @@ systems::Device::CreateDepthStencilImage(const DepthStencilImageCreateInfo &crea
} }
vk::ImageCreateInfo vk::ImageCreateInfo
ToImageCreateInfo(const systems::Texture2DCreateInfo &createInfo) ToImageCreateInfo(systems::Texture2DCreateInfo const &createInfo)
{ {
auto &[format, extent, name, isSampled, isMipMapped, isStorage] = 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)", WARN_IF(!IsPowerOfTwo(extent.width) || !IsPowerOfTwo(extent.width), "Image {2} is {0}x{1} (Non Power of Two)",
extent.width, extent.height, name ? name : "<unnamed>"); extent.width, extent.height, name ? name : "<unnamed>");
const u8 mipLevels = isMipMapped ? 1 + static_cast<u8>(floor(log2(eastl::max(extent.width, extent.height)))) : 1; u8 const mipLevels = isMipMapped ? 1 + static_cast<u8>(floor(log2(eastl::max(extent.width, extent.height)))) : 1;
auto usage = vk::ImageUsageFlags{}; auto usage = vk::ImageUsageFlags{};
if (isSampled) if (isSampled)
@ -335,13 +335,13 @@ ToImageCreateInfo(const systems::Texture2DCreateInfo &createInfo)
} }
vk::ImageCreateInfo vk::ImageCreateInfo
ToImageCreateInfo(const systems::TextureCubeCreateInfo &createInfo) ToImageCreateInfo(systems::TextureCubeCreateInfo const &createInfo)
{ {
auto &[format, side, name, isSampled, isMipMapped, isStorage] = 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 : "<unnamed>"); WARN_IF(!IsPowerOfTwo(side), "ImageCube {1} is {0}x{0} (Non Power of Two)", side, name ? name : "<unnamed>");
const u8 mipLevels = isMipMapped ? 1 + static_cast<u8>(floor(log2(side))) : 1; u8 const mipLevels = isMipMapped ? 1 + static_cast<u8>(floor(log2(side))) : 1;
auto usage = vk::ImageUsageFlags{}; auto usage = vk::ImageUsageFlags{};
if (isSampled) if (isSampled)
@ -363,7 +363,7 @@ ToImageCreateInfo(const systems::TextureCubeCreateInfo &createInfo)
} }
vk::ImageCreateInfo vk::ImageCreateInfo
ToImageCreateInfo(const systems::AttachmentCreateInfo &createInfo) ToImageCreateInfo(systems::AttachmentCreateInfo const &createInfo)
{ {
auto &[format, extent, name] = createInfo; auto &[format, extent, name] = createInfo;
@ -380,7 +380,7 @@ ToImageCreateInfo(const systems::AttachmentCreateInfo &createInfo)
} }
vk::ImageCreateInfo vk::ImageCreateInfo
ToImageCreateInfo(const systems::DepthStencilImageCreateInfo &createInfo) ToImageCreateInfo(systems::DepthStencilImageCreateInfo const &createInfo)
{ {
auto &[extent, name] = createInfo; auto &[extent, name] = createInfo;
@ -404,17 +404,17 @@ ToImageCreateInfo(const systems::DepthStencilImageCreateInfo &createInfo)
// ==================================================================================================== // ====================================================================================================
Ref<ImageView> Ref<ImageView>
systems::Device::CreateView(const ViewCreateInfo<Image> &createInfo) systems::Device::CreateView(ViewCreateInfo<Image> const &createInfo)
{ {
const auto layerCount = createInfo.GetLayerCount(); auto const layerCount = createInfo.GetLayerCount();
const auto mipCount = createInfo.GetMipLevelCount(); auto const mipCount = createInfo.GetMipLevelCount();
ERROR_IF((createInfo.m_BaseLayer + layerCount) > createInfo.m_Image->m_LayerCount, "Invalid Layer Access") ERROR_IF((createInfo.m_BaseLayer + layerCount) > createInfo.m_Image->m_LayerCount, "Invalid Layer Access")
THEN_ABORT(-1); THEN_ABORT(-1);
ERROR_IF((createInfo.m_BaseMipLevel + mipCount) > createInfo.m_Image->m_MipLevels, "Invalid Mip Level Access") ERROR_IF((createInfo.m_BaseMipLevel + mipCount) > createInfo.m_Image->m_MipLevels, "Invalid Mip Level Access")
THEN_ABORT(-1); THEN_ABORT(-1);
vk::ImageView view; vk::ImageView view;
const auto imageViewCreateInfo = static_cast<vk::ImageViewCreateInfo>(createInfo); auto const imageViewCreateInfo = static_cast<vk::ImageViewCreateInfo>(createInfo);
auto result = m_Device->createImageView(&imageViewCreateInfo, nullptr, &view); auto result = m_Device->createImageView(&imageViewCreateInfo, nullptr, &view);
ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", createInfo.m_Name, result) ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", createInfo.m_Name, result)
THEN_ABORT(result); THEN_ABORT(result);
@ -432,7 +432,7 @@ systems::Device::CreateView(const ViewCreateInfo<Image> &createInfo)
// ==================================================================================================== // ====================================================================================================
Ref<TextureView> Ref<TextureView>
systems::Device::CreateTexture2DWithView(const Texture2DCreateInfo &createInfo) systems::Device::CreateTexture2DWithView(Texture2DCreateInfo const &createInfo)
{ {
return CreateView<TextureView>({ return CreateView<TextureView>({
.m_Image = CastImage<Texture>(CreateTexture2D(createInfo)), .m_Image = CastImage<Texture>(CreateTexture2D(createInfo)),
@ -443,7 +443,7 @@ systems::Device::CreateTexture2DWithView(const Texture2DCreateInfo &createInfo)
} }
Ref<ImageCubeView> Ref<ImageCubeView>
systems::Device::CreateTextureCubeWithView(const TextureCubeCreateInfo &createInfo) systems::Device::CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo)
{ {
return CreateView<ImageCubeView>({ return CreateView<ImageCubeView>({
.m_Image = CreateTextureCube(createInfo), .m_Image = CreateTextureCube(createInfo),
@ -454,7 +454,7 @@ systems::Device::CreateTextureCubeWithView(const TextureCubeCreateInfo &createIn
} }
Ref<ImageView> Ref<ImageView>
systems::Device::CreateAttachmentWithView(const AttachmentCreateInfo &createInfo) systems::Device::CreateAttachmentWithView(AttachmentCreateInfo const &createInfo)
{ {
return CreateView({ return CreateView({
.m_Image = CreateAttachment(createInfo), .m_Image = CreateAttachment(createInfo),
@ -465,7 +465,7 @@ systems::Device::CreateAttachmentWithView(const AttachmentCreateInfo &createInfo
} }
Ref<ImageView> Ref<ImageView>
systems::Device::CreateDepthStencilImageWithView(const DepthStencilImageCreateInfo &createInfo) systems::Device::CreateDepthStencilImageWithView(DepthStencilImageCreateInfo const &createInfo)
{ {
return CreateView({ return CreateView({
.m_Image = CreateDepthStencilImage(createInfo), .m_Image = CreateDepthStencilImage(createInfo),
@ -482,11 +482,11 @@ systems::Device::CreateDepthStencilImageWithView(const DepthStencilImageCreateIn
// ==================================================================================================== // ====================================================================================================
Ref<Sampler> Ref<Sampler>
systems::Device::CreateSampler(const SamplerCreateInfo &createInfo) systems::Device::CreateSampler(SamplerCreateInfo const &createInfo)
{ {
auto vkCreateInfo = static_cast<vk::SamplerCreateInfo>(createInfo); auto vkCreateInfo = static_cast<vk::SamplerCreateInfo>(createInfo);
if (const auto iter = m_HashToSamplerIdx.find(vkCreateInfo); if (auto const iter = m_HashToSamplerIdx.find(vkCreateInfo);
iter != m_HashToSamplerIdx.end() && !iter->second.expired()) iter != m_HashToSamplerIdx.end() && !iter->second.expired())
{ {
return iter->second.lock(); return iter->second.lock();
@ -502,7 +502,7 @@ systems::Device::CreateSampler(const SamplerCreateInfo &createInfo)
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreatePipeline(Pipeline &pipelineOut, const GraphicsPipelineCreateInfo &createInfo) systems::Device::CreatePipeline(Pipeline &pipelineOut, GraphicsPipelineCreateInfo const &createInfo)
{ {
eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders; eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders;
Slang::ComPtr<slang::IComponentType> program; Slang::ComPtr<slang::IComponentType> program;
@ -641,7 +641,7 @@ systems::Device::CreatePipeline(Pipeline &pipelineOut, const GraphicsPipelineCre
} }
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreateComputePipeline(Pipeline &pipelineOut, const ComputePipelineCreateInfo &createInfo) systems::Device::CreateComputePipeline(Pipeline &pipelineOut, ComputePipelineCreateInfo const &createInfo)
{ {
eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders; eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders;
Slang::ComPtr<slang::IComponentType> program; Slang::ComPtr<slang::IComponentType> program;
@ -701,7 +701,7 @@ systems::Device::CreateComputePipeline(Pipeline &pipelineOut, const ComputePipel
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreateShaders( systems::Device::CreateShaders(
eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> &shadersOut, eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> &shadersOut,
Slang::ComPtr<slang::IComponentType> &program, const std::span<const ShaderInfo> &shaders) Slang::ComPtr<slang::IComponentType> &program, std::span<ShaderInfo const> const &shaders)
{ {
using Slang::ComPtr; using Slang::ComPtr;
@ -718,7 +718,7 @@ systems::Device::CreateShaders(
u32 entryPointCount = 0; u32 entryPointCount = 0;
for (const auto &shaderInfo : shaders) for (auto const &shaderInfo : shaders)
{ {
ComPtr<slang::IModule> shaderModule; ComPtr<slang::IModule> shaderModule;
shaderModule = m_SlangSession->loadModule(shaderInfo.m_ShaderFile.data(), shaderDiagnostics.writeRef()); shaderModule = m_SlangSession->loadModule(shaderInfo.m_ShaderFile.data(), shaderDiagnostics.writeRef());
@ -817,7 +817,7 @@ systems::Device::CreateShaders(
} }
WARN_IF(shaderDiagnostics, "{}", static_cast<cstr>(shaderDiagnostics->getBufferPointer())); WARN_IF(shaderDiagnostics, "{}", static_cast<cstr>(shaderDiagnostics->getBufferPointer()));
vk::Result result = vk::Result::eSuccess; auto result = vk::Result::eSuccess;
for (u32 entryPoint = 0; entryPoint < entryPointCount; ++entryPoint) for (u32 entryPoint = 0; entryPoint < entryPointCount; ++entryPoint)
{ {
auto &outShader = shadersOut.push_back(); auto &outShader = shadersOut.push_back();
@ -840,9 +840,9 @@ systems::Device::CreateShaders(
} }
} }
const vk::ShaderModuleCreateInfo shaderModuleCreateInfo = { vk::ShaderModuleCreateInfo const shaderModuleCreateInfo = {
.codeSize = kernelCode->getBufferSize(), .codeSize = kernelCode->getBufferSize(),
.pCode = static_cast<const u32 *>(kernelCode->getBufferPointer()), .pCode = static_cast<u32 const *>(kernelCode->getBufferPointer()),
}; };
result = m_Device->createShaderModule(&shaderModuleCreateInfo, nullptr, &outShader.module); result = m_Device->createShaderModule(&shaderModuleCreateInfo, nullptr, &outShader.module);
@ -887,14 +887,14 @@ systems::PipelineCreationError
PipelineLayoutBuilder::Build(vk::PipelineLayout &pipelineLayout, PipelineLayoutBuilder::Build(vk::PipelineLayout &pipelineLayout,
eastl::vector<vk::DescriptorSetLayout> &descriptorSetLayouts) eastl::vector<vk::DescriptorSetLayout> &descriptorSetLayouts)
{ {
const vk::PipelineLayoutCreateInfo layoutCreateInfo = { vk::PipelineLayoutCreateInfo const layoutCreateInfo = {
.setLayoutCount = static_cast<u32>(m_DescriptorSetLayouts.size()), .setLayoutCount = static_cast<u32>(m_DescriptorSetLayouts.size()),
.pSetLayouts = m_DescriptorSetLayouts.data(), .pSetLayouts = m_DescriptorSetLayouts.data(),
.pushConstantRangeCount = static_cast<u32>(m_PushConstantRanges.size()), .pushConstantRangeCount = static_cast<u32>(m_PushConstantRanges.size()),
.pPushConstantRanges = m_PushConstantRanges.data(), .pPushConstantRanges = m_PushConstantRanges.data(),
}; };
const auto result = m_Device->m_Device->createPipelineLayout(&layoutCreateInfo, nullptr, &pipelineLayout); auto const result = m_Device->m_Device->createPipelineLayout(&layoutCreateInfo, nullptr, &pipelineLayout);
for (const auto &descSet : descriptorSetLayouts) for (auto const &descSet : descriptorSetLayouts)
{ {
m_Device->m_Device->destroy(descSet, nullptr); m_Device->m_Device->destroy(descSet, nullptr);
} }
@ -903,7 +903,7 @@ PipelineLayoutBuilder::Build(vk::PipelineLayout &pipelineLayout,
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, systems::Device::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout,
const Slang::ComPtr<slang::IComponentType> &program) Slang::ComPtr<slang::IComponentType> const &program)
{ {
using Slang::ComPtr; using Slang::ComPtr;
@ -936,7 +936,7 @@ systems::Device::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout,
#pragma endregion #pragma endregion
QueueAllocation QueueAllocation
FindAppropriateQueueAllocation(const PhysicalDevice &physicalDevice) FindAppropriateQueueAllocation(PhysicalDevice const &physicalDevice)
{ {
for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies) for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies)
{ {
@ -953,7 +953,7 @@ FindAppropriateQueueAllocation(const PhysicalDevice &physicalDevice)
} }
std::optional<QueueAllocation> std::optional<QueueAllocation>
FindAsyncTransferQueue(const PhysicalDevice &physicalDevice, u32 primaryQueueFamilyIndex) FindAsyncTransferQueue(PhysicalDevice const &physicalDevice, u32 primaryQueueFamilyIndex)
{ {
for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies) for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies)
{ {
@ -973,7 +973,7 @@ FindAsyncTransferQueue(const PhysicalDevice &physicalDevice, u32 primaryQueueFam
} }
std::optional<QueueAllocation> std::optional<QueueAllocation>
FindAsyncComputeQueue(const PhysicalDevice &physicalDevice, u32 primaryQueueFamilyIndex) FindAsyncComputeQueue(PhysicalDevice const &physicalDevice, u32 primaryQueueFamilyIndex)
{ {
for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies) for (auto &queueFamilyInfo : physicalDevice.m_QueueFamilies)
{ {
@ -993,7 +993,7 @@ FindAsyncComputeQueue(const PhysicalDevice &physicalDevice, u32 primaryQueueFami
return std::nullopt; return std::nullopt;
} }
systems::Device::Device(const DeviceCreateInfo &createInfo) systems::Device::Device(DeviceCreateInfo const &createInfo)
: m_Window{createInfo.m_Window} : m_Window{createInfo.m_Window}
, m_SyncServer{new _internal::SyncServer{*this}} , 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_Instance = Instance{createInfo.m_AppName, createInfo.m_AppVersion};
m_Surface = Surface{m_Instance, createInfo.m_Window}; 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); auto physicalDevice = createInfo.m_PhysicalDeviceSelector(physicalDevices);
Features features = createInfo.m_Features; Features features = createInfo.m_Features;
@ -1017,9 +1017,9 @@ systems::Device::Device(const DeviceCreateInfo &createInfo)
m_PrimaryQueueFamily = primaryQueue.m_Family; m_PrimaryQueueFamily = primaryQueue.m_Family;
u32 transferQueueIndex; 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); queueAllocations.push_back(allocation);
m_TransferQueueFamily = allocation.m_Family; m_TransferQueueFamily = allocation.m_Family;
transferQueueIndex = 0; transferQueueIndex = 0;
@ -1032,9 +1032,9 @@ systems::Device::Device(const DeviceCreateInfo &createInfo)
} }
u32 computeQueueIndex; 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); queueAllocations.push_back(allocation);
m_ComputeQueueFamily = allocation.m_Family; m_ComputeQueueFamily = allocation.m_Family;
computeQueueIndex = 0; computeQueueIndex = 0;
@ -1082,13 +1082,13 @@ systems::Device::Device(const DeviceCreateInfo &createInfo)
eastl::array compilerOptions = {useOriginalEntrypointNames, bindlessSpaceIndex, scalarLayout}; eastl::array compilerOptions = {useOriginalEntrypointNames, bindlessSpaceIndex, scalarLayout};
slang::PreprocessorMacroDesc fancyFlag = {"_DEBUG", "1"}; slang::PreprocessorMacroDesc fancyFlag = {"_DEBUG", "1"};
const slang::TargetDesc spirvTargetDesc = { slang::TargetDesc const spirvTargetDesc = {
.format = SLANG_SPIRV, .format = SLANG_SPIRV,
.profile = m_GlobalSlangSession->findProfile("sm_6_6"), .profile = m_GlobalSlangSession->findProfile("sm_6_6"),
.compilerOptionEntries = compilerOptions.data(), .compilerOptionEntries = compilerOptions.data(),
.compilerOptionEntryCount = static_cast<u32>(compilerOptions.size()), .compilerOptionEntryCount = static_cast<u32>(compilerOptions.size()),
}; };
const slang::SessionDesc sessionDesc = { slang::SessionDesc const sessionDesc = {
.targets = &spirvTargetDesc, .targets = &spirvTargetDesc,
.targetCount = 1, .targetCount = 1,
.searchPaths = createInfo.m_ShaderSearchPaths.data(), .searchPaths = createInfo.m_ShaderSearchPaths.data(),
@ -1170,7 +1170,7 @@ void
systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext) systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext)
{ {
vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eColorAttachmentOutput; vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eColorAttachmentOutput;
const vk::SubmitInfo submitInfo = { vk::SubmitInfo const submitInfo = {
.waitSemaphoreCount = 1, .waitSemaphoreCount = 1,
.pWaitSemaphores = &frame.m_ImageAcquireSem, .pWaitSemaphores = &frame.m_ImageAcquireSem,
.pWaitDstStageMask = &waitDstStage, .pWaitDstStageMask = &waitDstStage,
@ -1183,7 +1183,7 @@ systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext)
ERROR_IF(Failed(result), "Command queue submit failed. Cause: {}", result) ERROR_IF(Failed(result), "Command queue submit failed. Cause: {}", result)
THEN_ABORT(result); THEN_ABORT(result);
const vk::PresentInfoKHR presentInfo = { vk::PresentInfoKHR const presentInfo = {
.waitSemaphoreCount = 1, .waitSemaphoreCount = 1,
.pWaitSemaphores = &frame.m_RenderFinishSem, .pWaitSemaphores = &frame.m_RenderFinishSem,
.swapchainCount = 1, .swapchainCount = 1,
@ -1220,7 +1220,7 @@ systems::Device::CreateComputeContext()
systems::Receipt systems::Receipt
systems::Device::Submit(Context &context) systems::Device::Submit(Context &context)
{ {
const auto rect = m_SyncServer->Allocate(); auto const rect = m_SyncServer->Allocate();
auto &entry = m_SyncServer->GetEntry(rect); auto &entry = m_SyncServer->GetEntry(rect);
if (context.m_Pool->m_ManagedBy == _internal::ContextPool::ManagedBy::eDevice) if (context.m_Pool->m_ManagedBy == _internal::ContextPool::ManagedBy::eDevice)
@ -1236,7 +1236,7 @@ systems::Device::Submit(Context &context)
// TODO: Separate per context // TODO: Separate per context
vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eAllCommands; vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eAllCommands;
const vk::SubmitInfo submitInfo = { vk::SubmitInfo const submitInfo = {
.pNext = &timelineSubmit, .pNext = &timelineSubmit,
.waitSemaphoreCount = 1, .waitSemaphoreCount = 1,
.pWaitSemaphores = &entry.m_Semaphore, .pWaitSemaphores = &entry.m_Semaphore,

View File

@ -80,7 +80,7 @@ systems::PipelineCreationError::What()
} }
vk::ShaderStageFlagBits vk::ShaderStageFlagBits
systems::SlangToVulkanShaderStage(const SlangStage stage) systems::SlangToVulkanShaderStage(SlangStage const stage)
{ {
switch (stage) switch (stage)
{ {
@ -142,7 +142,7 @@ PipelineLayoutBuilder::Build()
} }
} }
const vk::PipelineLayoutCreateInfo createInfo = { vk::PipelineLayoutCreateInfo const createInfo = {
.setLayoutCount = static_cast<u32>(filteredDescriptorSetLayouts.size()), .setLayoutCount = static_cast<u32>(filteredDescriptorSetLayouts.size()),
.pSetLayouts = filteredDescriptorSetLayouts.data(), .pSetLayouts = filteredDescriptorSetLayouts.data(),
.pushConstantRangeCount = static_cast<u32>(m_PushConstants.size()), .pushConstantRangeCount = static_cast<u32>(m_PushConstants.size()),
@ -154,7 +154,7 @@ PipelineLayoutBuilder::Build()
} }
vk::DescriptorSetLayout vk::DescriptorSetLayout
PipelineLayoutBuilder::CreateDescriptorSetLayout(const vk::DescriptorSetLayoutCreateInfo &createInfo) const PipelineLayoutBuilder::CreateDescriptorSetLayout(vk::DescriptorSetLayoutCreateInfo const &createInfo) const
{ {
vk::DescriptorSetLayout dsl; vk::DescriptorSetLayout dsl;
// Failure Cases are OoM errors. No recovery. // Failure Cases are OoM errors. No recovery.
@ -173,8 +173,8 @@ PipelineLayoutBuilder::AddDescriptorSetForParameterBlock(slang::TypeLayoutReflec
void void
PipelineLayoutBuilder::AddPushConstantRangeForConstantBuffer(slang::TypeLayoutReflection *layout) PipelineLayoutBuilder::AddPushConstantRangeForConstantBuffer(slang::TypeLayoutReflection *layout)
{ {
const auto elementTypeLayout = layout->getElementTypeLayout(); auto const elementTypeLayout = layout->getElementTypeLayout();
const auto elementSize = elementTypeLayout->getSize(); auto const elementSize = elementTypeLayout->getSize();
if (elementSize == 0) if (elementSize == 0)
return; return;
@ -193,13 +193,13 @@ PipelineLayoutBuilder::AddSubObjectRange(slang::TypeLayoutReflection *layout, i6
switch (layout->getBindingRangeType(bindingRangeIndex)) switch (layout->getBindingRangeType(bindingRangeIndex))
{ {
case slang::BindingType::ParameterBlock: { case slang::BindingType::ParameterBlock: {
const auto parameterBlockTypeLayout = layout->getBindingRangeLeafTypeLayout(bindingRangeIndex); auto const parameterBlockTypeLayout = layout->getBindingRangeLeafTypeLayout(bindingRangeIndex);
AddDescriptorSetForParameterBlock(parameterBlockTypeLayout); AddDescriptorSetForParameterBlock(parameterBlockTypeLayout);
} }
break; break;
case slang::BindingType::PushConstant: { case slang::BindingType::PushConstant: {
const auto constantBufferTypeLayout = layout->getBindingRangeLeafTypeLayout(bindingRangeIndex); auto const constantBufferTypeLayout = layout->getBindingRangeLeafTypeLayout(bindingRangeIndex);
AddPushConstantRangeForConstantBuffer(constantBufferTypeLayout); AddPushConstantRangeForConstantBuffer(constantBufferTypeLayout);
} }
break; break;
@ -256,19 +256,19 @@ DescriptorLayoutBuilder::DescriptorLayoutBuilder(PipelineLayoutBuilder *pipeline
} }
void void
DescriptorLayoutBuilder::AddDescriptorRange(slang::TypeLayoutReflection *layout, const i64 relativeSetIndex, DescriptorLayoutBuilder::AddDescriptorRange(slang::TypeLayoutReflection *layout, i64 const relativeSetIndex,
const i64 rangeIndex) i64 const rangeIndex)
{ {
const auto bindingType = layout->getDescriptorSetDescriptorRangeType(relativeSetIndex, rangeIndex); auto const bindingType = layout->getDescriptorSetDescriptorRangeType(relativeSetIndex, rangeIndex);
if (bindingType == slang::BindingType::PushConstant) if (bindingType == slang::BindingType::PushConstant)
return; return;
const u32 descriptorCount = u32 const descriptorCount =
static_cast<u32>(layout->getDescriptorSetDescriptorRangeDescriptorCount(relativeSetIndex, rangeIndex)); static_cast<u32>(layout->getDescriptorSetDescriptorRangeDescriptorCount(relativeSetIndex, rangeIndex));
const u32 bindingIndex = static_cast<u32>(m_LayoutBindings.size()); u32 const bindingIndex = static_cast<u32>(m_LayoutBindings.size());
const auto vkBindingType = BindingTypeToDescriptorType(bindingType); auto const vkBindingType = BindingTypeToDescriptorType(bindingType);
m_LayoutBindings.push_back({ m_LayoutBindings.push_back({
.binding = bindingIndex, .binding = bindingIndex,
@ -299,7 +299,7 @@ DescriptorLayoutBuilder::Build()
if (m_LayoutBindings.empty()) if (m_LayoutBindings.empty())
return; return;
const auto dsl = m_PipelineLayoutBuilder->CreateDescriptorSetLayout({ auto const dsl = m_PipelineLayoutBuilder->CreateDescriptorSetLayout({
.bindingCount = static_cast<u32>(m_LayoutBindings.size()), .bindingCount = static_cast<u32>(m_LayoutBindings.size()),
.pBindings = m_LayoutBindings.data(), .pBindings = m_LayoutBindings.data(),
}); });
@ -309,7 +309,7 @@ DescriptorLayoutBuilder::Build()
void void
DescriptorLayoutBuilder::AddAutomaticallyIntroducedUniformBuffer() DescriptorLayoutBuilder::AddAutomaticallyIntroducedUniformBuffer()
{ {
const auto vulkanBindingIndex = static_cast<u32>(m_LayoutBindings.size()); auto const vulkanBindingIndex = static_cast<u32>(m_LayoutBindings.size());
m_LayoutBindings.push_back({ m_LayoutBindings.push_back({
.binding = vulkanBindingIndex, .binding = vulkanBindingIndex,

View File

@ -34,7 +34,7 @@ SyncServer::Entry::Destroy(Device &device)
void void
SyncServer::Entry::Wait(Device &device) SyncServer::Entry::Wait(Device &device)
{ {
const vk::SemaphoreWaitInfo waitInfo = { vk::SemaphoreWaitInfo const waitInfo = {
.semaphoreCount = 1, .semaphoreCount = 1,
.pSemaphores = &m_Semaphore, .pSemaphores = &m_Semaphore,
.pValues = &m_CurrentPoint.m_NextValue, .pValues = &m_CurrentPoint.m_NextValue,
@ -75,13 +75,13 @@ SyncServer::Allocate()
} }
void void
SyncServer::Free(const Receipt receipt) SyncServer::Free(Receipt const receipt)
{ {
FreeEntry(GetEntry(receipt)); FreeEntry(GetEntry(receipt));
} }
void void
SyncServer::WaitOn(const Receipt receipt) SyncServer::WaitOn(Receipt const receipt)
{ {
auto &entry = GetEntry(receipt); auto &entry = GetEntry(receipt);
entry.Wait(*m_Device); entry.Wait(*m_Device);

View File

@ -22,7 +22,7 @@ ReadFile(std::string_view fileName)
do do
{ {
readCount = fread(buffer.data(), sizeof(u32), buffer.size(), filePtr); readCount = fread(buffer.data(), sizeof(u32), buffer.size(), filePtr);
const auto nextSize = totalRead + readCount; auto const nextSize = totalRead + readCount;
outputVec.resize(nextSize); outputVec.resize(nextSize);
memcpy(outputVec.data() + totalRead, buffer.data(), readCount * sizeof *buffer.data()); memcpy(outputVec.data() + totalRead, buffer.data(), readCount * sizeof *buffer.data());
totalRead = nextSize; totalRead = nextSize;
@ -49,7 +49,7 @@ ReadFileBytes(std::string_view fileName, bool errorOnFail)
do do
{ {
readCount = fread(buffer.data(), sizeof(u8), buffer.size(), filePtr); readCount = fread(buffer.data(), sizeof(u8), buffer.size(), filePtr);
const auto nextSize = totalRead + readCount; auto const nextSize = totalRead + readCount;
outputVec.resize(nextSize); outputVec.resize(nextSize);
memcpy(outputVec.data() + totalRead, buffer.data(), readCount * sizeof *buffer.data()); memcpy(outputVec.data() + totalRead, buffer.data(), readCount * sizeof *buffer.data());
totalRead = nextSize; totalRead = nextSize;
@ -61,7 +61,7 @@ ReadFileBytes(std::string_view fileName, bool errorOnFail)
} }
bool bool
WriteFileBytes(std::string_view fileName, const eastl::span<u8> data) WriteFileBytes(std::string_view fileName, eastl::span<u8> const data)
{ {
FILE *filePtr = fopen(fileName.data(), "wb"); FILE *filePtr = fopen(fileName.data(), "wb");
@ -71,7 +71,7 @@ WriteFileBytes(std::string_view fileName, const eastl::span<u8> data)
return false; 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); (void)fclose(filePtr);

View File

@ -12,7 +12,7 @@ auto g_Logger = Logger();
namespace eastl namespace eastl
{ {
void void
AssertionFailure(const char *af) AssertionFailure(char const *af)
{ {
ERROR("{}", af); ERROR("{}", af);
} }

View File

@ -45,7 +45,7 @@ Init(systems::Device &device, Window &window)
{vk::DescriptorType::eInputAttachment, 1000}, {vk::DescriptorType::eInputAttachment, 1000},
}; };
const vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo = { vk::DescriptorPoolCreateInfo const descriptorPoolCreateInfo = {
.flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, .flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet,
.maxSets = 1000, .maxSets = 1000,
.poolSizeCount = static_cast<u32>(poolSizes.size()), .poolSizeCount = static_cast<u32>(poolSizes.size()),
@ -93,8 +93,8 @@ Init(systems::Device &device, Window &window)
} }
void void
Init(const Instance *context, const Device *device, const Window *window, vk::Format attachmentFormat, Init(Instance const *context, Device const *device, Window const *window, vk::Format attachmentFormat,
const u32 imageCount, const u32 queueFamily, const vk::Queue queue) u32 const imageCount, u32 const queueFamily, vk::Queue const queue)
{ {
g_AttachmentFormat = attachmentFormat; g_AttachmentFormat = attachmentFormat;
@ -112,7 +112,7 @@ Init(const Instance *context, const Device *device, const Window *window, vk::Fo
{vk::DescriptorType::eInputAttachment, 1000}, {vk::DescriptorType::eInputAttachment, 1000},
}; };
const vk::DescriptorPoolCreateInfo descriptorPoolCreateInfo = { vk::DescriptorPoolCreateInfo const descriptorPoolCreateInfo = {
.flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet, .flags = vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet,
.maxSets = 1000, .maxSets = 1000,
.poolSizeCount = static_cast<u32>(poolSizes.size()), .poolSizeCount = static_cast<u32>(poolSizes.size()),
@ -158,7 +158,7 @@ Init(const Instance *context, const Device *device, const Window *window, vk::Fo
} }
void void
Destroy(const systems::Device &device) Destroy(systems::Device const &device)
{ {
ImGui_ImplVulkan_Shutdown(); ImGui_ImplVulkan_Shutdown();
ImGui_ImplGlfw_Shutdown(); ImGui_ImplGlfw_Shutdown();
@ -168,7 +168,7 @@ Destroy(const systems::Device &device)
} }
void void
Destroy(const Device *device) Destroy(Device const *device)
{ {
ImGui_ImplVulkan_Shutdown(); ImGui_ImplVulkan_Shutdown();
ImGui_ImplGlfw_Shutdown(); ImGui_ImplGlfw_Shutdown();
@ -190,7 +190,7 @@ StartBuild()
// because it would be confusing to have two docking targets within each others. // because it would be confusing to have two docking targets within each others.
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_None | ImGuiWindowFlags_NoDocking; ImGuiWindowFlags windowFlags = ImGuiWindowFlags_None | ImGuiWindowFlags_NoDocking;
const ImGuiViewport *viewport = GetMainViewport(); ImGuiViewport const *viewport = GetMainViewport();
SetNextWindowPos(viewport->WorkPos); SetNextWindowPos(viewport->WorkPos);
SetNextWindowSize(viewport->WorkSize); SetNextWindowSize(viewport->WorkSize);
// SetNextWindowViewport(viewport->ID); // SetNextWindowViewport(viewport->ID);
@ -215,7 +215,7 @@ StartBuild()
// DockSpace // DockSpace
if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable) if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
{ {
const ImGuiID dockspaceId = GetID("MyDockSpace"); ImGuiID const dockspaceId = GetID("MyDockSpace");
DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags); DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
} }
} }
@ -237,7 +237,7 @@ EndBuild()
} }
void 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(); // 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}, .clearValue = vk::ClearColorValue{0.0f, 0.0f, 0.0f, 1.0f},
}; };
const vk::RenderingInfo renderingInfo = { vk::RenderingInfo const renderingInfo = {
.renderArea = {.extent = extent}, .renderArea = {.extent = extent},
.layerCount = 1, .layerCount = 1,
.colorAttachmentCount = 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}, .clearValue = vk::ClearColorValue{0.0f, 0.0f, 0.0f, 1.0f},
}; };
const vk::RenderingInfo renderingInfo = { vk::RenderingInfo const renderingInfo = {
.renderArea = {.extent = frame.m_SwapchainSize}, .renderArea = {.extent = frame.m_SwapchainSize},
.layerCount = 1, .layerCount = 1,
.colorAttachmentCount = 1, .colorAttachmentCount = 1,

View File

@ -15,24 +15,24 @@ constexpr QueueSupportFlags REQUIRED_QUEUE_SUPPORT = QueueSupportFlags{} | Queue
QueueSupportFlagBits::eTransfer; QueueSupportFlagBits::eTransfer;
bool bool
IsSuitableDevice(const PhysicalDevice *physicalDevice) IsSuitableDevice(PhysicalDevice const *physicalDevice)
{ {
const bool hasAllRequiredQueues = bool const hasAllRequiredQueues =
std::ranges::any_of(physicalDevice->m_QueueFamilies, [](const auto &queueFamilyProp) { std::ranges::any_of(physicalDevice->m_QueueFamilies, [](auto const &queueFamilyProp) {
return (queueFamilyProp.m_Support & REQUIRED_QUEUE_SUPPORT) == REQUIRED_QUEUE_SUPPORT; 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; return hasSurfaceFormat && hasPresentMode && isNotCpu && hasAllRequiredQueues;
} }
PhysicalDevice PhysicalDevice
FindSuitableDevice(const PhysicalDevices &physicalDevices) FindSuitableDevice(PhysicalDevices const &physicalDevices)
{ {
for (auto &physicalDevice : physicalDevices) for (auto &physicalDevice : physicalDevices)
{ {
@ -47,7 +47,7 @@ FindSuitableDevice(const PhysicalDevices &physicalDevices)
} }
QueueAllocation QueueAllocation
FindAppropriateQueueAllocation(const PhysicalDevice *physicalDevice) FindAppropriateQueueAllocation(PhysicalDevice const *physicalDevice)
{ {
for (auto &queueFamilyInfo : physicalDevice->m_QueueFamilies) for (auto &queueFamilyInfo : physicalDevice->m_QueueFamilies)
{ {

View File

@ -37,7 +37,7 @@ struct ImageFile
operator eastl::span<u8>() const operator eastl::span<u8>() const
{ {
return {static_cast<u8*>(m_Data), GetSize()}; return {static_cast<u8 *>(m_Data), GetSize()};
} }
~ImageFile(); ~ImageFile();
@ -314,7 +314,7 @@ main(int, char **)
eastl::fixed_vector<Ref<ImageView>, MAX_FRAMES_IN_FLIGHT> depthImages; eastl::fixed_vector<Ref<ImageView>, 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) for (u32 i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i)
{ {
depthImages.push_back(device.CreateDepthStencilImageWithView({.m_Extent = extent, .m_Name = "Depth"})); depthImages.push_back(device.CreateDepthStencilImageWithView({.m_Extent = extent, .m_Name = "Depth"}));
@ -323,7 +323,7 @@ main(int, char **)
initDepthImages(swapchainSize); initDepthImages(swapchainSize);
auto recreateDepthBuffers = [&depthImages, &initDepthImages](const vk::Extent2D extent) { auto recreateDepthBuffers = [&depthImages, &initDepthImages](vk::Extent2D const extent) {
depthImages.clear(); depthImages.clear();
initDepthImages(extent); initDepthImages(extent);
}; };

View File

@ -30,7 +30,7 @@
constexpr vk::CommandBufferBeginInfo OneTimeCmdBeginInfo = {.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit}; constexpr vk::CommandBufferBeginInfo OneTimeCmdBeginInfo = {.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit};
vec4 vec4
VectorToVec4(const std::vector<double> &vec) VectorToVec4(std::vector<double> const &vec)
{ {
if (vec.empty()) if (vec.empty())
{ {
@ -41,7 +41,7 @@ VectorToVec4(const std::vector<double> &vec)
} }
vec4 vec4
VectorToVec4(const std::vector<double> &vec, float w) VectorToVec4(std::vector<double> const &vec, float w)
{ {
if (vec.empty()) if (vec.empty())
{ {
@ -52,7 +52,7 @@ VectorToVec4(const std::vector<double> &vec, float w)
} }
vec3 vec3
VectorToVec3(const std::vector<double> &vec) VectorToVec3(std::vector<double> const &vec)
{ {
if (vec.empty()) if (vec.empty())
{ {
@ -161,7 +161,7 @@ AssetLoader::LoadHdrImage(cstr path, cstr name) const
} }
void void
GenerateMipMaps(systems::TransferContext &context, const Ref<Texture> &texture, vk::ImageLayout initialLayout, GenerateMipMaps(systems::TransferContext &context, Ref<Texture> const &texture, vk::ImageLayout initialLayout,
vk::ImageLayout finalLayout, vk::PipelineStageFlags2 prevStage, vk::PipelineStageFlags2 finalStage) vk::ImageLayout finalLayout, vk::PipelineStageFlags2 prevStage, vk::PipelineStageFlags2 finalStage)
{ {
#if !defined(ASTER_NDEBUG) #if !defined(ASTER_NDEBUG)
@ -440,8 +440,8 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
tinygltf::Model model; tinygltf::Model model;
tinygltf::TinyGLTF loader; tinygltf::TinyGLTF loader;
const auto fsPath = fs::absolute(path); auto const fsPath = fs::absolute(path);
const auto ext = fsPath.extension(); auto const ext = fsPath.extension();
if (ext == GLTF_ASCII_FILE_EXTENSION) if (ext == GLTF_ASCII_FILE_EXTENSION)
{ {
std::string err; std::string err;
@ -480,17 +480,17 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
{ {
// TODO("Something broken on load here."); // TODO("Something broken on load here.");
auto getTextureHandle = [this, &context, &textureHandleMap, auto getTextureHandle = [this, &context, &textureHandleMap,
&model](i32 index, const bool isSrgb) -> systems::ResId<TextureView> { &model](i32 index, bool const isSrgb) -> systems::ResId<TextureView> {
if (index < 0) if (index < 0)
{ {
return systems::NullId{}; 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; return iter->second;
} }
const auto &texture = model.textures[index]; auto const &texture = model.textures[index];
auto *image = &model.images[texture.source]; auto *image = &model.images[texture.source];
auto handle = LoadImageToGpu(context, image, isSrgb, texture.name.empty() ? nullptr : texture.name.c_str()); auto handle = LoadImageToGpu(context, image, isSrgb, texture.name.empty() ? nullptr : texture.name.c_str());
textureHandleMap.emplace(index, handle); textureHandleMap.emplace(index, handle);
@ -749,7 +749,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
{ {
eastl::function<void(i32, i32)> processNode = [&processNode, &model, &nodes, &meshPrimRanges, eastl::function<void(i32, i32)> processNode = [&processNode, &model, &nodes, &meshPrimRanges,
&meshPrimitives](i32 idx, i32 parent) -> void { &meshPrimitives](i32 idx, i32 parent) -> void {
const auto *node = &model.nodes[idx]; auto const *node = &model.nodes[idx];
auto nodeTranslation = vec3{0.0f}; auto nodeTranslation = vec3{0.0f};
auto nodeRotation = quat{1.0f, 0.0f, 0.0f, 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()); 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; scale(mat4(1.0f), nodeScale) * nodeMatrix;
const i32 nodeArrayIndex = static_cast<i32>(nodes.Add(transform, parent)); i32 const nodeArrayIndex = static_cast<i32>(nodes.Add(transform, parent));
if (node->mesh >= 0) if (node->mesh >= 0)
{ {
auto [start, count] = meshPrimRanges[node->mesh]; auto [start, count] = meshPrimRanges[node->mesh];
const auto end = start + count; auto const end = start + count;
for (usize i = start; i != end; ++i) for (usize i = start; i != end; ++i)
{ {
meshPrimitives[i].m_TransformIdx = nodeArrayIndex; meshPrimitives[i].m_TransformIdx = nodeArrayIndex;
} }
} }
for (const i32 child : node->children) for (i32 const child : node->children)
{ {
processNode(child, nodeArrayIndex); processNode(child, nodeArrayIndex);
} }
@ -854,7 +854,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
} }
Model::Model(eastl::vector<systems::ResId<TextureView>> &textureHandles, Nodes &&nodes, Ref<Buffer> nodeBuffer, Model::Model(eastl::vector<systems::ResId<TextureView>> &textureHandles, Nodes &&nodes, Ref<Buffer> nodeBuffer,
ModelHandles &handles, Ref<IndexBuffer> indexBuffer, const eastl::vector<MeshPrimitive> &meshPrimitives) ModelHandles &handles, Ref<IndexBuffer> indexBuffer, eastl::vector<MeshPrimitive> const &meshPrimitives)
: m_TextureHandles(std::move(textureHandles)) : m_TextureHandles(std::move(textureHandles))
, m_Nodes(std::move(nodes)) , m_Nodes(std::move(nodes))
, m_Handles(std::move(handles)) , m_Handles(std::move(handles))
@ -864,14 +864,14 @@ Model::Model(eastl::vector<systems::ResId<TextureView>> &textureHandles, Nodes &
{ {
} }
const mat4 & mat4 const &
Model::GetModelTransform() const Model::GetModelTransform() const
{ {
return m_Nodes[0]; return m_Nodes[0];
} }
void void
Model::SetModelTransform(const mat4 &transform) Model::SetModelTransform(mat4 const &transform)
{ {
m_Nodes.Set(0, transform); m_Nodes.Set(0, transform);
} }

View File

@ -86,20 +86,19 @@ struct Model
Ref<IndexBuffer> m_IndexBuffer; Ref<IndexBuffer> m_IndexBuffer;
eastl::vector<MeshPrimitive> m_MeshPrimitives; eastl::vector<MeshPrimitive> m_MeshPrimitives;
[[nodiscard]] const mat4 &GetModelTransform() const; [[nodiscard]] mat4 const &GetModelTransform() const;
void SetModelTransform(const mat4 &transform); void SetModelTransform(mat4 const &transform);
void Update(); void Update();
Model(eastl::vector<systems::ResId<TextureView>> &textureHandles, Model(eastl::vector<systems::ResId<TextureView>> &textureHandles, Nodes &&nodes, Ref<Buffer> nodeBuffer,
Nodes &&nodes, Ref<Buffer> nodeBuffer, ModelHandles &handles, Ref<IndexBuffer> indexBuffer, ModelHandles &handles, Ref<IndexBuffer> indexBuffer, eastl::vector<MeshPrimitive> const &meshPrimitives);
const eastl::vector<MeshPrimitive> &meshPrimitives);
~Model() = default; ~Model() = default;
Model(Model &&other) noexcept = default; Model(Model &&other) noexcept = default;
Model &operator=(Model &&other) noexcept = default; Model &operator=(Model &&other) noexcept = default;
Model(const Model &) = delete; Model(Model const &) = delete;
const Model &operator=(const Model &) = delete; Model const &operator=(Model const &) = delete;
}; };
struct AssetLoader struct AssetLoader
@ -126,7 +125,7 @@ struct AssetLoader
}; };
void void
GenerateMipMaps(systems::TransferContext &context, const Ref<Texture> &textureView, vk::ImageLayout initialLayout, GenerateMipMaps(systems::TransferContext &context, Ref<Texture> const &textureView, vk::ImageLayout initialLayout,
vk::ImageLayout finalLayout, vk::PipelineStageFlags2 prevStage, vk::PipelineStageFlags2 finalStage); vk::ImageLayout finalLayout, vk::PipelineStageFlags2 prevStage, vk::PipelineStageFlags2 finalStage);
void void
@ -135,8 +134,7 @@ GenerateMipMaps(systems::TransferContext &context, concepts::ImageRefTo<Texture>
vk::PipelineStageFlags2 prevStage = vk::PipelineStageFlagBits2::eAllCommands, vk::PipelineStageFlags2 prevStage = vk::PipelineStageFlagBits2::eAllCommands,
vk::PipelineStageFlags2 finalStage = vk::PipelineStageFlagBits2::eAllCommands) vk::PipelineStageFlags2 finalStage = vk::PipelineStageFlagBits2::eAllCommands)
{ {
GenerateMipMaps(context, systems::CastImage<Texture>(texture), initialLayout, finalLayout, prevStage, GenerateMipMaps(context, systems::CastImage<Texture>(texture), initialLayout, finalLayout, prevStage, finalStage);
finalStage);
} }
void void

View File

@ -24,7 +24,7 @@ constexpr auto PREFILTER_ENTRY = "prefilter";
constexpr auto BRDF_LUT_ENTRY = "brdfLut"; constexpr auto BRDF_LUT_ENTRY = "brdfLut";
Environment Environment
CreateCubeFromHdrEnv(AssetLoader &assetLoader, const u32 cubeSide, systems::ResId<TextureView> hdrEnv) CreateCubeFromHdrEnv(AssetLoader &assetLoader, u32 const cubeSide, systems::ResId<TextureView> hdrEnv)
{ {
systems::Device &device = *assetLoader.m_Device; systems::Device &device = *assetLoader.m_Device;
auto *commitManager = device.m_CommitManager.get(); auto *commitManager = device.m_CommitManager.get();

View File

@ -34,22 +34,22 @@ static_assert((Light::TYPE_MASK & Light::TYPE_SPOT) == Light::TYPE_SPOT);
static_assert(Light::COLOR_MASK == 0xFFFFFF00); static_assert(Light::COLOR_MASK == 0xFFFFFF00);
inline u32 inline u32
ToColor32(const vec4 &col) ToColor32(vec4 const &col)
{ {
const u32 r = static_cast<u32>(eastl::min(col.r, 1.0f) * 255.99f); u32 const r = static_cast<u32>(eastl::min(col.r, 1.0f) * 255.99f);
const u32 g = static_cast<u32>(eastl::min(col.g, 1.0f) * 255.99f); u32 const g = static_cast<u32>(eastl::min(col.g, 1.0f) * 255.99f);
const u32 b = static_cast<u32>(eastl::min(col.b, 1.0f) * 255.99f); u32 const b = static_cast<u32>(eastl::min(col.b, 1.0f) * 255.99f);
const u32 a = static_cast<u32>(eastl::min(col.a, 1.0f) * 255.99f); u32 const a = static_cast<u32>(eastl::min(col.a, 1.0f) * 255.99f);
return r << 24 | g << 16 | b << 8 | a; return r << 24 | g << 16 | b << 8 | a;
} }
inline u32 inline u32
ToColor32(const vec3 &col) ToColor32(vec3 const &col)
{ {
const u32 r = static_cast<u32>(eastl::min(col.r, 1.0f) * 255.99f); u32 const r = static_cast<u32>(eastl::min(col.r, 1.0f) * 255.99f);
const u32 g = static_cast<u32>(eastl::min(col.g, 1.0f) * 255.99f); u32 const g = static_cast<u32>(eastl::min(col.g, 1.0f) * 255.99f);
const u32 b = static_cast<u32>(eastl::min(col.b, 1.0f) * 255.99f); u32 const b = static_cast<u32>(eastl::min(col.b, 1.0f) * 255.99f);
constexpr u32 a = 255; constexpr u32 a = 255;
return r << 24 | g << 16 | b << 8 | a; return r << 24 | g << 16 | b << 8 | a;
@ -89,9 +89,9 @@ LightManager::operator=(LightManager &&other) noexcept
} }
LightHandle 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) if (m_DirectionalLightCount < m_MetaInfo.m_DirectionalLightMaxCount)
{ {
u16 index = 0; u16 index = 0;
@ -99,7 +99,7 @@ LightManager::AddDirectional(const vec3 &direction, const vec3 &color, f32 inten
{ {
if (light.m_Range < 0) 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_Color_ = (ToColor32(color) & Light::COLOR_MASK) | Light::TYPE_DIRECTIONAL | gen;
light.m_Range = 1.0f; 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 && if (m_DirectionalLightCount == m_MetaInfo.m_DirectionalLightMaxCount &&
m_MetaInfo.m_DirectionalLightMaxCount == m_MetaInfo.m_PointLightOffset) m_MetaInfo.m_DirectionalLightMaxCount == m_MetaInfo.m_PointLightOffset)
{ {
const u16 oldPointLightOffset = m_MetaInfo.m_PointLightOffset; u16 const oldPointLightOffset = m_MetaInfo.m_PointLightOffset;
const u32 pointLightMaxCount = m_MetaInfo.m_PointLightMaxCount; u32 const pointLightMaxCount = m_MetaInfo.m_PointLightMaxCount;
// Might cause a capacity increase, but I want to use that for my gpu buffer resize. // Might cause a capacity increase, but I want to use that for my gpu buffer resize.
m_Lights.push_back(); m_Lights.push_back();
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].m_Range = 1.0f;
m_Lights[m_DirectionalLightCount].um_Direction = normDirection; m_Lights[m_DirectionalLightCount].um_Direction = normDirection;
m_Lights[m_DirectionalLightCount].m_Intensity = intensity; m_Lights[m_DirectionalLightCount].m_Intensity = intensity;
const u16 index = m_DirectionalLightCount; u16 const index = m_DirectionalLightCount;
++m_DirectionalLightCount; ++m_DirectionalLightCount;
++m_MetaInfo.m_DirectionalLightMaxCount; ++m_MetaInfo.m_DirectionalLightMaxCount;
@ -155,7 +155,7 @@ LightManager::AddDirectional(const vec3 &direction, const vec3 &color, f32 inten
} }
LightHandle 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(m_PointLightCount <= m_MetaInfo.m_PointLightMaxCount);
assert(radius >= 0.0f); assert(radius >= 0.0f);
@ -166,7 +166,7 @@ LightManager::AddPoint(const vec3 &position, const vec3 &color, const f32 radius
{ {
if (light->m_Range < 0) 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_Color_ = (ToColor32(color) & Light::COLOR_MASK) | Light::TYPE_POINT | gen;
light->m_Range = radius; light->m_Range = radius;
@ -184,7 +184,7 @@ LightManager::AddPoint(const vec3 &position, const vec3 &color, const f32 radius
} }
m_Lights.push_back(); m_Lights.push_back();
const u16 index = m_PointLightCount; u16 const index = m_PointLightCount;
Light *light = &m_Lights[index + m_MetaInfo.m_PointLightOffset]; Light *light = &m_Lights[index + m_MetaInfo.m_PointLightOffset];
constexpr u8 gen = 0; // New light constexpr u8 gen = 0; // New light
@ -205,7 +205,7 @@ LightManager::AddPoint(const vec3 &position, const vec3 &color, const f32 radius
void void
LightManager::Update() LightManager::Update()
{ {
const u16 requiredBufferCapacity = eastl::min(static_cast<u16>(m_Lights.capacity()), MAX_LIGHTS); u16 const requiredBufferCapacity = eastl::min(static_cast<u16>(m_Lights.capacity()), MAX_LIGHTS);
if ((m_GpuBufferCapacity_ & CAPACITY_MASK) < requiredBufferCapacity) if ((m_GpuBufferCapacity_ & CAPACITY_MASK) < requiredBufferCapacity)
{ {
auto newBuffer = m_Device->CreateStorageBuffer(requiredBufferCapacity * sizeof m_Lights[0], "Light Buffer"); auto newBuffer = m_Device->CreateStorageBuffer(requiredBufferCapacity * sizeof m_Lights[0], "Light Buffer");
@ -215,20 +215,20 @@ LightManager::Update()
} }
if (m_GpuBufferCapacity_ & UPDATE_REQUIRED_BIT) 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()); ref->Write(0, m_Lights.size() * sizeof m_Lights[0], m_Lights.data());
} }
} }
void 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) if (handle.m_Type == Light::TYPE_DIRECTIONAL)
{ {
Light *lightSlot = &m_Lights[handle.m_Index]; 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) if (slotGen > handleGen)
{ {
WARN("Invalid handle gen: {} being freed. (slot gen: {})", handleGen, slotGen); 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) if (handle.m_Type == Light::TYPE_POINT)
{ {
Light *lightSlot = &m_Lights[handle.m_Index + m_MetaInfo.m_PointLightOffset]; 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) if (slotGen > handleGen)
{ {
WARN("Invalid handle gen: {} being freed. (slot gen: {})", handleGen, slotGen); WARN("Invalid handle gen: {} being freed. (slot gen: {})", handleGen, slotGen);

View File

@ -243,11 +243,6 @@ main(int, char **)
.maxDepth = 1.0, .maxDepth = 1.0,
}; };
vk::Rect2D scissor = {
.offset = {0, 0},
.extent = internalResolution,
};
vk::ImageSubresourceRange subresourceRange = { vk::ImageSubresourceRange subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor, .aspectMask = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0, .baseMipLevel = 0,
@ -356,7 +351,7 @@ main(int, char **)
vec3 camPosition = cameraController.m_Camera.m_Position; vec3 camPosition = cameraController.m_Camera.m_Position;
vk::Extent2D inputResolution = internalResolution; vk::Extent2D inputResolution = internalResolution;
device.RegisterResizeCallback([&cameraController](vk::Extent2D extent) { device.RegisterResizeCallback([&cameraController](vk::Extent2D const extent) {
cameraController.SetAspectRatio(static_cast<f32>(extent.width) / static_cast<f32>(extent.height)); cameraController.SetAspectRatio(static_cast<f32>(extent.width) / static_cast<f32>(extent.height));
}); });
@ -393,7 +388,6 @@ main(int, char **)
viewport.width = static_cast<f32>(internalResolution.width); viewport.width = static_cast<f32>(internalResolution.width);
viewport.height = -static_cast<f32>(internalResolution.height); viewport.height = -static_cast<f32>(internalResolution.height);
viewport.y = static_cast<f32>(internalResolution.height); viewport.y = static_cast<f32>(internalResolution.height);
scissor.extent = internalResolution;
} }
} }
} }
@ -406,7 +400,6 @@ main(int, char **)
viewport.width = static_cast<f32>(internalResolution.width); viewport.width = static_cast<f32>(internalResolution.width);
viewport.height = -static_cast<f32>(internalResolution.height); viewport.height = -static_cast<f32>(internalResolution.height);
viewport.y = static_cast<f32>(internalResolution.height); viewport.y = static_cast<f32>(internalResolution.height);
scissor.extent = internalResolution;
} }
} }
gui::Separator(); gui::Separator();

View File

@ -6,40 +6,40 @@
#include "nodes.h" #include "nodes.h"
u32 u32
Nodes::Add(const mat4 &transform, const i32 parent) Nodes::Add(mat4 const &transform, i32 const parent)
{ {
m_Dirty = true; m_Dirty = true;
const u32 index = Count(); u32 const index = Count();
m_Transforms.push_back(transform); m_Transforms.push_back(transform);
m_GlobalTransforms.emplace_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); m_Parents_.push_back(parentVal);
return index; return index;
} }
const mat4 & mat4 const &
Nodes::Get(const u32 index) const Nodes::Get(u32 const index) const
{ {
return m_Transforms[index]; return m_Transforms[index];
} }
void void
Nodes::Set(const u32 index, const mat4 &transform) Nodes::Set(u32 const index, mat4 const &transform)
{ {
m_Dirty = true; m_Dirty = true;
m_Transforms[index] = transform; m_Transforms[index] = transform;
m_Parents_[index] |= DIRTY_BIT; m_Parents_[index] |= DIRTY_BIT;
} }
const mat4 & mat4 const &
Nodes::operator[](const u32 index) const Nodes::operator[](u32 const index) const
{ {
return m_Transforms[index]; return m_Transforms[index];
} }
mat4 & mat4 &
Nodes::operator[](const u32 index) Nodes::operator[](u32 const index)
{ {
m_Dirty = true; m_Dirty = true;
m_Parents_[index] |= DIRTY_BIT; m_Parents_[index] |= DIRTY_BIT;
@ -58,7 +58,7 @@ Nodes::GetGlobalTransformByteSize() const
return m_GlobalTransforms.size() * sizeof m_GlobalTransforms[0]; return m_GlobalTransforms.size() * sizeof m_GlobalTransforms[0];
} }
const Nodes::Transform * Nodes::Transform const *
Nodes::GetGlobalTransformPtr() const Nodes::GetGlobalTransformPtr() const
{ {
return m_GlobalTransforms.data(); return m_GlobalTransforms.data();
@ -73,12 +73,12 @@ Nodes::Update()
auto transformIter = m_Transforms.begin(); auto transformIter = m_Transforms.begin();
auto globalTransformIter = m_GlobalTransforms.begin(); auto globalTransformIter = m_GlobalTransforms.begin();
auto parentIter = m_Parents_.begin(); auto parentIter = m_Parents_.begin();
const auto parentEnd = m_Parents_.end(); auto const parentEnd = m_Parents_.end();
while (parentIter != parentEnd) while (parentIter != parentEnd)
{ {
const bool isRoot = *parentIter & ROOT_BIT; bool const isRoot = *parentIter & ROOT_BIT;
const bool isDirty = *parentIter & DIRTY_BIT; bool const isDirty = *parentIter & DIRTY_BIT;
if (isRoot) if (isRoot)
{ {
@ -90,8 +90,8 @@ Nodes::Update()
} }
else else
{ {
const u32 parentIdx = *parentIter & PARENT_MASK; u32 const parentIdx = *parentIter & PARENT_MASK;
const bool isParentDirty = m_Parents_[parentIdx] & DIRTY_BIT; bool const isParentDirty = m_Parents_[parentIdx] & DIRTY_BIT;
if (isDirty || isParentDirty) if (isDirty || isParentDirty)
{ {
// Update w.r.t parent if either local or parent transforms updated. // Update w.r.t parent if either local or parent transforms updated.

View File

@ -16,14 +16,14 @@ struct Nodes
mat4 m_GlobalTransforms; mat4 m_GlobalTransforms;
mat4 m_NormalTransforms; mat4 m_NormalTransforms;
explicit Transform(const mat4 &transform) explicit Transform(mat4 const &transform)
: m_GlobalTransforms(transform) : m_GlobalTransforms(transform)
, m_NormalTransforms(transpose(inverse(mat3{transform}))) , m_NormalTransforms(transpose(inverse(mat3{transform})))
{ {
} }
Transform & Transform &
operator=(const mat4 &transform) operator=(mat4 const &transform)
{ {
m_GlobalTransforms = transform; m_GlobalTransforms = transform;
m_NormalTransforms = transpose(inverse(mat3{transform})); m_NormalTransforms = transpose(inverse(mat3{transform}));
@ -41,16 +41,16 @@ struct Nodes
constexpr static u32 DIRTY_BIT = 1u << 30; constexpr static u32 DIRTY_BIT = 1u << 30;
constexpr static u32 PARENT_MASK = ~(ROOT_BIT | DIRTY_BIT); constexpr static u32 PARENT_MASK = ~(ROOT_BIT | DIRTY_BIT);
u32 Add(const mat4 &transform, i32 parent = -1); u32 Add(mat4 const &transform, i32 parent = -1);
[[nodiscard]] const mat4 &Get(u32 index) const; [[nodiscard]] mat4 const &Get(u32 index) const;
void Set(u32 index, const mat4 &transform); void Set(u32 index, mat4 const &transform);
[[nodiscard]] u32 Count() const; [[nodiscard]] u32 Count() const;
[[nodiscard]] const mat4 &operator[](u32 index) const; [[nodiscard]] mat4 const &operator[](u32 index) const;
[[nodiscard]] mat4 &operator[](u32 index); [[nodiscard]] mat4 &operator[](u32 index);
[[nodiscard]] usize GetGlobalTransformByteSize() const; [[nodiscard]] usize GetGlobalTransformByteSize() const;
[[nodiscard]] const Transform *GetGlobalTransformPtr() const; [[nodiscard]] Transform const *GetGlobalTransformPtr() const;
bool Update(); bool Update();
}; };