Skip to content

Commit 301facc

Browse files
committed
Carry usage of vk::StructureChain on pipeline creation into all chapters
1 parent c71397c commit 301facc

24 files changed

+284
-230
lines changed

attachments/12_graphics_pipeline_complete.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class HelloTriangleApplication {
327327
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
328328

329329
vk::StructureChain<vk::GraphicsPipelineCreateInfo, vk::PipelineRenderingCreateInfo> pipelineCreateInfoChain = {
330-
{ .stageCount = 2,
330+
{.stageCount = 2,
331331
.pStages = shaderStages,
332332
.pVertexInputState = &vertexInputInfo,
333333
.pInputAssemblyState = &inputAssembly,

attachments/14_command_buffers.cpp

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

331331
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
332332

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

344351
void createCommandPool() {

attachments/15_hello_triangle.cpp

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

341341
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
342342

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

354361
void createCommandPool() {

attachments/16_frames_in_flight.cpp

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

345345
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
346346

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

358365
void createCommandPool() {

attachments/17_swap_chain_recreation.cpp

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

372372
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
373373

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

385392
void createCommandPool() {

attachments/18_vertex_input.cpp

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

389389
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
390390

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

402409
void createCommandPool() {

attachments/19_vertex_buffer.cpp

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

393393
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
394394

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

406413
void createCommandPool() {

attachments/20_staging_buffer.cpp

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

393393
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
394394

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

406413
void createCommandPool() {

attachments/21_index_buffer.cpp

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

401401
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
402402

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

414421
void createCommandPool() {

attachments/22_descriptor_layout.cpp

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

424424
pipelineLayout = vk::raii::PipelineLayout( device, pipelineLayoutInfo );
425425

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

437444
void createCommandPool() {

0 commit comments

Comments
 (0)