Skip to content

Commit 19859be

Browse files
Merge pull request #178 from asuessenbach/12_graphics_pipeline_complete
Use vk::StructureChain on pipeline creation.
2 parents 7d02753 + 301facc commit 19859be

24 files changed

+299
-238
lines changed

attachments/12_graphics_pipeline_complete.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,22 @@ class HelloTriangleApplication {
324324

325325
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
326326

327-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
328-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
329-
.stageCount = 2, .pStages = shaderStages,
330-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
331-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
332-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
333-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
334-
335-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
327+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
328+
{.stageCount = 2,
329+
.pStages = shaderStages,
330+
.pVertexInputState = &vertexInputInfo,
331+
.pInputAssemblyState = &inputAssembly,
332+
.pViewportState = &viewportState,
333+
.pRasterizationState = &rasterizer,
334+
.pMultisampleState = &multisampling,
335+
.pColorBlendState = &colorBlending,
336+
.pDynamicState = &dynamicState,
337+
.layout = pipelineLayout,
338+
.renderPass = nullptr },
339+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
340+
};
341+
342+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
336343
}
337344

338345
[[nodiscard]] vk::raii::ShaderModule createShaderModule(const std::vector<char>& code) const {

attachments/14_command_buffers.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,22 @@ class HelloTriangleApplication {
328328

329329
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
330330

331-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
332-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
333-
.stageCount = 2, .pStages = shaderStages,
334-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
335-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
336-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
337-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
338-
339-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
331+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
332+
{.stageCount = 2,
333+
.pStages = shaderStages,
334+
.pVertexInputState = &vertexInputInfo,
335+
.pInputAssemblyState = &inputAssembly,
336+
.pViewportState = &viewportState,
337+
.pRasterizationState = &rasterizer,
338+
.pMultisampleState = &multisampling,
339+
.pColorBlendState = &colorBlending,
340+
.pDynamicState = &dynamicState,
341+
.layout = pipelineLayout,
342+
.renderPass = nullptr },
343+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
344+
};
345+
346+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
340347
}
341348

342349
void createCommandPool() {

attachments/15_hello_triangle.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,22 @@ class HelloTriangleApplication {
338338

339339
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
340340

341-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
342-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
343-
.stageCount = 2, .pStages = shaderStages,
344-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
345-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
346-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
347-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
348-
349-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
341+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
342+
{.stageCount = 2,
343+
.pStages = shaderStages,
344+
.pVertexInputState = &vertexInputInfo,
345+
.pInputAssemblyState = &inputAssembly,
346+
.pViewportState = &viewportState,
347+
.pRasterizationState = &rasterizer,
348+
.pMultisampleState = &multisampling,
349+
.pColorBlendState = &colorBlending,
350+
.pDynamicState = &dynamicState,
351+
.layout = pipelineLayout,
352+
.renderPass = nullptr },
353+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
354+
};
355+
356+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
350357
}
351358

352359
void createCommandPool() {

attachments/16_frames_in_flight.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,22 @@ class HelloTriangleApplication {
342342

343343
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
344344

345-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
346-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
347-
.stageCount = 2, .pStages = shaderStages,
348-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
349-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
350-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
351-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
352-
353-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
345+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
346+
{.stageCount = 2,
347+
.pStages = shaderStages,
348+
.pVertexInputState = &vertexInputInfo,
349+
.pInputAssemblyState = &inputAssembly,
350+
.pViewportState = &viewportState,
351+
.pRasterizationState = &rasterizer,
352+
.pMultisampleState = &multisampling,
353+
.pColorBlendState = &colorBlending,
354+
.pDynamicState = &dynamicState,
355+
.layout = pipelineLayout,
356+
.renderPass = nullptr },
357+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
358+
};
359+
360+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
354361
}
355362

356363
void createCommandPool() {

attachments/17_swap_chain_recreation.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,22 @@ class HelloTriangleApplication {
369369

370370
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
371371

372-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
373-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
374-
.stageCount = 2, .pStages = shaderStages,
375-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
376-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
377-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
378-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
379-
380-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
372+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
373+
{.stageCount = 2,
374+
.pStages = shaderStages,
375+
.pVertexInputState = &vertexInputInfo,
376+
.pInputAssemblyState = &inputAssembly,
377+
.pViewportState = &viewportState,
378+
.pRasterizationState = &rasterizer,
379+
.pMultisampleState = &multisampling,
380+
.pColorBlendState = &colorBlending,
381+
.pDynamicState = &dynamicState,
382+
.layout = pipelineLayout,
383+
.renderPass = nullptr },
384+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
385+
};
386+
387+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
381388
}
382389

383390
void createCommandPool() {

attachments/18_vertex_input.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,22 @@ class HelloTriangleApplication {
386386

387387
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
388388

389-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
390-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
391-
.stageCount = 2, .pStages = shaderStages,
392-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
393-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
394-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
395-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
396-
397-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
389+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
390+
{.stageCount = 2,
391+
.pStages = shaderStages,
392+
.pVertexInputState = &vertexInputInfo,
393+
.pInputAssemblyState = &inputAssembly,
394+
.pViewportState = &viewportState,
395+
.pRasterizationState = &rasterizer,
396+
.pMultisampleState = &multisampling,
397+
.pColorBlendState = &colorBlending,
398+
.pDynamicState = &dynamicState,
399+
.layout = pipelineLayout,
400+
.renderPass = nullptr },
401+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
402+
};
403+
404+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
398405
}
399406

400407
void createCommandPool() {

attachments/19_vertex_buffer.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,22 @@ class HelloTriangleApplication {
390390

391391
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
392392

393-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
394-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
395-
.stageCount = 2, .pStages = shaderStages,
396-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
397-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
398-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
399-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
400-
401-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
393+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
394+
{.stageCount = 2,
395+
.pStages = shaderStages,
396+
.pVertexInputState = &vertexInputInfo,
397+
.pInputAssemblyState = &inputAssembly,
398+
.pViewportState = &viewportState,
399+
.pRasterizationState = &rasterizer,
400+
.pMultisampleState = &multisampling,
401+
.pColorBlendState = &colorBlending,
402+
.pDynamicState = &dynamicState,
403+
.layout = pipelineLayout,
404+
.renderPass = nullptr },
405+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
406+
};
407+
408+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
402409
}
403410

404411
void createCommandPool() {

attachments/20_staging_buffer.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,22 @@ class HelloTriangleApplication {
390390

391391
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
392392

393-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
394-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
395-
.stageCount = 2, .pStages = shaderStages,
396-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
397-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
398-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
399-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
400-
401-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
393+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
394+
{.stageCount = 2,
395+
.pStages = shaderStages,
396+
.pVertexInputState = &vertexInputInfo,
397+
.pInputAssemblyState = &inputAssembly,
398+
.pViewportState = &viewportState,
399+
.pRasterizationState = &rasterizer,
400+
.pMultisampleState = &multisampling,
401+
.pColorBlendState = &colorBlending,
402+
.pDynamicState = &dynamicState,
403+
.layout = pipelineLayout,
404+
.renderPass = nullptr },
405+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
406+
};
407+
408+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
402409
}
403410

404411
void createCommandPool() {

attachments/21_index_buffer.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,22 @@ class HelloTriangleApplication {
398398

399399
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
400400

401-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
402-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
403-
.stageCount = 2, .pStages = shaderStages,
404-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
405-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
406-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
407-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
408-
409-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
401+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
402+
{.stageCount = 2,
403+
.pStages = shaderStages,
404+
.pVertexInputState = &vertexInputInfo,
405+
.pInputAssemblyState = &inputAssembly,
406+
.pViewportState = &viewportState,
407+
.pRasterizationState = &rasterizer,
408+
.pMultisampleState = &multisampling,
409+
.pColorBlendState = &colorBlending,
410+
.pDynamicState = &dynamicState,
411+
.layout = pipelineLayout,
412+
.renderPass = nullptr },
413+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
414+
};
415+
416+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
410417
}
411418

412419
void createCommandPool() {

attachments/22_descriptor_layout.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,22 @@ class HelloTriangleApplication {
421421

422422
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
423423

424-
vk::PipelineRenderingCreateInfo pipelineRenderingCreateInfo{ .colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format };
425-
vk::GraphicsPipelineCreateInfo pipelineInfo{ .pNext = &pipelineRenderingCreateInfo,
426-
.stageCount = 2, .pStages = shaderStages,
427-
.pVertexInputState = &vertexInputInfo, .pInputAssemblyState = &inputAssembly,
428-
.pViewportState = &viewportState, .pRasterizationState = &rasterizer,
429-
.pMultisampleState = &multisampling, .pColorBlendState = &colorBlending,
430-
.pDynamicState = &dynamicState, .layout = pipelineLayout, .renderPass = nullptr };
431-
432-
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineInfo);
424+
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
425+
{.stageCount = 2,
426+
.pStages = shaderStages,
427+
.pVertexInputState = &vertexInputInfo,
428+
.pInputAssemblyState = &inputAssembly,
429+
.pViewportState = &viewportState,
430+
.pRasterizationState = &rasterizer,
431+
.pMultisampleState = &multisampling,
432+
.pColorBlendState = &colorBlending,
433+
.pDynamicState = &dynamicState,
434+
.layout = pipelineLayout,
435+
.renderPass = nullptr },
436+
{.colorAttachmentCount = 1, .pColorAttachmentFormats = &swapChainSurfaceFormat.format }
437+
};
438+
439+
graphicsPipeline = vk::raii::Pipeline(device, nullptr, pipelineCreateInfoChain.get<vk::GraphicsPipelineCreateInfo>());
433440
}
434441

435442
void createCommandPool() {

0 commit comments

Comments
 (0)