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"
6
7namespace Foundation::RHI
8{
9 class VulkanDevice;
10 class VulkanCommandList;
11
13 {
14 protected:
17 vk::raii::CommandPool mCommandPool{nullptr};
19
20 public:
21 VulkanCommandPool(const VulkanDevice& device, PoolDesc const& desc, Allocator* allocator);
22
23 auto const& GetDevice() const { return mDevice; }
24 auto const& GetVkCommandPool() const { return mCommandPool; }
25
27 RHICommandList* GetCommandList(Handle handle) const override;
28 void DestroyCommandList(Handle handle) override;
29
30 void ResetAllCommandLists(bool freeResources) override;
31
32 void DebugSetObjectName(const char* name) override;
33 };
34
35 constexpr size_t kCommandBarrierReserveSize = 256;
36
38 {
39 protected:
41 vk::raii::CommandBuffer mCommandBuffer{nullptr};
43
56
57 // !! XXX: Resources allocated with m_allocator must be destroyed before
58 // the allocator goes down.
59 // VTable can in-fact get corrupted otherwise - we need a better solution
60 // to safeguard this type of issue.
62
64 public:
66
67 [[nodiscard]] auto const& GetVkCommandBuffer() const { return mCommandBuffer; }
68
69 RHICommandList& Begin() override;
70
72 RHICommandList& SetBufferTransition(RHIBuffer* image, TransitionDesc const& desc) override;
73 RHICommandList& SetImageTransition(RHITexture* image, TransitionDesc const& desc) override;
75 TransitionDesc const& desc) override;
76 RHICommandList& EndTransition() override;
77
78 RHICommandList& SetPipeline(PipelineDesc const& desc) override;
81 RHIPipelineState* pipeline,
83 size_t first,
85 RHICommandList& SetViewport(float x, float y, float width, float height, float depth_min = 0.0,
86 float depth_max = 1.0, bool flipY = false) override;
87 RHICommandList& SetScissor(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override;
89 uint32_t first_instance = 0) override;
94 uint32_t stride) override;
97 size_t stride) override;
100 uint32_t cmd_stride) override;
102 Span<const char> data) override;
103 RHICommandList& UpdateBuffer(RHIBuffer* buffer, size_t offset, Span<const char> data) override;
104 RHICommandList& FillBuffer(RHIBuffer* buffer, uint32_t value, size_t offset = 0,
105 size_t size = kFullSize) override;
113 bool compact) override;
114
115 RHICommandList& BeginGraphics(GraphicsDesc const& desc) override;
118 RHICommandList& BindIndexBuffer(RHIBuffer* buffer, size_t offset, RHIResourceFormat format) override;
119 RHICommandList& EndGraphics() override;
120
123
125 RHICommandList& TraceRays(uint32_t width, uint32_t height, uint32_t depth) override;
129 RHIDeviceQueryPool* pool, size_t queryIndex) override;
130 RHICommandList& DebugBegin(const char* message) override;
131 RHICommandList& DebugInsertMarker(const char* message) override;
132 RHICommandList& DebugEnd() override;
133
134 void End() override;
135 void Reset() override;
136
137 void DebugSetObjectName(const char* name) override;
138 };
139}
General Purpose Allocator (GPA) interface.
Definition Allocator.hpp:24
Definition Resource.hpp:57
Definition Command.hpp:42
Definition Command.hpp:18
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:190
Definition Command.hpp:38
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:170
auto const & GetVkCommandBuffer() const
Definition Command.hpp:67
RHICommandList & BindVertexBuffer(uint32_t index, Span< RHIBuffer *const > buffers, Span< const size_t > offsets) override
Definition Command.cpp:429
RHICommandList & BindDescriptorSet(RHIDevicePipelineType bindpoint, RHIPipelineState *pipeline, Span< RHIDeviceDescriptorSet *const > sets, size_t first, Span< const uint32_t > dynamicOffsets) override
Definition Command.cpp:470
RHICommandList & CopyImage(RHITexture *src_image, RHITextureLayout src_layout, RHITexture *dst_image, RHITextureLayout dst_layout, Span< const CopyImageRegion > regions) override
Definition Command.cpp:298
RHICommandList & TraceRays(uint32_t width, uint32_t height, uint32_t depth) override
Definition Command.cpp:537
RHICommandList & SetAccelerationStructureTransition(RHIAccelerationStructure *as, TransitionDesc const &desc) override
Definition Command.cpp:124
RHICommandList & Dispatch(uint32_t group_count_x, uint32_t group_count_y, uint32_t group_count_z) override
Definition Command.cpp:495
void End() override
Definition Command.cpp:572
RHICommandList & DrawMeshTasksIndirectCount(RHIBuffer *cmd_buffer, size_t cmd_offset, RHIBuffer *count_buffer, size_t count_offset, uint32_t max_draw_count, uint32_t cmd_stride) override
Definition Command.cpp:235
RHICommandList & DebugBegin(const char *message) override
Definition Command.cpp:585
UniquePtr< Barriers > mBarriers
Definition Command.hpp:61
RHICommandList & EndTransition() override
Definition Command.cpp:142
RHICommandList & DispatchIndirect(RHIBuffer *cmd_buffer, size_t cmd_offset) override
Definition Command.cpp:504
RHICommandList & Begin() override
Definition Command.cpp:63
RHICommandList & DebugInsertMarker(const char *message) override
Definition Command.cpp:593
RHICommandList & WriteAccelerationStructureCompactedSize(Span< RHIAccelerationStructure *const > as, RHIDeviceQueryPool *pool, size_t queryIndex) override
Definition Command.cpp:558
void DebugSetObjectName(const char *name) override
Definition Command.cpp:608
RHICommandList & DebugEnd() override
Definition Command.cpp:601
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:192
RHICommandList & BindIndexBuffer(RHIBuffer *buffer, size_t offset, RHIResourceFormat format) override
Definition Command.cpp:447
RHICommandList & BeginGraphics(GraphicsDesc const &desc) override
Definition Command.cpp:378
RHICommandList & SetImageTransition(RHITexture *image, TransitionDesc const &desc) override
Definition Command.cpp:101
RHICommandList & EndGraphics() override
Definition Command.cpp:488
RHIPipelineState * mLastPSO
Definition Command.hpp:63
RHICommandList & BuildAccelerationStructure(Span< const RHIAccelerationStructureBuildDesc > desc) override
Definition Command.cpp:512
RHICommandList & SetBufferTransition(RHIBuffer *image, TransitionDesc const &desc) override
Definition Command.cpp:84
RHICommandList & CopyBuffer(RHIBuffer *src_buffer, RHIBuffer *dst_buffer, Span< const CopyBufferRegion > regions) override
Definition Command.cpp:272
RHICommandList & SetPipeline(PipelineDesc const &desc) override
Definition Command.cpp:160
RHICommandList & CopyAccelerationStructure(RHIAccelerationStructure *src, RHIAccelerationStructure *dst, bool compact) override
Definition Command.cpp:363
RHICommandList & CopyBufferToImage(RHIBuffer *src_buffer, RHITexture *dst_image, RHITextureLayout dst_layout, Span< const CopyImageRegion > regions) override
Definition Command.cpp:332
RHICommandList & DrawMeshTasks(uint32_t group_count_x, uint32_t group_count_y, uint32_t group_count_z) override
Definition Command.cpp:219
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:200
RHICommandList & DrawMeshTasksIndirect(RHIBuffer *cmd_buffer, size_t cmd_offset, size_t draw_count, size_t stride) override
Definition Command.cpp:226
const VulkanCommandPool & mCommandPool
Definition Command.hpp:40
RHICommandList & FillBuffer(RHIBuffer *buffer, uint32_t value, size_t offset=0, size_t size=kFullSize) override
Definition Command.cpp:264
RHICommandList & SetScissor(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override
Definition Command.cpp:184
RHICommandList & UpdateBuffer(RHIBuffer *buffer, size_t offset, Span< const char > data) override
Definition Command.cpp:256
vk::raii::CommandBuffer mCommandBuffer
Definition Command.hpp:41
void Reset() override
Definition Command.cpp:579
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:208
Allocator * mAllocator
Definition Command.hpp:42
RHICommandList & WriteTimestamp(RHIDeviceQueryPool *pool, RHIPipelineStageBits stage, uint32_t queryIndex) override
Definition Command.cpp:548
RHICommandList & BeginTransition() override
Definition Command.cpp:75
Definition Command.hpp:13
vk::raii::CommandPool mCommandPool
Definition Command.hpp:17
auto const & GetDevice() const
Definition Command.hpp:23
void DestroyCommandList(Handle handle) override
Definition Command.cpp:44
Allocator * mAllocator
Definition Command.hpp:15
auto const & GetVkCommandPool() const
Definition Command.hpp:24
void ResetAllCommandLists(bool freeResources) override
Definition Command.cpp:46
const VulkanDevice & mDevice
Definition Command.hpp:16
RHICommandPoolScopedHandle< RHICommandList > CreateCommandList() override
Definition Command.cpp:34
RHICommandList * GetCommandList(Handle handle) const override
Definition Command.cpp:39
void DebugSetObjectName(const char *name) override
Definition Command.cpp:26
RHIObjectPool mStorage
Definition Command.hpp:18
Definition Device.hpp:104
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:148
uintptr_t Handle
Definition Details.hpp:8
constexpr size_t kCommandBarrierReserveSize
Definition Command.hpp:35
RHIResourceFormat
Definition Common.hpp:20
static constexpr size_t kFullSize
Definition Common.hpp:8
Vector< vk::ImageMemoryBarrier2 > image
Definition Command.hpp:46
Barriers(Allocator *allocator)
Definition Command.hpp:49
Vector< vk::BufferMemoryBarrier2 > buffer
Definition Command.hpp:47
Definition BindlessSimple.cpp:7