Skip to content

Commit b6c790f

Browse files
committed
[render-graph] Test pipeline wrapper (squash me)
1 parent 82a8ae9 commit b6c790f

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

include/inexor/vulkan-renderer/render_graph.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "inexor/vulkan-renderer/wrapper/device.hpp"
66
#include "inexor/vulkan-renderer/wrapper/fence.hpp"
77
#include "inexor/vulkan-renderer/wrapper/framebuffer.hpp"
8+
#include "inexor/vulkan-renderer/wrapper/pipeline.hpp"
89
#include "inexor/vulkan-renderer/wrapper/semaphore.hpp"
910
#include "inexor/vulkan-renderer/wrapper/shader.hpp"
1011
#include "inexor/vulkan-renderer/wrapper/swapchain.hpp"
@@ -334,7 +335,7 @@ class PhysicalStage : public RenderGraphObject {
334335
friend RenderGraph;
335336

336337
private:
337-
VkPipeline m_pipeline{VK_NULL_HANDLE};
338+
std::unique_ptr<wrapper::GraphicsPipeline> m_pipeline;
338339
VkPipelineLayout m_pipeline_layout{VK_NULL_HANDLE};
339340

340341
protected:
@@ -408,7 +409,7 @@ class RenderGraph {
408409
/// @brief Adds either a render resource or render stage to the render graph.
409410
/// @return A mutable reference to the just-added resource or stage
410411
template <typename T, typename... Args>
411-
T *add(Args &&...args) {
412+
T *add(Args &&... args) {
412413
auto ptr = std::make_unique<T>(std::forward<Args>(args)...);
413414
if constexpr (std::is_same_v<T, BufferResource>) {
414415
return static_cast<T *>(m_buffer_resources.emplace_back(std::move(ptr)).get());

src/vulkan-renderer/render_graph.cpp

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ PhysicalImage::~PhysicalImage() {
5454
}
5555

5656
PhysicalStage::~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

421416
void RenderGraph::compile(const RenderResource *target) {

0 commit comments

Comments
 (0)