I had some code that works at the low level that used to work with glm
. I switched all uses of glm
to Eigen
And I am now observing a strange behaviour where the same struct seems to have different alignments at different points in the code.
This is what gdb gives me after initializtion:
(gdb) p sizeof(CellShadingInfo)
$1 = 240
(gdb)
Now let's see the construction of a specific global structure:
const std::unordered_map<std::string, size_t> uniform_size_map = {
{"GuiTransform", sizeof(GuiTransform)},
{"UniformBufferObject", sizeof(UniformBufferObject)},
{"GuiVisualProperties", sizeof(GuiVisualProperties)},
{"PostProcessingEffects", sizeof(PostProcessingEffects)},
{"LineProperties", sizeof(LineProperties)},
{"PointInfo", sizeof(PointInfo)},
{"GaussianVisualization", sizeof(GaussianVisualization)},
{"ParticleUBO", sizeof(ParticleUBO)},
{"CameraInfo", sizeof(CameraInfo)},
{"MVPOnlyUbo", sizeof(MVPOnlyUbo)},
{"WireframeDebugInfo", sizeof(WireframeDebugInfo)},
{"CellShadingInfo", sizeof(CellShadingInfo)},
{"GaussianProperties", sizeof(GaussianProperties)}
};
That's global, so the initialization code for this would run before main. But as the LUP has been defined to be constant, all values in there should be final, thus preventing accidental overwrites.
However according to gdb:
(gdb) p uniform_size_map
$2 = std::unordered_map with 13 elements = {["CellShadingInfo"] = 228, ["MVPOnlyUbo"] = 192, ["ParticleUBO"] = 16,
["GaussianVisualization"] = 48, ["PointInfo"] = 36, ["PostProcessingEffects"] = 8, ["GuiVisualProperties"] = 20,
["GaussianProperties"] = 8, ["CameraInfo"] = 12, ["UniformBufferObject"] = 192, ["WireframeDebugInfo"] = 16,
["LineProperties"] = 40, ["GuiTransform"] = 16}
So the only explanation I have is that the compiler used a different alignment during compilation of preinit methods vs regular runtime. That however sounds ridiculous.