@@ -54,7 +54,6 @@ PhysicalImage::~PhysicalImage() {
5454}
5555
5656PhysicalStage::~PhysicalStage () {
57- vkDestroyPipeline (m_device.device (), m_pipeline, nullptr );
5857 vkDestroyPipelineLayout (m_device.device (), m_pipeline_layout, nullptr );
5958}
6059
@@ -215,7 +214,7 @@ void RenderGraph::record_command_buffer(const RenderStage *stage, const wrapper:
215214 cmd_buf.bind_vertex_buffers (vertex_buffers);
216215 }
217216
218- cmd_buf.bind_pipeline (physical.m_pipeline );
217+ cmd_buf.bind_pipeline (physical.m_pipeline -> pipeline () );
219218 stage->m_on_record (physical, cmd_buf);
220219
221220 if (graphics_stage != nullptr ) {
@@ -396,26 +395,22 @@ void RenderGraph::build_graphics_pipeline(const GraphicsStage *stage, PhysicalGr
396395 .pScissors = &scissor,
397396 });
398397
399- const auto pipeline_ci = wrapper::make_info<VkGraphicsPipelineCreateInfo>({
400- .stageCount = static_cast <std::uint32_t >(stage->m_shaders .size ()),
401- .pStages = stage->m_shaders .data (),
402- .pVertexInputState = &vertex_input,
403- .pInputAssemblyState = &input_assembly,
404- .pViewportState = &viewport_state,
405- .pRasterizationState = &rasterization_state,
406- .pMultisampleState = &multisample_state,
407- .pDepthStencilState = &depth_stencil,
408- .pColorBlendState = &blend_state,
409- .layout = physical.m_pipeline_layout ,
410- .renderPass = physical.m_render_pass ,
411- });
412-
413- // TODO: Pipeline caching (basically load the render graph from a file)
414- if (const auto result =
415- vkCreateGraphicsPipelines (m_device.device (), nullptr , 1 , &pipeline_ci, nullptr , &physical.m_pipeline );
416- result != VK_SUCCESS) {
417- throw VulkanException (" Error: vkCreateGraphicsPipelines failed for pipeline " + stage->name () + " !" , result);
418- }
398+ physical.m_pipeline = std::make_unique<wrapper::GraphicsPipeline>(
399+ m_device,
400+ wrapper::make_info<VkGraphicsPipelineCreateInfo>({
401+ .stageCount = static_cast <std::uint32_t >(stage->m_shaders .size ()),
402+ .pStages = stage->m_shaders .data (),
403+ .pVertexInputState = &vertex_input,
404+ .pInputAssemblyState = &input_assembly,
405+ .pViewportState = &viewport_state,
406+ .pRasterizationState = &rasterization_state,
407+ .pMultisampleState = &multisample_state,
408+ .pDepthStencilState = &depth_stencil,
409+ .pColorBlendState = &blend_state,
410+ .layout = physical.m_pipeline_layout ,
411+ .renderPass = physical.m_render_pass ,
412+ }),
413+ " graphics pipeline" );
419414}
420415
421416void RenderGraph::compile (const RenderResource *target) {
0 commit comments