Foundation
Loading...
Searching...
No Matches
Command.hpp
Go to the documentation of this file.
1#pragma once
3#include <RHICore/Command.hpp>
4#include "Common.hpp"
5#include "Resource.hpp"
6namespace Foundation::RHI {
7 class VulkanDevice;
8 class VulkanCommandList;
10 protected:
13 vk::raii::CommandPool mCommandPool{ nullptr };
15 public:
16 VulkanCommandPool(const VulkanDevice& device, PoolDesc const& desc, Allocator* allocator);
17
18 auto const& GetDevice() const { return mDevice; }
19 auto const& GetVkCommandPool() const { return mCommandPool; }
20
22 RHICommandList* GetCommandList(Handle handle) const override;
23 void DestroyCommandList(Handle handle) override;
24
25 void ResetAllCommandLists(bool freeResources) override;
26
27 void DebugSetObjectName(const char* name) override;
28 };
29 constexpr size_t kCommandBarrierReserveSize = 256;
31 protected:
33 vk::raii::CommandBuffer mCommandBuffer{ nullptr };
35
45 // !! XXX: Resources allocated with m_allocator must be destroyed before
46 // the allocator goes down.
47 // VTable can in-fact get corrupted otherwise - we need a better solution
48 // to safeguard this type of issue.
50 public:
52
53 [[nodiscard]] auto const& GetVkCommandBuffer() const { return mCommandBuffer; }
54
55 RHICommandList& Begin() override;
56
58 RHICommandList& SetBufferTransition(RHIBuffer* image, TransitionDesc const& desc) override;
59 RHICommandList& SetImageTransition(RHITexture* image, TransitionDesc const& desc) override;
60 RHICommandList& EndTransition() override;
61
62 RHICommandList& SetPipeline(PipelineDesc const& desc) override;
65 RHIPipelineState* pipeline,
67 size_t first,
69 RHICommandList& SetViewport(float x, float y, float width, float height, float depth_min = 0.0, float depth_max = 1.0, bool flipY = false) override;
70 RHICommandList& SetScissor(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override;
75 RHICommandList& DrawMeshTasksIndirect(RHIBuffer* cmd_buffer, size_t cmd_offset, size_t draw_count, size_t stride) override;
76
78 RHICommandList& UpdateBuffer(RHIBuffer* buffer, size_t offset, Span<const char> data) override;
79 RHICommandList& FillBuffer(RHIBuffer* buffer, uint32_t value, size_t offset = 0, size_t size = kFullSize) override;
83
84 RHICommandList& BeginGraphics(GraphicsDesc const& desc) override;
86 RHICommandList& BindIndexBuffer(RHIBuffer* buffer, size_t offset, RHIResourceFormat format) override;
87 RHICommandList& EndGraphics() override;
88
90
92
94 RHICommandList& DebugBegin(const char* message) override;
95 RHICommandList& DebugInsertMarker(const char* message) override;
96 RHICommandList& DebugEnd() override;
97
98 void End() override;
99 void Reset() override;
100
101 void DebugSetObjectName(const char* name) override;
102 };
103}
General Purpose Allocator (GPA) interface.
Definition Allocator.hpp:24
Definition Resource.hpp:48
Definition Command.hpp:35
Definition Command.hpp:14
Definition Device.hpp:164
Thread-safe type-erased handle dereference facility for RHI Objects.
Definition Details.hpp:149
Definition PipelineState.hpp:22
Scoped move-only RAII handle wrapper for RHI Objects.
Definition Details.hpp:86
Definition Resource.hpp:169
Definition Command.hpp:30
RHICommandList & SetViewport(float x, float y, float width, float height, float depth_min=0.0, float depth_max=1.0, bool flipY=false) override
Definition Command.cpp:140
auto const & GetVkCommandBuffer() const
Definition Command.hpp:53
RHICommandList & BindVertexBuffer(uint32_t index, Span< RHIBuffer *const > buffers, Span< const size_t > offsets) override
Definition Command.cpp:369
RHICommandList & BindDescriptorSet(RHIDevicePipelineType bindpoint, RHIPipelineState *pipeline, Span< RHIDeviceDescriptorSet *const > sets, size_t first, Span< const uint32_t > dynamicOffsets) override
Definition Command.cpp:409
RHICommandList & CopyImage(RHITexture *src_image, RHITextureLayout src_layout, RHITexture *dst_image, RHITextureLayout dst_layout, Span< const CopyImageRegion > regions) override
Definition Command.cpp:255
RHICommandList & Dispatch(uint32_t group_count_x, uint32_t group_count_y, uint32_t group_count_z) override
Definition Command.cpp:434
void End() override
Definition Command.cpp:458
RHICommandList & DebugBegin(const char *message) override
Definition Command.cpp:471
UniquePtr< Barriers > mBarriers
Definition Command.hpp:49
RHICommandList & EndTransition() override
Definition Command.cpp:114
RHICommandList & Begin() override
Definition Command.cpp:60
RHICommandList & DebugInsertMarker(const char *message) override
Definition Command.cpp:478
void DebugSetObjectName(const char *name) override
Definition Command.cpp:492
RHICommandList & DebugEnd() override
Definition Command.cpp:485
RHICommandList & Draw(uint32_t vertex_count, uint32_t instance_count=1, uint32_t first_vertex=0, uint32_t first_instance=0) override
Definition Command.cpp:162
RHICommandList & BindIndexBuffer(RHIBuffer *buffer, size_t offset, RHIResourceFormat format) override
Definition Command.cpp:387
RHICommandList & BeginGraphics(GraphicsDesc const &desc) override
Definition Command.cpp:320
RHICommandList & BuildAccelerationStructures(Span< const RayTracingASBuildDesc > desc) override
Definition Command.cpp:442
RHICommandList & SetImageTransition(RHITexture *image, TransitionDesc const &desc) override
Definition Command.cpp:92
RHICommandList & EndGraphics() override
Definition Command.cpp:427
RHICommandList & SetBufferTransition(RHIBuffer *image, TransitionDesc const &desc) override
Definition Command.cpp:76
RHICommandList & CopyBuffer(RHIBuffer *src_buffer, RHIBuffer *dst_buffer, Span< const CopyBufferRegion > regions) override
Definition Command.cpp:229
RHICommandList & SetPipeline(PipelineDesc const &desc) override
Definition Command.cpp:131
RHICommandList & CopyBufferToImage(RHIBuffer *src_buffer, RHITexture *dst_image, RHITextureLayout dst_layout, Span< const CopyImageRegion > regions) override
Definition Command.cpp:289
RHICommandList & DrawMeshTasks(uint32_t group_count_x, uint32_t group_count_y, uint32_t group_count_z) override
Definition Command.cpp:189
RHICommandList & DrawIndexed(uint32_t index_count, uint32_t instance_count=1, uint32_t first_index=0, int32_t vertex_offset=0, uint32_t first_instance=0) override
Definition Command.cpp:170
RHICommandList & DrawMeshTasksIndirect(RHIBuffer *cmd_buffer, size_t cmd_offset, size_t draw_count, size_t stride) override
Definition Command.cpp:196
const VulkanCommandPool & mCommandPool
Definition Command.hpp:32
RHICommandList & FillBuffer(RHIBuffer *buffer, uint32_t value, size_t offset=0, size_t size=kFullSize) override
Definition Command.cpp:221
RHICommandList & SetScissor(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override
Definition Command.cpp:154
RHICommandList & UpdateBuffer(RHIBuffer *buffer, size_t offset, Span< const char > data) override
Definition Command.cpp:214
vk::raii::CommandBuffer mCommandBuffer
Definition Command.hpp:33
void Reset() override
Definition Command.cpp:465
RHICommandList & DrawIndexedIndirectCount(RHIBuffer *buffer, size_t offset, RHIBuffer *count_buffer, size_t count_offset, uint32_t max_draw_count, uint32_t stride) override
Definition Command.cpp:178
Allocator * mAllocator
Definition Command.hpp:34
RHICommandList & WriteTimestamp(RHIDeviceQueryPool *pool, RHIPipelineStageBits stage, uint32_t queryIndex) override
Definition Command.cpp:448
RHICommandList & BeginTransition() override
Definition Command.cpp:69
Definition Command.hpp:9
vk::raii::CommandPool mCommandPool
Definition Command.hpp:13
auto const & GetDevice() const
Definition Command.hpp:18
void DestroyCommandList(Handle handle) override
Definition Command.cpp:41
Allocator * mAllocator
Definition Command.hpp:11
auto const & GetVkCommandPool() const
Definition Command.hpp:19
void ResetAllCommandLists(bool freeResources) override
Definition Command.cpp:43
const VulkanDevice & mDevice
Definition Command.hpp:12
RHICommandPoolScopedHandle< RHICommandList > CreateCommandList() override
Definition Command.cpp:33
RHICommandList * GetCommandList(Handle handle) const override
Definition Command.cpp:37
void DebugSetObjectName(const char *name) override
Definition Command.cpp:25
RHIObjectPool mStorage
Definition Command.hpp:14
Definition Device.hpp:94
std::vector< T, StlAllocator< T > > Vector
std::vector with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:130
std::unique_ptr< T, Deleter > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:166
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:149
std::span< T > Span
Alias for std::span
Definition Container.hpp:60
Low-level Rendering Hardware Interface (RHI) abstractions.
Definition Application.hpp:4
RHITextureLayout
Definition Common.hpp:144
uintptr_t Handle
Definition Details.hpp:8
constexpr size_t kCommandBarrierReserveSize
Definition Command.hpp:29
RHIResourceFormat
Definition Common.hpp:20
static constexpr size_t kFullSize
Definition Common.hpp:8
Vector< vk::ImageMemoryBarrier2 > image
Definition Command.hpp:37
Barriers(Allocator *allocator)
Definition Command.hpp:39
Vector< vk::BufferMemoryBarrier2 > buffer
Definition Command.hpp:38
Definition BindlessSimple.cpp:7