diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-05-20 21:52:23 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-05-20 21:52:23 +0000 |
| commit | 2b737638bee41bba51b02cbe052734ce1fb45a9e (patch) | |
| tree | 6168e272d8b276b31d72a7b117b371de75e15bc8 /Graphics/GLSLTools | |
| parent | Couple minor updates (diff) | |
| download | DiligentCore-2b737638bee41bba51b02cbe052734ce1fb45a9e.tar.gz DiligentCore-2b737638bee41bba51b02cbe052734ce1fb45a9e.zip | |
Imlemented pipeline compatibility test in Vulkan
Diffstat (limited to 'Graphics/GLSLTools')
| -rw-r--r-- | Graphics/GLSLTools/include/SPIRVShaderResources.h | 14 | ||||
| -rw-r--r-- | Graphics/GLSLTools/src/SPIRVShaderResources.cpp | 27 |
2 files changed, 35 insertions, 6 deletions
diff --git a/Graphics/GLSLTools/include/SPIRVShaderResources.h b/Graphics/GLSLTools/include/SPIRVShaderResources.h index bf90ae2a..58e003e2 100644 --- a/Graphics/GLSLTools/include/SPIRVShaderResources.h +++ b/Graphics/GLSLTools/include/SPIRVShaderResources.h @@ -118,8 +118,10 @@ struct SPIRVShaderResourceAttribs bool IsCompatibleWith(const SPIRVShaderResourceAttribs& Attibs)const { - return ArraySize == Attibs.ArraySize && - Type == Attibs.Type; + return ArraySize == Attibs.ArraySize && + Type == Attibs.Type && + VarType == Attibs.VarType && + (StaticSamplerInd < 0 && Attibs.StaticSamplerInd < 0 || StaticSamplerInd >= 0 && Attibs.StaticSamplerInd >= 0); } }; static_assert(sizeof(SPIRVShaderResourceAttribs) % sizeof(void*) == 0, "Size of SPIRVShaderResourceAttribs struct must be multiple of sizeof(void*)" ); @@ -253,9 +255,9 @@ public: } template<typename THandler> - void ProcessResources(const SHADER_VARIABLE_TYPE *AllowedVarTypes, - Uint32 NumAllowedTypes, - THandler Handler)const + void ProcessResources(const SHADER_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + THandler Handler)const { Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); @@ -269,7 +271,7 @@ public: std::string DumpResources(); - //bool IsCompatibleWith(const ShaderResources &Resources)const; + bool IsCompatibleWith(const SPIRVShaderResources& Resources)const; //size_t GetHash()const; diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp index f2f71e03..c4256b9b 100644 --- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp +++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp @@ -551,4 +551,31 @@ std::string SPIRVShaderResources::DumpResources() return ss.str(); } + + +bool SPIRVShaderResources::IsCompatibleWith(const SPIRVShaderResources& Resources)const +{ + if( GetNumUBs() != Resources.GetNumUBs() || + GetNumSBs() != Resources.GetNumSBs() || + GetNumImgs() != Resources.GetNumImgs() || + GetNumSmplImgs() != Resources.GetNumSmplImgs() || + GetNumACs() != Resources.GetNumACs() || + GetNumSepImgs() != Resources.GetNumSepImgs() || + GetNumSepSmpls() != Resources.GetNumSepSmpls() || + GetNumStaticSamplers() != Resources.GetNumStaticSamplers() ) + return false; + VERIFY_EXPR(GetTotalResources() == Resources.GetTotalResources()); + + bool IsCompatible = true; + ProcessResources(nullptr, 0, + [&](const SPIRVShaderResourceAttribs &Res, Uint32 n) + { + const auto &Res2 = Resources.GetResource(n); + if(!Res.IsCompatibleWith(Res2)) + IsCompatible = false; + }); + + return IsCompatible; +} + } |
