Rename systems::Device to RenderingDevice to avoid ambiguity.

This commit is contained in:
Anish Bhobe 2025-05-31 21:42:14 +02:00
parent 4cdb39c6ba
commit 19e3222460
22 changed files with 115 additions and 114 deletions

View File

@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13)
target_sources(aster_core target_sources(aster_core
INTERFACE INTERFACE
"device.h" "rendering_device.h"
"resource.h" "resource.h"
"context.h" "context.h"
"commit_manager.h") "commit_manager.h")

View File

@ -20,7 +20,7 @@
namespace systems namespace systems
{ {
class Device; class RenderingDevice;
class CommitManager class CommitManager
{ {
@ -212,9 +212,9 @@ class CommitManager
// using WriteOwner = std::variant<Handle<Buffer>, Handle<Image>>; // using WriteOwner = std::variant<Handle<Buffer>, Handle<Image>>;
public: public:
Device const *m_Device; RenderingDevice const *m_Device;
CommitManager(Device const *device, u32 maxBuffers, u32 maxImages, u32 maxStorageImages, CommitManager(RenderingDevice const *device, u32 maxBuffers, u32 maxImages, u32 maxStorageImages,
Ref<Sampler> defaultSampler); Ref<Sampler> defaultSampler);
~CommitManager(); ~CommitManager();

View File

@ -26,7 +26,7 @@
namespace systems namespace systems
{ {
class Device; class RenderingDevice;
struct Frame; struct Frame;
namespace _internal namespace _internal
@ -45,7 +45,7 @@ class Context
_internal::ContextPool *m_Pool; _internal::ContextPool *m_Pool;
vk::CommandBuffer m_Cmd; vk::CommandBuffer m_Cmd;
friend Device; friend RenderingDevice;
friend _internal::ContextPool; friend _internal::ContextPool;
explicit Context(_internal::ContextPool &pool, vk::CommandBuffer const cmd) explicit Context(_internal::ContextPool &pool, vk::CommandBuffer const cmd)
@ -87,7 +87,7 @@ Context::EndDebugRegion()
class TransferContext : public Context class TransferContext : public Context
{ {
protected: protected:
friend Device; friend RenderingDevice;
friend _internal::TransferContextPool; friend _internal::TransferContextPool;
explicit TransferContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd) explicit TransferContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd)
@ -120,7 +120,7 @@ class TransferContext : public Context
class ComputeContext : public TransferContext class ComputeContext : public TransferContext
{ {
protected: protected:
friend Device; friend RenderingDevice;
friend _internal::ComputeContextPool; friend _internal::ComputeContextPool;
Pipeline const *m_PipelineInUse; Pipeline const *m_PipelineInUse;
@ -167,7 +167,7 @@ class ComputeContext : public TransferContext
class GraphicsContext : public ComputeContext class GraphicsContext : public ComputeContext
{ {
protected: protected:
friend Device; friend RenderingDevice;
friend _internal::GraphicsContextPool; friend _internal::GraphicsContextPool;
explicit GraphicsContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd) explicit GraphicsContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd)
@ -199,7 +199,7 @@ namespace _internal
class ContextPool class ContextPool
{ {
protected: protected:
Device *m_Device; RenderingDevice *m_Device;
vk::CommandPool m_Pool; vk::CommandPool m_Pool;
eastl::vector<vk::CommandBuffer> m_CommandBuffers; eastl::vector<vk::CommandBuffer> m_CommandBuffers;
u32 m_BuffersAllocated; u32 m_BuffersAllocated;
@ -221,7 +221,7 @@ class ContextPool
vk::CommandBuffer AllocateCommandBuffer(); vk::CommandBuffer AllocateCommandBuffer();
public: public:
[[nodiscard]] Device & [[nodiscard]] RenderingDevice &
GetDevice() const GetDevice() const
{ {
assert(m_Device); assert(m_Device);
@ -242,7 +242,7 @@ class ContextPool
void Reset(); void Reset();
ContextPool() = default; ContextPool() = default;
ContextPool(Device &device, u32 queueFamilyIndex, ManagedBy managedBy); ContextPool(RenderingDevice &device, u32 queueFamilyIndex, ManagedBy managedBy);
ContextPool(ContextPool &&other) noexcept; ContextPool(ContextPool &&other) noexcept;
ContextPool &operator=(ContextPool &&other) noexcept; ContextPool &operator=(ContextPool &&other) noexcept;
@ -265,7 +265,7 @@ class TransferContextPool : public ContextPool
TransferContextPool() = default; TransferContextPool() = default;
TransferContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) TransferContextPool(RenderingDevice &device, u32 const queueFamilyIndex, ManagedBy const managedBy)
: ContextPool{device, queueFamilyIndex, managedBy} : ContextPool{device, queueFamilyIndex, managedBy}
{ {
} }
@ -285,7 +285,7 @@ class ComputeContextPool : public TransferContextPool
ComputeContextPool() = default; ComputeContextPool() = default;
ComputeContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) ComputeContextPool(RenderingDevice &device, u32 const queueFamilyIndex, ManagedBy const managedBy)
: TransferContextPool{device, queueFamilyIndex, managedBy} : TransferContextPool{device, queueFamilyIndex, managedBy}
{ {
} }
@ -305,7 +305,7 @@ class GraphicsContextPool : public ComputeContextPool
GraphicsContextPool() = default; GraphicsContextPool() = default;
GraphicsContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) GraphicsContextPool(RenderingDevice &device, u32 const queueFamilyIndex, ManagedBy const managedBy)
: ComputeContextPool{device, queueFamilyIndex, managedBy} : ComputeContextPool{device, queueFamilyIndex, managedBy}
{ {
} }
@ -336,7 +336,7 @@ class OrderlessContextPool
using ContextListType = eastl::intrusive_list<ContextListEntry>; using ContextListType = eastl::intrusive_list<ContextListEntry>;
Device *m_Device; RenderingDevice *m_Device;
memory::memory_pool<> m_ContextPoolEntryMemory; memory::memory_pool<> m_ContextPoolEntryMemory;
ContextListType m_FreeContextPools; ContextListType m_FreeContextPools;
ContextListType m_UsedContextPools; ContextListType m_UsedContextPools;
@ -355,7 +355,7 @@ class OrderlessContextPool
} }
void void
Init(Device &device, u32 const queueFamilyIndex) Init(RenderingDevice &device, u32 const queueFamilyIndex)
{ {
m_Device = &device; m_Device = &device;
m_QueueFamilyIndex = queueFamilyIndex; m_QueueFamilyIndex = queueFamilyIndex;

View File

@ -13,7 +13,7 @@
namespace systems namespace systems
{ {
class Device; class RenderingDevice;
struct PipelineCreationError struct PipelineCreationError
{ {
@ -35,12 +35,12 @@ namespace _internal
{ {
struct PipelineLayoutBuilder struct PipelineLayoutBuilder
{ {
Device *m_Device; RenderingDevice *m_Device;
eastl::vector<vk::DescriptorSetLayout> m_DescriptorSetLayouts; eastl::vector<vk::DescriptorSetLayout> m_DescriptorSetLayouts;
eastl::vector<vk::PushConstantRange> m_PushConstants; eastl::vector<vk::PushConstantRange> m_PushConstants;
vk::ShaderStageFlags m_Stage; vk::ShaderStageFlags m_Stage;
explicit PipelineLayoutBuilder(Device *device, vk::DescriptorSetLayout bindlessLayout = {}); explicit PipelineLayoutBuilder(RenderingDevice *device, vk::DescriptorSetLayout bindlessLayout = {});
[[nodiscard]] vk::PipelineLayout Build(); [[nodiscard]] vk::PipelineLayout Build();

View File

@ -1,5 +1,5 @@
// ============================================= // =============================================
// Aster: device.h // Aster: rendering_device.h
// Copyright (c) 2020-2025 Anish Bhobe // Copyright (c) 2020-2025 Anish Bhobe
// ============================================= // =============================================
@ -323,7 +323,7 @@ struct GraphicsPipelineCreateInfo
cstr m_Name; cstr m_Name;
private: private:
friend Device; friend RenderingDevice;
[[nodiscard]] vk::PipelineDepthStencilStateCreateInfo GetDepthStencilStateCreateInfo() const; [[nodiscard]] vk::PipelineDepthStencilStateCreateInfo GetDepthStencilStateCreateInfo() const;
}; };
@ -381,7 +381,7 @@ class Receipt
struct Frame struct Frame
{ {
// Persistent // Persistent
Device *m_Device; RenderingDevice *m_Device;
// TODO: ThreadSafe // TODO: ThreadSafe
_internal::GraphicsContextPool m_PrimaryPool; _internal::GraphicsContextPool m_PrimaryPool;
@ -406,7 +406,8 @@ struct Frame
void WaitUntilReady(); void WaitUntilReady();
Frame() = default; Frame() = default;
Frame(Device &device, u32 frameIndex, u32 primaryQueueFamily, u32 asyncTransferQueue, u32 asyncComputeQueue); Frame(RenderingDevice &device, u32 frameIndex, u32 primaryQueueFamily, u32 asyncTransferQueue,
u32 asyncComputeQueue);
Frame(Frame &&other) noexcept; Frame(Frame &&other) noexcept;
Frame &operator=(Frame &&other) noexcept; Frame &operator=(Frame &&other) noexcept;
@ -418,13 +419,13 @@ struct Frame
class CommitManager; class CommitManager;
class Device final class RenderingDevice final
{ {
public: // TODO: Temp public: // TODO: Temp
std::reference_wrapper<Window> m_Window; std::reference_wrapper<Window> m_Window;
Instance m_Instance; Instance m_Instance;
Surface m_Surface; Surface m_Surface;
::Device m_Device; Device m_Device;
Swapchain m_Swapchain; Swapchain m_Swapchain;
std::unique_ptr<CommitManager> m_CommitManager; std::unique_ptr<CommitManager> m_CommitManager;
@ -590,7 +591,7 @@ class Device final
void WaitOn(Receipt recpt); void WaitOn(Receipt recpt);
// //
// Device Methods // RenderingDevice Methods
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------
template <concepts::VkHandle T> template <concepts::VkHandle T>
@ -621,7 +622,7 @@ class Device final
// Inner // Inner
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------
[[nodiscard]] ::Device & [[nodiscard]] Device &
GetInner() GetInner()
{ {
return m_Device; return m_Device;
@ -635,11 +636,11 @@ class Device final
// Ctor/Dtor // Ctor/Dtor
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------
explicit Device(DeviceCreateInfo const &createInfo); explicit RenderingDevice(DeviceCreateInfo const &createInfo);
~Device(); ~RenderingDevice();
PIN_MEMORY(Device); PIN_MEMORY(RenderingDevice);
}; };
} // namespace systems } // namespace systems

View File

@ -12,7 +12,7 @@
namespace systems namespace systems
{ {
class Receipt; class Receipt;
class Device; class RenderingDevice;
} // namespace systems } // namespace systems
namespace systems::_internal namespace systems::_internal
@ -31,9 +31,9 @@ class SyncServer
TimelinePoint m_CurrentPoint; TimelinePoint m_CurrentPoint;
ContextPool *m_AttachedPool; ContextPool *m_AttachedPool;
explicit Entry(Device &device); explicit Entry(RenderingDevice &device);
void Destroy(Device &device); void Destroy(RenderingDevice &device);
void Wait(Device &device); void Wait(RenderingDevice &device);
void Next(); void Next();
void AttachPool(ContextPool *pool); void AttachPool(ContextPool *pool);
@ -45,7 +45,7 @@ class SyncServer
DISALLOW_COPY_AND_ASSIGN(Entry); DISALLOW_COPY_AND_ASSIGN(Entry);
}; };
Device *m_Device; RenderingDevice *m_Device;
eastl::deque<Entry> m_Allocations; eastl::deque<Entry> m_Allocations;
eastl::intrusive_list<Entry> m_FreeList; eastl::intrusive_list<Entry> m_FreeList;
@ -63,7 +63,7 @@ class SyncServer
void FreeEntry(Entry &entry); void FreeEntry(Entry &entry);
// Constructor/Destructor // Constructor/Destructor
explicit SyncServer(Device &device); explicit SyncServer(RenderingDevice &device);
public: public:
~SyncServer(); ~SyncServer();
@ -72,7 +72,7 @@ class SyncServer
SyncServer(SyncServer &&other) noexcept; SyncServer(SyncServer &&other) noexcept;
SyncServer &operator=(SyncServer &&other) noexcept; SyncServer &operator=(SyncServer &&other) noexcept;
friend Device; friend RenderingDevice;
DISALLOW_COPY_AND_ASSIGN(SyncServer); DISALLOW_COPY_AND_ASSIGN(SyncServer);
}; };

View File

@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13)
target_sources(aster_core target_sources(aster_core
PRIVATE PRIVATE
"device.cpp" "rendering_device.cpp"
"commit_manager.cpp" "commit_manager.cpp"
"pipeline_helpers.cpp" "pipeline_helpers.cpp"
"context.cpp" "context.cpp"

View File

@ -8,13 +8,13 @@
#include "EASTL/array.h" #include "EASTL/array.h"
#include "core/device.h" #include "core/device.h"
#include "core/image_view.h" #include "core/image_view.h"
#include "systems/device.h" #include "systems/rendering_device.h"
using namespace systems; using namespace systems;
CommitManager *CommitManager::m_Instance = nullptr; CommitManager *CommitManager::m_Instance = nullptr;
CommitManager::CommitManager(Device const *device, u32 const maxBuffers, u32 const maxImages, CommitManager::CommitManager(RenderingDevice const *device, u32 const maxBuffers, u32 const maxImages,
u32 const maxStorageImages, Ref<Sampler> defaultSampler) u32 const maxStorageImages, Ref<Sampler> defaultSampler)
: m_Device{device} : m_Device{device}
, m_Buffers{maxBuffers} , m_Buffers{maxBuffers}

View File

@ -6,7 +6,7 @@
#include "aster/systems/context.h" #include "aster/systems/context.h"
#include "aster/systems/commit_manager.h" #include "aster/systems/commit_manager.h"
#include "systems/device.h" #include "aster/systems/rendering_device.h"
constexpr static u32 constexpr static u32
GetFormatSize(vk::Format const format) GetFormatSize(vk::Format const format)
@ -373,7 +373,7 @@ systems::ComputeContext::PushConstantBlock(usize const offset, usize const size,
using namespace systems::_internal; using namespace systems::_internal;
ContextPool::ContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) ContextPool::ContextPool(RenderingDevice &device, u32 const queueFamilyIndex, ManagedBy const managedBy)
: m_Device{&device} : m_Device{&device}
, m_BuffersAllocated{0} , m_BuffersAllocated{0}
, m_ExtraData{0} , m_ExtraData{0}

View File

@ -3,7 +3,7 @@
// Copyright (c) 2020-2025 Anish Bhobe // Copyright (c) 2020-2025 Anish Bhobe
// ============================================= // =============================================
#include "systems/device.h" #include "systems/rendering_device.h"
#include <aster/systems/pipeline_helpers.h> #include <aster/systems/pipeline_helpers.h>
@ -121,7 +121,7 @@ systems::SlangToVulkanShaderStage(SlangStage const stage)
return {}; return {};
} }
PipelineLayoutBuilder::PipelineLayoutBuilder(Device *device, vk::DescriptorSetLayout bindlessLayout) PipelineLayoutBuilder::PipelineLayoutBuilder(RenderingDevice *device, vk::DescriptorSetLayout bindlessLayout)
: m_Device{device} : m_Device{device}
, m_DescriptorSetLayouts{bindlessLayout} // if `null` will be filtered out during build. , m_DescriptorSetLayouts{bindlessLayout} // if `null` will be filtered out during build.
{ {

View File

@ -1,9 +1,9 @@
// ============================================= // =============================================
// Aster: device.cpp // Aster: rendering_device.cpp
// Copyright (c) 2020-2025 Anish Bhobe // Copyright (c) 2020-2025 Anish Bhobe
// ============================================= // =============================================
#include "systems/device.h" #include "systems/rendering_device.h"
#include "core/queue_allocation.h" #include "core/queue_allocation.h"
#include "core/window.h" #include "core/window.h"
@ -107,7 +107,7 @@ systems::DefaultPhysicalDeviceSelector(PhysicalDevices const &physicalDevices)
// ==================================================================================================== // ====================================================================================================
Ref<StorageBuffer> Ref<StorageBuffer>
systems::Device::CreateStorageBuffer(usize const size, cstr const name) systems::RenderingDevice::CreateStorageBuffer(usize const size, cstr const name)
{ {
// TODO: Storage and Index buffer are set. // TODO: Storage and Index buffer are set.
// This is hacky and should be improved. // This is hacky and should be improved.
@ -122,7 +122,7 @@ systems::Device::CreateStorageBuffer(usize const size, cstr const name)
} }
Ref<IndexBuffer> Ref<IndexBuffer>
systems::Device::CreateIndexBuffer(usize size, cstr name) systems::RenderingDevice::CreateIndexBuffer(usize size, cstr name)
{ {
// TODO: Storage and Index buffer are set. // TODO: Storage and Index buffer are set.
// This is hacky and should be improved. // This is hacky and should be improved.
@ -137,7 +137,7 @@ systems::Device::CreateIndexBuffer(usize size, cstr name)
} }
Ref<UniformBuffer> Ref<UniformBuffer>
systems::Device::CreateUniformBuffer(usize const size, cstr const name) systems::RenderingDevice::CreateUniformBuffer(usize const size, cstr const name)
{ {
constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eUniformBuffer; constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eUniformBuffer;
constexpr VmaAllocationCreateFlags createFlags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | constexpr VmaAllocationCreateFlags createFlags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT |
@ -148,7 +148,7 @@ systems::Device::CreateUniformBuffer(usize const size, cstr const name)
} }
Ref<StagingBuffer> Ref<StagingBuffer>
systems::Device::CreateStagingBuffer(usize const size, cstr const name) systems::RenderingDevice::CreateStagingBuffer(usize const size, cstr const name)
{ {
constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eTransferSrc; constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eTransferSrc;
constexpr VmaAllocationCreateFlags createFlags = constexpr VmaAllocationCreateFlags createFlags =
@ -158,7 +158,7 @@ systems::Device::CreateStagingBuffer(usize const size, cstr const name)
} }
Ref<VertexBuffer> Ref<VertexBuffer>
systems::Device::CreateVertexBuffer(usize const size, cstr const name) systems::RenderingDevice::CreateVertexBuffer(usize const size, cstr const name)
{ {
constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eVertexBuffer; constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eVertexBuffer;
constexpr VmaAllocationCreateFlags createFlags = constexpr VmaAllocationCreateFlags createFlags =
@ -189,7 +189,7 @@ constexpr vk::ImageUsageFlags DEPTH_STENCIL_ATTACHMENT = vk::ImageUsageFlagBits:
} // namespace usage_flags } // namespace usage_flags
Ref<Image> Ref<Image>
systems::Device::CreateTexture2D(Texture2DCreateInfo const &createInfo) systems::RenderingDevice::CreateTexture2D(Texture2DCreateInfo const &createInfo)
{ {
constexpr VmaAllocationCreateInfo allocationCreateInfo = { constexpr VmaAllocationCreateInfo allocationCreateInfo = {
.flags = {}, .flags = {},
@ -221,7 +221,7 @@ systems::Device::CreateTexture2D(Texture2DCreateInfo const &createInfo)
} }
Ref<ImageCube> Ref<ImageCube>
systems::Device::CreateTextureCube(TextureCubeCreateInfo const &createInfo) systems::RenderingDevice::CreateTextureCube(TextureCubeCreateInfo const &createInfo)
{ {
constexpr VmaAllocationCreateInfo allocationCreateInfo = { constexpr VmaAllocationCreateInfo allocationCreateInfo = {
.flags = {}, .flags = {},
@ -253,7 +253,7 @@ systems::Device::CreateTextureCube(TextureCubeCreateInfo const &createInfo)
} }
Ref<Image> Ref<Image>
systems::Device::CreateAttachment(AttachmentCreateInfo const &createInfo) systems::RenderingDevice::CreateAttachment(AttachmentCreateInfo const &createInfo)
{ {
constexpr VmaAllocationCreateInfo allocationCreateInfo = { constexpr VmaAllocationCreateInfo allocationCreateInfo = {
.flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
@ -280,7 +280,7 @@ systems::Device::CreateAttachment(AttachmentCreateInfo const &createInfo)
} }
Ref<Image> Ref<Image>
systems::Device::CreateDepthStencilImage(DepthStencilImageCreateInfo const &createInfo) systems::RenderingDevice::CreateDepthStencilImage(DepthStencilImageCreateInfo const &createInfo)
{ {
constexpr VmaAllocationCreateInfo allocationCreateInfo = { constexpr VmaAllocationCreateInfo allocationCreateInfo = {
.flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT,
@ -404,7 +404,7 @@ ToImageCreateInfo(systems::DepthStencilImageCreateInfo const &createInfo)
// ==================================================================================================== // ====================================================================================================
Ref<ImageView> Ref<ImageView>
systems::Device::CreateView(ViewCreateInfo<Image> const &createInfo) systems::RenderingDevice::CreateView(ViewCreateInfo<Image> const &createInfo)
{ {
auto const layerCount = createInfo.GetLayerCount(); auto const layerCount = createInfo.GetLayerCount();
auto const mipCount = createInfo.GetMipLevelCount(); auto const mipCount = createInfo.GetMipLevelCount();
@ -432,7 +432,7 @@ systems::Device::CreateView(ViewCreateInfo<Image> const &createInfo)
// ==================================================================================================== // ====================================================================================================
Ref<TextureView> Ref<TextureView>
systems::Device::CreateTexture2DWithView(Texture2DCreateInfo const &createInfo) systems::RenderingDevice::CreateTexture2DWithView(Texture2DCreateInfo const &createInfo)
{ {
return CreateView<TextureView>({ return CreateView<TextureView>({
.m_Image = CastImage<Texture>(CreateTexture2D(createInfo)), .m_Image = CastImage<Texture>(CreateTexture2D(createInfo)),
@ -443,7 +443,7 @@ systems::Device::CreateTexture2DWithView(Texture2DCreateInfo const &createInfo)
} }
Ref<ImageCubeView> Ref<ImageCubeView>
systems::Device::CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo) systems::RenderingDevice::CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo)
{ {
return CreateView<ImageCubeView>({ return CreateView<ImageCubeView>({
.m_Image = CreateTextureCube(createInfo), .m_Image = CreateTextureCube(createInfo),
@ -454,7 +454,7 @@ systems::Device::CreateTextureCubeWithView(TextureCubeCreateInfo const &createIn
} }
Ref<ImageView> Ref<ImageView>
systems::Device::CreateAttachmentWithView(AttachmentCreateInfo const &createInfo) systems::RenderingDevice::CreateAttachmentWithView(AttachmentCreateInfo const &createInfo)
{ {
return CreateView({ return CreateView({
.m_Image = CreateAttachment(createInfo), .m_Image = CreateAttachment(createInfo),
@ -465,7 +465,7 @@ systems::Device::CreateAttachmentWithView(AttachmentCreateInfo const &createInfo
} }
Ref<ImageView> Ref<ImageView>
systems::Device::CreateDepthStencilImageWithView(DepthStencilImageCreateInfo const &createInfo) systems::RenderingDevice::CreateDepthStencilImageWithView(DepthStencilImageCreateInfo const &createInfo)
{ {
return CreateView({ return CreateView({
.m_Image = CreateDepthStencilImage(createInfo), .m_Image = CreateDepthStencilImage(createInfo),
@ -482,7 +482,7 @@ systems::Device::CreateDepthStencilImageWithView(DepthStencilImageCreateInfo con
// ==================================================================================================== // ====================================================================================================
Ref<Sampler> Ref<Sampler>
systems::Device::CreateSampler(SamplerCreateInfo const &createInfo) systems::RenderingDevice::CreateSampler(SamplerCreateInfo const &createInfo)
{ {
auto vkCreateInfo = static_cast<vk::SamplerCreateInfo>(createInfo); auto vkCreateInfo = static_cast<vk::SamplerCreateInfo>(createInfo);
@ -502,7 +502,7 @@ systems::Device::CreateSampler(SamplerCreateInfo const &createInfo)
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreateGraphicsPipeline(Pipeline &pipelineOut, GraphicsPipelineCreateInfo const &createInfo) systems::RenderingDevice::CreateGraphicsPipeline(Pipeline &pipelineOut, GraphicsPipelineCreateInfo const &createInfo)
{ {
eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders; eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders;
Slang::ComPtr<slang::IComponentType> program; Slang::ComPtr<slang::IComponentType> program;
@ -641,7 +641,7 @@ systems::Device::CreateGraphicsPipeline(Pipeline &pipelineOut, GraphicsPipelineC
} }
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreateComputePipeline(Pipeline &pipelineOut, ComputePipelineCreateInfo const &createInfo) systems::RenderingDevice::CreateComputePipeline(Pipeline &pipelineOut, ComputePipelineCreateInfo const &createInfo)
{ {
eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders; eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> shaders;
Slang::ComPtr<slang::IComponentType> program; Slang::ComPtr<slang::IComponentType> program;
@ -699,7 +699,7 @@ systems::Device::CreateComputePipeline(Pipeline &pipelineOut, ComputePipelineCre
return SLANG_FAIL return SLANG_FAIL
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreateShaders( systems::RenderingDevice::CreateShaders(
eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> &shadersOut, eastl::fixed_vector<vk::PipelineShaderStageCreateInfo, ShaderTypeCount, false> &shadersOut,
Slang::ComPtr<slang::IComponentType> &program, std::span<ShaderInfo const> const &shaders) Slang::ComPtr<slang::IComponentType> &program, std::span<ShaderInfo const> const &shaders)
{ {
@ -870,11 +870,11 @@ systems::Device::CreateShaders(
struct PipelineLayoutBuilder struct PipelineLayoutBuilder
{ {
systems::Device *m_Device; systems::RenderingDevice *m_Device;
eastl::vector<vk::DescriptorSetLayout> m_DescriptorSetLayouts; eastl::vector<vk::DescriptorSetLayout> m_DescriptorSetLayouts;
eastl::vector<vk::PushConstantRange> m_PushConstantRanges; eastl::vector<vk::PushConstantRange> m_PushConstantRanges;
explicit PipelineLayoutBuilder(systems::Device *device) explicit PipelineLayoutBuilder(systems::RenderingDevice *device)
: m_Device{device} : m_Device{device}
{ {
} }
@ -902,7 +902,7 @@ PipelineLayoutBuilder::Build(vk::PipelineLayout &pipelineLayout,
} }
systems::PipelineCreationError systems::PipelineCreationError
systems::Device::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, systems::RenderingDevice::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout,
Slang::ComPtr<slang::IComponentType> const &program) Slang::ComPtr<slang::IComponentType> const &program)
{ {
using Slang::ComPtr; using Slang::ComPtr;
@ -993,7 +993,7 @@ FindAsyncComputeQueue(PhysicalDevice const &physicalDevice, u32 primaryQueueFami
return std::nullopt; return std::nullopt;
} }
systems::Device::Device(DeviceCreateInfo const &createInfo) systems::RenderingDevice::RenderingDevice(DeviceCreateInfo const &createInfo)
: m_Window{createInfo.m_Window} : m_Window{createInfo.m_Window}
, m_SyncServer{new _internal::SyncServer{*this}} , m_SyncServer{new _internal::SyncServer{*this}}
{ {
@ -1046,7 +1046,7 @@ systems::Device::Device(DeviceCreateInfo const &createInfo)
m_ComputeQueueFamily = m_PrimaryQueueFamily; m_ComputeQueueFamily = m_PrimaryQueueFamily;
} }
m_Device = ::Device{m_Instance, physicalDevice, features, queueAllocations, createInfo.m_PipelineCacheData, m_Device = Device{m_Instance, physicalDevice, features, queueAllocations, createInfo.m_PipelineCacheData,
createInfo.m_Name}; createInfo.m_Name};
m_PrimaryQueue = m_Device.GetQueue(m_PrimaryQueueFamily, primaryQueueIndex); m_PrimaryQueue = m_Device.GetQueue(m_PrimaryQueueFamily, primaryQueueIndex);
@ -1110,7 +1110,7 @@ systems::Device::Device(DeviceCreateInfo const &createInfo)
} }
} }
systems::Device::~Device() systems::RenderingDevice::~RenderingDevice()
{ {
for (auto &frame : m_Frames) for (auto &frame : m_Frames)
{ {
@ -1126,7 +1126,7 @@ systems::Device::~Device()
// ==================================================================================================== // ====================================================================================================
systems::Frame & systems::Frame &
systems::Device::GetNextFrame() systems::RenderingDevice::GetNextFrame()
{ {
if (m_CommitManager) if (m_CommitManager)
m_CommitManager->Update(); m_CommitManager->Update();
@ -1167,7 +1167,7 @@ systems::Device::GetNextFrame()
} }
void void
systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext) systems::RenderingDevice::Present(Frame &frame, GraphicsContext &graphicsContext)
{ {
vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eColorAttachmentOutput; vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eColorAttachmentOutput;
vk::SubmitInfo const submitInfo = { vk::SubmitInfo const submitInfo = {
@ -1206,19 +1206,19 @@ systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext)
} }
systems::TransferContext systems::TransferContext
systems::Device::CreateTransferContext() systems::RenderingDevice::CreateTransferContext()
{ {
return m_TransferContextPool.CreateTransferContext(); return m_TransferContextPool.CreateTransferContext();
} }
systems::ComputeContext systems::ComputeContext
systems::Device::CreateComputeContext() systems::RenderingDevice::CreateComputeContext()
{ {
return m_ComputeContextPool.CreateComputeContext(); return m_ComputeContextPool.CreateComputeContext();
} }
systems::Receipt systems::Receipt
systems::Device::Submit(Context &context) systems::RenderingDevice::Submit(Context &context)
{ {
auto const rect = m_SyncServer->Allocate(); auto const rect = m_SyncServer->Allocate();
auto &entry = m_SyncServer->GetEntry(rect); auto &entry = m_SyncServer->GetEntry(rect);
@ -1254,7 +1254,7 @@ systems::Device::Submit(Context &context)
} }
void void
systems::Device::WaitOn(Receipt recpt) systems::RenderingDevice::WaitOn(Receipt recpt)
{ {
m_SyncServer->WaitOn(recpt); m_SyncServer->WaitOn(recpt);
} }
@ -1319,8 +1319,8 @@ systems::Frame::operator=(Frame &&other) noexcept
return *this; return *this;
} }
systems::Frame::Frame(Device &device, u32 frameIndex, u32 const primaryQueueFamily, u32 const asyncTransferQueue, systems::Frame::Frame(RenderingDevice &device, u32 frameIndex, u32 const primaryQueueFamily,
u32 const asyncComputeQueue) u32 const asyncTransferQueue, u32 const asyncComputeQueue)
: m_Device{&device} : m_Device{&device}
, m_PrimaryPool{device, primaryQueueFamily, _internal::ContextPool::ManagedBy::eFrame} , m_PrimaryPool{device, primaryQueueFamily, _internal::ContextPool::ManagedBy::eFrame}
, m_AsyncTransferPool{device, asyncTransferQueue, _internal::ContextPool::ManagedBy::eFrame} , m_AsyncTransferPool{device, asyncTransferQueue, _internal::ContextPool::ManagedBy::eFrame}

View File

@ -5,11 +5,11 @@
#include "aster/systems/sync_server.h" #include "aster/systems/sync_server.h"
#include "aster/systems/device.h" #include "aster/systems/rendering_device.h"
using namespace systems::_internal; using namespace systems::_internal;
SyncServer::Entry::Entry(Device &device) SyncServer::Entry::Entry(RenderingDevice &device)
: m_CurrentPoint{0, 1} : m_CurrentPoint{0, 1}
, m_AttachedPool{nullptr} , m_AttachedPool{nullptr}
{ {
@ -23,7 +23,7 @@ SyncServer::Entry::Entry(Device &device)
} }
void void
SyncServer::Entry::Destroy(Device &device) SyncServer::Entry::Destroy(RenderingDevice &device)
{ {
if (m_Semaphore) if (m_Semaphore)
{ {
@ -32,7 +32,7 @@ SyncServer::Entry::Destroy(Device &device)
} }
void void
SyncServer::Entry::Wait(Device &device) SyncServer::Entry::Wait(RenderingDevice &device)
{ {
vk::SemaphoreWaitInfo const waitInfo = { vk::SemaphoreWaitInfo const waitInfo = {
.semaphoreCount = 1, .semaphoreCount = 1,
@ -114,7 +114,7 @@ SyncServer::GetEntry(Receipt receipt)
return *static_cast<Entry *>(receipt.m_Opaque); return *static_cast<Entry *>(receipt.m_Opaque);
} }
SyncServer::SyncServer(Device &device) SyncServer::SyncServer(RenderingDevice &device)
: m_Device{&device} : m_Device{&device}
{ {
} }

View File

@ -8,7 +8,7 @@
#include "aster/core/device.h" #include "aster/core/device.h"
#include "aster/core/instance.h" #include "aster/core/instance.h"
#include "aster/core/window.h" #include "aster/core/window.h"
#include "aster/systems/device.h" #include "aster/systems/rendering_device.h"
#include "helpers.h" #include "helpers.h"
#include <imgui_impl_glfw.h> #include <imgui_impl_glfw.h>
@ -27,7 +27,7 @@ VulkanAssert(VkResult result)
} }
void void
Init(systems::Device &device, Window &window) Init(systems::RenderingDevice &device, Window &window)
{ {
g_AttachmentFormat = device.m_Swapchain.m_Format; g_AttachmentFormat = device.m_Swapchain.m_Format;
@ -70,7 +70,7 @@ Init(systems::Device &device, Window &window)
.pColorAttachmentFormats = &g_AttachmentFormat, .pColorAttachmentFormats = &g_AttachmentFormat,
}; };
// TODO: Switch this into being managed by Device. // TODO: Switch this into being managed by RenderingDevice.
// m_Instance etc should private. // m_Instance etc should private.
ImGui_ImplVulkan_InitInfo imguiVulkanInitInfo = { ImGui_ImplVulkan_InitInfo imguiVulkanInitInfo = {
.Instance = device.m_Instance.m_Instance, .Instance = device.m_Instance.m_Instance,
@ -158,7 +158,7 @@ Init(Instance const *context, Device const *device, Window const *window, vk::Fo
} }
void void
Destroy(systems::Device const &device) Destroy(systems::RenderingDevice const &device)
{ {
ImGui_ImplVulkan_Shutdown(); ImGui_ImplVulkan_Shutdown();
ImGui_ImplGlfw_Shutdown(); ImGui_ImplGlfw_Shutdown();

View File

@ -17,7 +17,7 @@ struct Swapchain;
namespace systems namespace systems
{ {
class Device; class RenderingDevice;
class GraphicsContext; class GraphicsContext;
struct Frame; struct Frame;
} }
@ -25,10 +25,10 @@ struct Frame;
// ReSharper disable once CppInconsistentNaming // ReSharper disable once CppInconsistentNaming
namespace ImGui namespace ImGui
{ {
void Init(systems::Device &device, Window &window); void Init(systems::RenderingDevice &device, Window &window);
void Init(const Instance *context, const Device *device, const Window *window, vk::Format attachmentFormat, void Init(const Instance *context, const Device *device, const Window *window, vk::Format attachmentFormat,
u32 imageCount, u32 queueFamily, vk::Queue queue); u32 imageCount, u32 queueFamily, vk::Queue queue);
void Destroy(const systems::Device &device); void Destroy(const systems::RenderingDevice &device);
void Destroy(const Device *device); void Destroy(const Device *device);
void Recreate(); void Recreate();

View File

@ -14,7 +14,7 @@
#include "aster/core/window.h" #include "aster/core/window.h"
#include "aster/core/pipeline.h" #include "aster/core/pipeline.h"
#include "aster/systems/device.h" #include "aster/systems/rendering_device.h"
#include "aster/util/files.h" #include "aster/util/files.h"
#include "helpers.h" #include "helpers.h"
@ -51,7 +51,7 @@ main(int, char **)
MIN_LOG_LEVEL(Logger::LogType::eInfo); MIN_LOG_LEVEL(Logger::LogType::eInfo);
Window window = {"Triangle (Aster)", {640, 480}}; Window window = {"Triangle (Aster)", {640, 480}};
systems::Device device{{ systems::RenderingDevice device{{
.m_Window = window, .m_Window = window,
.m_Features = {.m_Vulkan12Features = {.bufferDeviceAddress = true}, .m_Features = {.m_Vulkan12Features = {.bufferDeviceAddress = true},
.m_Vulkan13Features = {.synchronization2 = true, .dynamicRendering = true}}, .m_Vulkan13Features = {.synchronization2 = true, .dynamicRendering = true}},

View File

@ -15,7 +15,7 @@
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "aster/systems/commit_manager.h" #include "aster/systems/commit_manager.h"
#include "aster/systems/device.h" #include "aster/systems/rendering_device.h"
#include "aster/util/files.h" #include "aster/util/files.h"
#include "stb_image.h" #include "stb_image.h"
@ -117,7 +117,7 @@ main(int, char **)
.m_Vulkan13Features = {.synchronization2 = true, .dynamicRendering = true}, .m_Vulkan13Features = {.synchronization2 = true, .dynamicRendering = true},
}; };
systems::Device device{{ systems::RenderingDevice device{{
.m_Window = window, .m_Window = window,
.m_Features = enabledDeviceFeatures, .m_Features = enabledDeviceFeatures,
.m_AppName = "Box", .m_AppName = "Box",

View File

@ -11,7 +11,7 @@
#include "helpers.h" #include "helpers.h"
#include "aster/systems/commit_manager.h" #include "aster/systems/commit_manager.h"
#include "aster/systems/device.h" #include "aster/systems/rendering_device.h"
#include <EASTL/fixed_vector.h> #include <EASTL/fixed_vector.h>
#include <EASTL/hash_map.h> #include <EASTL/hash_map.h>
@ -885,7 +885,7 @@ Model::Update()
} }
} }
AssetLoader::AssetLoader(systems::Device &device) AssetLoader::AssetLoader(systems::RenderingDevice &device)
: m_Device{&device} : m_Device{&device}
{ {
} }

View File

@ -20,7 +20,7 @@ class TransferContext;
namespace systems namespace systems
{ {
class Device; class RenderingDevice;
class ResourceManager; class ResourceManager;
class SamplerManager; class SamplerManager;
class BufferManager; class BufferManager;
@ -103,7 +103,7 @@ struct Model
struct AssetLoader struct AssetLoader
{ {
systems::Device *m_Device; systems::RenderingDevice *m_Device;
Ref<TextureView> LoadHdrImage(cstr path, cstr name = nullptr) const; Ref<TextureView> LoadHdrImage(cstr path, cstr name = nullptr) const;
Model LoadModelToGpu(cstr path, cstr name = nullptr); Model LoadModelToGpu(cstr path, cstr name = nullptr);
@ -117,7 +117,7 @@ struct AssetLoader
constexpr static auto AJoints0 = "JOINTS_0"; constexpr static auto AJoints0 = "JOINTS_0";
constexpr static auto AWeights0 = "WEIGHTS_0"; constexpr static auto AWeights0 = "WEIGHTS_0";
explicit AssetLoader(systems::Device &device); explicit AssetLoader(systems::RenderingDevice &device);
private: private:
systems::ResId<TextureView> systems::ResId<TextureView>

View File

@ -12,7 +12,7 @@
#include "helpers.h" #include "helpers.h"
#include "aster/systems/commit_manager.h" #include "aster/systems/commit_manager.h"
#include "aster/systems/device.h" #include "aster/systems/rendering_device.h"
#include <EASTL/fixed_vector.h> #include <EASTL/fixed_vector.h>
#include <EASTL/tuple.h> #include <EASTL/tuple.h>
@ -26,7 +26,7 @@ constexpr auto BRDF_LUT_ENTRY = "brdfLut";
Environment Environment
CreateCubeFromHdrEnv(AssetLoader &assetLoader, u32 const cubeSide, systems::ResId<TextureView> hdrEnv) CreateCubeFromHdrEnv(AssetLoader &assetLoader, u32 const cubeSide, systems::ResId<TextureView> hdrEnv)
{ {
systems::Device &device = *assetLoader.m_Device; systems::RenderingDevice &device = *assetLoader.m_Device;
auto *commitManager = device.m_CommitManager.get(); auto *commitManager = device.m_CommitManager.get();
auto skybox = device.CreateTextureCubeWithView<StorageTextureCubeView>({ auto skybox = device.CreateTextureCubeWithView<StorageTextureCubeView>({

View File

@ -7,7 +7,7 @@
#include "aster/core/buffer.h" #include "aster/core/buffer.h"
#include "aster/systems/commit_manager.h" #include "aster/systems/commit_manager.h"
#include "aster/systems/device.h" #include "aster/systems/rendering_device.h"
#include "aster/systems/resource.h" #include "aster/systems/resource.h"
#include "glm/ext/matrix_transform.hpp" #include "glm/ext/matrix_transform.hpp"
@ -55,7 +55,7 @@ ToColor32(vec3 const &col)
return r << 24 | g << 16 | b << 8 | a; return r << 24 | g << 16 | b << 8 | a;
} }
LightManager::LightManager(systems::Device &device) LightManager::LightManager(systems::RenderingDevice &device)
: m_Device{&device} : m_Device{&device}
, m_DirectionalLightCount{} , m_DirectionalLightCount{}
, m_PointLightCount{} , m_PointLightCount{}

View File

@ -15,7 +15,7 @@
namespace systems namespace systems
{ {
class Device; class RenderingDevice;
} }
namespace systems namespace systems
@ -89,7 +89,7 @@ struct LightManager
u16 m_UnusedPadding0 = 0; // 02 12 u16 m_UnusedPadding0 = 0; // 02 12
}; };
systems::Device *m_Device; systems::RenderingDevice *m_Device;
eastl::vector<Light> m_Lights; eastl::vector<Light> m_Lights;
// We don't need a Directional Light free list. We will just brute force iterate. // We don't need a Directional Light free list. We will just brute force iterate.
@ -113,7 +113,7 @@ struct LightManager
~LightManager() = default; ~LightManager() = default;
LightManager(systems::Device &device); LightManager(systems::RenderingDevice &device);
LightManager(LightManager &&other) noexcept; LightManager(LightManager &&other) noexcept;
LightManager &operator=(LightManager &&other) noexcept; LightManager &operator=(LightManager &&other) noexcept;

View File

@ -17,7 +17,7 @@
#include "aster/util/files.h" #include "aster/util/files.h"
#include "aster/systems/commit_manager.h" #include "aster/systems/commit_manager.h"
#include "aster/systems/device.h" #include "aster/systems/rendering_device.h"
#include "asset_loader.h" #include "asset_loader.h"
#include "light_manager.h" #include "light_manager.h"
@ -163,7 +163,7 @@ main(int, char **)
}; };
auto pipelineCacheData = ReadFileBytes(PIPELINE_CACHE_FILE, false); auto pipelineCacheData = ReadFileBytes(PIPELINE_CACHE_FILE, false);
systems::Device device{{ systems::RenderingDevice device{{
.m_Window = window, .m_Window = window,
.m_Features = enabledDeviceFeatures, .m_Features = enabledDeviceFeatures,
.m_AppName = "ModelRender", .m_AppName = "ModelRender",