CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
VKDevice.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
12#include "VKComputePipeline.hpp"
14#include "VKPipelineLayout.hpp"
15#include "VKRenderPass.hpp"
16#include "VKRenderTarget.hpp"
17#include "VKSampler.hpp"
18#include "VKShader.hpp"
19
22
28
31
32namespace CeresEngine {
33
34 class VKSwapchain;
35 class VKMemoryAllocator;
36
53
66
68 template<typename ObjectType> using VKDeviceObjectCache = VKObjectCache<ObjectType, VKDevice>;
69
70 extern template class VKObjectCache<VKRenderPass, VKDevice>;
74 extern template class VKObjectCache<VKShader, VKDevice>;
75 extern template class VKObjectCache<VKShaderProgram, VKDevice>;
76 extern template class VKObjectCache<VKRenderTarget, VKDevice>;
77 extern template class VKObjectCache<VKSampler, VKDevice>;
78
80 friend class VKCommandQueue;
81
82 private:
85
88
91
94
97
99 ThreadPool mTransferExecutor{1};
100
103
105
106 private:
109
110 private: // Command Queues
113
116
119
120 public: // Caches & shared objects
129
130 private: // Default Objects
134
138
139 private: // Memory Manager
141
142 public:
145
146 public:
149
152
153 public:
156
159
162
165
168
171
174
177
180
183
186
189
192
195
198
199 public: // Default Queues
202
204 [[nodiscard]] GPUCommandQueuePtr getTransferQueue() final;
205
207 [[nodiscard]] GPUCommandQueuePtr getComputeQueue() final;
208
209 public:
210 void update();
211 void wait();
212
213 void didSubmitCommandBuffer(VKCommandBuffer& commandBuffer);
214
215 public:
218 [[nodiscard]] GPUBufferPtr getDummyBuffer() const;
219
222 [[nodiscard]] GPUImagePtr getDummyImage() const;
223
226 [[nodiscard]] GPUSamplerPtr getDummySampler() const;
227
228 public:
230 [[nodiscard]] VKMemoryAllocator& getMemoryAllocator() const { return *mMemoryAllocator; }
231
233 [[nodiscard]] VKRenderAPI& getRenderer() { return mRenderer; }
234
236 [[nodiscard]] VkPhysicalDevice getPhysicalDevice() { return mPhysicalDevice; }
237
238 [[nodiscard]] VkPipelineCache getPipelineCache() const { return mPipelineCache; }
239 [[nodiscard]] const VkPhysicalDeviceProperties& getPhysicalDeviceProperties() const { return mPhysicalDeviceProperties; }
240 [[nodiscard]] const Vector<VkQueueFamilyProperties>& getQueueFamilyProperties() const { return mQueueFamilyProperties; }
241
242 public:
248
254
255 public:
256 VkAllocationCallbacks* allocationCallbacks = nullptr;
257 };
258
259} // namespace CeresEngine
#define CE_EXPLICIT_FALSE
Definition Macros.hpp:416
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
Definition GPUDevice.hpp:357
A helper class that wraps and protects a value from non-synchronized access.
Definition Threading.hpp:516
The thread pool class is an execution context where functions are permitted to run on one of a fixed ...
Definition ThreadPool.hpp:40
The GPUCommandBuffer implementation for the Vulkan RenderAPI.
Definition VKCommandBuffer.hpp:72
Definition VKDevice.hpp:79
UPtr< VKMemoryAllocator > mMemoryAllocator
Definition VKDevice.hpp:140
VkPipelineCache mPipelineCache
Definition VKDevice.hpp:104
GPUPipelineLayoutPtr createPipelineLayout(const GPUPipelineLayoutDescriptor &descriptor) final
VkDevice mDevice
The Vulkan device object.
Definition VKDevice.hpp:90
GPURenderTargetPtr createRenderTarget(const GPURenderTargetDescriptor &descriptor) final
VkPhysicalDeviceProperties mPhysicalDeviceProperties
Definition VKDevice.hpp:107
GPUImagePtr createImage(const GPUImageDescriptor &descriptor) final
VKDeviceExtensionSet enabledExtensions
Definition VKDevice.hpp:144
GPUCommandBufferPtr createCommandBuffer(const GPUCommandBufferDescriptor &descriptor) final
VkPhysicalDevice mPhysicalDevice
The Vulkan physical device that backs the virtual device instance.
Definition VKDevice.hpp:87
GPUShaderPtr createShader(const GPUShaderDescriptor &descriptor) final
GPUBufferPtr createBuffer(const GPUBufferDescriptor &descriptor) final
VKCommandQueuePtr mGraphicsQueue
The Vulkan graphics queue.
Definition VKDevice.hpp:112
GPUCommandQueuePtr getGraphicsQueue() final
GPUGraphicsPipelinePtr createGraphicsPipeline(const GPUGraphicsPipelineDescriptor &descriptor) final
VKDevice(VKRenderAPI &renderer, const GPUDeviceDescriptor &descriptor, VkPhysicalDevice physicalDevice)
Vector< VkQueueFamilyProperties > mQueueFamilyProperties
Definition VKDevice.hpp:108
VKBufferPtr mDummyBuffer
Definition VKDevice.hpp:131
GPUDeviceInfo mInfo
The device information structure.
Definition VKDevice.hpp:93
VKRenderAPI & getRenderer()
Definition VKDevice.hpp:233
LockedObject< Deque< VKCommandBufferPtr > > mPendingCommandBuffers
The set of command buffer currently in execution.
Definition VKDevice.hpp:102
UInt32 findMemoryType(UInt32 typeFilter, VkMemoryPropertyFlags properties)
Finds a suitable memory type.
VkPhysicalDevice getPhysicalDevice()
Definition VKDevice.hpp:236
VKCommandQueuePtr mTransferQueue
The Vulkan presentation queue.
Definition VKDevice.hpp:115
GPUComputePipelinePtr createComputePipeline(const GPUComputePipelineDescriptor &descriptor) final
GPUTimerQueryPtr createTimerQuery(const GPUTimerQueryDescriptor &descriptor) final
const VkPhysicalDeviceProperties & getPhysicalDeviceProperties() const
Definition VKDevice.hpp:239
GPUSwapchainPtr createSwapchain(const GPUSwapchainDescriptor &descriptor) final
GPUSamplerPtr createSampler(const GPUSamplerDescriptor &descriptor) final
VKSwapchainPtr mSwapchain
The device's default swapchain object.
Definition VKDevice.hpp:137
VKSamplerPtr mDummySampler
Definition VKDevice.hpp:133
GPURenderPassPtr createRenderPass(const GPURenderPassDescriptor &descriptor) final
VKImagePtr mDummyImage
Definition VKDevice.hpp:132
static VkPhysicalDevice pickPhysicalDevice(VkInstance instance, const DevicePickerFunc &picker)
Picks a suitable physical device to be used with the renderer.
const VKDeviceExtensionSet supportedExtensions
Definition VKDevice.hpp:143
VkPipelineCache getPipelineCache() const
Definition VKDevice.hpp:238
GPURenderingCapabilities mCapabilities
The device capabilities.
Definition VKDevice.hpp:96
GPUShaderProgramPtr createShaderProgram(const GPUShaderProgramDescriptor &descriptor) final
VKCommandQueuePtr mComputeQueue
The Vulkan compute queue.
Definition VKDevice.hpp:118
GPUFencePtr createFence(const GPUFenceDescriptor &descriptor) final
VKRenderAPI & mRenderer
The owning VKRenderer instance.
Definition VKDevice.hpp:84
friend class VKCommandQueue
Definition VKDevice.hpp:80
const Vector< VkQueueFamilyProperties > & getQueueFamilyProperties() const
Definition VKDevice.hpp:240
GPUOcclusionQueryPtr createOcclusionQuery(const GPUOcclusionQueryDescriptor &descriptor) final
Definition VKMemoryAllocator.hpp:87
A object that caches existing Vulkan objects.
Definition VKCommon.hpp:154
Definition VKCommon.hpp:93
Definition VKRenderAPI.hpp:47
Definition Application.hpp:19
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
std::uint64_t UInt64
Definition DataTypes.hpp:26
auto wait()
Awaits (and blocks) until the continuation has finished running.
Definition Async.hpp:226
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
std::function< bool(const GPUDeviceInfo &, const GPURenderingCapabilities &)> DevicePickerFunc
Callback interface for the createDevice method.
Definition RenderAPI.hpp:79
Hardware buffer descriptor structure.
Definition GPUBuffer.hpp:92
Command buffer descriptor structure.
Definition GPUCommandBuffer.hpp:32
Compute pipeline descriptor structure.
Definition GPUComputePipeline.hpp:25
Device descriptor structure.
Definition GPUDevice.hpp:313
Renderer basic information structure.
Definition GPUDevice.hpp:330
Definition GPUFence.hpp:23
Definition GPUGraphicsPipeline.hpp:721
Definition GPUImage.hpp:247
Definition GPUQuery.hpp:171
Pipeline layout descriptor structure.
Definition GPUPipelineLayout.hpp:70
Render pass descriptor structure.
Definition GPURenderPass.hpp:112
Definition GPURenderTarget.hpp:78
Structure with all attributes describing the rendering capabilities of the render system.
Definition GPUDevice.hpp:269
Image sampler descriptor structure.
Definition GPUSampler.hpp:61
Shader source and binary code descriptor structure.
Definition GPUShader.hpp:193
Descriptor structure for shader programs.
Definition GPUShader.hpp:303
Swapchain descriptor structure.
Definition GPUSwapchain.hpp:50
A descriptor structure for TimerQuery.
Definition GPUQuery.hpp:29
Definition VKDevice.hpp:37
Vector< String > enabledExtensions
List of enabled Vulkan extensions.
Definition VKDevice.hpp:46
Vector< String > enabledLayers
List of enabled Vulkan layers.
Definition VKDevice.hpp:51
UInt64 preferredLargeHeapBlockSize
Preferred size of a single VkDeviceMemory block to be allocated from large heaps > 1 GiB.
Definition VKDevice.hpp:41
Definition VKDevice.hpp:54
bool debugMarker
Definition VKDevice.hpp:56
Vector< VkExtensionProperties > properties
Definition VKDevice.hpp:55
VKDeviceExtensionSet(Vector< VkExtensionProperties > properties)
bool operator[](StringView name) const
VKDeviceExtensionSet(VkPhysicalDevice device)
VKDeviceExtensionSet extract(const Vector< const char * > &extensions) const