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