Skip to content

Commit

Permalink
Pipelines now share ownership of their pipeline-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
stuart6854 committed Dec 11, 2023
1 parent 3d42735 commit 91a8249
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion samples_app/src/samples/HelloTriangle/HelloTriangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace VkMana::SamplesApp
.Fragment = fragSpirvOpt.value(),
.Topology = vk::PrimitiveTopology::eTriangleList,
.ColorTargetFormats = { vk::Format::eB8G8R8A8Srgb },
.Layout = pipelineLayout.Get(),
.Layout = pipelineLayout,
};
m_pipeline = ctx.CreateGraphicsPipeline(pipelineInfo);

Expand Down
2 changes: 1 addition & 1 deletion samples_app/src/samples/ModelLoading/ModelLoading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace VkMana::SamplesApp
.Topology = vk::PrimitiveTopology::eTriangleList,
.ColorTargetFormats = { vk::Format::eB8G8R8A8Srgb },
.DepthTargetFormat = vk::Format::eD24UnormS8Uint,
.Layout = m_pipelineLayout.Get(),
.Layout = m_pipelineLayout,
};
m_pipeline = ctx.CreateGraphicsPipeline(pipelineInfo);
if (m_pipeline == nullptr)
Expand Down
6 changes: 3 additions & 3 deletions samples_app/src/samples/Sandbox/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace VkMana::SamplesApp
.Topology = vk::PrimitiveTopology::eTriangleList,
.ColorTargetFormats = { positionImageInfo.Format, normalImageInfo.Format, albedoImageInfo.Format },
.DepthTargetFormat = depthImageInfo.Format,
.Layout = m_gBufferPipelineLayout.Get(),
.Layout = m_gBufferPipelineLayout,
};
m_gBufferStaticPipeline = m_ctx->CreateGraphicsPipeline(pipelineInfo);

Expand Down Expand Up @@ -227,7 +227,7 @@ namespace VkMana::SamplesApp
.Fragment = fragmentSpirvOpt.value(),
.Topology = vk::PrimitiveTopology::eTriangleList,
.ColorTargetFormats = { compositionImageInfo.Format },
.Layout = m_compositionPipelineLayout.Get(),
.Layout = m_compositionPipelineLayout,
};
m_compositionPipeline = m_ctx->CreateGraphicsPipeline(pipelineInfo);
}
Expand Down Expand Up @@ -270,7 +270,7 @@ namespace VkMana::SamplesApp
.Fragment = fragmentSpirvOpt.value(),
.Topology = vk::PrimitiveTopology::eTriangleList,
.ColorTargetFormats = { vk::Format::eB8G8R8A8Srgb },
.Layout = m_screenPipelineLayout.Get(),
.Layout = m_screenPipelineLayout,
};
m_screenPipeline = m_ctx->CreateGraphicsPipeline(pipelineInfo);
}
Expand Down
4 changes: 2 additions & 2 deletions src/VkMana/CommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace VkMana

void CommandBuffer::SetPushConstants(vk::ShaderStageFlags shaderStages, uint32_t offset, uint32_t size, const void* data)
{
m_cmd.pushConstants(m_pipeline->GetLayout(), shaderStages, offset, size, data);
m_cmd.pushConstants(m_pipeline->GetLayout()->GetLayout(), shaderStages, offset, size, data);
}

void CommandBuffer::BindDescriptorSets(
Expand All @@ -123,7 +123,7 @@ namespace VkMana
for (auto i = 0u; i < sets.size(); ++i)
descSets[i] = sets[i]->GetSet();

m_cmd.bindDescriptorSets(m_pipeline->GetBindPoint(), m_pipeline->GetLayout(), firstSet, descSets, dynamicOffsets);
m_cmd.bindDescriptorSets(m_pipeline->GetBindPoint(), m_pipeline->GetLayout()->GetLayout(), firstSet, descSets, dynamicOffsets);
}

void CommandBuffer::BindIndexBuffer(const Buffer* buffer, uint64_t offsetBytes, vk::IndexType indexType)
Expand Down
2 changes: 1 addition & 1 deletion src/VkMana/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ namespace VkMana
pipelineInfo.setPNext(&renderingInfo);
auto pipeline = m_device.createGraphicsPipeline({}, pipelineInfo).value; // #TODO: Pipeline Cache

return IntrusivePtr(new Pipeline(this, info.Layout->GetLayout(), pipeline, vk::PipelineBindPoint::eGraphics));
return IntrusivePtr(new Pipeline(this, info.Layout, pipeline, vk::PipelineBindPoint::eGraphics));
}

auto Context::CreateImage(ImageCreateInfo info, const ImageDataSource* initialData) -> ImageHandle
Expand Down
2 changes: 1 addition & 1 deletion src/VkMana/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace VkMana
m_ctx->DestroyPipeline(m_pipeline);
}

Pipeline::Pipeline(Context* context, vk::PipelineLayout layout, vk::Pipeline pipeline, vk::PipelineBindPoint bindPoint)
Pipeline::Pipeline(Context* context, const IntrusivePtr<PipelineLayout>& layout, vk::Pipeline pipeline, vk::PipelineBindPoint bindPoint)
: m_ctx(context)
, m_layout(layout)
, m_pipeline(pipeline)
Expand Down
6 changes: 3 additions & 3 deletions src/VkMana/Pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace VkMana
vk::Format DepthTargetFormat = vk::Format::eUndefined;
vk::Format StencilTargetFormat = vk::Format::eUndefined;

PipelineLayout* Layout = nullptr;
IntrusivePtr<PipelineLayout> Layout = nullptr;
};

class PipelineLayout : public IntrusivePtrEnabled<PipelineLayout>
Expand Down Expand Up @@ -80,11 +80,11 @@ namespace VkMana
private:
friend class Context;

Pipeline(Context* context, vk::PipelineLayout layout, vk::Pipeline pipeline, vk::PipelineBindPoint bindPoint);
Pipeline(Context* context, const IntrusivePtr<PipelineLayout>& layout, vk::Pipeline pipeline, vk::PipelineBindPoint bindPoint);

private:
Context* m_ctx;
vk::PipelineLayout m_layout;
IntrusivePtr<PipelineLayout> m_layout;
vk::Pipeline m_pipeline;
vk::PipelineBindPoint m_bindPoint;
};
Expand Down

0 comments on commit 91a8249

Please sign in to comment.