Issue's with shader storage buffer

I am having problems where shader storage buffers are inconsistent with what is actually on the cpu. For example i have a structure in a compute shader:

struct BVHNode
{
    AABB BoundingBox;
    int LeftNode;
     int RightNode;
    bool IsLeaf;
    int Primitive[20];
};

readonly layout(std430, binding = 4) buffer AccelerationStructure
{
	BVHNode nodes[];
} BVHStructure;

which is the same as the structure on the cpu.

struct BVHNode
{
	AABB BoundingBox;
	int LeftNode = -1; //-1 represent null
	int RightNode = -1;
	bool IsLeaf = false;
	int Primitive[20] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
					 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
};

however the IsLeaf variable is set to true within the Nsight debugger and is set to false within my visual studio debugger.

I have made sure that my code is following the alignment rules of std430 using vec4s instead of vec3s etc… however I can’t seem to fix this issue.

I tried using an integer to represnt IsLeaf both on cpp code and in shader, however it seemed to crash my program here

Triangle* TriData = (Triangle*)m_TriangleBuffer.Map();
memmove(TriData, m_TriangleData.data(), m_TriangleData.size() * sizeof(Triangle));
m_TriangleBuffer.UnMap();

BVHNode* nodes = (BVHNode*)m_NodeBuffer.Map();
memmove(nodes, m_Nodes.data(), m_Nodes.size() * sizeof(BVHNode));
m_NodeBuffer.UnMap();

specifically at the line where i am mapping the Triangle buffer. the crash is cased by nvogl64 (nvidia opengl) and it gives me no more information other than that. Map and Unmap are just the

  • glMapNamedBuffer(m_Buffer, GL_WRITE_ONLY) and
  • glUnmap.

I have been stuck on this issue for quite a couple of days now and i am not sure how to go about further debugging it.

also to add the structures have the same size and alignment i just verified in nsight.

I changed the cpp side to be an int:

struct BVHNode
{
	AABB BoundingBox;
	int LeftNode = -1; //-1 represent null
	int RightNode = -1;
	int IsLeaf = false;
	int Primitive[20] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
					 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
};

and then i kept the glsl side as a bool:

struct BVHNode
{
    AABB BoundingBox;
    int LeftNode;
    int RightNode;
    bool IsLeaf;
    int Primitive[20];
};

and that for some reason doesn’t crash. I am still a little confused as to why this is even happening as a bool and an int are the same size according to Nsight.