diff --git a/aster/include/aster/systems/CMakeLists.txt b/aster/include/aster/systems/CMakeLists.txt index 3bd3bfa..e7aefd7 100644 --- a/aster/include/aster/systems/CMakeLists.txt +++ b/aster/include/aster/systems/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13) target_sources(aster_core INTERFACE - "device.h" + "rendering_device.h" "resource.h" "context.h" "commit_manager.h") diff --git a/aster/include/aster/systems/commit_manager.h b/aster/include/aster/systems/commit_manager.h index 73e518f..b0afaca 100644 --- a/aster/include/aster/systems/commit_manager.h +++ b/aster/include/aster/systems/commit_manager.h @@ -20,7 +20,7 @@ namespace systems { -class Device; +class RenderingDevice; class CommitManager { @@ -212,9 +212,9 @@ class CommitManager // using WriteOwner = std::variant, Handle>; 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 defaultSampler); ~CommitManager(); diff --git a/aster/include/aster/systems/context.h b/aster/include/aster/systems/context.h index fb53043..35058a8 100644 --- a/aster/include/aster/systems/context.h +++ b/aster/include/aster/systems/context.h @@ -26,7 +26,7 @@ namespace systems { -class Device; +class RenderingDevice; struct Frame; namespace _internal @@ -45,7 +45,7 @@ class Context _internal::ContextPool *m_Pool; vk::CommandBuffer m_Cmd; - friend Device; + friend RenderingDevice; friend _internal::ContextPool; explicit Context(_internal::ContextPool &pool, vk::CommandBuffer const cmd) @@ -87,7 +87,7 @@ Context::EndDebugRegion() class TransferContext : public Context { protected: - friend Device; + friend RenderingDevice; friend _internal::TransferContextPool; explicit TransferContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd) @@ -120,7 +120,7 @@ class TransferContext : public Context class ComputeContext : public TransferContext { protected: - friend Device; + friend RenderingDevice; friend _internal::ComputeContextPool; Pipeline const *m_PipelineInUse; @@ -167,7 +167,7 @@ class ComputeContext : public TransferContext class GraphicsContext : public ComputeContext { protected: - friend Device; + friend RenderingDevice; friend _internal::GraphicsContextPool; explicit GraphicsContext(_internal::ContextPool &pool, vk::CommandBuffer const cmd) @@ -199,7 +199,7 @@ namespace _internal class ContextPool { protected: - Device *m_Device; + RenderingDevice *m_Device; vk::CommandPool m_Pool; eastl::vector m_CommandBuffers; u32 m_BuffersAllocated; @@ -221,7 +221,7 @@ class ContextPool vk::CommandBuffer AllocateCommandBuffer(); public: - [[nodiscard]] Device & + [[nodiscard]] RenderingDevice & GetDevice() const { assert(m_Device); @@ -242,7 +242,7 @@ class ContextPool void Reset(); ContextPool() = default; - ContextPool(Device &device, u32 queueFamilyIndex, ManagedBy managedBy); + ContextPool(RenderingDevice &device, u32 queueFamilyIndex, ManagedBy managedBy); ContextPool(ContextPool &&other) noexcept; ContextPool &operator=(ContextPool &&other) noexcept; @@ -265,7 +265,7 @@ class TransferContextPool : public ContextPool TransferContextPool() = default; - TransferContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) + TransferContextPool(RenderingDevice &device, u32 const queueFamilyIndex, ManagedBy const managedBy) : ContextPool{device, queueFamilyIndex, managedBy} { } @@ -285,7 +285,7 @@ class ComputeContextPool : public TransferContextPool ComputeContextPool() = default; - ComputeContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) + ComputeContextPool(RenderingDevice &device, u32 const queueFamilyIndex, ManagedBy const managedBy) : TransferContextPool{device, queueFamilyIndex, managedBy} { } @@ -305,7 +305,7 @@ class GraphicsContextPool : public ComputeContextPool GraphicsContextPool() = default; - GraphicsContextPool(Device &device, u32 const queueFamilyIndex, ManagedBy const managedBy) + GraphicsContextPool(RenderingDevice &device, u32 const queueFamilyIndex, ManagedBy const managedBy) : ComputeContextPool{device, queueFamilyIndex, managedBy} { } @@ -336,7 +336,7 @@ class OrderlessContextPool using ContextListType = eastl::intrusive_list; - Device *m_Device; + RenderingDevice *m_Device; memory::memory_pool<> m_ContextPoolEntryMemory; ContextListType m_FreeContextPools; ContextListType m_UsedContextPools; @@ -355,7 +355,7 @@ class OrderlessContextPool } void - Init(Device &device, u32 const queueFamilyIndex) + Init(RenderingDevice &device, u32 const queueFamilyIndex) { m_Device = &device; m_QueueFamilyIndex = queueFamilyIndex; diff --git a/aster/include/aster/systems/pipeline_helpers.h b/aster/include/aster/systems/pipeline_helpers.h index 4e8a748..18464d8 100644 --- a/aster/include/aster/systems/pipeline_helpers.h +++ b/aster/include/aster/systems/pipeline_helpers.h @@ -13,7 +13,7 @@ namespace systems { -class Device; +class RenderingDevice; struct PipelineCreationError { @@ -35,12 +35,12 @@ namespace _internal { struct PipelineLayoutBuilder { - Device *m_Device; + RenderingDevice *m_Device; eastl::vector m_DescriptorSetLayouts; eastl::vector m_PushConstants; vk::ShaderStageFlags m_Stage; - explicit PipelineLayoutBuilder(Device *device, vk::DescriptorSetLayout bindlessLayout = {}); + explicit PipelineLayoutBuilder(RenderingDevice *device, vk::DescriptorSetLayout bindlessLayout = {}); [[nodiscard]] vk::PipelineLayout Build(); diff --git a/aster/include/aster/systems/device.h b/aster/include/aster/systems/rendering_device.h similarity index 97% rename from aster/include/aster/systems/device.h rename to aster/include/aster/systems/rendering_device.h index 7f54314..d685092 100644 --- a/aster/include/aster/systems/device.h +++ b/aster/include/aster/systems/rendering_device.h @@ -1,6 +1,6 @@ // ============================================= -// Aster: device.h -// Copyright (c) 2020-2025 Anish Bhobe +// Aster: rendering_device.h +// Copyright (c) 2020-2025 Anish Bhobe // ============================================= #pragma once @@ -323,7 +323,7 @@ struct GraphicsPipelineCreateInfo cstr m_Name; private: - friend Device; + friend RenderingDevice; [[nodiscard]] vk::PipelineDepthStencilStateCreateInfo GetDepthStencilStateCreateInfo() const; }; @@ -381,7 +381,7 @@ class Receipt struct Frame { // Persistent - Device *m_Device; + RenderingDevice *m_Device; // TODO: ThreadSafe _internal::GraphicsContextPool m_PrimaryPool; @@ -406,7 +406,8 @@ struct Frame void WaitUntilReady(); 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 &operator=(Frame &&other) noexcept; @@ -418,13 +419,13 @@ struct Frame class CommitManager; -class Device final +class RenderingDevice final { public: // TODO: Temp std::reference_wrapper m_Window; Instance m_Instance; Surface m_Surface; - ::Device m_Device; + Device m_Device; Swapchain m_Swapchain; std::unique_ptr m_CommitManager; @@ -590,7 +591,7 @@ class Device final void WaitOn(Receipt recpt); // - // Device Methods + // RenderingDevice Methods // ---------------------------------------------------------------------------------------------------- template @@ -621,7 +622,7 @@ class Device final // Inner // ---------------------------------------------------------------------------------------------------- - [[nodiscard]] ::Device & + [[nodiscard]] Device & GetInner() { return m_Device; @@ -635,11 +636,11 @@ class Device final // Ctor/Dtor // ---------------------------------------------------------------------------------------------------- - explicit Device(DeviceCreateInfo const &createInfo); + explicit RenderingDevice(DeviceCreateInfo const &createInfo); - ~Device(); + ~RenderingDevice(); - PIN_MEMORY(Device); + PIN_MEMORY(RenderingDevice); }; } // namespace systems \ No newline at end of file diff --git a/aster/include/aster/systems/sync_server.h b/aster/include/aster/systems/sync_server.h index e6bc9e7..7e5e8d5 100644 --- a/aster/include/aster/systems/sync_server.h +++ b/aster/include/aster/systems/sync_server.h @@ -12,7 +12,7 @@ namespace systems { class Receipt; -class Device; +class RenderingDevice; } // namespace systems namespace systems::_internal @@ -31,9 +31,9 @@ class SyncServer TimelinePoint m_CurrentPoint; ContextPool *m_AttachedPool; - explicit Entry(Device &device); - void Destroy(Device &device); - void Wait(Device &device); + explicit Entry(RenderingDevice &device); + void Destroy(RenderingDevice &device); + void Wait(RenderingDevice &device); void Next(); void AttachPool(ContextPool *pool); @@ -45,7 +45,7 @@ class SyncServer DISALLOW_COPY_AND_ASSIGN(Entry); }; - Device *m_Device; + RenderingDevice *m_Device; eastl::deque m_Allocations; eastl::intrusive_list m_FreeList; @@ -63,7 +63,7 @@ class SyncServer void FreeEntry(Entry &entry); // Constructor/Destructor - explicit SyncServer(Device &device); + explicit SyncServer(RenderingDevice &device); public: ~SyncServer(); @@ -72,7 +72,7 @@ class SyncServer SyncServer(SyncServer &&other) noexcept; SyncServer &operator=(SyncServer &&other) noexcept; - friend Device; + friend RenderingDevice; DISALLOW_COPY_AND_ASSIGN(SyncServer); }; diff --git a/aster/src/aster/systems/CMakeLists.txt b/aster/src/aster/systems/CMakeLists.txt index 1613e16..d5815c1 100644 --- a/aster/src/aster/systems/CMakeLists.txt +++ b/aster/src/aster/systems/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13) target_sources(aster_core PRIVATE -"device.cpp" +"rendering_device.cpp" "commit_manager.cpp" "pipeline_helpers.cpp" "context.cpp" diff --git a/aster/src/aster/systems/commit_manager.cpp b/aster/src/aster/systems/commit_manager.cpp index f91c57e..bac151a 100644 --- a/aster/src/aster/systems/commit_manager.cpp +++ b/aster/src/aster/systems/commit_manager.cpp @@ -8,13 +8,13 @@ #include "EASTL/array.h" #include "core/device.h" #include "core/image_view.h" -#include "systems/device.h" +#include "systems/rendering_device.h" using namespace systems; 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 defaultSampler) : m_Device{device} , m_Buffers{maxBuffers} diff --git a/aster/src/aster/systems/context.cpp b/aster/src/aster/systems/context.cpp index 6c09800..f4db75e 100644 --- a/aster/src/aster/systems/context.cpp +++ b/aster/src/aster/systems/context.cpp @@ -6,7 +6,7 @@ #include "aster/systems/context.h" #include "aster/systems/commit_manager.h" -#include "systems/device.h" +#include "aster/systems/rendering_device.h" constexpr static u32 GetFormatSize(vk::Format const format) @@ -373,7 +373,7 @@ systems::ComputeContext::PushConstantBlock(usize const offset, usize const size, 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_BuffersAllocated{0} , m_ExtraData{0} diff --git a/aster/src/aster/systems/pipeline_helpers.cpp b/aster/src/aster/systems/pipeline_helpers.cpp index a648d60..da28879 100644 --- a/aster/src/aster/systems/pipeline_helpers.cpp +++ b/aster/src/aster/systems/pipeline_helpers.cpp @@ -3,7 +3,7 @@ // Copyright (c) 2020-2025 Anish Bhobe // ============================================= -#include "systems/device.h" +#include "systems/rendering_device.h" #include @@ -121,7 +121,7 @@ systems::SlangToVulkanShaderStage(SlangStage const stage) return {}; } -PipelineLayoutBuilder::PipelineLayoutBuilder(Device *device, vk::DescriptorSetLayout bindlessLayout) +PipelineLayoutBuilder::PipelineLayoutBuilder(RenderingDevice *device, vk::DescriptorSetLayout bindlessLayout) : m_Device{device} , m_DescriptorSetLayouts{bindlessLayout} // if `null` will be filtered out during build. { diff --git a/aster/src/aster/systems/device.cpp b/aster/src/aster/systems/rendering_device.cpp similarity index 94% rename from aster/src/aster/systems/device.cpp rename to aster/src/aster/systems/rendering_device.cpp index e7003d2..7a876a6 100644 --- a/aster/src/aster/systems/device.cpp +++ b/aster/src/aster/systems/rendering_device.cpp @@ -1,9 +1,9 @@ // ============================================= -// Aster: device.cpp -// Copyright (c) 2020-2025 Anish Bhobe +// Aster: rendering_device.cpp +// Copyright (c) 2020-2025 Anish Bhobe // ============================================= -#include "systems/device.h" +#include "systems/rendering_device.h" #include "core/queue_allocation.h" #include "core/window.h" @@ -107,7 +107,7 @@ systems::DefaultPhysicalDeviceSelector(PhysicalDevices const &physicalDevices) // ==================================================================================================== Ref -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. // This is hacky and should be improved. @@ -122,7 +122,7 @@ systems::Device::CreateStorageBuffer(usize const size, cstr const name) } Ref -systems::Device::CreateIndexBuffer(usize size, cstr name) +systems::RenderingDevice::CreateIndexBuffer(usize size, cstr name) { // TODO: Storage and Index buffer are set. // This is hacky and should be improved. @@ -137,7 +137,7 @@ systems::Device::CreateIndexBuffer(usize size, cstr name) } Ref -systems::Device::CreateUniformBuffer(usize const size, cstr const name) +systems::RenderingDevice::CreateUniformBuffer(usize const size, cstr const name) { constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eUniformBuffer; constexpr VmaAllocationCreateFlags createFlags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | @@ -148,7 +148,7 @@ systems::Device::CreateUniformBuffer(usize const size, cstr const name) } Ref -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 VmaAllocationCreateFlags createFlags = @@ -158,7 +158,7 @@ systems::Device::CreateStagingBuffer(usize const size, cstr const name) } Ref -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 VmaAllocationCreateFlags createFlags = @@ -189,7 +189,7 @@ constexpr vk::ImageUsageFlags DEPTH_STENCIL_ATTACHMENT = vk::ImageUsageFlagBits: } // namespace usage_flags Ref -systems::Device::CreateTexture2D(Texture2DCreateInfo const &createInfo) +systems::RenderingDevice::CreateTexture2D(Texture2DCreateInfo const &createInfo) { constexpr VmaAllocationCreateInfo allocationCreateInfo = { .flags = {}, @@ -221,7 +221,7 @@ systems::Device::CreateTexture2D(Texture2DCreateInfo const &createInfo) } Ref -systems::Device::CreateTextureCube(TextureCubeCreateInfo const &createInfo) +systems::RenderingDevice::CreateTextureCube(TextureCubeCreateInfo const &createInfo) { constexpr VmaAllocationCreateInfo allocationCreateInfo = { .flags = {}, @@ -253,7 +253,7 @@ systems::Device::CreateTextureCube(TextureCubeCreateInfo const &createInfo) } Ref -systems::Device::CreateAttachment(AttachmentCreateInfo const &createInfo) +systems::RenderingDevice::CreateAttachment(AttachmentCreateInfo const &createInfo) { constexpr VmaAllocationCreateInfo allocationCreateInfo = { .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, @@ -280,7 +280,7 @@ systems::Device::CreateAttachment(AttachmentCreateInfo const &createInfo) } Ref -systems::Device::CreateDepthStencilImage(DepthStencilImageCreateInfo const &createInfo) +systems::RenderingDevice::CreateDepthStencilImage(DepthStencilImageCreateInfo const &createInfo) { constexpr VmaAllocationCreateInfo allocationCreateInfo = { .flags = VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, @@ -404,7 +404,7 @@ ToImageCreateInfo(systems::DepthStencilImageCreateInfo const &createInfo) // ==================================================================================================== Ref -systems::Device::CreateView(ViewCreateInfo const &createInfo) +systems::RenderingDevice::CreateView(ViewCreateInfo const &createInfo) { auto const layerCount = createInfo.GetLayerCount(); auto const mipCount = createInfo.GetMipLevelCount(); @@ -432,7 +432,7 @@ systems::Device::CreateView(ViewCreateInfo const &createInfo) // ==================================================================================================== Ref -systems::Device::CreateTexture2DWithView(Texture2DCreateInfo const &createInfo) +systems::RenderingDevice::CreateTexture2DWithView(Texture2DCreateInfo const &createInfo) { return CreateView({ .m_Image = CastImage(CreateTexture2D(createInfo)), @@ -443,7 +443,7 @@ systems::Device::CreateTexture2DWithView(Texture2DCreateInfo const &createInfo) } Ref -systems::Device::CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo) +systems::RenderingDevice::CreateTextureCubeWithView(TextureCubeCreateInfo const &createInfo) { return CreateView({ .m_Image = CreateTextureCube(createInfo), @@ -454,7 +454,7 @@ systems::Device::CreateTextureCubeWithView(TextureCubeCreateInfo const &createIn } Ref -systems::Device::CreateAttachmentWithView(AttachmentCreateInfo const &createInfo) +systems::RenderingDevice::CreateAttachmentWithView(AttachmentCreateInfo const &createInfo) { return CreateView({ .m_Image = CreateAttachment(createInfo), @@ -465,7 +465,7 @@ systems::Device::CreateAttachmentWithView(AttachmentCreateInfo const &createInfo } Ref -systems::Device::CreateDepthStencilImageWithView(DepthStencilImageCreateInfo const &createInfo) +systems::RenderingDevice::CreateDepthStencilImageWithView(DepthStencilImageCreateInfo const &createInfo) { return CreateView({ .m_Image = CreateDepthStencilImage(createInfo), @@ -482,7 +482,7 @@ systems::Device::CreateDepthStencilImageWithView(DepthStencilImageCreateInfo con // ==================================================================================================== Ref -systems::Device::CreateSampler(SamplerCreateInfo const &createInfo) +systems::RenderingDevice::CreateSampler(SamplerCreateInfo const &createInfo) { auto vkCreateInfo = static_cast(createInfo); @@ -502,7 +502,7 @@ systems::Device::CreateSampler(SamplerCreateInfo const &createInfo) // ---------------------------------------------------------------------------------------------------- systems::PipelineCreationError -systems::Device::CreateGraphicsPipeline(Pipeline &pipelineOut, GraphicsPipelineCreateInfo const &createInfo) +systems::RenderingDevice::CreateGraphicsPipeline(Pipeline &pipelineOut, GraphicsPipelineCreateInfo const &createInfo) { eastl::fixed_vector shaders; Slang::ComPtr program; @@ -641,7 +641,7 @@ systems::Device::CreateGraphicsPipeline(Pipeline &pipelineOut, GraphicsPipelineC } systems::PipelineCreationError -systems::Device::CreateComputePipeline(Pipeline &pipelineOut, ComputePipelineCreateInfo const &createInfo) +systems::RenderingDevice::CreateComputePipeline(Pipeline &pipelineOut, ComputePipelineCreateInfo const &createInfo) { eastl::fixed_vector shaders; Slang::ComPtr program; @@ -699,7 +699,7 @@ systems::Device::CreateComputePipeline(Pipeline &pipelineOut, ComputePipelineCre return SLANG_FAIL systems::PipelineCreationError -systems::Device::CreateShaders( +systems::RenderingDevice::CreateShaders( eastl::fixed_vector &shadersOut, Slang::ComPtr &program, std::span const &shaders) { @@ -870,11 +870,11 @@ systems::Device::CreateShaders( struct PipelineLayoutBuilder { - systems::Device *m_Device; + systems::RenderingDevice *m_Device; eastl::vector m_DescriptorSetLayouts; eastl::vector m_PushConstantRanges; - explicit PipelineLayoutBuilder(systems::Device *device) + explicit PipelineLayoutBuilder(systems::RenderingDevice *device) : m_Device{device} { } @@ -902,8 +902,8 @@ PipelineLayoutBuilder::Build(vk::PipelineLayout &pipelineLayout, } systems::PipelineCreationError -systems::Device::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, - Slang::ComPtr const &program) +systems::RenderingDevice::CreatePipelineLayout(vk::PipelineLayout &pipelineLayout, + Slang::ComPtr const &program) { using Slang::ComPtr; @@ -993,7 +993,7 @@ FindAsyncComputeQueue(PhysicalDevice const &physicalDevice, u32 primaryQueueFami return std::nullopt; } -systems::Device::Device(DeviceCreateInfo const &createInfo) +systems::RenderingDevice::RenderingDevice(DeviceCreateInfo const &createInfo) : m_Window{createInfo.m_Window} , m_SyncServer{new _internal::SyncServer{*this}} { @@ -1046,8 +1046,8 @@ systems::Device::Device(DeviceCreateInfo const &createInfo) m_ComputeQueueFamily = m_PrimaryQueueFamily; } - m_Device = ::Device{m_Instance, physicalDevice, features, queueAllocations, createInfo.m_PipelineCacheData, - createInfo.m_Name}; + m_Device = Device{m_Instance, physicalDevice, features, queueAllocations, createInfo.m_PipelineCacheData, + createInfo.m_Name}; m_PrimaryQueue = m_Device.GetQueue(m_PrimaryQueueFamily, primaryQueueIndex); m_TransferQueue = m_Device.GetQueue(m_TransferQueueFamily, transferQueueIndex); @@ -1110,7 +1110,7 @@ systems::Device::Device(DeviceCreateInfo const &createInfo) } } -systems::Device::~Device() +systems::RenderingDevice::~RenderingDevice() { for (auto &frame : m_Frames) { @@ -1126,7 +1126,7 @@ systems::Device::~Device() // ==================================================================================================== systems::Frame & -systems::Device::GetNextFrame() +systems::RenderingDevice::GetNextFrame() { if (m_CommitManager) m_CommitManager->Update(); @@ -1167,7 +1167,7 @@ systems::Device::GetNextFrame() } void -systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext) +systems::RenderingDevice::Present(Frame &frame, GraphicsContext &graphicsContext) { vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eColorAttachmentOutput; vk::SubmitInfo const submitInfo = { @@ -1206,19 +1206,19 @@ systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext) } systems::TransferContext -systems::Device::CreateTransferContext() +systems::RenderingDevice::CreateTransferContext() { return m_TransferContextPool.CreateTransferContext(); } systems::ComputeContext -systems::Device::CreateComputeContext() +systems::RenderingDevice::CreateComputeContext() { return m_ComputeContextPool.CreateComputeContext(); } systems::Receipt -systems::Device::Submit(Context &context) +systems::RenderingDevice::Submit(Context &context) { auto const rect = m_SyncServer->Allocate(); auto &entry = m_SyncServer->GetEntry(rect); @@ -1254,7 +1254,7 @@ systems::Device::Submit(Context &context) } void -systems::Device::WaitOn(Receipt recpt) +systems::RenderingDevice::WaitOn(Receipt recpt) { m_SyncServer->WaitOn(recpt); } @@ -1319,8 +1319,8 @@ systems::Frame::operator=(Frame &&other) noexcept return *this; } -systems::Frame::Frame(Device &device, u32 frameIndex, u32 const primaryQueueFamily, u32 const asyncTransferQueue, - u32 const asyncComputeQueue) +systems::Frame::Frame(RenderingDevice &device, u32 frameIndex, u32 const primaryQueueFamily, + u32 const asyncTransferQueue, u32 const asyncComputeQueue) : m_Device{&device} , m_PrimaryPool{device, primaryQueueFamily, _internal::ContextPool::ManagedBy::eFrame} , m_AsyncTransferPool{device, asyncTransferQueue, _internal::ContextPool::ManagedBy::eFrame} @@ -1364,4 +1364,4 @@ systems::Frame::Frame(Frame &&other) noexcept { } -#pragma endregion +#pragma endregion \ No newline at end of file diff --git a/aster/src/aster/systems/sync_server.cpp b/aster/src/aster/systems/sync_server.cpp index 3c2c126..6f40b52 100644 --- a/aster/src/aster/systems/sync_server.cpp +++ b/aster/src/aster/systems/sync_server.cpp @@ -5,11 +5,11 @@ #include "aster/systems/sync_server.h" -#include "aster/systems/device.h" +#include "aster/systems/rendering_device.h" using namespace systems::_internal; -SyncServer::Entry::Entry(Device &device) +SyncServer::Entry::Entry(RenderingDevice &device) : m_CurrentPoint{0, 1} , m_AttachedPool{nullptr} { @@ -23,7 +23,7 @@ SyncServer::Entry::Entry(Device &device) } void -SyncServer::Entry::Destroy(Device &device) +SyncServer::Entry::Destroy(RenderingDevice &device) { if (m_Semaphore) { @@ -32,7 +32,7 @@ SyncServer::Entry::Destroy(Device &device) } void -SyncServer::Entry::Wait(Device &device) +SyncServer::Entry::Wait(RenderingDevice &device) { vk::SemaphoreWaitInfo const waitInfo = { .semaphoreCount = 1, @@ -114,7 +114,7 @@ SyncServer::GetEntry(Receipt receipt) return *static_cast(receipt.m_Opaque); } -SyncServer::SyncServer(Device &device) +SyncServer::SyncServer(RenderingDevice &device) : m_Device{&device} { } diff --git a/samples/00_util/gui.cpp b/samples/00_util/gui.cpp index 6dc0cb2..a25cf4b 100644 --- a/samples/00_util/gui.cpp +++ b/samples/00_util/gui.cpp @@ -8,7 +8,7 @@ #include "aster/core/device.h" #include "aster/core/instance.h" #include "aster/core/window.h" -#include "aster/systems/device.h" +#include "aster/systems/rendering_device.h" #include "helpers.h" #include @@ -27,7 +27,7 @@ VulkanAssert(VkResult result) } void -Init(systems::Device &device, Window &window) +Init(systems::RenderingDevice &device, Window &window) { g_AttachmentFormat = device.m_Swapchain.m_Format; @@ -70,7 +70,7 @@ Init(systems::Device &device, Window &window) .pColorAttachmentFormats = &g_AttachmentFormat, }; - // TODO: Switch this into being managed by Device. + // TODO: Switch this into being managed by RenderingDevice. // m_Instance etc should private. ImGui_ImplVulkan_InitInfo imguiVulkanInitInfo = { .Instance = device.m_Instance.m_Instance, @@ -158,7 +158,7 @@ Init(Instance const *context, Device const *device, Window const *window, vk::Fo } void -Destroy(systems::Device const &device) +Destroy(systems::RenderingDevice const &device) { ImGui_ImplVulkan_Shutdown(); ImGui_ImplGlfw_Shutdown(); diff --git a/samples/00_util/gui.h b/samples/00_util/gui.h index 86edb39..04673e8 100644 --- a/samples/00_util/gui.h +++ b/samples/00_util/gui.h @@ -17,7 +17,7 @@ struct Swapchain; namespace systems { -class Device; +class RenderingDevice; class GraphicsContext; struct Frame; } @@ -25,10 +25,10 @@ struct Frame; // ReSharper disable once CppInconsistentNaming 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, 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 Recreate(); diff --git a/samples/01_triangle/triangle.cpp b/samples/01_triangle/triangle.cpp index 28d9aae..5001890 100644 --- a/samples/01_triangle/triangle.cpp +++ b/samples/01_triangle/triangle.cpp @@ -14,7 +14,7 @@ #include "aster/core/window.h" #include "aster/core/pipeline.h" -#include "aster/systems/device.h" +#include "aster/systems/rendering_device.h" #include "aster/util/files.h" #include "helpers.h" @@ -51,7 +51,7 @@ main(int, char **) MIN_LOG_LEVEL(Logger::LogType::eInfo); Window window = {"Triangle (Aster)", {640, 480}}; - systems::Device device{{ + systems::RenderingDevice device{{ .m_Window = window, .m_Features = {.m_Vulkan12Features = {.bufferDeviceAddress = true}, .m_Vulkan13Features = {.synchronization2 = true, .dynamicRendering = true}}, diff --git a/samples/02_box/box.cpp b/samples/02_box/box.cpp index dc915e5..d6fa76c 100644 --- a/samples/02_box/box.cpp +++ b/samples/02_box/box.cpp @@ -15,7 +15,7 @@ #define STB_IMAGE_IMPLEMENTATION #include "aster/systems/commit_manager.h" -#include "aster/systems/device.h" +#include "aster/systems/rendering_device.h" #include "aster/util/files.h" #include "stb_image.h" @@ -117,7 +117,7 @@ main(int, char **) .m_Vulkan13Features = {.synchronization2 = true, .dynamicRendering = true}, }; - systems::Device device{{ + systems::RenderingDevice device{{ .m_Window = window, .m_Features = enabledDeviceFeatures, .m_AppName = "Box", diff --git a/samples/03_model_render/asset_loader.cpp b/samples/03_model_render/asset_loader.cpp index 08475da..e174d2d 100644 --- a/samples/03_model_render/asset_loader.cpp +++ b/samples/03_model_render/asset_loader.cpp @@ -11,7 +11,7 @@ #include "helpers.h" #include "aster/systems/commit_manager.h" -#include "aster/systems/device.h" +#include "aster/systems/rendering_device.h" #include #include @@ -885,7 +885,7 @@ Model::Update() } } -AssetLoader::AssetLoader(systems::Device &device) +AssetLoader::AssetLoader(systems::RenderingDevice &device) : m_Device{&device} { } \ No newline at end of file diff --git a/samples/03_model_render/asset_loader.h b/samples/03_model_render/asset_loader.h index 78c3580..ed0cd23 100644 --- a/samples/03_model_render/asset_loader.h +++ b/samples/03_model_render/asset_loader.h @@ -20,7 +20,7 @@ class TransferContext; namespace systems { -class Device; +class RenderingDevice; class ResourceManager; class SamplerManager; class BufferManager; @@ -103,7 +103,7 @@ struct Model struct AssetLoader { - systems::Device *m_Device; + systems::RenderingDevice *m_Device; Ref LoadHdrImage(cstr path, cstr name = nullptr) const; Model LoadModelToGpu(cstr path, cstr name = nullptr); @@ -117,7 +117,7 @@ struct AssetLoader constexpr static auto AJoints0 = "JOINTS_0"; constexpr static auto AWeights0 = "WEIGHTS_0"; - explicit AssetLoader(systems::Device &device); + explicit AssetLoader(systems::RenderingDevice &device); private: systems::ResId diff --git a/samples/03_model_render/ibl_helpers.cpp b/samples/03_model_render/ibl_helpers.cpp index b55b7c2..050c1db 100644 --- a/samples/03_model_render/ibl_helpers.cpp +++ b/samples/03_model_render/ibl_helpers.cpp @@ -12,7 +12,7 @@ #include "helpers.h" #include "aster/systems/commit_manager.h" -#include "aster/systems/device.h" +#include "aster/systems/rendering_device.h" #include #include @@ -26,7 +26,7 @@ constexpr auto BRDF_LUT_ENTRY = "brdfLut"; Environment CreateCubeFromHdrEnv(AssetLoader &assetLoader, u32 const cubeSide, systems::ResId hdrEnv) { - systems::Device &device = *assetLoader.m_Device; + systems::RenderingDevice &device = *assetLoader.m_Device; auto *commitManager = device.m_CommitManager.get(); auto skybox = device.CreateTextureCubeWithView({ diff --git a/samples/03_model_render/light_manager.cpp b/samples/03_model_render/light_manager.cpp index 4acb0f2..7ec49da 100644 --- a/samples/03_model_render/light_manager.cpp +++ b/samples/03_model_render/light_manager.cpp @@ -7,7 +7,7 @@ #include "aster/core/buffer.h" #include "aster/systems/commit_manager.h" -#include "aster/systems/device.h" +#include "aster/systems/rendering_device.h" #include "aster/systems/resource.h" #include "glm/ext/matrix_transform.hpp" @@ -55,7 +55,7 @@ ToColor32(vec3 const &col) return r << 24 | g << 16 | b << 8 | a; } -LightManager::LightManager(systems::Device &device) +LightManager::LightManager(systems::RenderingDevice &device) : m_Device{&device} , m_DirectionalLightCount{} , m_PointLightCount{} diff --git a/samples/03_model_render/light_manager.h b/samples/03_model_render/light_manager.h index 5518061..cd38abf 100644 --- a/samples/03_model_render/light_manager.h +++ b/samples/03_model_render/light_manager.h @@ -15,7 +15,7 @@ namespace systems { -class Device; +class RenderingDevice; } namespace systems @@ -89,7 +89,7 @@ struct LightManager u16 m_UnusedPadding0 = 0; // 02 12 }; - systems::Device *m_Device; + systems::RenderingDevice *m_Device; eastl::vector m_Lights; // We don't need a Directional Light free list. We will just brute force iterate. @@ -113,7 +113,7 @@ struct LightManager ~LightManager() = default; - LightManager(systems::Device &device); + LightManager(systems::RenderingDevice &device); LightManager(LightManager &&other) noexcept; LightManager &operator=(LightManager &&other) noexcept; diff --git a/samples/03_model_render/model_render.cpp b/samples/03_model_render/model_render.cpp index 3e59f97..1cdb46d 100644 --- a/samples/03_model_render/model_render.cpp +++ b/samples/03_model_render/model_render.cpp @@ -17,7 +17,7 @@ #include "aster/util/files.h" #include "aster/systems/commit_manager.h" -#include "aster/systems/device.h" +#include "aster/systems/rendering_device.h" #include "asset_loader.h" #include "light_manager.h" @@ -163,7 +163,7 @@ main(int, char **) }; auto pipelineCacheData = ReadFileBytes(PIPELINE_CACHE_FILE, false); - systems::Device device{{ + systems::RenderingDevice device{{ .m_Window = window, .m_Features = enabledDeviceFeatures, .m_AppName = "ModelRender",