Download

Assertion failed: AlignedOffset == TypeLayout.Size

While trying to implement a global shader, I get this error:

Assertion failed: AlignedOffset == TypeLayout.Size [File:D:/Build/++UE4/Sync/Engine/Source/Runtime/Core/Private/Serialization/MemoryImage.cpp] [Line: 224] 
[FMyComputeShader] Calculated Size: 280, Real Size: 288

It appears that the calculated AlignedOffset, and the provided TypeLayout.Size are different. I followed the callstack to see where TypeLayout.Size is being set, but I end up at the IMPLMEMENT_GLOBAL_SHADER macro without ever seeing where/how TypeLayout.Size is set, though I assume that it has to do with the data necessary to store the shader in main memory?

Does anyone have some knowledge as to how Shaders are initialized/compiled? Unsure as to exactly what data in my global shader might influence this TypeLayout.Size, and why there would be discrepancies in the alignment/size.

Update:

I had declared a TRefCountPtr<IPooledRenderTarget> in the shader class (which I’m guessing was the extra 8 bytes). Moving it’s declaration into a function call (making it a stack/local var) fixed the error, though I’m still confused as to where the issue came from.

It seems like the engine just ignored the fact that this variable existed in my shader class.
Any ideas as to where this alignment bug is coming from?