Nebula
Loading...
Searching...
No Matches
vkcommandbuffer.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
10#include "ids/idallocator.h"
11#include "vkloader.h"
13#include "coregraphics/pass.h"
14#include "coregraphics/shader.h"
15
16
17namespace CoreGraphics
18{
19struct PassId;
20struct ShaderProgramId;
21};
22
23namespace Vulkan
24{
25
26
27#if NEBULA_GRAPHICS_DEBUG
28struct NvidiaAftermathCheckpoint
29{
30 Util::String name;
31 NvidiaAftermathCheckpoint* prev;
32 bool push : 1;
33};
34#endif
35
36extern PFN_vkCmdBeginDebugUtilsLabelEXT VkCmdDebugMarkerBegin;
37extern PFN_vkCmdEndDebugUtilsLabelEXT VkCmdDebugMarkerEnd;
38extern PFN_vkCmdInsertDebugUtilsLabelEXT VkCmdDebugMarkerInsert;
39
41const VkCommandPool CmdBufferPoolGetVk(const CoreGraphics::CmdBufferPoolId id);
44
45enum
46{
49};
51
52//------------------------------------------------------------------------------
55static const uint NumPoolTypes = 4;
62
64const VkCommandBuffer CmdBufferGetVk(const CoreGraphics::CmdBufferId id);
66const VkCommandPool CmdBufferGetVkPool(const CoreGraphics::CmdBufferId id);
68const VkDevice CmdBufferGetVkDevice(const CoreGraphics::CmdBufferId id);
69#if NEBULA_GRAPHICS_DEBUG
71Util::Array<NvidiaAftermathCheckpoint> CmdBufferMoveVkNvCheckpoints(const CoreGraphics::CmdBufferId id);
72#endif
73
74enum
75{
84#if NEBULA_ENABLE_PROFILING
85 , CmdBuffer_RecordsMarkers
86 , CmdBuffer_ProfilingMarkers
87 , CmdBuffer_Query
88#endif
89#if NEBULA_GRAPHICS_DEBUG
90 , CmdBuffer_NVCheckpoints
91#endif
92};
93
95{
96 VkGraphicsPipelineCreateInfo pipelineInfo;
97 VkPipelineColorBlendStateCreateInfo blendInfo;
98 VkPipelineMultisampleStateCreateInfo multisampleInfo;
100 VkPipelineLayout computeLayout;
101 VkPipelineLayout graphicsLayout;
102 VkPipelineLayout raytracingLayout;
104 CoreGraphics::ShaderProgramId program;
105};
106
108{
110
116
118
125
126
128 {
129 Util::Array<QueryChunk>& chunks = this->chunks[queryType];
130 QueryState& state = this->states[queryType];
131
132 auto chunkCreator = [&state, &chunks](CoreGraphics::QueryType type) -> QueryChunk&
133 {
134 QueryChunk& newChunk = chunks.Emplace();
135 newChunk.offset = CoreGraphics::AllocateQueries(type, state.chunkSize);
136 newChunk.queryCount = 0;
137 return newChunk;
138 };
139
140 if (!chunks.IsEmpty())
141 {
142 QueryChunk& currentChunk = chunks[state.currentChunk];
143
144 // If chunk is full, get new
145 if (currentChunk.queryCount == state.chunkSize)
146 {
147 QueryChunk& newChunk = chunkCreator(queryType);
148 state.currentChunk++;
149 return newChunk;
150 }
151 return currentChunk;
152 }
153 else
154 {
155 return chunkCreator(queryType);
156 }
157 };
158};
159
165
171
173 0x1000
174 , VkDevice
175 , VkCommandBuffer
176 , VkCommandPool
182#if NEBULA_ENABLE_PROFILING
183 , bool
186#endif
187#if NEBULA_GRAPHICS_DEBUG
189#endif
191
192} // Vulkan
An ID allocator associates an id with a slice in an N number of arrays.
Definition idallocator.h:39
Definition idallocator.h:106
Nebula's dynamic array class.
Definition array.h:60
Implements a fixed size one-dimensional array.
Definition fixedarray.h:20
Acceleration structures are used to enable ray tracing on the GPU by dividing the scene into a BVH.
Definition accelerationstructure.h:24
QueryType
Definition config.h:52
@ NumQueryTypes
Definition config.h:56
QueueType
Definition config.h:40
@ NumQueueTypes
Definition config.h:46
CmdPipelineBuildBits
Definition commandbuffer.h:54
uint AllocateQueries(const CoreGraphics::QueryType type, uint numQueries)
Allocate a range of queries.
Definition vkgraphicsdevice.cc:2060
Vulkan implementation of GPU acceleration structure.
Definition vkaccelerationstructure.cc:15
PFN_vkCmdEndDebugUtilsLabelEXT VkCmdDebugMarkerEnd
Definition vkcommandbufferthread.cc:25
@ CommandBufferPool_VkCommandPool
Definition vkcommandbuffer.h:48
@ CommandBufferPool_VkDevice
Definition vkcommandbuffer.h:47
Ids::IdAllocatorSafe< 0x1000, VkDevice, VkCommandBuffer, VkCommandPool, CoreGraphics::CmdPipelineBuildBits, VkPipelineBundle, ViewportBundle, ScissorBundle, CoreGraphics::QueueType > VkCommandBufferAllocator
Definition vkcommandbuffer.h:190
const VkCommandPool CmdBufferPoolGetVk(const CoreGraphics::CmdBufferPoolId id)
get vk command buffer pool
Definition vkcommandbuffer.cc:37
PFN_vkCmdInsertDebugUtilsLabelEXT VkCmdDebugMarkerInsert
Definition vkcommandbufferthread.cc:26
Ids::IdAllocator< VkDevice, VkCommandPool > VkCommandBufferPoolAllocator
Definition vkcommandbuffer.h:50
@ CmdBuffer_PendingViewports
Definition vkcommandbuffer.h:81
@ CmdBuffer_PipelineBuildBits
Definition vkcommandbuffer.h:79
@ CmdBuffer_VkCommandPool
Definition vkcommandbuffer.h:78
@ CmdBuffer_VkDevice
Definition vkcommandbuffer.h:76
@ CmdBuffer_VkPipelineBundle
Definition vkcommandbuffer.h:80
@ CmdBuffer_VkCommandBuffer
Definition vkcommandbuffer.h:77
@ CmdBuffer_Usage
Definition vkcommandbuffer.h:83
@ CmdBuffer_PendingScissors
Definition vkcommandbuffer.h:82
static const uint NumPoolTypes
Definition vkcommandbuffer.h:55
Vulkan::GraphicsDeviceState state
const VkCommandBuffer CmdBufferGetVk(const CoreGraphics::CmdBufferId id)
Get vk command buffer.
Definition vkcommandbuffer.cc:55
const VkCommandPool CmdBufferGetVkPool(const CoreGraphics::CmdBufferId id)
Get vk command buffer pool.
Definition vkcommandbuffer.cc:65
const VkDevice CmdBufferPoolGetVkDevice(const CoreGraphics::CmdBufferPoolId id)
get vk device that created the pool
Definition vkcommandbuffer.cc:46
const VkDevice CmdBufferGetVkDevice(const CoreGraphics::CmdBufferId id)
Get vk device.
Definition vkcommandbuffer.cc:74
PFN_vkCmdBeginDebugUtilsLabelEXT VkCmdDebugMarkerBegin
Definition vkcommandbufferthread.cc:24
A shader represents an entire shader resource, containing several stages and programs.
Definition commandbuffer.h:155
Definition commandbuffer.h:150
Definition commandbuffer.h:101
Definition pass.h:28
Nebula's universal string class.
Definition string.h:50
Definition vkcommandbuffer.h:57
VkCommandPool pools[CoreGraphics::QueueType::NumQueueTypes][NumPoolTypes]
Definition vkcommandbuffer.h:58
uint queueFamilies[CoreGraphics::QueueType::NumQueueTypes]
Definition vkcommandbuffer.h:59
VkDevice dev
Definition vkcommandbuffer.h:60
Definition vkcommandbuffer.h:112
uint queryCount
Definition vkcommandbuffer.h:114
uint offset
Definition vkcommandbuffer.h:113
Definition vkcommandbuffer.h:120
uint chunkSize
Definition vkcommandbuffer.h:122
uint currentChunk
Definition vkcommandbuffer.h:121
Definition vkcommandbuffer.h:108
QueryState states[CoreGraphics::QueryType::NumQueryTypes]
Definition vkcommandbuffer.h:124
QueryChunk & GetChunk(CoreGraphics::QueryType queryType)
Definition vkcommandbuffer.h:127
bool enabled[CoreGraphics::QueryType::NumQueryTypes]
Definition vkcommandbuffer.h:109
Util::Array< QueryChunk > chunks[CoreGraphics::QueryType::NumQueryTypes]
Definition vkcommandbuffer.h:117
Definition vkcommandbuffer.h:167
uint numPending
Definition vkcommandbuffer.h:169
Util::FixedArray< VkRect2D > scissors
Definition vkcommandbuffer.h:168
Definition vkcommandbuffer.h:161
uint numPending
Definition vkcommandbuffer.h:163
Util::FixedArray< VkViewport > viewports
Definition vkcommandbuffer.h:162
Definition vkcommandbuffer.h:95
VkPipelineLayout raytracingLayout
Definition vkcommandbuffer.h:102
VkGraphicsPipelineCreateInfo pipelineInfo
Definition vkcommandbuffer.h:96
CoreGraphics::PassId pass
Definition vkcommandbuffer.h:103
VkPipelineLayout graphicsLayout
Definition vkcommandbuffer.h:101
VkPipelineMultisampleStateCreateInfo multisampleInfo
Definition vkcommandbuffer.h:98
VkPipelineLayout computeLayout
Definition vkcommandbuffer.h:100
CoreGraphics::ShaderProgramId program
Definition vkcommandbuffer.h:104
CoreGraphics::InputAssemblyKey inputAssembly
Definition vkcommandbuffer.h:99
VkPipelineColorBlendStateCreateInfo blendInfo
Definition vkcommandbuffer.h:97
unsigned int uint
Definition types.h:31
Definition config.h:24