Fixed crash caused by loading incorrect renderpass for subpass replacement

This commit is contained in:
Kah Wei 2023-01-30 16:55:15 +08:00
parent a3ca04535f
commit c2aa067cc4
4 changed files with 15 additions and 15 deletions

View File

@ -92,12 +92,18 @@ namespace SHADE
if (vertShader && fragShader && gfxSystem) if (vertShader && fragShader && gfxSystem)
{ {
// - Retrieve pipeline from pipeline library // - Retrieve pipeline from pipeline library
auto renderPass = gfxSystem->GetPrimaryRenderpass(); auto subPass = gfxSystem->GetUsableSubpass(currentMatSpec->subpassName);
auto subPass = renderPass->GetSubpass(currentMatSpec->subpassName); if (subPass)
auto pipeline = renderPass->GetOrCreatePipeline({ vertShader, fragShader }, subPass); {
// - Set Pipeline // Set Pipeline if valid
auto pipeline = subPass->GetParentNode()->GetOrCreatePipeline({vertShader, fragShader}, subPass);
matHandle->SetPipeline(pipeline); matHandle->SetPipeline(pipeline);
} }
else
{
SHLOG_ERROR("[SHMaterialInspector] Failed to find material subpass of type \"{}\"", currentMatSpec->subpassName);
}
}
} }
// Save Properties // Save Properties

View File

@ -474,7 +474,7 @@ namespace SHADE
*/ */
/***************************************************************************/ /***************************************************************************/
Handle<SHRenderGraphNode> const& SHSubpass::GetParentNode(void) const noexcept Handle<SHRenderGraphNode> SHSubpass::GetParentNode(void) const noexcept
{ {
return parentNode; return parentNode;
} }

View File

@ -159,7 +159,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void SetCompanionSubpass (Handle<SHSubpass> companion, Handle<SHVkPipeline> pipeline) noexcept; void SetCompanionSubpass (Handle<SHSubpass> companion, Handle<SHVkPipeline> pipeline) noexcept;
Handle<SHRenderGraphNode> const& GetParentNode(void) const noexcept; Handle<SHRenderGraphNode> GetParentNode(void) const noexcept;
SHSubPassIndex GetIndex() const noexcept; SHSubPassIndex GetIndex() const noexcept;
Handle<SHSuperBatch> GetSuperBatch(void) const noexcept; Handle<SHSuperBatch> GetSuperBatch(void) const noexcept;
std::vector<vk::AttachmentReference> const& GetColorAttachmentReferences (void) const noexcept; std::vector<vk::AttachmentReference> const& GetColorAttachmentReferences (void) const noexcept;

View File

@ -270,14 +270,8 @@ namespace SHADE
return {}; return {};
} }
// Grab subpass from worldRenderer // Grab subpass
auto renderPass = gfxSystem->GetPrimaryRenderpass(); auto subPass = gfxSystem->GetUsableSubpass(assetData.subpassName);
if (!renderPass)
{
SHLOG_ERROR("[SHResourceManager] Failed to load material as RenderPass could not be found.");
return {};
}
auto subPass = renderPass->GetSubpass(assetData.subpassName);
if (!subPass) if (!subPass)
{ {
SHLOG_ERROR("[SHResourceManager] Failed to load material as SubPass could not be found."); SHLOG_ERROR("[SHResourceManager] Failed to load material as SubPass could not be found.");