MCPcopy Create free account
hub / github.com/KomputeProject/kompute / createPipeline

Method createPipeline

src/Algorithm.cpp:227–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227void
228Algorithm::createPipeline()
229{
230 KP_LOG_DEBUG("Kompute Algorithm calling create Pipeline");
231
232 vk::PipelineLayoutCreateInfo pipelineLayoutInfo(
233 vk::PipelineLayoutCreateFlags(),
234 1, // Set layout count
235 this->mDescriptorSetLayout.get());
236
237 vk::PushConstantRange pushConstantRange;
238 if (this->mPushConstantsSize) {
239 pushConstantRange.setStageFlags(vk::ShaderStageFlagBits::eCompute);
240 pushConstantRange.setOffset(0);
241 pushConstantRange.setSize(this->mPushConstantsDataTypeMemorySize *
242 this->mPushConstantsSize);
243
244 pipelineLayoutInfo.setPushConstantRangeCount(1);
245 pipelineLayoutInfo.setPPushConstantRanges(&pushConstantRange);
246 }
247
248 this->mPipelineLayout = std::make_shared<vk::PipelineLayout>();
249 this->mDevice->createPipelineLayout(
250 &pipelineLayoutInfo, nullptr, this->mPipelineLayout.get());
251 this->mFreePipelineLayout = true;
252
253 std::vector<vk::SpecializationMapEntry> specializationEntries;
254
255 for (uint32_t i = 0; i < this->mSpecializationConstantsSize; i++) {
256 vk::SpecializationMapEntry specializationEntry(
257 static_cast<uint32_t>(i),
258 static_cast<uint32_t>(
259 this->mSpecializationConstantsDataTypeMemorySize * i),
260 this->mSpecializationConstantsDataTypeMemorySize);
261
262 specializationEntries.push_back(specializationEntry);
263 }
264
265 // This passes ownership of the memory so we remove ownership from
266 // specialization container by using "transferDataOwnership"
267 vk::SpecializationInfo specializationInfo(
268 static_cast<uint32_t>(specializationEntries.size()),
269 specializationEntries.data(),
270 this->mSpecializationConstantsDataTypeMemorySize *
271 this->mSpecializationConstantsSize,
272 this->mSpecializationConstantsData);
273
274 vk::PipelineShaderStageCreateInfo shaderStage(
275 vk::PipelineShaderStageCreateFlags(),
276 vk::ShaderStageFlagBits::eCompute,
277 *this->mShaderModule,
278 "main",
279 &specializationInfo);
280
281 vk::ComputePipelineCreateInfo pipelineInfo(vk::PipelineCreateFlags(),
282 shaderStage,
283 *this->mPipelineLayout,
284 vk::Pipeline(),

Callers 1

rebuildMethod · 0.95

Calls 2

sizeMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected