Compare commits
4 Commits
8f9b6d66be
...
98660a11fa
| Author | SHA1 | Date |
|---|---|---|
|
|
98660a11fa | |
|
|
8eb5a678fc | |
|
|
e5b002c8cc | |
|
|
ec6aeb6f3b |
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: buffer.h
|
// Aster: buffer.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -109,4 +109,4 @@ struct IndexBuffer : Buffer
|
||||||
struct StagingBuffer : Buffer
|
struct StagingBuffer : Buffer
|
||||||
{
|
{
|
||||||
void Init(const Device *device, usize size, cstr name = nullptr);
|
void Init(const Device *device, usize size, cstr name = nullptr);
|
||||||
};
|
};
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: config.h
|
// Aster: config.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS
|
#define VULKAN_HPP_NO_STRUCT_CONSTRUCTORS
|
||||||
#define VULKAN_HPP_DISABLE_ENHANCED_MODE 1
|
#define VULKAN_HPP_DISABLE_ENHANCED_MODE 1
|
||||||
#define VULKAN_HPP_NO_EXCEPTIONS 1
|
#define VULKAN_HPP_NO_EXCEPTIONS 1
|
||||||
|
#define VULKAN_HPP_NO_SMART_HANDLE 1
|
||||||
|
|
||||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||||
|
|
@ -25,4 +26,4 @@
|
||||||
#define USE_OPTICK (0)
|
#define USE_OPTICK (0)
|
||||||
#else
|
#else
|
||||||
#define USE_OPTICK (1)
|
#define USE_OPTICK (1)
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: constants.h
|
// Aster: constants.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -167,4 +167,4 @@ template <typename T>
|
||||||
constexpr T Qnan = std::numeric_limits<T>::quiet_NaN();
|
constexpr T Qnan = std::numeric_limits<T>::quiet_NaN();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr T Snan = std::numeric_limits<T>::signalling_NaN();
|
constexpr T Snan = std::numeric_limits<T>::signalling_NaN();
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: context.h
|
// Aster: context.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -35,4 +35,4 @@ struct Context final
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Context);
|
DISALLOW_COPY_AND_ASSIGN(Context);
|
||||||
};
|
};
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: device.h
|
// Aster: device.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <EASTL/vector.h>
|
|
||||||
#include <EASTL/span.h>
|
#include <EASTL/span.h>
|
||||||
|
#include <EASTL/vector.h>
|
||||||
|
|
||||||
struct QueueAllocation;
|
struct QueueAllocation;
|
||||||
struct Context;
|
struct Context;
|
||||||
|
|
@ -31,8 +31,8 @@ struct Device final
|
||||||
vk::PipelineCache m_PipelineCache = nullptr;
|
vk::PipelineCache m_PipelineCache = nullptr;
|
||||||
bool m_ValidationEnabled = true;
|
bool m_ValidationEnabled = true;
|
||||||
|
|
||||||
template <typename T>
|
template <concepts::VkHandle T>
|
||||||
requires vk::isVulkanHandleType<T>::value void SetName(const T &object, cstr name) const;
|
void SetName(const T &object, cstr name) const;
|
||||||
[[nodiscard]] vk::Queue GetQueue(u32 familyIndex, u32 queueIndex) const;
|
[[nodiscard]] vk::Queue GetQueue(u32 familyIndex, u32 queueIndex) const;
|
||||||
|
|
||||||
[[nodiscard]] eastl::vector<u8> DumpPipelineCache() const;
|
[[nodiscard]] eastl::vector<u8> DumpPipelineCache() const;
|
||||||
|
|
@ -43,7 +43,8 @@ struct Device final
|
||||||
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name);
|
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name);
|
||||||
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData, NameString &&name);
|
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
||||||
|
NameString &&name);
|
||||||
~Device();
|
~Device();
|
||||||
|
|
||||||
// Move
|
// Move
|
||||||
|
|
@ -53,8 +54,8 @@ struct Device final
|
||||||
DISALLOW_COPY_AND_ASSIGN(Device);
|
DISALLOW_COPY_AND_ASSIGN(Device);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <concepts::VkHandle T>
|
||||||
requires vk::isVulkanHandleType<T>::value void
|
void
|
||||||
Device::SetName(const T &object, cstr name) const
|
Device::SetName(const T &object, cstr name) const
|
||||||
{
|
{
|
||||||
if (!m_ValidationEnabled || !name || !object)
|
if (!m_ValidationEnabled || !name || !object)
|
||||||
|
|
@ -69,4 +70,4 @@ Device::SetName(const T &object, cstr name) const
|
||||||
vk::Result result = m_Device.setDebugUtilsObjectNameEXT(&objectNameInfo);
|
vk::Result result = m_Device.setDebugUtilsObjectNameEXT(&objectNameInfo);
|
||||||
WARN_IF(Failed(result), "Could not name {:x}: {} as {}. Cause: {}", handle, to_string(object.objectType), name,
|
WARN_IF(Failed(result), "Could not name {:x}: {} as {}. Cause: {}", handle, to_string(object.objectType), name,
|
||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: global.h
|
// Aster: global.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -27,8 +27,8 @@
|
||||||
#define VULKAN_HPP_ASSERT(expr) DEBUG_IF(!(expr), "Vulkan assert failed")
|
#define VULKAN_HPP_ASSERT(expr) DEBUG_IF(!(expr), "Vulkan assert failed")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "type_traits.h"
|
|
||||||
#include "EASTL/intrusive_ptr.h"
|
#include "EASTL/intrusive_ptr.h"
|
||||||
|
#include "type_traits.h"
|
||||||
|
|
||||||
#include <EASTL/fixed_string.h>
|
#include <EASTL/fixed_string.h>
|
||||||
#include <EASTL/string.h>
|
#include <EASTL/string.h>
|
||||||
|
|
@ -61,6 +61,12 @@ Failed(const vk::Result result)
|
||||||
return result != vk::Result::eSuccess;
|
return result != vk::Result::eSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace concepts
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
concept VkHandle = vk::isVulkanHandleType<T>::value;
|
||||||
|
}
|
||||||
|
|
||||||
using NameString = eastl::fixed_string<char, 32, false>;
|
using NameString = eastl::fixed_string<char, 32, false>;
|
||||||
|
|
||||||
template <typename TFlagBits>
|
template <typename TFlagBits>
|
||||||
|
|
@ -216,4 +222,4 @@ struct fmt::formatter<eastl::fixed_string<TType, TCount, TOverflow>> : nested_fo
|
||||||
};
|
};
|
||||||
|
|
||||||
template <concepts::Manageable T>
|
template <concepts::Manageable T>
|
||||||
using Ref = eastl::intrusive_ptr<T>;
|
using Ref = eastl::intrusive_ptr<T>;
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: image.h
|
// Aster: image.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -119,7 +119,7 @@ struct Image
|
||||||
namespace concepts
|
namespace concepts
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept Image = std::derived_from<T, ::Image> and Manageable<T>;
|
concept Image = std::derived_from<T, Image> and Manageable<T>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept ImageRef = Derefencable<T> and Image<DereferencesTo<T>>;
|
concept ImageRef = Derefencable<T> and Image<DereferencesTo<T>>;
|
||||||
|
|
@ -218,4 +218,4 @@ struct StorageTextureCube : StorageImage
|
||||||
{
|
{
|
||||||
return other.IsStorage() && other.IsSampled() && other.IsCube();
|
return other.IsStorage() && other.IsSampled() && other.IsCube();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
|
||||||
template <concepts::Image TImage = Image>
|
template <concepts::Image TImage>
|
||||||
struct View
|
struct View
|
||||||
{
|
{
|
||||||
using ImageType = TImage;
|
using ImageType = TImage;
|
||||||
|
|
@ -69,18 +69,38 @@ struct View
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImageView : View<> {};
|
struct ImageView : View<Image>
|
||||||
struct ImageCubeView : View<ImageCube> {};
|
{
|
||||||
struct TextureView : View<Texture> {};
|
};
|
||||||
struct TextureCubeView : View<TextureCube> {};
|
|
||||||
struct StorageImageView : View<StorageImage> {};
|
struct ImageCubeView : View<ImageCube>
|
||||||
struct StorageTextureView : View<StorageTexture> {};
|
{
|
||||||
struct StorageTextureCubeView : View<StorageTextureCube> {};
|
};
|
||||||
|
|
||||||
|
struct TextureView : View<Texture>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TextureCubeView : View<TextureCube>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct StorageImageView : View<StorageImage>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct StorageTextureView : View<StorageTexture>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
struct StorageTextureCubeView : View<StorageTextureCube>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
namespace concepts
|
namespace concepts
|
||||||
{
|
{
|
||||||
template <typename TView>
|
template <typename TView>
|
||||||
concept View = std::derived_from<TView, ::View<typename TView::ImageType>>;
|
concept View = std::derived_from<TView, View<typename TView::ImageType>>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept ViewRef = Derefencable<T> and View<DereferencesTo<T>>;
|
concept ViewRef = Derefencable<T> and View<DereferencesTo<T>>;
|
||||||
|
|
@ -106,4 +126,4 @@ concept StorageImageView = View<T> and StorageImage<typename T::ImageType>;
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept StorageImageViewRef = Derefencable<T> and StorageImageView<DereferencesTo<T>>;
|
concept StorageImageViewRef = Derefencable<T> and StorageImageView<DereferencesTo<T>>;
|
||||||
|
|
||||||
} // namespace concepts
|
} // namespace concepts
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: physical_device.h
|
// Aster: physical_device.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: pipeline.h
|
// Aster: pipeline.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: queue_allocation.h
|
// Aster: queue_allocation.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: sampler.h
|
// Aster: sampler.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -49,4 +49,4 @@ struct Sampler
|
||||||
{
|
{
|
||||||
return m_Sampler;
|
return m_Sampler;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: size.h
|
// Aster: size.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -17,4 +17,4 @@ struct Size2D
|
||||||
{
|
{
|
||||||
return {m_Width, m_Height};
|
return {m_Width, m_Height};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: surface.h
|
// Aster: surface.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/// =============================================
|
/// =============================================
|
||||||
// Aster: swapchain.h
|
// Aster: swapchain.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// ==============================================
|
// ==============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -44,4 +44,4 @@ struct Swapchain final
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
};
|
};
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: type_traits.h
|
// Aster: type_traits.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "constants.h"
|
||||||
|
|
||||||
struct Device;
|
struct Device;
|
||||||
struct Image;
|
struct Image;
|
||||||
|
|
||||||
|
|
@ -37,6 +39,7 @@ concept SelfDestructible = requires(T a) {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept Manageable = std::is_default_constructible_v<T> and (DeviceDestructible<T> or SelfDestructible<T>) and RefCounted<T>;
|
concept Manageable =
|
||||||
|
std::is_default_constructible_v<T> and (DeviceDestructible<T> or SelfDestructible<T>) and RefCounted<T>;
|
||||||
|
|
||||||
} // namespace concepts
|
} // namespace concepts
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: window.h
|
// Aster: window.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -44,4 +44,4 @@ struct Window final
|
||||||
Window &operator=(Window &&other) noexcept;
|
Window &operator=(Window &&other) noexcept;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Window);
|
DISALLOW_COPY_AND_ASSIGN(Window);
|
||||||
};
|
};
|
||||||
|
|
@ -7,7 +7,7 @@ INTERFACE
|
||||||
"manager.h"
|
"manager.h"
|
||||||
"buffer_manager.h"
|
"buffer_manager.h"
|
||||||
"image_manager.h"
|
"image_manager.h"
|
||||||
"image_view_manager.h"
|
"view_manager.h"
|
||||||
"sampler_manager.h"
|
"sampler_manager.h"
|
||||||
"resource.h"
|
"resource.h"
|
||||||
"resource_manager.h"
|
"resource_manager.h"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: buffer_manager.h
|
// Aster: buffer_manager.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -21,4 +21,4 @@ class BufferManager final : public Manager<Buffer>
|
||||||
[[nodiscard]] Handle CreateUniformBuffer(usize size, cstr name = nullptr);
|
[[nodiscard]] Handle CreateUniformBuffer(usize size, cstr name = nullptr);
|
||||||
[[nodiscard]] Handle CreateStagingBuffer(usize size, cstr name = nullptr);
|
[[nodiscard]] Handle CreateStagingBuffer(usize size, cstr name = nullptr);
|
||||||
};
|
};
|
||||||
} // namespace systems
|
} // namespace systems
|
||||||
|
|
@ -1,30 +1,27 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: render_resource_manager.h
|
// Aster: render_resource_manager.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "aster/aster.h"
|
#include "aster/aster.h"
|
||||||
#include "buffer_manager.h"
|
#include "buffer_manager.h"
|
||||||
#include "image_manager.h"
|
|
||||||
#include "sampler_manager.h"
|
#include "sampler_manager.h"
|
||||||
|
#include "view_manager.h"
|
||||||
|
|
||||||
#include "aster/util/intrusive_slist.h"
|
#include "aster/util/freelist.h"
|
||||||
|
|
||||||
#include "EASTL/deque.h"
|
#include "EASTL/deque.h"
|
||||||
#include "EASTL/intrusive_hash_map.h"
|
#include "EASTL/intrusive_hash_map.h"
|
||||||
#include "EASTL/bonus/fixed_ring_buffer.h"
|
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "aster/core/image_view.h"
|
|
||||||
|
|
||||||
namespace systems
|
namespace systems
|
||||||
{
|
{
|
||||||
|
|
||||||
class CommitManager
|
class CommitManager
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
template <concepts::Manageable T>
|
template <concepts::Manageable T>
|
||||||
struct HandleMapper
|
struct HandleMapper
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +30,7 @@ class CommitManager
|
||||||
using Handle = typename Manager::Handle;
|
using Handle = typename Manager::Handle;
|
||||||
using Resource = ResId<Type>;
|
using Resource = ResId<Type>;
|
||||||
|
|
||||||
struct Entry : public eastl::intrusive_hash_node_key<Handle>
|
struct Entry : eastl::intrusive_hash_node_key<Handle>
|
||||||
{
|
{
|
||||||
std::atomic<u32> m_CommitCount;
|
std::atomic<u32> m_CommitCount;
|
||||||
|
|
||||||
|
|
@ -51,7 +48,7 @@ class CommitManager
|
||||||
assert(rc < MaxValue<u32>);
|
assert(rc < MaxValue<u32>);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
u32
|
||||||
IsReferenced() const
|
IsReferenced() const
|
||||||
{
|
{
|
||||||
return m_CommitCount;
|
return m_CommitCount;
|
||||||
|
|
@ -84,12 +81,13 @@ class CommitManager
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(Entry) == 24);
|
static_assert(sizeof(Entry) == 24);
|
||||||
|
|
||||||
eastl::vector<Entry> m_Data;
|
eastl::vector<Entry> m_Data;
|
||||||
IntrusiveStack<Entry> m_FreeList;
|
FreeList<Entry> m_FreeList;
|
||||||
eastl::intrusive_hash_map<typename Entry::key_type, Entry, 31, typename Entry::Hash> m_InUse;
|
eastl::intrusive_hash_map<typename Entry::key_type, Entry, 31, typename Entry::Hash> m_InUse;
|
||||||
std::array<IntrusiveStack<Entry>, 4> m_ToDelete;
|
std::array<FreeList<Entry>, 4> m_ToDelete;
|
||||||
u8 m_ToDeleteIndex = 0;
|
u8 m_ToDeleteIndex = 0;
|
||||||
|
|
||||||
explicit HandleMapper(const u32 maxCount)
|
explicit HandleMapper(const u32 maxCount)
|
||||||
|
|
@ -104,7 +102,7 @@ class CommitManager
|
||||||
|
|
||||||
~HandleMapper()
|
~HandleMapper()
|
||||||
{
|
{
|
||||||
for (auto & toDelete : m_ToDelete)
|
for (auto &toDelete : m_ToDelete)
|
||||||
{
|
{
|
||||||
ClearEntries(toDelete);
|
ClearEntries(toDelete);
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +128,7 @@ class CommitManager
|
||||||
Entry &data = m_FreeList.Pop();
|
Entry &data = m_FreeList.Pop();
|
||||||
|
|
||||||
data.mKey = object;
|
data.mKey = object;
|
||||||
data.m_CommitCount = 1;
|
data.m_CommitCount = 0;
|
||||||
|
|
||||||
m_InUse.insert(data);
|
m_InUse.insert(data);
|
||||||
|
|
||||||
|
|
@ -189,11 +187,11 @@ class CommitManager
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClearEntries(IntrusiveStack<Entry>& entries)
|
ClearEntries(FreeList<Entry> &entries)
|
||||||
{
|
{
|
||||||
while (auto item = entries.TryPop())
|
while (!entries.Empty())
|
||||||
{
|
{
|
||||||
Entry &entry = item.value();
|
Entry &entry = entries.Pop();
|
||||||
entry.mKey.reset();
|
entry.mKey.reset();
|
||||||
entry.m_CommitCount = 0;
|
entry.m_CommitCount = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -227,10 +225,12 @@ class CommitManager
|
||||||
ResId<Buffer> CommitBuffer(const Ref<Buffer> &buffer);
|
ResId<Buffer> CommitBuffer(const Ref<Buffer> &buffer);
|
||||||
|
|
||||||
// Commit Storage Images
|
// Commit Storage Images
|
||||||
ResId<StorageImageView> CommitStorageImage(const concepts::StorageImageViewRef auto &image)
|
ResId<StorageImageView>
|
||||||
|
CommitStorageImage(const concepts::StorageImageViewRef auto &image)
|
||||||
{
|
{
|
||||||
return CommitStorageImage(CastView<StorageImageView>(image));
|
return CommitStorageImage(CastView<StorageImageView>(image));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResId<StorageImageView> CommitStorageImage(const Ref<StorageImageView> &image);
|
ResId<StorageImageView> CommitStorageImage(const Ref<StorageImageView> &image);
|
||||||
|
|
||||||
// Sampled Images
|
// Sampled Images
|
||||||
|
|
@ -283,7 +283,8 @@ class CommitManager
|
||||||
return m_DescriptorSet;
|
return m_DescriptorSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CommitManager &Instance()
|
static CommitManager &
|
||||||
|
Instance()
|
||||||
{
|
{
|
||||||
assert(m_Instance);
|
assert(m_Instance);
|
||||||
return *m_Instance;
|
return *m_Instance;
|
||||||
|
|
@ -318,11 +319,13 @@ class CommitManager
|
||||||
{
|
{
|
||||||
m_Buffers.AddRef(handle);
|
m_Buffers.AddRef(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AddRef(const ResId<TextureView> &handle)
|
AddRef(const ResId<TextureView> &handle)
|
||||||
{
|
{
|
||||||
m_Images.AddRef(handle);
|
m_Images.AddRef(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AddRef(const ResId<StorageImageView> &handle)
|
AddRef(const ResId<StorageImageView> &handle)
|
||||||
{
|
{
|
||||||
|
|
@ -334,11 +337,13 @@ class CommitManager
|
||||||
{
|
{
|
||||||
m_Buffers.Release(handle);
|
m_Buffers.Release(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Release(const ResId<TextureView> &handle)
|
Release(const ResId<TextureView> &handle)
|
||||||
{
|
{
|
||||||
m_Images.Release(handle);
|
m_Images.Release(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Release(const ResId<StorageImageView> &handle)
|
Release(const ResId<StorageImageView> &handle)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: image_manager.h
|
// Aster: image_manager.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -57,7 +57,7 @@ struct DepthStencilImageCreateInfo
|
||||||
class ImageManager final : public Manager<Image>
|
class ImageManager final : public Manager<Image>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageManager(const Device *device, const u32 maxCount);
|
ImageManager(const Device *device, u32 maxCount);
|
||||||
|
|
||||||
template <concepts::Image T>
|
template <concepts::Image T>
|
||||||
[[nodiscard]] Ref<T>
|
[[nodiscard]] Ref<T>
|
||||||
|
|
@ -80,4 +80,4 @@ class ImageManager final : public Manager<Image>
|
||||||
[[nodiscard]] Ref<Image> CreateAttachment(const AttachmentCreateInfo &createInfo);
|
[[nodiscard]] Ref<Image> CreateAttachment(const AttachmentCreateInfo &createInfo);
|
||||||
[[nodiscard]] Ref<Image> CreateDepthStencilImage(const DepthStencilImageCreateInfo &createInfo);
|
[[nodiscard]] Ref<Image> CreateDepthStencilImage(const DepthStencilImageCreateInfo &createInfo);
|
||||||
};
|
};
|
||||||
} // namespace systems
|
} // namespace systems
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: manager.h
|
// Aster: manager.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "aster/aster.h"
|
#include "aster/aster.h"
|
||||||
#include "aster/core/type_traits.h"
|
#include "aster/core/type_traits.h"
|
||||||
|
#include "aster/util/freelist.h"
|
||||||
|
|
||||||
#include <EASTL/intrusive_ptr.h>
|
#include <EASTL/intrusive_ptr.h>
|
||||||
#include <EASTL/vector.h>
|
#include <EASTL/vector.h>
|
||||||
|
|
@ -32,10 +33,9 @@ class Manager
|
||||||
: m_Data{maxCount}
|
: m_Data{maxCount}
|
||||||
, m_Device{device}
|
, m_Device{device}
|
||||||
{
|
{
|
||||||
u32 i = 0;
|
|
||||||
for (auto &element : m_Data)
|
for (auto &element : m_Data)
|
||||||
{
|
{
|
||||||
*Recast<u32 *>(&element) = ++i;
|
m_FreeList.Push(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,7 +49,6 @@ class Manager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_FreeHead = 0;
|
|
||||||
m_Device = nullptr;
|
m_Device = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,11 +59,24 @@ class Manager
|
||||||
{
|
{
|
||||||
for (i64 i = m_Data.size() - 1; i >= 0; --i)
|
for (i64 i = m_Data.size() - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
if (auto *pIter = &m_Data[i]; !pIter->IsValid())
|
if (auto *pIter = &m_Data[i]; !pIter->IsReferenced())
|
||||||
{
|
{
|
||||||
pIter->Destroy(m_Device);
|
pIter->Destroy(m_Device);
|
||||||
*Recast<u32 *>(pIter) = m_FreeHead;
|
m_FreeList.Push(*pIter);
|
||||||
m_FreeHead = i;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Sweep()
|
||||||
|
requires concepts::SelfDestructible<Type>
|
||||||
|
{
|
||||||
|
for (i64 i = m_Data.size() - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
if (auto *pIter = &m_Data[i]; !pIter->IsValid())
|
||||||
|
{
|
||||||
|
pIter->Destroy();
|
||||||
|
m_FreeList.Push(*pIter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +85,7 @@ class Manager
|
||||||
|
|
||||||
private:
|
private:
|
||||||
eastl::vector<Type> m_Data; // Data also keeps the freelist during 'not use'.
|
eastl::vector<Type> m_Data; // Data also keeps the freelist during 'not use'.
|
||||||
u32 m_FreeHead = 0;
|
FreeList<Type> m_FreeList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const Device *m_Device;
|
const Device *m_Device;
|
||||||
|
|
@ -85,17 +97,15 @@ class Manager
|
||||||
[[nodiscard]] Handle
|
[[nodiscard]] Handle
|
||||||
Alloc()
|
Alloc()
|
||||||
{
|
{
|
||||||
ERROR_IF(m_FreeHead >= m_Data.size(), "Max buffers allocated.") THEN_ABORT(-1);
|
ERROR_IF(m_FreeList.Empty(), "Max buffers allocated.") THEN_ABORT(-1);
|
||||||
|
|
||||||
const auto index = m_FreeHead;
|
Type &pAlloc = m_FreeList.Pop();
|
||||||
Type *pAlloc = &m_Data[index];
|
memset(&pAlloc, 0, sizeof pAlloc);
|
||||||
m_FreeHead = *Recast<u32 *>(pAlloc);
|
|
||||||
memset(pAlloc, 0, sizeof *pAlloc);
|
|
||||||
if constexpr (concepts::SelfDestructible<Type>)
|
if constexpr (concepts::SelfDestructible<Type>)
|
||||||
{
|
{
|
||||||
pAlloc->m_Device = m_Device;
|
pAlloc.m_Device = m_Device;
|
||||||
}
|
}
|
||||||
return {pAlloc};
|
return {&pAlloc};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace systems
|
} // namespace systems
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: resource.h
|
// Aster: resource.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -89,4 +89,4 @@ struct NullId
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace systems
|
} // namespace systems
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: resource_manager.h
|
// Aster: resource_manager.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#include "buffer_manager.h"
|
#include "buffer_manager.h"
|
||||||
#include "image_manager.h"
|
#include "image_manager.h"
|
||||||
#include "image_view_manager.h"
|
|
||||||
#include "sampler_manager.h"
|
#include "sampler_manager.h"
|
||||||
|
#include "view_manager.h"
|
||||||
|
|
||||||
namespace systems
|
namespace systems
|
||||||
{
|
{
|
||||||
|
|
@ -20,9 +20,9 @@ class ResourceManager
|
||||||
struct CombinedImageViewManager
|
struct CombinedImageViewManager
|
||||||
{
|
{
|
||||||
ImageManager *m_ImageManager;
|
ImageManager *m_ImageManager;
|
||||||
ImageViewManager *m_ViewManager;
|
ViewManager *m_ViewManager;
|
||||||
|
|
||||||
CombinedImageViewManager(ImageManager *imageManager, ImageViewManager *viewManager)
|
CombinedImageViewManager(ImageManager *imageManager, ViewManager *viewManager)
|
||||||
: m_ImageManager{imageManager}
|
: m_ImageManager{imageManager}
|
||||||
, m_ViewManager{viewManager}
|
, m_ViewManager{viewManager}
|
||||||
{
|
{
|
||||||
|
|
@ -44,7 +44,8 @@ class ResourceManager
|
||||||
return CastView<T>(handle);
|
return CastView<T>(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Ref<TextureView> CreateTexture2D(const Texture2DCreateInfo &createInfo) const
|
[[nodiscard]] Ref<TextureView>
|
||||||
|
CreateTexture2D(const Texture2DCreateInfo &createInfo) const
|
||||||
{
|
{
|
||||||
return m_ViewManager->CreateView<TextureView>({
|
return m_ViewManager->CreateView<TextureView>({
|
||||||
.m_Image = CastImage<Texture>(m_ImageManager->CreateTexture2D(createInfo)),
|
.m_Image = CastImage<Texture>(m_ImageManager->CreateTexture2D(createInfo)),
|
||||||
|
|
@ -53,7 +54,9 @@ class ResourceManager
|
||||||
.m_AspectMask = vk::ImageAspectFlagBits::eColor,
|
.m_AspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
[[nodiscard]] Ref<ImageCubeView> CreateTextureCube(const TextureCubeCreateInfo &createInfo) const
|
|
||||||
|
[[nodiscard]] Ref<ImageCubeView>
|
||||||
|
CreateTextureCube(const TextureCubeCreateInfo &createInfo) const
|
||||||
{
|
{
|
||||||
return m_ViewManager->CreateView<ImageCubeView>({
|
return m_ViewManager->CreateView<ImageCubeView>({
|
||||||
.m_Image = m_ImageManager->CreateTextureCube(createInfo),
|
.m_Image = m_ImageManager->CreateTextureCube(createInfo),
|
||||||
|
|
@ -63,7 +66,8 @@ class ResourceManager
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Ref<ImageView> CreateAttachment(const AttachmentCreateInfo &createInfo) const
|
[[nodiscard]] Ref<ImageView>
|
||||||
|
CreateAttachment(const AttachmentCreateInfo &createInfo) const
|
||||||
{
|
{
|
||||||
return m_ViewManager->CreateView({
|
return m_ViewManager->CreateView({
|
||||||
.m_Image = m_ImageManager->CreateAttachment(createInfo),
|
.m_Image = m_ImageManager->CreateAttachment(createInfo),
|
||||||
|
|
@ -73,7 +77,8 @@ class ResourceManager
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Ref<ImageView> CreateDepthStencilImage(const DepthStencilImageCreateInfo &createInfo) const
|
[[nodiscard]] Ref<ImageView>
|
||||||
|
CreateDepthStencilImage(const DepthStencilImageCreateInfo &createInfo) const
|
||||||
{
|
{
|
||||||
return m_ViewManager->CreateView({
|
return m_ViewManager->CreateView({
|
||||||
.m_Image = m_ImageManager->CreateDepthStencilImage(createInfo),
|
.m_Image = m_ImageManager->CreateDepthStencilImage(createInfo),
|
||||||
|
|
@ -87,7 +92,7 @@ class ResourceManager
|
||||||
BufferManager m_Buffers;
|
BufferManager m_Buffers;
|
||||||
ImageManager m_Images;
|
ImageManager m_Images;
|
||||||
SamplerManager m_Samplers;
|
SamplerManager m_Samplers;
|
||||||
ImageViewManager m_Views;
|
ViewManager m_Views;
|
||||||
CombinedImageViewManager m_CombinedImageViews;
|
CombinedImageViewManager m_CombinedImageViews;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -112,7 +117,7 @@ class ResourceManager
|
||||||
return m_Images;
|
return m_Images;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageViewManager &
|
ViewManager &
|
||||||
Views()
|
Views()
|
||||||
{
|
{
|
||||||
return m_Views;
|
return m_Views;
|
||||||
|
|
@ -124,11 +129,21 @@ class ResourceManager
|
||||||
return m_Samplers;
|
return m_Samplers;
|
||||||
}
|
}
|
||||||
|
|
||||||
CombinedImageViewManager &CombinedImageViews()
|
CombinedImageViewManager &
|
||||||
|
CombinedImageViews()
|
||||||
{
|
{
|
||||||
return m_CombinedImageViews;
|
return m_CombinedImageViews;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Update()
|
||||||
|
{
|
||||||
|
m_Views.Sweep();
|
||||||
|
m_Images.Sweep();
|
||||||
|
m_Buffers.Sweep();
|
||||||
|
m_Samplers.Sweep();
|
||||||
|
}
|
||||||
|
|
||||||
~ResourceManager() = default;
|
~ResourceManager() = default;
|
||||||
|
|
||||||
PIN_MEMORY(ResourceManager);
|
PIN_MEMORY(ResourceManager);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: sampler_manager.h
|
// Aster: sampler_manager.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "manager.h"
|
|
||||||
#include "EASTL/hash_map.h"
|
#include "EASTL/hash_map.h"
|
||||||
|
#include "manager.h"
|
||||||
|
|
||||||
#include "aster/aster.h"
|
#include "aster/aster.h"
|
||||||
#include "aster/core/sampler.h"
|
#include "aster/core/sampler.h"
|
||||||
|
|
@ -67,7 +67,8 @@ struct SamplerCreateInfo
|
||||||
bool m_CompareEnable = false;
|
bool m_CompareEnable = false;
|
||||||
bool m_NormalizedCoordinates = true;
|
bool m_NormalizedCoordinates = true;
|
||||||
|
|
||||||
explicit operator vk::SamplerCreateInfo() const
|
explicit
|
||||||
|
operator vk::SamplerCreateInfo() const
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
.flags = m_Flags,
|
.flags = m_Flags,
|
||||||
|
|
@ -100,9 +101,9 @@ class SamplerManager final : public Manager<Sampler>
|
||||||
eastl::hash_map<vk::SamplerCreateInfo, Handle> m_HashToSamplerIdx;
|
eastl::hash_map<vk::SamplerCreateInfo, Handle> m_HashToSamplerIdx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SamplerManager(const Device *device, const u32 maxCount);
|
SamplerManager(const Device *device, u32 maxCount);
|
||||||
~SamplerManager() override;
|
~SamplerManager() override;
|
||||||
|
|
||||||
Ref<Sampler> CreateSampler(const SamplerCreateInfo &createInfo);
|
Ref<Sampler> CreateSampler(const SamplerCreateInfo &createInfo);
|
||||||
};
|
};
|
||||||
} // namespace systems
|
} // namespace systems
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: image_manager.h
|
// Aster: view_manager.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -86,10 +86,10 @@ struct ViewCreateInfo
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImageViewManager final : public Manager<ImageView>
|
class ViewManager final : public Manager<ImageView>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ImageViewManager(const Device *device, const u32 maxCount);
|
ViewManager(const Device *device, u32 maxCount);
|
||||||
|
|
||||||
template <concepts::ImageView TImageView>
|
template <concepts::ImageView TImageView>
|
||||||
Ref<TImageView>
|
Ref<TImageView>
|
||||||
|
|
@ -101,4 +101,4 @@ class ImageViewManager final : public Manager<ImageView>
|
||||||
Ref<ImageView> CreateView(const ViewCreateInfo<> &createInfo);
|
Ref<ImageView> CreateView(const ViewCreateInfo<> &createInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace systems
|
} // namespace systems
|
||||||
|
|
@ -5,4 +5,4 @@ cmake_minimum_required(VERSION 3.13)
|
||||||
target_sources(aster_core
|
target_sources(aster_core
|
||||||
INTERFACE
|
INTERFACE
|
||||||
"logger.h"
|
"logger.h"
|
||||||
"intrusive_slist.h")
|
"freelist.h")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
// =============================================
|
||||||
|
// Aster: freelist.h
|
||||||
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
|
// =============================================
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
struct FreeListNode
|
||||||
|
{
|
||||||
|
FreeListNode *m_Next;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept FreeListCapable = sizeof(T) >= sizeof(FreeListNode);
|
||||||
|
|
||||||
|
template <FreeListCapable T>
|
||||||
|
struct FreeList
|
||||||
|
{
|
||||||
|
using Value = T;
|
||||||
|
using Reference = T &;
|
||||||
|
using ConstReference = const T &;
|
||||||
|
using Pointer = T *;
|
||||||
|
|
||||||
|
FreeListNode *m_Top;
|
||||||
|
|
||||||
|
FreeList()
|
||||||
|
: m_Top{nullptr}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeList(FreeList &&other) noexcept
|
||||||
|
: m_Top{Take(other.m_Top)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeList &
|
||||||
|
operator=(FreeList &&other) noexcept
|
||||||
|
{
|
||||||
|
if (this == &other)
|
||||||
|
return *this;
|
||||||
|
m_Top = Take(other.m_Top);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(FreeList);
|
||||||
|
|
||||||
|
~FreeList()
|
||||||
|
{
|
||||||
|
m_Top = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool
|
||||||
|
Empty() const
|
||||||
|
{
|
||||||
|
return !m_Top;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] Reference
|
||||||
|
Pop()
|
||||||
|
{
|
||||||
|
assert(m_Top);
|
||||||
|
Reference ref = *Recast<Pointer>(m_Top);
|
||||||
|
m_Top = m_Top->m_Next;
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Push(Reference ref)
|
||||||
|
{
|
||||||
|
auto next = Recast<FreeListNode *>(&ref);
|
||||||
|
next->m_Next = m_Top;
|
||||||
|
m_Top = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] ConstReference
|
||||||
|
Peek() const
|
||||||
|
{
|
||||||
|
assert(m_Top);
|
||||||
|
return *m_Top;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] Reference
|
||||||
|
Peek()
|
||||||
|
{
|
||||||
|
assert(m_Top);
|
||||||
|
return *m_Top;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Clear()
|
||||||
|
{
|
||||||
|
m_Top = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -1,127 +0,0 @@
|
||||||
// =============================================
|
|
||||||
// Aster: intrusive_slist.h
|
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
|
||||||
// =============================================
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
concept HasNext = requires(T &a) {
|
|
||||||
{ a.Next() } -> std::same_as<T *>;
|
|
||||||
{ a.SetNext(a) };
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IntrusiveStackNode
|
|
||||||
{
|
|
||||||
IntrusiveStackNode *m_Next;
|
|
||||||
|
|
||||||
IntrusiveStackNode *
|
|
||||||
Next() const
|
|
||||||
{
|
|
||||||
return m_Next;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SetNext(IntrusiveStackNode &a)
|
|
||||||
{
|
|
||||||
m_Next = &a;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <HasNext T = IntrusiveStackNode>
|
|
||||||
struct IntrusiveStack
|
|
||||||
{
|
|
||||||
using Value = T;
|
|
||||||
using Reference = T &;
|
|
||||||
using OptionalRef = std::optional<std::reference_wrapper<T>>;
|
|
||||||
using ConstReference = const T &;
|
|
||||||
using Pointer = T *;
|
|
||||||
|
|
||||||
Pointer m_Top;
|
|
||||||
|
|
||||||
IntrusiveStack()
|
|
||||||
: m_Top{nullptr}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
IntrusiveStack(IntrusiveStack &&other) noexcept
|
|
||||||
: m_Top{Take(other.m_Top)}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
IntrusiveStack &
|
|
||||||
operator=(IntrusiveStack &&other) noexcept
|
|
||||||
{
|
|
||||||
if (this == &other)
|
|
||||||
return *this;
|
|
||||||
m_Top = Take(other.m_Top);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(IntrusiveStack);
|
|
||||||
|
|
||||||
~IntrusiveStack()
|
|
||||||
{
|
|
||||||
m_Top = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] bool
|
|
||||||
Empty() const
|
|
||||||
{
|
|
||||||
return !m_Top;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] Reference
|
|
||||||
Pop()
|
|
||||||
{
|
|
||||||
assert(m_Top);
|
|
||||||
Reference ref = *m_Top;
|
|
||||||
m_Top = m_Top->Next();
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] OptionalRef
|
|
||||||
TryPop()
|
|
||||||
{
|
|
||||||
if (m_Top)
|
|
||||||
return Pop();
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Push(Reference ref)
|
|
||||||
{
|
|
||||||
ref.SetNext(*m_Top);
|
|
||||||
m_Top = &ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] ConstReference
|
|
||||||
Peek() const
|
|
||||||
{
|
|
||||||
assert(m_Top);
|
|
||||||
return *m_Top;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] Reference
|
|
||||||
Peek()
|
|
||||||
{
|
|
||||||
assert(m_Top);
|
|
||||||
return *m_Top;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] OptionalRef
|
|
||||||
TryPeek()
|
|
||||||
{
|
|
||||||
if (m_Top)
|
|
||||||
return Peek();
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Clear()
|
|
||||||
{
|
|
||||||
m_Top = nullptr;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -208,4 +208,4 @@ extern Logger g_Logger;
|
||||||
|
|
||||||
#define DO(code) , code
|
#define DO(code) , code
|
||||||
#define ABORT(code) exit(Cast<i32>(code))
|
#define ABORT(code) exit(Cast<i32>(code))
|
||||||
#define THEN_ABORT(code) , ABORT(code)
|
#define THEN_ABORT(code) , ABORT(code)
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: buffer.cpp
|
// Aster: buffer.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/buffer.h"
|
#include "core/buffer.h"
|
||||||
|
|
@ -113,7 +113,7 @@ StorageBuffer::Init(const Device *device, usize size, bool hostVisible, bool dev
|
||||||
vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eStorageBuffer;
|
vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eStorageBuffer;
|
||||||
if (deviceAddress)
|
if (deviceAddress)
|
||||||
{
|
{
|
||||||
usage |= vk::BufferUsageFlagBits::eShaderDeviceAddress;
|
usage |= vk::BufferUsageFlagBits::eShaderDeviceAddress;
|
||||||
}
|
}
|
||||||
if (hostVisible)
|
if (hostVisible)
|
||||||
{
|
{
|
||||||
|
|
@ -125,8 +125,7 @@ StorageBuffer::Init(const Device *device, usize size, bool hostVisible, bool dev
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usage |= vk::BufferUsageFlagBits::eTransferDst;
|
usage |= vk::BufferUsageFlagBits::eTransferDst;
|
||||||
Allocate(device, size, usage, 0,
|
Allocate(device, size, usage, 0, VMA_MEMORY_USAGE_AUTO, name);
|
||||||
VMA_MEMORY_USAGE_AUTO, name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +154,8 @@ StorageIndexBuffer::Init(const Device *device, usize size, bool hostVisible, boo
|
||||||
void
|
void
|
||||||
IndirectBuffer::Init(const Device *device, usize size, bool hostVisible, cstr name)
|
IndirectBuffer::Init(const Device *device, usize size, bool hostVisible, cstr name)
|
||||||
{
|
{
|
||||||
vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eStorageBuffer | vk::BufferUsageFlagBits::eIndirectBuffer | vk::BufferUsageFlagBits::eShaderDeviceAddress;
|
vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eStorageBuffer | vk::BufferUsageFlagBits::eIndirectBuffer |
|
||||||
|
vk::BufferUsageFlagBits::eShaderDeviceAddress;
|
||||||
if (hostVisible)
|
if (hostVisible)
|
||||||
{
|
{
|
||||||
Allocate(device, size, usage,
|
Allocate(device, size, usage,
|
||||||
|
|
@ -173,15 +173,15 @@ IndirectBuffer::Init(const Device *device, usize size, bool hostVisible, cstr na
|
||||||
void
|
void
|
||||||
VertexBuffer::Init(const Device *device, usize size, cstr name)
|
VertexBuffer::Init(const Device *device, usize size, cstr name)
|
||||||
{
|
{
|
||||||
Allocate(device, size, vk::BufferUsageFlagBits::eVertexBuffer | vk::BufferUsageFlagBits::eTransferDst,
|
Allocate(device, size, vk::BufferUsageFlagBits::eVertexBuffer | vk::BufferUsageFlagBits::eTransferDst, 0,
|
||||||
0, VMA_MEMORY_USAGE_AUTO, name);
|
VMA_MEMORY_USAGE_AUTO, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IndexBuffer::Init(const Device *device, usize size, cstr name)
|
IndexBuffer::Init(const Device *device, usize size, cstr name)
|
||||||
{
|
{
|
||||||
Allocate(device, size, vk::BufferUsageFlagBits::eIndexBuffer | vk::BufferUsageFlagBits::eTransferDst,
|
Allocate(device, size, vk::BufferUsageFlagBits::eIndexBuffer | vk::BufferUsageFlagBits::eTransferDst, 0,
|
||||||
0, VMA_MEMORY_USAGE_AUTO, name);
|
VMA_MEMORY_USAGE_AUTO, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: context.cpp
|
// Aster: context.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/context.h"
|
#include "core/context.h"
|
||||||
|
|
@ -122,4 +122,4 @@ Context::operator=(Context &&other) noexcept
|
||||||
m_Instance = Take(other.m_Instance);
|
m_Instance = Take(other.m_Instance);
|
||||||
m_DebugMessenger = Take(other.m_DebugMessenger);
|
m_DebugMessenger = Take(other.m_DebugMessenger);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: device.cpp
|
// Aster: device.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/device.h"
|
#include "core/device.h"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: global.cpp
|
// Aster: global.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/global.h"
|
#include "core/global.h"
|
||||||
|
|
@ -51,7 +51,7 @@ struct fmt::formatter<MemorySize>
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
// ReSharper disable once CppInconsistentNaming
|
// ReSharper disable once CppInconsistentNaming
|
||||||
constexpr auto
|
constexpr auto
|
||||||
format(MemorySize const &mem, Context &ctx) const
|
format(const MemorySize &mem, Context &ctx) const
|
||||||
{
|
{
|
||||||
// return format_to(ctx.out(), "({}, {})", foo.a, foo.b); // --== KEY LINE ==--
|
// return format_to(ctx.out(), "({}, {})", foo.a, foo.b); // --== KEY LINE ==--
|
||||||
if (mem.m_Gigabytes > 0)
|
if (mem.m_Gigabytes > 0)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: image.cpp
|
// Aster: image.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/image.h"
|
#include "core/image.h"
|
||||||
|
|
@ -24,8 +24,8 @@ Image::DestroyView(const vk::ImageView imageView) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//void
|
// void
|
||||||
//Texture::Init(const Device *device, const vk::Extent2D extent, vk::Format imageFormat, const bool isMipMapped,
|
// Texture::Init(const Device *device, const vk::Extent2D extent, vk::Format imageFormat, const bool isMipMapped,
|
||||||
// const cstr name)
|
// const cstr name)
|
||||||
//{
|
//{
|
||||||
// WARN_IF(!IsPowerOfTwo(extent.width) || !IsPowerOfTwo(extent.width), "Image {2} is {0}x{1} (Non Power of Two)",
|
// WARN_IF(!IsPowerOfTwo(extent.width) || !IsPowerOfTwo(extent.width), "Image {2} is {0}x{1} (Non Power of Two)",
|
||||||
|
|
@ -92,9 +92,9 @@ Image::DestroyView(const vk::ImageView imageView) const
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
///*
|
///*
|
||||||
//Cube map Faces info.
|
// Cube map Faces info.
|
||||||
//
|
//
|
||||||
//TODO: Correct this based on the actual layout for upside down viewport.
|
// TODO: Correct this based on the actual layout for upside down viewport.
|
||||||
//
|
//
|
||||||
//| Axis | Layer | Up |
|
//| Axis | Layer | Up |
|
||||||
//|:----:|:-----:|:--:|
|
//|:----:|:-----:|:--:|
|
||||||
|
|
@ -105,325 +105,330 @@ Image::DestroyView(const vk::ImageView imageView) const
|
||||||
//| +z | 4 | -y |
|
//| +z | 4 | -y |
|
||||||
//| -z | 5 | -y |
|
//| -z | 5 | -y |
|
||||||
//
|
//
|
||||||
//Remember, we use upside down viewport.
|
// Remember, we use upside down viewport.
|
||||||
//
|
//
|
||||||
//*/
|
//*/
|
||||||
//
|
//
|
||||||
//void
|
// void
|
||||||
//TextureCube::Init(const Device *device, u32 cubeSide, vk::Format imageFormat, bool isMipMapped, cstr name)
|
// TextureCube::Init(const Device *device, u32 cubeSide, vk::Format imageFormat, bool isMipMapped, cstr name)
|
||||||
//{
|
//{
|
||||||
// WARN_IF(!IsPowerOfTwo(cubeSide), "Image Cube {1} has side {0}x{0} (Non Power of Two)", cubeSide,
|
// WARN_IF(!IsPowerOfTwo(cubeSide), "Image Cube {1} has side {0}x{0} (Non Power of Two)", cubeSide,
|
||||||
// name ? name : "<unnamed>");
|
// name ? name : "<unnamed>");
|
||||||
//
|
//
|
||||||
// const u8 mipLevels = isMipMapped ? 1 + Cast<u8>(floor(log2(cubeSide))) : 1;
|
// const u8 mipLevels = isMipMapped ? 1 + Cast<u8>(floor(log2(cubeSide))) : 1;
|
||||||
//
|
//
|
||||||
// auto usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst;
|
// auto usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst;
|
||||||
// if (isMipMapped)
|
// if (isMipMapped)
|
||||||
// {
|
// {
|
||||||
// usage |= vk::ImageUsageFlagBits::eTransferSrc;
|
// usage |= vk::ImageUsageFlagBits::eTransferSrc;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// const vk::Extent3D extent = {.width = cubeSide, .height = cubeSide, .depth = 1};
|
// const vk::Extent3D extent = {.width = cubeSide, .height = cubeSide, .depth = 1};
|
||||||
//
|
//
|
||||||
// vk::ImageCreateInfo imageCreateInfo = {
|
// vk::ImageCreateInfo imageCreateInfo = {
|
||||||
// .flags = vk::ImageCreateFlagBits::eCubeCompatible,
|
// .flags = vk::ImageCreateFlagBits::eCubeCompatible,
|
||||||
// .imageType = vk::ImageType::e2D,
|
// .imageType = vk::ImageType::e2D,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .extent = extent,
|
// .extent = extent,
|
||||||
// .mipLevels = mipLevels,
|
// .mipLevels = mipLevels,
|
||||||
// .arrayLayers = 6,
|
// .arrayLayers = 6,
|
||||||
// .samples = vk::SampleCountFlagBits::e1,
|
// .samples = vk::SampleCountFlagBits::e1,
|
||||||
// .tiling = vk::ImageTiling::eOptimal,
|
// .tiling = vk::ImageTiling::eOptimal,
|
||||||
// .usage = usage,
|
// .usage = usage,
|
||||||
// .sharingMode = vk::SharingMode::eExclusive,
|
// .sharingMode = vk::SharingMode::eExclusive,
|
||||||
// .initialLayout = vk::ImageLayout::eUndefined,
|
// .initialLayout = vk::ImageLayout::eUndefined,
|
||||||
// };
|
// };
|
||||||
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
||||||
// .flags = {},
|
// .flags = {},
|
||||||
// .usage = VMA_MEMORY_USAGE_AUTO,
|
// .usage = VMA_MEMORY_USAGE_AUTO,
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// VkImage image;
|
// VkImage image;
|
||||||
// VmaAllocation allocation;
|
// VmaAllocation allocation;
|
||||||
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
||||||
// &allocationCreateInfo, &image, &allocation, nullptr));
|
// &allocationCreateInfo, &image, &allocation, nullptr));
|
||||||
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// vk::ImageView view;
|
// vk::ImageView view;
|
||||||
// vk::ImageViewCreateInfo imageViewCreateInfo = {
|
// vk::ImageViewCreateInfo imageViewCreateInfo = {
|
||||||
// .image = image,
|
// .image = image,
|
||||||
// .viewType = vk::ImageViewType::eCube,
|
// .viewType = vk::ImageViewType::eCube,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .components = {},
|
// .components = {},
|
||||||
// .subresourceRange =
|
// .subresourceRange =
|
||||||
// {
|
// {
|
||||||
// .aspectMask = vk::ImageAspectFlagBits::eColor,
|
// .aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
// .baseMipLevel = 0,
|
// .baseMipLevel = 0,
|
||||||
// .levelCount = mipLevels,
|
// .levelCount = mipLevels,
|
||||||
// .baseArrayLayer = 0,
|
// .baseArrayLayer = 0,
|
||||||
// .layerCount = 6,
|
// .layerCount = 6,
|
||||||
// },
|
// },
|
||||||
// };
|
// };
|
||||||
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
||||||
// ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// m_Device = device;
|
// m_Device = device;
|
||||||
// m_Image = image;
|
// m_Image = image;
|
||||||
// m_View = view;
|
// m_View = view;
|
||||||
// m_Allocation = allocation;
|
// m_Allocation = allocation;
|
||||||
// m_Extent = extent;
|
// m_Extent = extent;
|
||||||
// m_MipLevels = mipLevels;
|
// m_MipLevels = mipLevels;
|
||||||
// m_LayerCount = 6;
|
// m_LayerCount = 6;
|
||||||
//
|
//
|
||||||
// device->SetName(m_Image, name);
|
// device->SetName(m_Image, name);
|
||||||
//}
|
// }
|
||||||
//
|
//
|
||||||
//void
|
// void
|
||||||
//AttachmentImage::Init(const Device *device, vk::Extent2D extent, vk::Format imageFormat, cstr name)
|
// AttachmentImage::Init(const Device *device, vk::Extent2D extent, vk::Format imageFormat, cstr name)
|
||||||
//{
|
//{
|
||||||
// vk::ImageCreateInfo imageCreateInfo = {
|
// vk::ImageCreateInfo imageCreateInfo = {
|
||||||
// .imageType = vk::ImageType::e2D,
|
// .imageType = vk::ImageType::e2D,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .extent = ToExtent3D(extent, 1),
|
// .extent = ToExtent3D(extent, 1),
|
||||||
// .mipLevels = 1,
|
// .mipLevels = 1,
|
||||||
// .arrayLayers = 1,
|
// .arrayLayers = 1,
|
||||||
// .samples = vk::SampleCountFlagBits::e1,
|
// .samples = vk::SampleCountFlagBits::e1,
|
||||||
// .tiling = vk::ImageTiling::eOptimal,
|
// .tiling = vk::ImageTiling::eOptimal,
|
||||||
// .usage = vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc,
|
// .usage = vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc,
|
||||||
// .sharingMode = vk::SharingMode::eExclusive,
|
// .sharingMode = vk::SharingMode::eExclusive,
|
||||||
// .initialLayout = vk::ImageLayout::eUndefined,
|
// .initialLayout = vk::ImageLayout::eUndefined,
|
||||||
// };
|
// };
|
||||||
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
||||||
// .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
|
// .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
|
||||||
// .usage = VMA_MEMORY_USAGE_AUTO,
|
// .usage = VMA_MEMORY_USAGE_AUTO,
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// VkImage image;
|
// VkImage image;
|
||||||
// VmaAllocation allocation;
|
// VmaAllocation allocation;
|
||||||
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
||||||
// &allocationCreateInfo, &image, &allocation, nullptr));
|
// &allocationCreateInfo, &image, &allocation, nullptr));
|
||||||
// ERROR_IF(Failed(result), "Could not allocate depth buffer. Cause: {}", result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not allocate depth buffer. Cause: {}", result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// vk::ImageView view;
|
// vk::ImageView view;
|
||||||
// vk::ImageViewCreateInfo imageViewCreateInfo = {
|
// vk::ImageViewCreateInfo imageViewCreateInfo = {
|
||||||
// .image = image,
|
// .image = image,
|
||||||
// .viewType = vk::ImageViewType::e2D,
|
// .viewType = vk::ImageViewType::e2D,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .components = {},
|
// .components = {},
|
||||||
// .subresourceRange =
|
// .subresourceRange =
|
||||||
// {
|
// {
|
||||||
// .aspectMask = vk::ImageAspectFlagBits::eColor,
|
// .aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
// .baseMipLevel = 0,
|
// .baseMipLevel = 0,
|
||||||
// .levelCount = 1,
|
// .levelCount = 1,
|
||||||
// .baseArrayLayer = 0,
|
// .baseArrayLayer = 0,
|
||||||
// .layerCount = 1,
|
// .layerCount = 1,
|
||||||
// },
|
// },
|
||||||
// };
|
// };
|
||||||
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
||||||
// ERROR_IF(Failed(result), "Could not create attachment image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not create attachment image view {}. Cause: {}", name, result)
|
||||||
|
// THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// m_Device = device;
|
// m_Device = device;
|
||||||
// m_Image = image;
|
// m_Image = image;
|
||||||
// m_View = view;
|
// m_View = view;
|
||||||
// m_Allocation = allocation;
|
// m_Allocation = allocation;
|
||||||
// m_Extent = imageCreateInfo.extent;
|
// m_Extent = imageCreateInfo.extent;
|
||||||
// m_MipLevels = 1;
|
// m_MipLevels = 1;
|
||||||
// m_LayerCount = 1;
|
// m_LayerCount = 1;
|
||||||
//
|
//
|
||||||
// device->SetName(m_Image, name);
|
// device->SetName(m_Image, name);
|
||||||
//}
|
// }
|
||||||
//
|
//
|
||||||
//void
|
// void
|
||||||
//DepthImage::Init(const Device *device, vk::Extent2D extent, cstr name)
|
// DepthImage::Init(const Device *device, vk::Extent2D extent, cstr name)
|
||||||
//{
|
//{
|
||||||
// constexpr vk::Format imageFormat = vk::Format::eD24UnormS8Uint;
|
// constexpr vk::Format imageFormat = vk::Format::eD24UnormS8Uint;
|
||||||
// vk::ImageCreateInfo imageCreateInfo = {
|
// vk::ImageCreateInfo imageCreateInfo = {
|
||||||
// .imageType = vk::ImageType::e2D,
|
// .imageType = vk::ImageType::e2D,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .extent = ToExtent3D(extent, 1),
|
// .extent = ToExtent3D(extent, 1),
|
||||||
// .mipLevels = 1,
|
// .mipLevels = 1,
|
||||||
// .arrayLayers = 1,
|
// .arrayLayers = 1,
|
||||||
// .samples = vk::SampleCountFlagBits::e1,
|
// .samples = vk::SampleCountFlagBits::e1,
|
||||||
// .tiling = vk::ImageTiling::eOptimal,
|
// .tiling = vk::ImageTiling::eOptimal,
|
||||||
// .usage = vk::ImageUsageFlagBits::eDepthStencilAttachment,
|
// .usage = vk::ImageUsageFlagBits::eDepthStencilAttachment,
|
||||||
// .sharingMode = vk::SharingMode::eExclusive,
|
// .sharingMode = vk::SharingMode::eExclusive,
|
||||||
// .initialLayout = vk::ImageLayout::eUndefined,
|
// .initialLayout = vk::ImageLayout::eUndefined,
|
||||||
// };
|
// };
|
||||||
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
||||||
// .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
|
// .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
|
||||||
// .usage = VMA_MEMORY_USAGE_AUTO,
|
// .usage = VMA_MEMORY_USAGE_AUTO,
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// VkImage image;
|
// VkImage image;
|
||||||
// VmaAllocation allocation;
|
// VmaAllocation allocation;
|
||||||
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
||||||
// &allocationCreateInfo, &image, &allocation, nullptr));
|
// &allocationCreateInfo, &image, &allocation, nullptr));
|
||||||
// ERROR_IF(Failed(result), "Could not allocate depth buffer. Cause: {}", result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not allocate depth buffer. Cause: {}", result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// vk::ImageView view;
|
// vk::ImageView view;
|
||||||
// vk::ImageViewCreateInfo imageViewCreateInfo = {
|
// vk::ImageViewCreateInfo imageViewCreateInfo = {
|
||||||
// .image = image,
|
// .image = image,
|
||||||
// .viewType = vk::ImageViewType::e2D,
|
// .viewType = vk::ImageViewType::e2D,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .components = {},
|
// .components = {},
|
||||||
// .subresourceRange =
|
// .subresourceRange =
|
||||||
// {
|
// {
|
||||||
// .aspectMask = vk::ImageAspectFlagBits::eDepth,
|
// .aspectMask = vk::ImageAspectFlagBits::eDepth,
|
||||||
// .baseMipLevel = 0,
|
// .baseMipLevel = 0,
|
||||||
// .levelCount = 1,
|
// .levelCount = 1,
|
||||||
// .baseArrayLayer = 0,
|
// .baseArrayLayer = 0,
|
||||||
// .layerCount = 1,
|
// .layerCount = 1,
|
||||||
// },
|
// },
|
||||||
// };
|
// };
|
||||||
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
||||||
// ERROR_IF(Failed(result), "Could not create depth image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not create depth image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// m_Device = device;
|
// m_Device = device;
|
||||||
// m_Image = image;
|
// m_Image = image;
|
||||||
// m_View = view;
|
// m_View = view;
|
||||||
// m_Allocation = allocation;
|
// m_Allocation = allocation;
|
||||||
// m_Extent = imageCreateInfo.extent;
|
// m_Extent = imageCreateInfo.extent;
|
||||||
// m_MipLevels = 1;
|
// m_MipLevels = 1;
|
||||||
// m_LayerCount = 1;
|
// m_LayerCount = 1;
|
||||||
//
|
//
|
||||||
// device->SetName(m_Image, name);
|
// device->SetName(m_Image, name);
|
||||||
//}
|
// }
|
||||||
//
|
//
|
||||||
//void
|
// void
|
||||||
//StorageTexture::Init(const Device *device, vk::Extent2D extent, const vk::Format imageFormat, const bool isSampled,
|
// StorageTexture::Init(const Device *device, vk::Extent2D extent, const vk::Format imageFormat, const bool isSampled,
|
||||||
// cstr name)
|
// cstr name)
|
||||||
//{
|
//{
|
||||||
// // Reasoning:
|
// // Reasoning:
|
||||||
// // Transfer Src and Dst to copy to and from the buffer since Storage will often be loaded with info, and read for
|
// // Transfer Src and Dst to copy to and from the buffer since Storage will often be loaded with info, and read for
|
||||||
// // results.
|
// // results.
|
||||||
// auto usage =
|
// auto usage =
|
||||||
// vk::ImageUsageFlagBits::eStorage | vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst;
|
// vk::ImageUsageFlagBits::eStorage | vk::ImageUsageFlagBits::eTransferSrc |
|
||||||
// if (isSampled)
|
// vk::ImageUsageFlagBits::eTransferDst;
|
||||||
// {
|
// if (isSampled)
|
||||||
// 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>");
|
// WARN_IF(!IsPowerOfTwo(extent.width) || !IsPowerOfTwo(extent.width), "Image {2} is {0}x{1} (Non Power of
|
||||||
// usage |= vk::ImageUsageFlagBits::eSampled;
|
// Two)",
|
||||||
// }
|
// extent.width, extent.height, name ? name : "<unnamed>");
|
||||||
|
// usage |= vk::ImageUsageFlagBits::eSampled;
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// vk::ImageCreateInfo imageCreateInfo = {
|
// vk::ImageCreateInfo imageCreateInfo = {
|
||||||
// .imageType = vk::ImageType::e2D,
|
// .imageType = vk::ImageType::e2D,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .extent = ToExtent3D(extent, 1),
|
// .extent = ToExtent3D(extent, 1),
|
||||||
// .mipLevels = 1,
|
// .mipLevels = 1,
|
||||||
// .arrayLayers = 1,
|
// .arrayLayers = 1,
|
||||||
// .samples = vk::SampleCountFlagBits::e1,
|
// .samples = vk::SampleCountFlagBits::e1,
|
||||||
// .tiling = vk::ImageTiling::eOptimal,
|
// .tiling = vk::ImageTiling::eOptimal,
|
||||||
// .usage = usage,
|
// .usage = usage,
|
||||||
// .sharingMode = vk::SharingMode::eExclusive,
|
// .sharingMode = vk::SharingMode::eExclusive,
|
||||||
// .initialLayout = vk::ImageLayout::eUndefined,
|
// .initialLayout = vk::ImageLayout::eUndefined,
|
||||||
// };
|
// };
|
||||||
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
||||||
// .flags = {},
|
// .flags = {},
|
||||||
// .usage = VMA_MEMORY_USAGE_AUTO,
|
// .usage = VMA_MEMORY_USAGE_AUTO,
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// VkImage image;
|
// VkImage image;
|
||||||
// VmaAllocation allocation;
|
// VmaAllocation allocation;
|
||||||
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
||||||
// &allocationCreateInfo, &image, &allocation, nullptr));
|
// &allocationCreateInfo, &image, &allocation, nullptr));
|
||||||
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// vk::ImageView view;
|
// vk::ImageView view;
|
||||||
// const vk::ImageViewCreateInfo imageViewCreateInfo = {
|
// const vk::ImageViewCreateInfo imageViewCreateInfo = {
|
||||||
// .image = image,
|
// .image = image,
|
||||||
// .viewType = vk::ImageViewType::e2D,
|
// .viewType = vk::ImageViewType::e2D,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .components = {},
|
// .components = {},
|
||||||
// .subresourceRange =
|
// .subresourceRange =
|
||||||
// {
|
// {
|
||||||
// .aspectMask = vk::ImageAspectFlagBits::eColor,
|
// .aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
// .baseMipLevel = 0,
|
// .baseMipLevel = 0,
|
||||||
// .levelCount = 1,
|
// .levelCount = 1,
|
||||||
// .baseArrayLayer = 0,
|
// .baseArrayLayer = 0,
|
||||||
// .layerCount = 1,
|
// .layerCount = 1,
|
||||||
// },
|
// },
|
||||||
// };
|
// };
|
||||||
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
||||||
// ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// m_Device = device;
|
// m_Device = device;
|
||||||
// m_Image = image;
|
// m_Image = image;
|
||||||
// m_View = view;
|
// m_View = view;
|
||||||
// m_Allocation = allocation;
|
// m_Allocation = allocation;
|
||||||
// m_Extent = imageCreateInfo.extent;
|
// m_Extent = imageCreateInfo.extent;
|
||||||
// m_MipLevels = 1;
|
// m_MipLevels = 1;
|
||||||
// m_LayerCount = 1;
|
// m_LayerCount = 1;
|
||||||
//
|
//
|
||||||
// device->SetName(m_Image, name);
|
// device->SetName(m_Image, name);
|
||||||
//}
|
// }
|
||||||
//
|
//
|
||||||
//void
|
// void
|
||||||
//StorageTextureCube::Init(const Device *device, u32 cubeSide, vk::Format imageFormat, bool isSampled, bool isMipMapped,
|
// StorageTextureCube::Init(const Device *device, u32 cubeSide, vk::Format imageFormat, bool isSampled, bool
|
||||||
// cstr name)
|
// isMipMapped,
|
||||||
|
// cstr name)
|
||||||
//{
|
//{
|
||||||
// // Reasoning:
|
// // Reasoning:
|
||||||
// // Transfer Src and Dst to copy to and from the buffer since Storage will often be loaded with info, and read for
|
// // Transfer Src and Dst to copy to and from the buffer since Storage will often be loaded with info, and read for
|
||||||
// // results.
|
// // results.
|
||||||
// auto usage =
|
// auto usage =
|
||||||
// vk::ImageUsageFlagBits::eStorage | vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst;
|
// vk::ImageUsageFlagBits::eStorage | vk::ImageUsageFlagBits::eTransferSrc |
|
||||||
// if (isSampled)
|
// vk::ImageUsageFlagBits::eTransferDst;
|
||||||
// {
|
// if (isSampled)
|
||||||
// WARN_IF(!IsPowerOfTwo(cubeSide), "Image {1} is {0}x{0} (Non Power of Two)", cubeSide,
|
// {
|
||||||
// name ? name : "<unnamed>");
|
// WARN_IF(!IsPowerOfTwo(cubeSide), "Image {1} is {0}x{0} (Non Power of Two)", cubeSide,
|
||||||
// usage |= vk::ImageUsageFlagBits::eSampled;
|
// name ? name : "<unnamed>");
|
||||||
// }
|
// usage |= vk::ImageUsageFlagBits::eSampled;
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// const u8 mipLevels = isMipMapped ? 1 + Cast<u8>(floor(log2(cubeSide))) : 1;
|
// const u8 mipLevels = isMipMapped ? 1 + Cast<u8>(floor(log2(cubeSide))) : 1;
|
||||||
//
|
//
|
||||||
// vk::ImageCreateInfo imageCreateInfo = {
|
// vk::ImageCreateInfo imageCreateInfo = {
|
||||||
// .flags = vk::ImageCreateFlagBits::eCubeCompatible,
|
// .flags = vk::ImageCreateFlagBits::eCubeCompatible,
|
||||||
// .imageType = vk::ImageType::e2D,
|
// .imageType = vk::ImageType::e2D,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .extent = {cubeSide, cubeSide, 1},
|
// .extent = {cubeSide, cubeSide, 1},
|
||||||
// .mipLevels = mipLevels,
|
// .mipLevels = mipLevels,
|
||||||
// .arrayLayers = 6,
|
// .arrayLayers = 6,
|
||||||
// .samples = vk::SampleCountFlagBits::e1,
|
// .samples = vk::SampleCountFlagBits::e1,
|
||||||
// .tiling = vk::ImageTiling::eOptimal,
|
// .tiling = vk::ImageTiling::eOptimal,
|
||||||
// .usage = usage,
|
// .usage = usage,
|
||||||
// .sharingMode = vk::SharingMode::eExclusive,
|
// .sharingMode = vk::SharingMode::eExclusive,
|
||||||
// .initialLayout = vk::ImageLayout::eUndefined,
|
// .initialLayout = vk::ImageLayout::eUndefined,
|
||||||
// };
|
// };
|
||||||
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
// constexpr VmaAllocationCreateInfo allocationCreateInfo = {
|
||||||
// .flags = {},
|
// .flags = {},
|
||||||
// .usage = VMA_MEMORY_USAGE_AUTO,
|
// .usage = VMA_MEMORY_USAGE_AUTO,
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// VkImage image;
|
// VkImage image;
|
||||||
// VmaAllocation allocation;
|
// VmaAllocation allocation;
|
||||||
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
// auto result = Cast<vk::Result>(vmaCreateImage(device->m_Allocator, Recast<VkImageCreateInfo *>(&imageCreateInfo),
|
||||||
// &allocationCreateInfo, &image, &allocation, nullptr));
|
// &allocationCreateInfo, &image, &allocation, nullptr));
|
||||||
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not allocate image {}. Cause: {}", name, result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// vk::ImageView view;
|
// vk::ImageView view;
|
||||||
// const vk::ImageViewCreateInfo imageViewCreateInfo = {
|
// const vk::ImageViewCreateInfo imageViewCreateInfo = {
|
||||||
// .image = image,
|
// .image = image,
|
||||||
// .viewType = vk::ImageViewType::eCube,
|
// .viewType = vk::ImageViewType::eCube,
|
||||||
// .format = imageFormat,
|
// .format = imageFormat,
|
||||||
// .components = {},
|
// .components = {},
|
||||||
// .subresourceRange =
|
// .subresourceRange =
|
||||||
// {
|
// {
|
||||||
// .aspectMask = vk::ImageAspectFlagBits::eColor,
|
// .aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||||
// .baseMipLevel = 0,
|
// .baseMipLevel = 0,
|
||||||
// .levelCount = mipLevels,
|
// .levelCount = mipLevels,
|
||||||
// .baseArrayLayer = 0,
|
// .baseArrayLayer = 0,
|
||||||
// .layerCount = 6,
|
// .layerCount = 6,
|
||||||
// },
|
// },
|
||||||
// };
|
// };
|
||||||
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
// result = device->m_Device.createImageView(&imageViewCreateInfo, nullptr, &view);
|
||||||
// ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
// ERROR_IF(Failed(result), "Could not create image view {}. Cause: {}", name, result) THEN_ABORT(result);
|
||||||
//
|
//
|
||||||
// m_Device = device;
|
// m_Device = device;
|
||||||
// m_Image = image;
|
// m_Image = image;
|
||||||
// m_View = view;
|
// m_View = view;
|
||||||
// m_Allocation = allocation;
|
// m_Allocation = allocation;
|
||||||
// m_Extent = imageCreateInfo.extent;
|
// m_Extent = imageCreateInfo.extent;
|
||||||
// m_MipLevels = mipLevels;
|
// m_MipLevels = mipLevels;
|
||||||
// m_LayerCount = 6;
|
// m_LayerCount = 6;
|
||||||
//
|
//
|
||||||
// device->SetName(m_Image, name);
|
// device->SetName(m_Image, name);
|
||||||
//}
|
// }
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: physical_device.cpp
|
// Aster: physical_device.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/physical_device.h"
|
#include "core/physical_device.h"
|
||||||
|
|
@ -161,4 +161,4 @@ PhysicalDevices::PhysicalDevices(const Surface *surface, const Context *context)
|
||||||
{
|
{
|
||||||
this->emplace_back(surface->m_Surface, physicalDevice);
|
this->emplace_back(surface->m_Surface, physicalDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: pipeline.cpp
|
// Aster: pipeline.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/pipeline.h"
|
#include "core/pipeline.h"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: sampler.cpp
|
// Aster: sampler.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/sampler.h"
|
#include "core/sampler.h"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: surface.cpp
|
// Aster: surface.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/surface.h"
|
#include "core/surface.h"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/// =============================================
|
/// =============================================
|
||||||
// Aster: swapchain.cpp
|
// Aster: swapchain.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// ==============================================
|
// ==============================================
|
||||||
|
|
||||||
#include "core/swapchain.h"
|
#include "core/swapchain.h"
|
||||||
|
|
@ -67,7 +67,7 @@ Swapchain::Create(const Surface *surface, Size2D size)
|
||||||
auto presentModes = GetSurfacePresentModes(m_Device->m_PhysicalDevice, surface->m_Surface);
|
auto presentModes = GetSurfacePresentModes(m_Device->m_PhysicalDevice, surface->m_Surface);
|
||||||
|
|
||||||
m_Format = vk::Format::eUndefined;
|
m_Format = vk::Format::eUndefined;
|
||||||
vk::ColorSpaceKHR swapchainColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear;
|
auto swapchainColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear;
|
||||||
for (auto [format, colorSpace] : surfaceFormats)
|
for (auto [format, colorSpace] : surfaceFormats)
|
||||||
{
|
{
|
||||||
if (format == vk::Format::eB8G8R8A8Srgb && colorSpace == vk::ColorSpaceKHR::eSrgbNonlinear)
|
if (format == vk::Format::eB8G8R8A8Srgb && colorSpace == vk::ColorSpaceKHR::eSrgbNonlinear)
|
||||||
|
|
@ -84,7 +84,7 @@ Swapchain::Create(const Surface *surface, Size2D size)
|
||||||
swapchainColorSpace = colorSpace;
|
swapchainColorSpace = colorSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::PresentModeKHR swapchainPresentMode = vk::PresentModeKHR::eFifo;
|
auto swapchainPresentMode = vk::PresentModeKHR::eFifo;
|
||||||
for (const auto presentMode : presentModes)
|
for (const auto presentMode : presentModes)
|
||||||
{
|
{
|
||||||
if (presentMode == vk::PresentModeKHR::eMailbox)
|
if (presentMode == vk::PresentModeKHR::eMailbox)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: window.cpp
|
// Aster: window.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/window.h"
|
#include "core/window.h"
|
||||||
|
|
@ -96,7 +96,7 @@ Window::~Window()
|
||||||
--m_WindowCount;
|
--m_WindowCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_WindowCount== 0 && m_IsGlfwInit)
|
if (m_WindowCount == 0 && m_IsGlfwInit)
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
m_IsGlfwInit = false;
|
m_IsGlfwInit = false;
|
||||||
|
|
@ -119,4 +119,4 @@ Window::operator=(Window &&other) noexcept
|
||||||
m_Window = Take(other.m_Window);
|
m_Window = Take(other.m_Window);
|
||||||
m_Name = Take(other.m_Name);
|
m_Name = Take(other.m_Name);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
@ -7,6 +7,6 @@ PRIVATE
|
||||||
"manager.cpp"
|
"manager.cpp"
|
||||||
"buffer_manager.cpp"
|
"buffer_manager.cpp"
|
||||||
"image_manager.cpp"
|
"image_manager.cpp"
|
||||||
"image_view_manager.cpp"
|
"view_manager.cpp"
|
||||||
"sampler_manager.cpp"
|
"sampler_manager.cpp"
|
||||||
"commit_manager.cpp")
|
"commit_manager.cpp")
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ using namespace systems;
|
||||||
|
|
||||||
CommitManager *CommitManager::m_Instance = nullptr;
|
CommitManager *CommitManager::m_Instance = nullptr;
|
||||||
|
|
||||||
CommitManager::CommitManager(const Device *device, u32 const maxBuffers, const u32 maxImages, const u32 maxStorageImages,
|
CommitManager::CommitManager(const Device *device, const u32 maxBuffers, const u32 maxImages,
|
||||||
Ref<Sampler> defaultSampler)
|
const u32 maxStorageImages, Ref<Sampler> defaultSampler)
|
||||||
: m_Device{device}
|
: m_Device{device}
|
||||||
, m_Buffers{maxBuffers}
|
, m_Buffers{maxBuffers}
|
||||||
, m_Images{maxImages}
|
, m_Images{maxImages}
|
||||||
|
|
@ -55,10 +55,10 @@ CommitManager::CommitManager(const Device *device, u32 const maxBuffers, const u
|
||||||
.type = vk::DescriptorType::eCombinedImageSampler,
|
.type = vk::DescriptorType::eCombinedImageSampler,
|
||||||
.descriptorCount = maxImages,
|
.descriptorCount = maxImages,
|
||||||
},
|
},
|
||||||
// vk::DescriptorPoolSize{
|
vk::DescriptorPoolSize{
|
||||||
// .type = vk::DescriptorType::eStorageImage,
|
.type = vk::DescriptorType::eStorageImage,
|
||||||
// .descriptorCount = storageTexturesCount,
|
.descriptorCount = maxStorageImages,
|
||||||
// },
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const vk::DescriptorPoolCreateInfo poolCreateInfo = {
|
const vk::DescriptorPoolCreateInfo poolCreateInfo = {
|
||||||
|
|
@ -82,12 +82,12 @@ CommitManager::CommitManager(const Device *device, u32 const maxBuffers, const u
|
||||||
.descriptorCount = Cast<u32>(maxImages),
|
.descriptorCount = Cast<u32>(maxImages),
|
||||||
.stageFlags = vk::ShaderStageFlagBits::eAll,
|
.stageFlags = vk::ShaderStageFlagBits::eAll,
|
||||||
},
|
},
|
||||||
vk::DescriptorSetLayoutBinding{
|
vk::DescriptorSetLayoutBinding{
|
||||||
.binding = STORAGE_IMAGE_BINDING_INDEX,
|
.binding = STORAGE_IMAGE_BINDING_INDEX,
|
||||||
.descriptorType = vk::DescriptorType::eStorageImage,
|
.descriptorType = vk::DescriptorType::eStorageImage,
|
||||||
.descriptorCount = Cast<u32>(maxStorageImages),
|
.descriptorCount = Cast<u32>(maxStorageImages),
|
||||||
.stageFlags = vk::ShaderStageFlagBits::eAll,
|
.stageFlags = vk::ShaderStageFlagBits::eAll,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
vk::DescriptorBindingFlags bindingFlags =
|
vk::DescriptorBindingFlags bindingFlags =
|
||||||
|
|
@ -258,4 +258,4 @@ CommitManager::Update()
|
||||||
|
|
||||||
m_Buffers.Update();
|
m_Buffers.Update();
|
||||||
m_Images.Update();
|
m_Images.Update();
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: buffer_manager.cpp
|
// Aster: image_manager.cpp
|
||||||
// Copyright (c) 2020-2025 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ ToImageCreateInfo(const DepthStencilImageCreateInfo &createInfo)
|
||||||
{
|
{
|
||||||
auto &[extent, name] = createInfo;
|
auto &[extent, name] = createInfo;
|
||||||
|
|
||||||
constexpr vk::Format format = vk::Format::eD24UnormS8Uint;
|
constexpr auto format = vk::Format::eD24UnormS8Uint;
|
||||||
constexpr auto usage = usage_flags::DEPTH_STENCIL_ATTACHMENT;
|
constexpr auto usage = usage_flags::DEPTH_STENCIL_ATTACHMENT;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@
|
||||||
// Copyright (c) 2020-2025 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "systems/manager.h"
|
#include "systems/manager.h"
|
||||||
|
|
@ -35,4 +35,4 @@ SamplerManager::CreateSampler(const SamplerCreateInfo &createInfo)
|
||||||
m_HashToSamplerIdx.emplace(vkCreateInfo, object);
|
m_HashToSamplerIdx.emplace(vkCreateInfo, object);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
@ -1,29 +1,27 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: image_view_manager.cpp
|
// Aster: view_manager.cpp
|
||||||
// Copyright (c) 2020-2025 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "systems/image_view_manager.h"
|
#include "systems/view_manager.h"
|
||||||
|
|
||||||
#include "core/device.h"
|
#include "core/device.h"
|
||||||
|
|
||||||
using namespace systems;
|
using namespace systems;
|
||||||
|
|
||||||
ImageViewManager::ImageViewManager(const Device *device, const u32 maxCount)
|
ViewManager::ViewManager(const Device *device, const u32 maxCount)
|
||||||
: Manager{device, maxCount}
|
: Manager{device, maxCount}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<ImageView>
|
Ref<ImageView>
|
||||||
ImageViewManager::CreateView(const ViewCreateInfo<> &createInfo)
|
ViewManager::CreateView(const ViewCreateInfo<> &createInfo)
|
||||||
{
|
{
|
||||||
const auto layerCount = createInfo.GetLayerCount();
|
const auto layerCount = createInfo.GetLayerCount();
|
||||||
const auto mipCount = createInfo.GetMipLevelCount();
|
const auto mipCount = createInfo.GetMipLevelCount();
|
||||||
ERROR_IF((createInfo.m_BaseLayer + layerCount) > createInfo.m_Image->m_LayerCount,
|
ERROR_IF((createInfo.m_BaseLayer + layerCount) > createInfo.m_Image->m_LayerCount, "Invalid Layer Access")
|
||||||
"Invalid Layer Access")
|
|
||||||
THEN_ABORT(-1);
|
THEN_ABORT(-1);
|
||||||
ERROR_IF((createInfo.m_BaseMipLevel + mipCount) > createInfo.m_Image->m_MipLevels,
|
ERROR_IF((createInfo.m_BaseMipLevel + mipCount) > createInfo.m_Image->m_MipLevels, "Invalid Mip Level Access")
|
||||||
"Invalid Mip Level Access")
|
|
||||||
THEN_ABORT(-1);
|
THEN_ABORT(-1);
|
||||||
|
|
||||||
vk::ImageView view;
|
vk::ImageView view;
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: logger.cpp
|
// Aster: logger.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "util/logger.h"
|
#include "util/logger.h"
|
||||||
|
|
||||||
Logger g_Logger = Logger();
|
auto g_Logger = Logger();
|
||||||
// ReSharper disable once CppInconsistentNaming
|
// ReSharper disable once CppInconsistentNaming
|
||||||
|
|
||||||
/* Credits to Const-me */
|
/* Credits to Const-me */
|
||||||
|
|
@ -16,4 +16,4 @@ AssertionFailure(const char *af)
|
||||||
{
|
{
|
||||||
ERROR("{}", af);
|
ERROR("{}", af);
|
||||||
}
|
}
|
||||||
} // namespace eastl
|
} // namespace eastl
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: frame.cpp
|
// Aster: frame.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
@ -171,4 +171,4 @@ FrameManager::GetNextFrame(Swapchain *swapchain, const Surface *surface, Size2D
|
||||||
currentFrame->m_ImageIdx = imageIndex;
|
currentFrame->m_ImageIdx = imageIndex;
|
||||||
|
|
||||||
return currentFrame;
|
return currentFrame;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: frame.h
|
// Aster: frame.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -31,7 +31,7 @@ struct Frame
|
||||||
// Transient
|
// Transient
|
||||||
u32 m_ImageIdx;
|
u32 m_ImageIdx;
|
||||||
|
|
||||||
void Present(const vk::Queue commandQueue, Swapchain* swapchain, const Surface* surface, Size2D size);
|
void Present(vk::Queue commandQueue, Swapchain *swapchain, const Surface *surface, Size2D size);
|
||||||
|
|
||||||
Frame(const Device *device, u32 queueFamilyIndex, u32 frameCount);
|
Frame(const Device *device, u32 queueFamilyIndex, u32 frameCount);
|
||||||
~Frame();
|
~Frame();
|
||||||
|
|
@ -52,4 +52,4 @@ struct FrameManager
|
||||||
FrameManager(const Device *device, u32 queueFamilyIndex, u32 framesInFlight);
|
FrameManager(const Device *device, u32 queueFamilyIndex, u32 framesInFlight);
|
||||||
|
|
||||||
Frame *GetNextFrame(Swapchain *swapchain, const Surface *surface, Size2D size);
|
Frame *GetNextFrame(Swapchain *swapchain, const Surface *surface, Size2D size);
|
||||||
};
|
};
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: gui.cpp
|
// Aster: gui.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
@ -108,7 +108,7 @@ StartBuild()
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
NewFrame();
|
NewFrame();
|
||||||
|
|
||||||
static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_PassthruCentralNode;
|
static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_PassthruCentralNode;
|
||||||
|
|
||||||
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
|
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
|
||||||
// because it would be confusing to have two docking targets within each others.
|
// because it would be confusing to have two docking targets within each others.
|
||||||
|
|
@ -130,18 +130,18 @@ StartBuild()
|
||||||
// all active windows docked into it will lose their parent and become undocked.
|
// all active windows docked into it will lose their parent and become undocked.
|
||||||
// We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
|
// We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
|
||||||
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
|
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
|
||||||
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
Begin("DockSpace Demo", nullptr, windowFlags);
|
Begin("DockSpace Demo", nullptr, windowFlags);
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
|
|
||||||
PopStyleVar(2);
|
PopStyleVar(2);
|
||||||
|
|
||||||
// DockSpace
|
// DockSpace
|
||||||
if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||||
{
|
{
|
||||||
const ImGuiID dockspaceId = GetID("MyDockSpace");
|
const ImGuiID dockspaceId = GetID("MyDockSpace");
|
||||||
DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
|
DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -213,4 +213,4 @@ PopDisable()
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
PopItemFlag();
|
PopItemFlag();
|
||||||
}
|
}
|
||||||
} // namespace ImGui
|
} // namespace ImGui
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: gui.h
|
// Aster: gui.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: helpers.cpp
|
// Aster: helpers.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: helpers.h
|
// Aster: helpers.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -46,4 +46,4 @@ using StackString = eastl::fixed_string<char, TSize, false>;
|
||||||
{ \
|
{ \
|
||||||
auto _checkResultValue_ = Cast<vk::Result>(RESULT); \
|
auto _checkResultValue_ = Cast<vk::Result>(RESULT); \
|
||||||
ERROR_IF(Failed(_checkResultValue_), MSG " Cause: {}", _checkResultValue_) THEN_ABORT(_checkResultValue_); \
|
ERROR_IF(Failed(_checkResultValue_), MSG " Cause: {}", _checkResultValue_) THEN_ABORT(_checkResultValue_); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: triangle.cpp
|
// Aster: triangle.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "aster/aster.h"
|
#include "aster/aster.h"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: box.cpp
|
// Aster: box.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "aster/aster.h"
|
#include "aster/aster.h"
|
||||||
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "aster/systems/buffer_manager.h"
|
#include "aster/systems/buffer_manager.h"
|
||||||
#include "aster/systems/image_manager.h"
|
|
||||||
#include "aster/systems/commit_manager.h"
|
#include "aster/systems/commit_manager.h"
|
||||||
|
#include "aster/systems/image_manager.h"
|
||||||
|
#include "aster/systems/resource_manager.h"
|
||||||
|
#include "aster/systems/view_manager.h"
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
#include "aster/systems/image_view_manager.h"
|
|
||||||
#include "aster/systems/resource_manager.h"
|
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
|
|
||||||
|
|
@ -139,7 +139,7 @@ main(int, char **)
|
||||||
|
|
||||||
Camera camera = {
|
Camera camera = {
|
||||||
.m_Model = {1.0f},
|
.m_Model = {1.0f},
|
||||||
.m_View = glm::lookAt(vec3(0.0f, 2.0f, 2.0f), vec3(0.0f), vec3(0.0f, 1.0f, 0.0f)),
|
.m_View = lookAt(vec3(0.0f, 2.0f, 2.0f), vec3(0.0f), vec3(0.0f, 1.0f, 0.0f)),
|
||||||
.m_Perspective = glm::perspective(
|
.m_Perspective = glm::perspective(
|
||||||
70_deg, Cast<f32>(swapchain.m_Extent.width) / Cast<f32>(swapchain.m_Extent.height), 0.1f, 100.0f),
|
70_deg, Cast<f32>(swapchain.m_Extent.width) / Cast<f32>(swapchain.m_Extent.height), 0.1f, 100.0f),
|
||||||
};
|
};
|
||||||
|
|
@ -214,12 +214,11 @@ main(int, char **)
|
||||||
auto vbo = resourceManager.Buffers().CreateStorageBuffer(vertices.size() * sizeof vertices[0], "Vertex Buffer");
|
auto vbo = resourceManager.Buffers().CreateStorageBuffer(vertices.size() * sizeof vertices[0], "Vertex Buffer");
|
||||||
vbo->Write(0, vertices.size() * sizeof vertices[0], vertices.data());
|
vbo->Write(0, vertices.size() * sizeof vertices[0], vertices.data());
|
||||||
|
|
||||||
auto crate = resourceManager.CombinedImageViews()
|
auto crate = resourceManager.CombinedImageViews().CreateTexture2D({
|
||||||
.CreateTexture2D({
|
.m_Format = vk::Format::eR8G8B8A8Srgb,
|
||||||
.m_Format = vk::Format::eR8G8B8A8Srgb,
|
.m_Extent = {imageFile.m_Width, imageFile.m_Height},
|
||||||
.m_Extent = {imageFile.m_Width, imageFile.m_Height},
|
.m_Name = "Crate Texture",
|
||||||
.m_Name = "Crate Texture",
|
});
|
||||||
});
|
|
||||||
|
|
||||||
{
|
{
|
||||||
StagingBuffer imageStaging;
|
StagingBuffer imageStaging;
|
||||||
|
|
@ -411,7 +410,7 @@ main(int, char **)
|
||||||
{
|
{
|
||||||
systems::ResId<Buffer> m_Camera;
|
systems::ResId<Buffer> m_Camera;
|
||||||
systems::ResId<Buffer> m_VertexBuffer;
|
systems::ResId<Buffer> m_VertexBuffer;
|
||||||
systems::ResId<TextureView> m_Texture;
|
systems::ResId<TextureView> m_Texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
PCB pcb = {
|
PCB pcb = {
|
||||||
|
|
@ -427,6 +426,7 @@ main(int, char **)
|
||||||
{
|
{
|
||||||
Time::Update();
|
Time::Update();
|
||||||
commitManager.Update();
|
commitManager.Update();
|
||||||
|
resourceManager.Update();
|
||||||
|
|
||||||
camera.m_Model *= rotate(mat4{1.0f}, Cast<f32>(45.0_deg * Time::m_Delta), vec3(0.0f, 1.0f, 0.0f));
|
camera.m_Model *= rotate(mat4{1.0f}, Cast<f32>(45.0_deg * Time::m_Delta), vec3(0.0f, 1.0f, 0.0f));
|
||||||
ubo->Write(0, sizeof camera, &camera);
|
ubo->Write(0, sizeof camera, &camera);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: asset_loader.cpp
|
// Aster: asset_loader.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
|
|
@ -553,8 +553,8 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
if (!model.materials.empty())
|
if (!model.materials.empty())
|
||||||
{
|
{
|
||||||
// TODO("Something broken on load here.");
|
// TODO("Something broken on load here.");
|
||||||
auto getTextureHandle = [this, &textureHandleMap, &stagingBuffers, &model](i32 index,
|
auto getTextureHandle = [this, &textureHandleMap, &stagingBuffers,
|
||||||
const bool isSrgb) -> systems::ResId<TextureView> {
|
&model](i32 index, const bool isSrgb) -> systems::ResId<TextureView> {
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
return systems::NullId{};
|
return systems::NullId{};
|
||||||
|
|
@ -642,12 +642,12 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
|
|
||||||
if (posAccessor->type == TINYGLTF_TYPE_VEC4)
|
if (posAccessor->type == TINYGLTF_TYPE_VEC4)
|
||||||
{
|
{
|
||||||
vec4 *data = Recast<vec4 *>(posBuffer->data.data() + byteOffset);
|
auto data = Recast<vec4 *>(posBuffer->data.data() + byteOffset);
|
||||||
vertexPositions.insert(vertexPositions.end(), data, data + vertexCount);
|
vertexPositions.insert(vertexPositions.end(), data, data + vertexCount);
|
||||||
}
|
}
|
||||||
else if (posAccessor->type == TINYGLTF_TYPE_VEC3)
|
else if (posAccessor->type == TINYGLTF_TYPE_VEC3)
|
||||||
{
|
{
|
||||||
vec3 *data = Recast<vec3 *>(posBuffer->data.data() + byteOffset);
|
auto data = Recast<vec3 *>(posBuffer->data.data() + byteOffset);
|
||||||
for (u32 i = 0; i < vertexCount; ++i)
|
for (u32 i = 0; i < vertexCount; ++i)
|
||||||
{
|
{
|
||||||
vertexPositions.push_back(vec4(data[i], 1.0f));
|
vertexPositions.push_back(vec4(data[i], 1.0f));
|
||||||
|
|
@ -655,7 +655,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
}
|
}
|
||||||
else if (posAccessor->type == TINYGLTF_TYPE_VEC2)
|
else if (posAccessor->type == TINYGLTF_TYPE_VEC2)
|
||||||
{
|
{
|
||||||
vec2 *data = Recast<vec2 *>(posBuffer->data.data() + byteOffset);
|
auto data = Recast<vec2 *>(posBuffer->data.data() + byteOffset);
|
||||||
for (u32 i = 0; i < vertexCount; ++i)
|
for (u32 i = 0; i < vertexCount; ++i)
|
||||||
{
|
{
|
||||||
vertexPositions.push_back(vec4(data[i], 0.0f, 1.0f));
|
vertexPositions.push_back(vec4(data[i], 0.0f, 1.0f));
|
||||||
|
|
@ -679,7 +679,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
|
|
||||||
if (normAccessor->type == TINYGLTF_TYPE_VEC4)
|
if (normAccessor->type == TINYGLTF_TYPE_VEC4)
|
||||||
{
|
{
|
||||||
vec4 *data = Recast<vec4 *>(normBuffer->data.data() + byteOffset);
|
auto data = Recast<vec4 *>(normBuffer->data.data() + byteOffset);
|
||||||
|
|
||||||
vec4 *end = data + vertexCount;
|
vec4 *end = data + vertexCount;
|
||||||
u32 idx = vertexOffset;
|
u32 idx = vertexOffset;
|
||||||
|
|
@ -691,7 +691,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
}
|
}
|
||||||
else if (normAccessor->type == TINYGLTF_TYPE_VEC3)
|
else if (normAccessor->type == TINYGLTF_TYPE_VEC3)
|
||||||
{
|
{
|
||||||
vec3 *data = Recast<vec3 *>(normBuffer->data.data() + byteOffset);
|
auto data = Recast<vec3 *>(normBuffer->data.data() + byteOffset);
|
||||||
for (u32 i = 0; i < vertexCount; ++i)
|
for (u32 i = 0; i < vertexCount; ++i)
|
||||||
{
|
{
|
||||||
auto norm = vec4(data[i], 0.0f);
|
auto norm = vec4(data[i], 0.0f);
|
||||||
|
|
@ -700,7 +700,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
}
|
}
|
||||||
else if (normAccessor->type == TINYGLTF_TYPE_VEC2)
|
else if (normAccessor->type == TINYGLTF_TYPE_VEC2)
|
||||||
{
|
{
|
||||||
vec2 *data = Recast<vec2 *>(normBuffer->data.data() + byteOffset);
|
auto data = Recast<vec2 *>(normBuffer->data.data() + byteOffset);
|
||||||
for (u32 i = 0; i < vertexCount; ++i)
|
for (u32 i = 0; i < vertexCount; ++i)
|
||||||
{
|
{
|
||||||
auto norm = vec4(data[i], 0.0f, 0.0f);
|
auto norm = vec4(data[i], 0.0f, 0.0f);
|
||||||
|
|
@ -723,7 +723,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
assert(uvAccessor->type == TINYGLTF_TYPE_VEC2 &&
|
assert(uvAccessor->type == TINYGLTF_TYPE_VEC2 &&
|
||||||
uvAccessor->componentType == TINYGLTF_COMPONENT_TYPE_FLOAT);
|
uvAccessor->componentType == TINYGLTF_COMPONENT_TYPE_FLOAT);
|
||||||
{
|
{
|
||||||
vec2 *data = Recast<vec2 *>(uvBuffer->data.data() + byteOffset);
|
auto data = Recast<vec2 *>(uvBuffer->data.data() + byteOffset);
|
||||||
vec2 *end = data + vertexCount;
|
vec2 *end = data + vertexCount;
|
||||||
u32 idx = vertexOffset;
|
u32 idx = vertexOffset;
|
||||||
vec2 *it = data;
|
vec2 *it = data;
|
||||||
|
|
@ -746,7 +746,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
|
|
||||||
if (colorAccessor->type == TINYGLTF_TYPE_VEC4)
|
if (colorAccessor->type == TINYGLTF_TYPE_VEC4)
|
||||||
{
|
{
|
||||||
vec4 *data = Recast<vec4 *>(colorBuffer->data.data() + byteOffset);
|
auto data = Recast<vec4 *>(colorBuffer->data.data() + byteOffset);
|
||||||
|
|
||||||
vec4 *end = data + vertexCount;
|
vec4 *end = data + vertexCount;
|
||||||
u32 idx = vertexOffset;
|
u32 idx = vertexOffset;
|
||||||
|
|
@ -758,7 +758,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
}
|
}
|
||||||
else if (colorAccessor->type == TINYGLTF_TYPE_VEC3)
|
else if (colorAccessor->type == TINYGLTF_TYPE_VEC3)
|
||||||
{
|
{
|
||||||
vec3 *data = Recast<vec3 *>(colorBuffer->data.data() + byteOffset);
|
auto data = Recast<vec3 *>(colorBuffer->data.data() + byteOffset);
|
||||||
for (u32 i = 0; i < vertexCount; ++i)
|
for (u32 i = 0; i < vertexCount; ++i)
|
||||||
{
|
{
|
||||||
auto color = vec4(data[i], 1.0f);
|
auto color = vec4(data[i], 1.0f);
|
||||||
|
|
@ -784,17 +784,17 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
|
|
||||||
if (indexAccessor->componentType == TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT)
|
if (indexAccessor->componentType == TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT)
|
||||||
{
|
{
|
||||||
u32 *data = Recast<u32 *>(indexBuffer->data.data() + byteOffset);
|
auto data = Recast<u32 *>(indexBuffer->data.data() + byteOffset);
|
||||||
indices.insert(indices.end(), data, data + indexCount);
|
indices.insert(indices.end(), data, data + indexCount);
|
||||||
}
|
}
|
||||||
else if (indexAccessor->componentType == TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT)
|
else if (indexAccessor->componentType == TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT)
|
||||||
{
|
{
|
||||||
u16 *data = Recast<u16 *>(indexBuffer->data.data() + byteOffset);
|
auto data = Recast<u16 *>(indexBuffer->data.data() + byteOffset);
|
||||||
indices.insert(indices.end(), data, data + indexCount);
|
indices.insert(indices.end(), data, data + indexCount);
|
||||||
}
|
}
|
||||||
else if (indexAccessor->componentType == TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE)
|
else if (indexAccessor->componentType == TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE)
|
||||||
{
|
{
|
||||||
u8 *data = Recast<u8 *>(indexBuffer->data.data() + byteOffset);
|
auto data = Recast<u8 *>(indexBuffer->data.data() + byteOffset);
|
||||||
indices.insert(indices.end(), data, data + indexCount);
|
indices.insert(indices.end(), data, data + indexCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -831,10 +831,10 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
&meshPrimitives](i32 idx, i32 parent) -> void {
|
&meshPrimitives](i32 idx, i32 parent) -> void {
|
||||||
const auto *node = &model.nodes[idx];
|
const auto *node = &model.nodes[idx];
|
||||||
|
|
||||||
vec3 nodeTranslation = vec3{0.0f};
|
auto nodeTranslation = vec3{0.0f};
|
||||||
quat nodeRotation = quat{1.0f, 0.0f, 0.0f, 0.0f};
|
auto nodeRotation = quat{1.0f, 0.0f, 0.0f, 0.0f};
|
||||||
vec3 nodeScale = vec3{1.0f};
|
auto nodeScale = vec3{1.0f};
|
||||||
mat4 nodeMatrix = mat4{1.0f};
|
auto nodeMatrix = mat4{1.0f};
|
||||||
if (node->translation.size() == 3)
|
if (node->translation.size() == 3)
|
||||||
{
|
{
|
||||||
nodeTranslation = glm::make_vec3(node->translation.data());
|
nodeTranslation = glm::make_vec3(node->translation.data());
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: asset_loader.h
|
// Aster: asset_loader.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -9,11 +9,11 @@
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
|
|
||||||
|
#include "aster/systems/image_manager.h"
|
||||||
|
#include "aster/systems/resource.h"
|
||||||
|
#include "aster/systems/view_manager.h"
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
#include "tiny_gltf.h"
|
#include "tiny_gltf.h"
|
||||||
#include "aster/systems/image_manager.h"
|
|
||||||
#include "aster/systems/image_view_manager.h"
|
|
||||||
#include "aster/systems/resource.h"
|
|
||||||
|
|
||||||
namespace systems
|
namespace systems
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +22,7 @@ class SamplerManager;
|
||||||
class BufferManager;
|
class BufferManager;
|
||||||
class ImageManager;
|
class ImageManager;
|
||||||
class CommitManager;
|
class CommitManager;
|
||||||
}
|
} // namespace systems
|
||||||
|
|
||||||
namespace tinygltf
|
namespace tinygltf
|
||||||
{
|
{
|
||||||
|
|
@ -46,10 +46,10 @@ struct MeshPrimitive
|
||||||
|
|
||||||
struct Material
|
struct Material
|
||||||
{
|
{
|
||||||
vec4 m_AlbedoFactor; // 16 16
|
vec4 m_AlbedoFactor; // 16 16
|
||||||
vec3 m_EmissionFactor; // 12 28
|
vec3 m_EmissionFactor; // 12 28
|
||||||
f32 m_MetalFactor; // 04 32
|
f32 m_MetalFactor; // 04 32
|
||||||
f32 m_RoughFactor; // 04 36
|
f32 m_RoughFactor; // 04 36
|
||||||
systems::ResId<TextureView> m_AlbedoTex; // 04 40
|
systems::ResId<TextureView> m_AlbedoTex; // 04 40
|
||||||
systems::ResId<TextureView> m_NormalTex; // 04 44
|
systems::ResId<TextureView> m_NormalTex; // 04 44
|
||||||
systems::ResId<TextureView> m_MetalRoughTex; // 04 48
|
systems::ResId<TextureView> m_MetalRoughTex; // 04 48
|
||||||
|
|
@ -88,8 +88,9 @@ struct Model
|
||||||
void SetModelTransform(const mat4 &transform);
|
void SetModelTransform(const mat4 &transform);
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
Model(systems::CommitManager *resourceManager, eastl::vector<systems::ResId<TextureView>> &textureHandles, Nodes &&nodes, Ref<Buffer> nodeBuffer,
|
Model(systems::CommitManager *resourceManager, eastl::vector<systems::ResId<TextureView>> &textureHandles,
|
||||||
ModelHandles &handles, Ref<Buffer> indexBuffer, const eastl::vector<MeshPrimitive> &meshPrimitives);
|
Nodes &&nodes, Ref<Buffer> nodeBuffer, ModelHandles &handles, Ref<Buffer> indexBuffer,
|
||||||
|
const eastl::vector<MeshPrimitive> &meshPrimitives);
|
||||||
~Model() = default;
|
~Model() = default;
|
||||||
|
|
||||||
Model(Model &&other) noexcept = default;
|
Model(Model &&other) noexcept = default;
|
||||||
|
|
@ -124,8 +125,7 @@ struct AssetLoader
|
||||||
constexpr static auto AWeights0 = "WEIGHTS_0";
|
constexpr static auto AWeights0 = "WEIGHTS_0";
|
||||||
|
|
||||||
AssetLoader(systems::ResourceManager *resourceManager, systems::CommitManager *commitManager,
|
AssetLoader(systems::ResourceManager *resourceManager, systems::CommitManager *commitManager,
|
||||||
vk::Queue transferQueue, u32 transferQueueIndex,
|
vk::Queue transferQueue, u32 transferQueueIndex, u32 graphicsQueueIndex);
|
||||||
u32 graphicsQueueIndex);
|
|
||||||
~AssetLoader();
|
~AssetLoader();
|
||||||
|
|
||||||
AssetLoader(AssetLoader &&other) noexcept;
|
AssetLoader(AssetLoader &&other) noexcept;
|
||||||
|
|
@ -138,7 +138,6 @@ void
|
||||||
GenerateMipMaps(vk::CommandBuffer commandBuffer, const Ref<Texture> &textureView, vk::ImageLayout initialLayout,
|
GenerateMipMaps(vk::CommandBuffer commandBuffer, const Ref<Texture> &textureView, vk::ImageLayout initialLayout,
|
||||||
vk::ImageLayout finalLayout, vk::PipelineStageFlags2 prevStage, vk::PipelineStageFlags2 finalStage);
|
vk::ImageLayout finalLayout, vk::PipelineStageFlags2 prevStage, vk::PipelineStageFlags2 finalStage);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GenerateMipMaps(vk::CommandBuffer commandBuffer, concepts::SampledImageRef auto &texture, vk::ImageLayout initialLayout,
|
GenerateMipMaps(vk::CommandBuffer commandBuffer, concepts::SampledImageRef auto &texture, vk::ImageLayout initialLayout,
|
||||||
vk::ImageLayout finalLayout,
|
vk::ImageLayout finalLayout,
|
||||||
|
|
@ -150,8 +149,8 @@ GenerateMipMaps(vk::CommandBuffer commandBuffer, concepts::SampledImageRef auto
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GenerateMipMaps(vk::CommandBuffer commandBuffer, concepts::SampledImageViewRef auto &texture, vk::ImageLayout initialLayout,
|
GenerateMipMaps(vk::CommandBuffer commandBuffer, concepts::SampledImageViewRef auto &texture,
|
||||||
vk::ImageLayout finalLayout,
|
vk::ImageLayout initialLayout, vk::ImageLayout finalLayout,
|
||||||
vk::PipelineStageFlags2 prevStage = vk::PipelineStageFlagBits2::eAllCommands,
|
vk::PipelineStageFlags2 prevStage = vk::PipelineStageFlagBits2::eAllCommands,
|
||||||
vk::PipelineStageFlags2 finalStage = vk::PipelineStageFlagBits2::eAllCommands)
|
vk::PipelineStageFlags2 finalStage = vk::PipelineStageFlagBits2::eAllCommands)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: ibl_helpers.cpp
|
// Aster: ibl_helpers.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "ibl_helpers.h"
|
#include "ibl_helpers.h"
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
#include <EASTL/fixed_vector.h>
|
#include <EASTL/fixed_vector.h>
|
||||||
#include <EASTL/tuple.h>
|
#include <EASTL/tuple.h>
|
||||||
|
|
||||||
constexpr cstr EQUIRECT_TO_CUBE_SHADER_FILE = "shader/eqrect_to_cube.cs.hlsl.spv";
|
constexpr auto EQUIRECT_TO_CUBE_SHADER_FILE = "shader/eqrect_to_cube.cs.hlsl.spv";
|
||||||
constexpr cstr DIFFUSE_IRRADIANCE_SHADER_FILE = "shader/diffuse_irradiance.cs.hlsl.spv";
|
constexpr auto DIFFUSE_IRRADIANCE_SHADER_FILE = "shader/diffuse_irradiance.cs.hlsl.spv";
|
||||||
constexpr cstr PREFILTER_SHADER_FILE = "shader/prefilter.cs.hlsl.spv";
|
constexpr auto PREFILTER_SHADER_FILE = "shader/prefilter.cs.hlsl.spv";
|
||||||
constexpr cstr BRDF_LUT_SHADER_FILE = "shader/brdf_lut.cs.hlsl.spv";
|
constexpr auto BRDF_LUT_SHADER_FILE = "shader/brdf_lut.cs.hlsl.spv";
|
||||||
|
|
||||||
Environment
|
Environment
|
||||||
CreateCubeFromHdrEnv(AssetLoader *assetLoader, vk::Queue computeQueue, const u32 cubeSide,
|
CreateCubeFromHdrEnv(AssetLoader *assetLoader, vk::Queue computeQueue, const u32 cubeSide,
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: ibl_helpers.h
|
// Aster: ibl_helpers.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "aster/aster.h"
|
#include "aster/aster.h"
|
||||||
#include "aster/systems/resource.h"
|
|
||||||
#include "aster/core/image.h"
|
#include "aster/core/image.h"
|
||||||
#include "aster/core/image_view.h"
|
#include "aster/core/image_view.h"
|
||||||
|
#include "aster/systems/resource.h"
|
||||||
|
|
||||||
struct Pipeline;
|
struct Pipeline;
|
||||||
struct Texture;
|
struct Texture;
|
||||||
|
|
@ -23,5 +23,5 @@ struct Environment
|
||||||
systems::ResId<TextureView> m_BrdfLut;
|
systems::ResId<TextureView> m_BrdfLut;
|
||||||
};
|
};
|
||||||
|
|
||||||
Environment CreateCubeFromHdrEnv(AssetLoader *assetLoader, vk::Queue computeQueue, u32 cubeSide, systems::ResId<TextureView> hdrEnv,
|
Environment CreateCubeFromHdrEnv(AssetLoader *assetLoader, vk::Queue computeQueue, u32 cubeSide,
|
||||||
cstr name = nullptr);
|
systems::ResId<TextureView> hdrEnv, cstr name = nullptr);
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: light_manager.cpp
|
// Aster: light_manager.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "light_manager.h"
|
#include "light_manager.h"
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
|
#include "aster/systems/commit_manager.h"
|
||||||
#include "aster/systems/resource.h"
|
#include "aster/systems/resource.h"
|
||||||
#include "aster/systems/resource_manager.h"
|
#include "aster/systems/resource_manager.h"
|
||||||
#include "aster/systems/commit_manager.h"
|
|
||||||
#include "glm/ext/matrix_transform.hpp"
|
#include "glm/ext/matrix_transform.hpp"
|
||||||
|
|
||||||
// Static Checks
|
// Static Checks
|
||||||
|
|
@ -60,7 +60,7 @@ LightManager::LightManager(systems::ResourceManager *resourceManager, systems::C
|
||||||
, m_CommitManager{commitManager}
|
, m_CommitManager{commitManager}
|
||||||
, m_DirectionalLightCount{}
|
, m_DirectionalLightCount{}
|
||||||
, m_PointLightCount{}
|
, m_PointLightCount{}
|
||||||
, m_MetaInfo{.m_LightBuffer = systems::ResId<Buffer>::Null() }
|
, m_MetaInfo{.m_LightBuffer = systems::NullId()}
|
||||||
, m_GpuBufferCapacity_{0}
|
, m_GpuBufferCapacity_{0}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +210,8 @@ LightManager::Update()
|
||||||
const u16 requiredBufferCapacity = eastl::min(Cast<u16>(m_Lights.capacity()), MAX_LIGHTS);
|
const u16 requiredBufferCapacity = eastl::min(Cast<u16>(m_Lights.capacity()), MAX_LIGHTS);
|
||||||
if ((m_GpuBufferCapacity_ & CAPACITY_MASK) < requiredBufferCapacity)
|
if ((m_GpuBufferCapacity_ & CAPACITY_MASK) < requiredBufferCapacity)
|
||||||
{
|
{
|
||||||
auto newBuffer = m_ResourceManager->Buffers().CreateStorageBuffer(requiredBufferCapacity * sizeof m_Lights[0], "Light Buffer");
|
auto newBuffer = m_ResourceManager->Buffers().CreateStorageBuffer(requiredBufferCapacity * sizeof m_Lights[0],
|
||||||
|
"Light Buffer");
|
||||||
m_GpuBufferCapacity_ = requiredBufferCapacity | UPDATE_REQUIRED_BIT;
|
m_GpuBufferCapacity_ = requiredBufferCapacity | UPDATE_REQUIRED_BIT;
|
||||||
|
|
||||||
m_MetaInfo.m_LightBuffer = m_CommitManager->CommitBuffer(newBuffer);
|
m_MetaInfo.m_LightBuffer = m_CommitManager->CommitBuffer(newBuffer);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: light_manager.h
|
// Aster: light_manager.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
#include "aster/aster.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
// TODO: Separate files so you only import handles.
|
// TODO: Separate files so you only import handles.
|
||||||
#include "aster/systems/resource.h"
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
|
#include "aster/systems/resource.h"
|
||||||
|
|
||||||
#include <EASTL/vector.h>
|
#include <EASTL/vector.h>
|
||||||
|
|
||||||
|
|
@ -48,6 +48,7 @@ struct Light
|
||||||
vec3 um_Position;
|
vec3 um_Position;
|
||||||
vec3 um_Direction;
|
vec3 um_Direction;
|
||||||
};
|
};
|
||||||
|
|
||||||
f32 m_Range; // < 0.0 for invalid
|
f32 m_Range; // < 0.0 for invalid
|
||||||
u32 m_Color_; // LSB is used for flags. (R G B Flags)
|
u32 m_Color_; // LSB is used for flags. (R G B Flags)
|
||||||
f32 m_Intensity;
|
f32 m_Intensity;
|
||||||
|
|
@ -67,6 +68,7 @@ struct Light
|
||||||
struct LightManager
|
struct LightManager
|
||||||
{
|
{
|
||||||
constexpr static u16 MAX_LIGHTS = MaxValue<u16>;
|
constexpr static u16 MAX_LIGHTS = MaxValue<u16>;
|
||||||
|
|
||||||
struct LightMetaInfo
|
struct LightMetaInfo
|
||||||
{
|
{
|
||||||
// The number of directional lights is relatively low (1 - 2) and will almost never change in a scene.
|
// The number of directional lights is relatively low (1 - 2) and will almost never change in a scene.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: model_render.cpp
|
// Aster: model_render.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "aster/aster.h"
|
#include "aster/aster.h"
|
||||||
|
|
@ -57,7 +57,7 @@ struct Camera
|
||||||
|
|
||||||
struct CameraController
|
struct CameraController
|
||||||
{
|
{
|
||||||
constexpr static vec3 UP = vec3(0.0f, 1.0f, 0.0f);
|
constexpr static auto UP = vec3(0.0f, 1.0f, 0.0f);
|
||||||
|
|
||||||
f32 m_Fov;
|
f32 m_Fov;
|
||||||
f32 m_Pitch;
|
f32 m_Pitch;
|
||||||
|
|
@ -98,7 +98,7 @@ struct CameraController
|
||||||
m_Camera.m_Position = vec4(position, 1.0f);
|
m_Camera.m_Position = vec4(position, 1.0f);
|
||||||
|
|
||||||
f32 cosPitch = cos(m_Pitch);
|
f32 cosPitch = cos(m_Pitch);
|
||||||
const vec3 target = vec3(sin(m_Yaw) * cosPitch, sin(m_Pitch), -cos(m_Yaw) * cosPitch);
|
const auto target = vec3(sin(m_Yaw) * cosPitch, sin(m_Pitch), -cos(m_Yaw) * cosPitch);
|
||||||
m_Camera.m_View = lookAt(position, position + target, UP);
|
m_Camera.m_View = lookAt(position, position + target, UP);
|
||||||
|
|
||||||
m_Camera.CalculateInverses();
|
m_Camera.CalculateInverses();
|
||||||
|
|
@ -111,7 +111,7 @@ struct CameraController
|
||||||
m_Yaw = yaw;
|
m_Yaw = yaw;
|
||||||
|
|
||||||
f32 cosPitch = cos(m_Pitch);
|
f32 cosPitch = cos(m_Pitch);
|
||||||
const vec3 target = vec3(sin(m_Yaw) * cosPitch, sin(m_Pitch), -cos(m_Yaw) * cosPitch);
|
const auto target = vec3(sin(m_Yaw) * cosPitch, sin(m_Pitch), -cos(m_Yaw) * cosPitch);
|
||||||
const vec3 position = m_Camera.m_Position;
|
const vec3 position = m_Camera.m_Position;
|
||||||
m_Camera.m_View = lookAt(position, position + target, UP);
|
m_Camera.m_View = lookAt(position, position + target, UP);
|
||||||
|
|
||||||
|
|
@ -179,11 +179,12 @@ main(int, char **)
|
||||||
Swapchain swapchain = {&surface, &device, window.GetSize(), "Primary Chain"};
|
Swapchain swapchain = {&surface, &device, window.GetSize(), "Primary Chain"};
|
||||||
|
|
||||||
systems::ResourceManager resourceManager = {&device, 1000, 1000, 10, 1000};
|
systems::ResourceManager resourceManager = {&device, 1000, 1000, 10, 1000};
|
||||||
systems::CommitManager commitManager = {&device, 1000, 1000, 1000, resourceManager.Samplers().CreateSampler({.m_Name = "Default Sampler"})};
|
systems::CommitManager commitManager = {&device, 1000, 1000, 1000,
|
||||||
|
resourceManager.Samplers().CreateSampler({.m_Name = "Default Sampler"})};
|
||||||
|
|
||||||
AssetLoader assetLoader = {&resourceManager, &commitManager, graphicsQueue, queueAllocation.m_Family,
|
AssetLoader assetLoader = {&resourceManager, &commitManager, graphicsQueue, queueAllocation.m_Family,
|
||||||
queueAllocation.m_Family};
|
queueAllocation.m_Family};
|
||||||
LightManager lightManager = LightManager{&resourceManager, &commitManager};
|
auto lightManager = LightManager{&resourceManager, &commitManager};
|
||||||
|
|
||||||
Model model = assetLoader.LoadModelToGpu(MODEL_FILE);
|
Model model = assetLoader.LoadModelToGpu(MODEL_FILE);
|
||||||
auto environmentHdri = assetLoader.LoadHdrImage(BACKDROP_FILE);
|
auto environmentHdri = assetLoader.LoadHdrImage(BACKDROP_FILE);
|
||||||
|
|
@ -191,7 +192,7 @@ main(int, char **)
|
||||||
|
|
||||||
auto environment = CreateCubeFromHdrEnv(&assetLoader, graphicsQueue, 512, envHdriHandle, "Cube Env");
|
auto environment = CreateCubeFromHdrEnv(&assetLoader, graphicsQueue, 512, envHdriHandle, "Cube Env");
|
||||||
|
|
||||||
vk::Format attachmentFormat = vk::Format::eR8G8B8A8Srgb;
|
auto attachmentFormat = vk::Format::eR8G8B8A8Srgb;
|
||||||
|
|
||||||
Pipeline pipeline = CreatePipeline(&device, attachmentFormat, &commitManager);
|
Pipeline pipeline = CreatePipeline(&device, attachmentFormat, &commitManager);
|
||||||
Pipeline backGroundPipeline = CreateBackgroundPipeline(&device, attachmentFormat, &commitManager);
|
Pipeline backGroundPipeline = CreateBackgroundPipeline(&device, attachmentFormat, &commitManager);
|
||||||
|
|
@ -238,7 +239,7 @@ main(int, char **)
|
||||||
usize lightingSize = sizeof environment + sizeof lightManager.m_MetaInfo;
|
usize lightingSize = sizeof environment + sizeof lightManager.m_MetaInfo;
|
||||||
uboSize += ClosestMultiple(lightingSize, physicalDeviceOffsetAlignment);
|
uboSize += ClosestMultiple(lightingSize, physicalDeviceOffsetAlignment);
|
||||||
|
|
||||||
u8 *data = new u8[uboSize];
|
auto data = new u8[uboSize];
|
||||||
memcpy(data, &cameraController.m_Camera, cameraSize);
|
memcpy(data, &cameraController.m_Camera, cameraSize);
|
||||||
memcpy(data + lightOffset, &environment, sizeof environment);
|
memcpy(data + lightOffset, &environment, sizeof environment);
|
||||||
memcpy(data + lightOffset + sizeof environment, &lightManager.m_MetaInfo, sizeof lightManager.m_MetaInfo);
|
memcpy(data + lightOffset + sizeof environment, &lightManager.m_MetaInfo, sizeof lightManager.m_MetaInfo);
|
||||||
|
|
@ -351,15 +352,15 @@ main(int, char **)
|
||||||
};
|
};
|
||||||
|
|
||||||
vk::ImageMemoryBarrier2 transferDstToGuiRenderBarrier = {
|
vk::ImageMemoryBarrier2 transferDstToGuiRenderBarrier = {
|
||||||
.srcStageMask = vk::PipelineStageFlagBits2::eTransfer,
|
.srcStageMask = vk::PipelineStageFlagBits2::eTransfer,
|
||||||
.srcAccessMask = vk::AccessFlagBits2::eTransferWrite | vk::AccessFlagBits2::eTransferRead,
|
.srcAccessMask = vk::AccessFlagBits2::eTransferWrite | vk::AccessFlagBits2::eTransferRead,
|
||||||
.dstStageMask = vk::PipelineStageFlagBits2::eColorAttachmentOutput,
|
.dstStageMask = vk::PipelineStageFlagBits2::eColorAttachmentOutput,
|
||||||
.dstAccessMask = vk::AccessFlagBits2::eColorAttachmentRead,
|
.dstAccessMask = vk::AccessFlagBits2::eColorAttachmentRead,
|
||||||
.oldLayout = vk::ImageLayout::eTransferDstOptimal,
|
.oldLayout = vk::ImageLayout::eTransferDstOptimal,
|
||||||
.newLayout = vk::ImageLayout::eColorAttachmentOptimal,
|
.newLayout = vk::ImageLayout::eColorAttachmentOptimal,
|
||||||
.srcQueueFamilyIndex = vk::QueueFamilyIgnored,
|
.srcQueueFamilyIndex = vk::QueueFamilyIgnored,
|
||||||
.dstQueueFamilyIndex = vk::QueueFamilyIgnored,
|
.dstQueueFamilyIndex = vk::QueueFamilyIgnored,
|
||||||
.subresourceRange = subresourceRange,
|
.subresourceRange = subresourceRange,
|
||||||
};
|
};
|
||||||
vk::DependencyInfo preGuiDependencies = {
|
vk::DependencyInfo preGuiDependencies = {
|
||||||
.imageMemoryBarrierCount = 1,
|
.imageMemoryBarrierCount = 1,
|
||||||
|
|
@ -432,6 +433,8 @@ main(int, char **)
|
||||||
while (window.Poll())
|
while (window.Poll())
|
||||||
{
|
{
|
||||||
Time::Update();
|
Time::Update();
|
||||||
|
commitManager.Update();
|
||||||
|
resourceManager.Update();
|
||||||
|
|
||||||
gui::StartBuild();
|
gui::StartBuild();
|
||||||
|
|
||||||
|
|
@ -707,4 +710,4 @@ main(int, char **)
|
||||||
device.m_Device.destroy(descriptorPool, nullptr);
|
device.m_Device.destroy(descriptorPool, nullptr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: nodes.cpp
|
// Aster: nodes.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: nodes.h
|
// Aster: nodes.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -41,16 +41,16 @@ struct Nodes
|
||||||
constexpr static u32 DIRTY_BIT = 1u << 30;
|
constexpr static u32 DIRTY_BIT = 1u << 30;
|
||||||
constexpr static u32 PARENT_MASK = ~(ROOT_BIT | DIRTY_BIT);
|
constexpr static u32 PARENT_MASK = ~(ROOT_BIT | DIRTY_BIT);
|
||||||
|
|
||||||
u32 Add(const mat4 &transform, const i32 parent = -1);
|
u32 Add(const mat4 &transform, i32 parent = -1);
|
||||||
[[nodiscard]] const mat4 &Get(const u32 index) const;
|
[[nodiscard]] const mat4 &Get(u32 index) const;
|
||||||
void Set(const u32 index, const mat4 &transform);
|
void Set(u32 index, const mat4 &transform);
|
||||||
[[nodiscard]] u32 Count() const;
|
[[nodiscard]] u32 Count() const;
|
||||||
|
|
||||||
[[nodiscard]] const mat4 &operator[](const u32 index) const;
|
[[nodiscard]] const mat4 &operator[](u32 index) const;
|
||||||
[[nodiscard]] mat4 &operator[](const u32 index);
|
[[nodiscard]] mat4 &operator[](u32 index);
|
||||||
|
|
||||||
[[nodiscard]] usize GetGlobalTransformByteSize() const;
|
[[nodiscard]] usize GetGlobalTransformByteSize() const;
|
||||||
[[nodiscard]] const Transform *GetGlobalTransformPtr() const;
|
[[nodiscard]] const Transform *GetGlobalTransformPtr() const;
|
||||||
|
|
||||||
bool Update();
|
bool Update();
|
||||||
};
|
};
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: pipeline_utils.cpp
|
// Aster: pipeline_utils.cpp
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "pipeline_utils.h"
|
#include "pipeline_utils.h"
|
||||||
|
|
@ -350,4 +350,4 @@ CreateShader(const Device *device, cstr shaderFile)
|
||||||
AbortIfFailedMV(device->m_Device.createShaderModule(&shaderModuleCreateInfo, nullptr, &shaderModule),
|
AbortIfFailedMV(device->m_Device.createShaderModule(&shaderModuleCreateInfo, nullptr, &shaderModule),
|
||||||
"Shader {} could not be created.", shaderFile);
|
"Shader {} could not be created.", shaderFile);
|
||||||
return shaderModule;
|
return shaderModule;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// =============================================
|
// =============================================
|
||||||
// Aster: pipeline_utils.h
|
// Aster: pipeline_utils.h
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
@ -24,6 +24,7 @@ constexpr auto BACKGROUND_VERTEX_SHADER_FILE = "shader/background.vs.hlsl.spv";
|
||||||
constexpr auto BACKGROUND_FRAGMENT_SHADER_FILE = "shader/background.ps.hlsl.spv";
|
constexpr auto BACKGROUND_FRAGMENT_SHADER_FILE = "shader/background.ps.hlsl.spv";
|
||||||
|
|
||||||
vk::ShaderModule CreateShader(const Device *device, cstr shaderFile);
|
vk::ShaderModule CreateShader(const Device *device, cstr shaderFile);
|
||||||
Pipeline CreatePipeline(const Device *device, vk::Format attachmentFormat, const systems::CommitManager *resourceManager);
|
|
||||||
Pipeline
|
Pipeline
|
||||||
CreateBackgroundPipeline(const Device *device, vk::Format attachmentFormat, const systems::CommitManager *resourceManager);
|
CreatePipeline(const Device *device, vk::Format attachmentFormat, const systems::CommitManager *resourceManager);
|
||||||
|
Pipeline CreateBackgroundPipeline(const Device *device, vk::Format attachmentFormat,
|
||||||
|
const systems::CommitManager *resourceManager);
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
|
// =============================================
|
||||||
|
// Aster: tiny_gltf_setup.cpp
|
||||||
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
|
// =============================================
|
||||||
|
|
||||||
#define TINYGLTF_NOEXCEPTION
|
#define TINYGLTF_NOEXCEPTION
|
||||||
#define JSON_NOEXCEPTION
|
#define JSON_NOEXCEPTION
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue