diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-03-06 06:05:17 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-03-06 06:05:17 +0000 |
| commit | 772ef0e6cfbb218814ad4e7d25dd94b697a6b4f3 (patch) | |
| tree | cc60120d48012dc8cd45e27d5f39931bae751d0b /Graphics/GLSLTools | |
| parent | Keep fixing metal back-end (diff) | |
| download | DiligentCore-772ef0e6cfbb218814ad4e7d25dd94b697a6b4f3.tar.gz DiligentCore-772ef0e6cfbb218814ad4e7d25dd94b697a6b4f3.zip | |
Keep fixing Metal backend + few other minor changes
Diffstat (limited to 'Graphics/GLSLTools')
| -rw-r--r-- | Graphics/GLSLTools/include/SPIRVShaderResources.h | 6 | ||||
| -rw-r--r-- | Graphics/GLSLTools/src/SPIRVShaderResources.cpp | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/Graphics/GLSLTools/include/SPIRVShaderResources.h b/Graphics/GLSLTools/include/SPIRVShaderResources.h index 523ccc29..b117c05a 100644 --- a/Graphics/GLSLTools/include/SPIRVShaderResources.h +++ b/Graphics/GLSLTools/include/SPIRVShaderResources.h @@ -28,8 +28,8 @@ // SPIRVShaderResources class uses continuous chunk of memory to store all resources, as follows: // -// m_MemoryBuffer m_TotalResources -// | | +// m_MemoryBuffer m_TotalResources end of names data may not be aligned +// | | | // | Uniform Buffers | Storage Buffers | Storage Images | Sampled Images | Atomic Counters | Separate Samplers | Separate Images | Stage Inputs | Resource Names | #include <memory> @@ -333,6 +333,8 @@ private: // Memory buffer that holds all resources as continuous chunk of memory: // | UBs | SBs | StrgImgs | SmplImgs | ACs | SepSamplers | SepImgs | Stage Inputs | Resource Names | + // | + // end of names data may not be aligned std::unique_ptr< void, STDDeleterRawMem<void> > m_MemoryBuffer; StringPool m_ResourceNames; diff --git a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp index 7289e9fd..82743cfd 100644 --- a/Graphics/GLSLTools/src/SPIRVShaderResources.cpp +++ b/Graphics/GLSLTools/src/SPIRVShaderResources.cpp @@ -28,6 +28,7 @@ #include "ShaderBase.h" #include "GraphicsAccessories.h" #include "StringTools.h" +#include "Align.h" namespace Diligent { @@ -439,10 +440,12 @@ void SPIRVShaderResources::Initialize(IMemoryAllocator& Allocator, VERIFY(NumShaderStageInputs <= MaxOffset, "Max offset exceeded"); m_NumShaderStageInputs = static_cast<OffsetType>(NumShaderStageInputs); + auto AlignedResourceNamesPoolSize = Align(ResourceNamesPoolSize, sizeof(void*)); + static_assert(sizeof(SPIRVShaderResourceAttribs) % sizeof(void*) == 0, "Size of SPIRVShaderResourceAttribs struct must be multiple of sizeof(void*)"); - auto MemorySize = m_TotalResources * sizeof(SPIRVShaderResourceAttribs) + - m_NumShaderStageInputs * sizeof(SPIRVShaderStageInputAttribs) + - ResourceNamesPoolSize * sizeof(char); + auto MemorySize = m_TotalResources * sizeof(SPIRVShaderResourceAttribs) + + m_NumShaderStageInputs * sizeof(SPIRVShaderStageInputAttribs) + + AlignedResourceNamesPoolSize * sizeof(char); VERIFY_EXPR(GetNumUBs() == Counters.NumUBs); VERIFY_EXPR(GetNumSBs() == Counters.NumSBs); |
