Ctor for compute pipelines

This commit is contained in:
Brandon Mak 2022-09-23 18:50:40 +08:00
parent 5c4384b589
commit bd54b16e01
5 changed files with 40 additions and 13 deletions

View File

@ -493,9 +493,9 @@ namespace SHADE
*/ */
/***************************************************************************/ /***************************************************************************/
Handle<SHVkPipeline> SHVkLogicalDevice::CreatePipeline(Handle<SHVkPipelineLayout> const& pipelineLayoutHdl, SHVkPipelineState const* const state, Handle<SHVkRenderpass> const& renderpassHdl, Handle<SHSubpass> subpass, SH_PIPELINE_TYPE type) noexcept Handle<SHVkPipeline> SHVkLogicalDevice::CreateGraphicsPipeline(Handle<SHVkPipelineLayout> const& pipelineLayoutHdl, SHVkPipelineState const* const state, Handle<SHVkRenderpass> const& renderpassHdl, Handle<SHSubpass> subpass) noexcept
{ {
return SHVkInstance::GetResourceManager().Create <SHVkPipeline>(GetHandle(), pipelineLayoutHdl, state, renderpassHdl, subpass, type); return SHVkInstance::GetResourceManager().Create <SHVkPipeline>(GetHandle(), pipelineLayoutHdl, state, renderpassHdl, subpass);
} }

View File

@ -21,6 +21,7 @@
#include "Graphics/Descriptors/SHVkDescriptorSetLayout.h" #include "Graphics/Descriptors/SHVkDescriptorSetLayout.h"
#include "Graphics/Images/SHVkImage.h" #include "Graphics/Images/SHVkImage.h"
namespace SHADE namespace SHADE
{ {
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
@ -171,12 +172,11 @@ namespace SHADE
std::string const& shaderName std::string const& shaderName
) noexcept; ) noexcept;
Handle<SHVkPipeline> CreatePipeline ( Handle<SHVkPipeline> CreateGraphicsPipeline (
Handle<SHVkPipelineLayout> const& pipelineLayoutHdl, Handle<SHVkPipelineLayout> const& pipelineLayoutHdl,
SHVkPipelineState const* const state, SHVkPipelineState const* const state,
Handle<SHVkRenderpass> const& renderpassHdl, Handle<SHVkRenderpass> const& renderpassHdl,
Handle<SHSubpass> subpass, Handle<SHSubpass> subpass
SH_PIPELINE_TYPE type
) noexcept; ) noexcept;
Handle<SHVkRenderpass> CreateRenderpass (std::span<vk::AttachmentDescription> const vkDescriptions, std::vector<SHVkSubpassParams> const& subpasses) noexcept; Handle<SHVkRenderpass> CreateRenderpass (std::span<vk::AttachmentDescription> const vkDescriptions, std::vector<SHVkSubpassParams> const& subpasses) noexcept;

View File

@ -18,7 +18,7 @@ namespace SHADE
auto pipelineLayout = logicalDevice->CreatePipelineLayout(params); auto pipelineLayout = logicalDevice->CreatePipelineLayout(params);
// Create the pipeline and configure the default vertex input state // Create the pipeline and configure the default vertex input state
auto newPipeline = logicalDevice->CreatePipeline(pipelineLayout, nullptr, renderpass, subpass, SH_PIPELINE_TYPE::GRAPHICS); auto newPipeline = logicalDevice->CreateGraphicsPipeline(pipelineLayout, nullptr, renderpass, subpass);
newPipeline->GetPipelineState().SetVertexInputState(globalData->GetDefaultViState()); newPipeline->GetPipelineState().SetVertexInputState(globalData->GetDefaultViState());
// Actually construct the pipeline // Actually construct the pipeline

View File

@ -179,7 +179,7 @@ namespace SHADE
/*! /*!
\brief \brief
Non-default ctor. Non-default ctor for creating graphics pipeline.
\param inLogicalDeviceHdl \param inLogicalDeviceHdl
Needed for creation and destruction. Needed for creation and destruction.
@ -200,14 +200,12 @@ namespace SHADE
The subpass that this pipeline will be used in. If state is not The subpass that this pipeline will be used in. If state is not
nullptr, this parameter is ignored. nullptr, this parameter is ignored.
\param type
The type of the pipeline.
*/ */
/***************************************************************************/ /***************************************************************************/
SHVkPipeline::SHVkPipeline(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, Handle<SHVkPipelineLayout> const& inPipelineLayout, SHVkPipelineState const* const state, Handle<SHVkRenderpass> const& renderpassHdl, Handle<SHSubpass> subpass, SH_PIPELINE_TYPE type) noexcept SHVkPipeline::SHVkPipeline(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, Handle<SHVkPipelineLayout> const& inPipelineLayout, SHVkPipelineState const* const state, Handle<SHVkRenderpass> const& renderpassHdl, Handle<SHSubpass> subpass) noexcept
: pipelineState{ } : pipelineState{ }
, pipelineType {type} , pipelineType {SH_PIPELINE_TYPE::GRAPHICS}
, vkPipeline {VK_NULL_HANDLE} , vkPipeline {VK_NULL_HANDLE}
, logicalDeviceHdl{ inLogicalDeviceHdl } , logicalDeviceHdl{ inLogicalDeviceHdl }
, pipelineLayout { inPipelineLayout } , pipelineLayout { inPipelineLayout }
@ -250,6 +248,33 @@ namespace SHADE
vkPipeline = VK_NULL_HANDLE; vkPipeline = VK_NULL_HANDLE;
} }
/***************************************************************************/
/*!
\brief
Just to differentiate between compute and graphics pipeline, we will
have a constructor that takes in less parameters; sufficient for the
compute pipeline to be created.
\param inLogicalDeviceHdl
\param inPipelineLayout
\return
*/
/***************************************************************************/
SHVkPipeline::SHVkPipeline(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl, Handle<SHVkPipelineLayout> const& inPipelineLayout) noexcept
: pipelineState{ }
, pipelineType{ SH_PIPELINE_TYPE::COMPUTE }
, vkPipeline{ VK_NULL_HANDLE }
, logicalDeviceHdl{ inLogicalDeviceHdl }
, pipelineLayout{ inPipelineLayout }
, created{ false }
{
}
/***************************************************************************/ /***************************************************************************/
/*! /*!

View File

@ -51,8 +51,10 @@ namespace SHADE
Handle<SHVkPipelineLayout> const& inPipelineLayout, Handle<SHVkPipelineLayout> const& inPipelineLayout,
SHVkPipelineState const* const state, SHVkPipelineState const* const state,
Handle<SHVkRenderpass> const& renderpassHdl, Handle<SHVkRenderpass> const& renderpassHdl,
Handle<SHSubpass> subpass, Handle<SHSubpass> subpass) noexcept;
SH_PIPELINE_TYPE type) noexcept;
SHVkPipeline(Handle<SHVkLogicalDevice> const& inLogicalDeviceHdl,
Handle<SHVkPipelineLayout> const& inPipelineLayout) noexcept;
SHVkPipeline (SHVkPipeline&& rhs) noexcept; SHVkPipeline (SHVkPipeline&& rhs) noexcept;
~SHVkPipeline (void) noexcept; ~SHVkPipeline (void) noexcept;