CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
VKCommandBuffer.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "VKCommon.hpp"
11
14
18
20
21namespace CeresEngine {
22
28
30// Allocator mAllocator{
31// sizeof(RC<GPUObject>) * 200,
32// gVKAllocator(),
33// };
35
38// Allocator::marker mMarker = mAllocator.top();
39
42
43 public:
46
51
54
55 public:
58 void track(GPUObject* resource) { mResources.emplace_back(resource); }
59
62 void track(GPUObject& resource) { track(&resource); }
63
65 void reset() {
66 mResources.clear();
67// mAllocator.unwind(mMarker);
68 }
69 };
70
72 class VKCommandBuffer final : public GPUCommandBuffer, public VKDeviceObject<VKCommandBuffer, GPUCommandBuffer> {
73 friend class VKCommandQueue;
74 friend class VKGraphicsPipeline;
75 friend class VKComputePipeline;
76 friend class VKRenderPass;
77 friend class VKTimerQuery;
78
79 private:
82
85
88
91
95
98
101
106
107 private:
110
113
114 private: // Current State
119
120 public:
123
127
130
132 static void* operator new(size_t size) noexcept;
133
135 static void operator delete(void* p, std::size_t size) noexcept;
136
139
140 public:
143
145 void bindVertexBuffer(GPUBuffer& vertexBuffer, UInt32 offset = 0, UInt32 slot = 0) final;
146
149
151 void draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) final;
152
155
157 void drawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) final;
158
161
164
165 public: // Dynamic States
168
171
174
177
178 public: // Mesh-shaders
181
184
187
188 public: // Buffer read, write & copy.
191
194
197
198 public: // Image read, write & copy.
202
205 const TExtent3<UInt32>& extent) final;
206
210
213 const TExtent3<UInt32>& extent) final;
214
216 void clear(GPUImage& image) final;
217
220
223
224 public:
226 void barrier(GPUImage& image, GPUImageLayout layout) final;
227
228 public:
230 void begin() final;
231
233 void end() final;
234
236 void wait() final;
237
238 public:
240
242 void reset();
243
250 };
251
252} // namespace CeresEngine
#define CE_EXPLICIT_FALSE
Definition Macros.hpp:416
Definition GPUBuffer.hpp:124
Definition GPUCommandBuffer.hpp:77
GPUDevice & device
The owning device this object was created from.
Definition Common.hpp:55
Definition GPUImage.hpp:331
Definition Common.hpp:16
A RenderAPI object that holds a set of resources that can be bound into shader.
Definition GPUResourceSet.hpp:735
const Descriptor & descriptor
A structure that describes the object and it's properties.
Definition Common.hpp:69
The GPUCommandBuffer implementation for the Vulkan RenderAPI.
Definition VKCommandBuffer.hpp:72
VKGraphicsPipeline * mGraphicsPipeline
Definition VKCommandBuffer.hpp:117
void copyImageFromBuffer(GPUImage &dstImage, const GPUImageRegion &dstRegion, GPUBuffer &srcBuffer, std::uint64_t srcOffset, std::uint32_t rowStride=0, std::uint32_t layerStride=0) final
void copyBufferFromImage(GPUBuffer &dstBuffer, std::uint64_t dstOffset, GPUImage &srcImage, const GPUImageRegion &srcImageRegion, std::uint32_t rowStride=0, std::uint32_t layerStride=0) final
void barrier(GPUImage &image, GPUImageLayout layout) final
void bindVertexBuffer(GPUBuffer &vertexBuffer, UInt32 offset=0, UInt32 slot=0) final
VKCommandBufferTracker mTrackedState
The tracked state for the submitted command buffer.
Definition VKCommandBuffer.hpp:97
void bindResourceSet(GPUResourceSet &resourceSet, UInt32 firstSet=0, Int32 offset=-1) final
void resolveImage(GPUImage &dstImage, const GPUImageLocation &dstLocation, GPUImage &srcImage, const GPUImageLocation &srcLocation, const TExtent3< UInt32 > &extent) final
VKCommandBuffer(VKDevice &device, VKCommandQueue &commandQueue, const GPUCommandBufferDescriptor &descriptor)
void copyImage(GPUImage &dstImage, const GPUImageLocation &dstLocation, GPUImage &srcImage, const GPUImageLocation &srcLocation, const TExtent3< UInt32 > &extent) final
void drawMeshTasks(UInt32 groupCountX, UInt32 groupCountY, UInt32 groupCountZ) final
Draw mesh task work items.
const GPUCommandBufferDescriptor mDescriptorVK
A structure that describes the command buffer and it's properties.
Definition VKCommandBuffer.hpp:81
VkCommandPool mCommandPool
The command pool used to allocate commands on the queue.
Definition VKCommandBuffer.hpp:87
bool tryFinish()
A method called internally on every frame to check if the buffer has finished execution on the GPU.
void setScissors(const SmallVector< Scissor, 16 > &scissors) final
void setScissor(const Scissor &scissor) final
static Allocator & getAllocator() noexcept
Returns the allocator for VKCommandBuffer.
void drawIndexed(UInt32 indexCount, UInt32 instanceCount=1, UInt32 firstVertex=0, Int32 vertexOffset=0, UInt32 firstInstance=0) final
VKRenderPass * mRenderPass
Definition VKCommandBuffer.hpp:116
void setViewports(const SmallVector< Viewport, 16 > &viewports) final
void clear(GPUImage &image) final
void fillBuffer(GPUBuffer &dstBuffer, std::uint64_t dstOffset, std::uint32_t value, std::uint64_t fillSize=~0u) final
void bindIndexBuffer(GPUBuffer &indexBuffer, UInt32 offset=0, IndexType indexType=IndexType::UInt32) final
void generateMips(GPUImage &image) final
SmallVector< VKImage *, 16, VKAllocator > mImages
The list of render targets used on the command buffer.
Definition VKCommandBuffer.hpp:109
Vector< VKTimerQuery *, VKAllocator > mTimerQueries
The list of timer queries submitted on this command buffer.
Definition VKCommandBuffer.hpp:112
void updateBuffer(GPUBuffer &dstBuffer, std::uint64_t dstOffset, const void *data, std::uint16_t dataSize) final
void reset()
Resets the active command buffer.
void copyBuffer(GPUBuffer &dstBuffer, std::uint64_t dstOffset, GPUBuffer &srcBuffer, std::uint64_t srcOffset, std::uint64_t size) final
void setViewport(const Viewport &viewport) final
void draw(UInt32 vertexCount, UInt32 instanceCount=1, UInt32 firstVertex=0, UInt32 firstInstance=0) final
VkPipelineBindPoint mPipelineBindPoint
The current pipeline bind point.
Definition VKCommandBuffer.hpp:100
VkFence mCompletionFence
A fence that must be signalled to indicate that the command buffer as finished execution.
Definition VKCommandBuffer.hpp:94
VKRenderTarget * mRenderTarget
Definition VKCommandBuffer.hpp:115
VKCommandQueue & mCommandQueue
The command queue that owns this command buffer.
Definition VKCommandBuffer.hpp:84
VKObjectAllocator Allocator
An allocator type used to allocate new VKCommandBuffer instances from a memory pool.
Definition VKCommandBuffer.hpp:126
VkCommandBuffer mCommandBuffer
The current active command buffer.
Definition VKCommandBuffer.hpp:90
Promise mCompletionPromise
A promise to be fulfilled once the command buffer has completed execution.
Definition VKCommandBuffer.hpp:105
void drawMeshTasksIndirect(GPUBuffer &buffer, UInt64 offset, UInt32 drawCount, UInt32 stride) final
Issue an indirect mesh tasks draw into a command buffer.
VKComputePipeline * mComputePipeline
Definition VKCommandBuffer.hpp:118
A helper class that keeps track of any resource so that they remain alive for as long as Vulkan needs...
Definition VKCommandBuffer.hpp:25
void reset()
Resets any tracked state.
Definition VKCommandBuffer.hpp:65
void track(GPUObject &resource)
Tracks a resource by reference.
Definition VKCommandBuffer.hpp:62
Deque< RC< GPUObject >, Allocator > mResources
The marker that points to the top of the allocator before it allocates anything.
Definition VKCommandBuffer.hpp:41
~VKCommandBufferTracker()
Destroys the tracker and releases any resource that may be tracked.
Definition VKCommandBuffer.hpp:53
VKCommandBufferTracker(VKCommandBufferTracker &&)=default
VKCommandBufferTracker & operator=(VKCommandBufferTracker &&)=default
VKCommandBufferTracker & operator=(const VKCommandBufferTracker &)=delete
Allocator mAllocator
An allocator that stores the state of tracked objects.
Definition VKCommandBuffer.hpp:34
VKCommandBufferTracker()=default
Creates a new empty tracker.
void track(GPUObject *resource)
Tracks a resource by pointer.
Definition VKCommandBuffer.hpp:58
VKCommandBufferTracker(const VKCommandBufferTracker &)=delete
Definition VKCommandQueue.hpp:28
Definition VKComputePipeline.hpp:21
Definition VKDevice.hpp:79
Definition VKCommon.hpp:143
Definition VKGraphicsPipeline.hpp:29
Definition VKRenderPass.hpp:24
Definition VKRenderTarget.hpp:23
The Vulkan implementation of TimerQuery.
Definition VKTimerQuery.hpp:22
Definition Application.hpp:19
std::deque< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Deque
Deque (double-ended queue) is an indexed sequence container that allows fast insertion and deletion a...
Definition Deque.hpp:20
std::uint64_t UInt64
Definition DataTypes.hpp:26
VKAllocator & gVKAllocator()
GPUImageLayout
Definition GPUImage.hpp:65
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
std::int32_t Int32
Definition DataTypes.hpp:21
sfl::small_vector< T, N, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > SmallVector
SmallVector is a sequence container similar to Vector.
Definition SmallVector.hpp:31
ThreadSafeAllocator< MemoryPool< NodePool, AllocatorReference< VKAllocator > > > VKObjectAllocator
A pool allocator to be used for individual object pools.
Definition VKCommon.hpp:59
cti::promise< Args... > Promise
Defines a non-copyable promise type which is using the function2 backend for type erasure.
Definition Async.hpp:28
std::uint32_t UInt32
Definition DataTypes.hpp:23
DefaultAllocator VKAllocator
Definition VKCommon.hpp:55
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668
Definition Allocator.hpp:66
Command buffer descriptor structure.
Definition GPUCommandBuffer.hpp:32
Structure specifying a draw indirect command.
Definition GPUCommandBuffer.hpp:59
Structure specifying a draw indirect command.
Definition GPUCommandBuffer.hpp:44
Image location structure: MIP-map level and offset.
Definition GPUImage.hpp:120
Image region structure: Subresource (MIP-map level and array layer range), offset,...
Definition GPUImage.hpp:156
Image subresource descriptor which specifies the array layer and MIP-map level range of a image resou...
Definition GPUImage.hpp:77
Definition IndexType.hpp:20
Definition GPUGraphicsPipeline.hpp:281
Definition GPUGraphicsPipeline.hpp:214