diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp index 2a0ae8b5..4681c4ae 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHGraphicsSystem.cpp @@ -909,7 +909,7 @@ namespace SHADE SHGraphicsPredefinedData::SystemType::BATCHING, SHGraphicsPredefinedData::GetShadowMapViState(), rasterState ); - shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, shadowMapFS }); + shadowMapPipeline = tempLibrary.GetGraphicsPipeline({ shadowMapVS, shadowMapFS, newSubpass }); } newSubpass->SetCompanionSubpass(companionSubpass, shadowMapPipeline); // set companion subpass and pipeline diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.cpp index d5aa648d..c337a808 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.cpp @@ -44,8 +44,8 @@ namespace SHADE .srcColorBlendFactor = vk::BlendFactor::eSrcAlpha, .dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha, .colorBlendOp = vk::BlendOp::eAdd, - .srcAlphaBlendFactor = vk::BlendFactor::eOne, - .dstAlphaBlendFactor = vk::BlendFactor::eZero, + .srcAlphaBlendFactor = vk::BlendFactor::eSrcAlpha, + .dstAlphaBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha, .alphaBlendOp = vk::BlendOp::eAdd, .colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA, } @@ -60,7 +60,7 @@ namespace SHADE newPipeline->ConstructPipeline(); // Emplace the new pipeline - graphicsPipelines.emplace (vsFsPair, newPipeline); + graphicsPipelines.emplace (std::make_tuple(vsFsPair.first, vsFsPair.second, subpass), newPipeline); return newPipeline; } @@ -70,19 +70,19 @@ namespace SHADE logicalDevice = device; } - Handle SHPipelineLibrary::GetGraphicsPipeline(std::pair, Handle> const& vsFsPair) noexcept + Handle SHPipelineLibrary::GetGraphicsPipeline(PipelineCombo const& pipelineCombo) noexcept { // return the pipeline requested for - if (graphicsPipelines.contains(vsFsPair)) - return graphicsPipelines.at(vsFsPair); + if (graphicsPipelines.contains(pipelineCombo)) + return graphicsPipelines.at(pipelineCombo); else return {}; } - bool SHPipelineLibrary::CheckGraphicsPipelineExistence(std::pair, Handle> const& vsFsPair) noexcept + bool SHPipelineLibrary::CheckGraphicsPipelineExistence(PipelineCombo const& pipelineCombo) noexcept { // Returns if a pipeline exists or not - return graphicsPipelines.contains(vsFsPair); + return graphicsPipelines.contains(pipelineCombo); } } \ No newline at end of file diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h b/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h index 1a6fc45f..e781d257 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Pipeline/SHPipelineLibrary.h @@ -20,11 +20,13 @@ namespace SHADE private: // TOOD: Move this somewhere eventually. Can use for other things + using PipelineCombo = std::tuple, Handle, Handle>; + //! Logical Device required for creation of pipelines Handle logicalDevice; //! a map of pipelines that are hashed using a pair of shader module handles - std::unordered_map, Handle>, Handle> graphicsPipelines; + std::unordered_map> graphicsPipelines; public: void Init (Handle device) noexcept; @@ -38,8 +40,8 @@ namespace SHADE SHVertexInputState const& viState = SHGraphicsPredefinedData::GetDefaultViState(), SHRasterizationState const& rasterState = SHRasterizationState{} ) noexcept; - Handle GetGraphicsPipeline (std::pair, Handle> const& vsFsPair) noexcept; - bool CheckGraphicsPipelineExistence (std::pair, Handle> const& vsFsPair) noexcept; + Handle GetGraphicsPipeline (PipelineCombo const& pipelineCombo) noexcept; + bool CheckGraphicsPipelineExistence (PipelineCombo const& pipelineCombo) noexcept; }; } diff --git a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp index e5cc231c..34bfe8cd 100644 --- a/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp +++ b/SHADE_Engine/src/Graphics/RenderGraph/SHRenderGraphNode.cpp @@ -688,7 +688,7 @@ namespace SHADE } - Handle pipeline = pipelineLibrary.GetGraphicsPipeline(vsFsPair); + Handle pipeline = pipelineLibrary.GetGraphicsPipeline(std::make_tuple(vsFsPair.first, vsFsPair.second, subpass)); if (!pipeline) { // default to batching system type diff --git a/SHADE_Engine/src/Graphics/SHVkUtil.cpp b/SHADE_Engine/src/Graphics/SHVkUtil.cpp index 040433cb..25a00663 100644 --- a/SHADE_Engine/src/Graphics/SHVkUtil.cpp +++ b/SHADE_Engine/src/Graphics/SHVkUtil.cpp @@ -37,6 +37,7 @@ namespace SHADE case vk::Format::eR32G32Sfloat: case vk::Format::eR32G32B32Sfloat: case vk::Format::eR32G32B32A32Sfloat: + case vk::Format::eB8G8R8A8Unorm: return true; } return false; diff --git a/SHADE_Engine/src/Resource/SHHandle.h b/SHADE_Engine/src/Resource/SHHandle.h index 49dd56b9..b643588e 100644 --- a/SHADE_Engine/src/Resource/SHHandle.h +++ b/SHADE_Engine/src/Resource/SHHandle.h @@ -282,7 +282,17 @@ namespace std template struct hash, SHADE::Handle>> { - std::size_t operator() (std::pair, SHADE::Handle> const& pair) const; + std::size_t operator() (std::pair, SHADE::Handle> const& pair) const; + }; + /// + /// std::hash template specialization for std::pair, Handle> + /// + /// Type for the first Handle. + /// Type for the second Handle. + template + struct hash, SHADE::Handle, SHADE::Handle>> + { + std::size_t operator() (std::tuple, SHADE::Handle, SHADE::Handle> const& tuple) const; }; } diff --git a/SHADE_Engine/src/Resource/SHHandle.hpp b/SHADE_Engine/src/Resource/SHHandle.hpp index ff544d3b..18bc3206 100644 --- a/SHADE_Engine/src/Resource/SHHandle.hpp +++ b/SHADE_Engine/src/Resource/SHHandle.hpp @@ -163,4 +163,15 @@ namespace std { return std::hash{}(pair.first.GetId().Raw) ^ std::hash{}(pair.second.GetId().Raw); } + + template + std::size_t hash, SHADE::Handle, SHADE::Handle>>::operator()( + std::tuple, SHADE::Handle, SHADE::Handle> const& tuple) const + { + return std::hash{}(std::get<0>(tuple).GetId().Raw) + ^ + std::hash{}(std::get<1>(tuple).GetId().Raw) + ^ + std::hash{}(std::get<2>(tuple).GetId().Raw); + } }