summaryrefslogtreecommitdiffstats
path: root/Graphics/GLSLTools
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-03-06 06:05:17 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-03-06 06:05:17 +0000
commit772ef0e6cfbb218814ad4e7d25dd94b697a6b4f3 (patch)
treecc60120d48012dc8cd45e27d5f39931bae751d0b /Graphics/GLSLTools
parentKeep fixing metal back-end (diff)
downloadDiligentCore-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.h6
-rw-r--r--Graphics/GLSLTools/src/SPIRVShaderResources.cpp9
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);