2
3
4
5
27 m_InputStrides.clear();
29 m_IndirectCmdsLayout =
nullptr;
38 m_InputBuffer =
nullptr;
39 m_InputStreams.clear();
40 m_PreprocessBuffer =
nullptr;
48 m_InputStrides.push_back(stride);
56 m_InputBuffer = std::make_shared<VulkanBuffer>(
60 VK_BUFFER_USAGE_TRANSFER_DST_BIT ,
61 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
71 VkGeneratedCommandsMemoryRequirementsInfoNV memInfo{};
72 memInfo.sType = VK_STRUCTURE_TYPE_GENERATED_COMMANDS_MEMORY_REQUIREMENTS_INFO_NV;
73 memInfo.maxSequencesCount = m_NSequence;
74 memInfo.indirectCommandsLayout = m_IndirectCmdsLayout->Get();
75 memInfo.pipeline = m_Pipeline->GetPipeline();
76 memInfo.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
78 VkMemoryRequirements2 memReqs{};
79 memReqs.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
81 m_VulkanState.m_VkFunc.vkGetGeneratedCommandsMemoryRequirementsNV(m_VulkanState.m_Device, &memInfo, &memReqs);
83 m_PreprocessBuffer = std::make_shared<VulkanBuffer>(
85 "GDCPreprocessBuffer" ,
86 memReqs.memoryRequirements.size ,
87 VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT ,
88 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
89 VMA_MEMORY_PROPERTY_DEDICATED_MEMORY_BIT
92 m_PreprocessSize = memReqs.memoryRequirements.size;
99 m_LayoutTokens = inputInfos;
102
103
104 VkIndirectCommandsLayoutCreateInfoNV genInfo{};
105 genInfo.sType = VK_STRUCTURE_TYPE_INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NV;
106 genInfo.flags = VK_INDIRECT_COMMANDS_LAYOUT_USAGE_UNORDERED_SEQUENCES_BIT_NV;
107 genInfo.tokenCount =
static_cast<uint32_t>(inputInfos.size());
108 genInfo.pTokens = inputInfos.data();
109 genInfo.streamCount =
static_cast<uint32_t>(m_InputStrides.size());
110 genInfo.pStreamStrides = m_InputStrides.data();
112 m_IndirectCmdsLayout = std::make_shared<VulkanIndirectCommandsLayoutNV>(m_VulkanState, genInfo);
119 m_Pipeline = std::make_shared<VulkanIndirectMeshPipelineNV>(
135
136
137 VkGeneratedCommandsInfoNV info{};
138 info.sType = VK_STRUCTURE_TYPE_GENERATED_COMMANDS_INFO_NV;
139 info.pipeline = m_Pipeline->GetPipeline();
140 info.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
141 info.indirectCommandsLayout = m_IndirectCmdsLayout->Get();
142 info.sequencesCount = m_NSequence;
143 info.streamCount =
static_cast<uint32_t>(m_InputStreams.size());
144 info.pStreams = m_InputStreams.data();
145 info.preprocessBuffer = m_PreprocessBuffer->Get();
146 info.preprocessSize = m_PreprocessSize;
149
150
151 m_VulkanState.m_VkFunc.vkCmdPreprocessGeneratedCommandsNV(cmdBuffer, &info);
161
162
163 VkGeneratedCommandsInfoNV info{};
164 info.sType = VK_STRUCTURE_TYPE_GENERATED_COMMANDS_INFO_NV;
165 info.pipeline = m_Pipeline->GetPipeline();
166 info.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
167 info.indirectCommandsLayout = m_IndirectCmdsLayout->Get();
168 info.sequencesCount = m_NSequence;
169 info.streamCount =
static_cast<uint32_t>(m_InputStreams.size());
170 info.pStreams = m_InputStreams.data();
171 info.preprocessBuffer = m_PreprocessBuffer->Get();
172 info.preprocessSize = m_PreprocessSize;
175
176
177 m_VulkanState.m_VkFunc.vkCmdExecuteGeneratedCommandsNV(cmdBuffer,
true, &info);
#define SPICES_PROFILE_ZONE
This Class is a Wrapper of VulkanBuffer.
void PreprocessDGC(const VkCommandBuffer &cmdBuffer) const
Preprocess with Indirect Command Buffer.
void BuildCommandLayout(const std::vector< VkIndirectCommandsLayoutTokenNV > &inputInfos)
Build CommandLayout.
uint32_t m_PreprocessSize
PreprocessBuffer bytes.
void ResetCommandsLayout()
Reset this CommandsLayout.
std::shared_ptr< VulkanBuffer > CreateInputBuffer(uint32_t size)
Create Input Buffer.
void CreatePreprocessBuffer()
Create Process Buffer.
void ExecuteDGC(const VkCommandBuffer &cmdBuffer) const
Execute Commands in Indirect Command Buffer.
void CreateMeshPipeline(const std::string &pipelineName, const std::string &materialName, PipelineConfigInfo &config)
Build Raytracing Pipeline.
void AddInputStride(uint32_t stride)
Add a stride to m_InputStrides.
VulkanDeviceGeneratedCommandsNV(VulkanState &vulkanState)
Constructor Function. Create VkCommandPool.
void ResetInput()
Reset this Input.
uint32_t m_Strides
DrawCall total Input Strides.
uint32_t m_NSequence
Draw count.
VulkanDeviceGeneratedCommandsNV Class. This class defines the VulkanDeviceGeneratedCommandsNV behaves...
VulkanObject(VulkanState &vulkanState)
Constructor Function. Init member variables.
VulkanObject Class. This class defines the basic behaves of VulkanObject. When we create an new Vulka...
This struct included all infos usd to create a VkPipeline.
This struct contains all Vulkan object in used global.