Hi,
I am trying to check the values for bool, bvec2, bvec3 and bvec4 from shader storage block. But the value of size for all 4 boolean type is same as 4.
My compute shader:
layout(std140) buffer Bool_buffer{
bool a,
bvec2 b;
bvec3 c;
bvec4 d;
}x;
void main(){
x.a=true;
x.b=bvec2(true, false);
x.c=bvec3(true, true, true);
x.d=bvec4(true, true, true, true);
}
Getting correct value for each GL_TYPE for all three as GL_BOOL, GL_BOOL_VEC2, GL_BOOL_VEC3 and GL_BOOL_VEC4.
Some part of code :
GLenum prop[3]={GL_BUFFER_DATA_SIZE, GL_OFFSET, GL_TYPE};
index=glGetProgramResourceIndex(progObj, GL_BUFFER_VARIABLE, "Bool_buffer.d");
glGetProgramResourceiv(progObj, GL_BUFFER_VARIABLE, index, 2, &prop[1], 2*sizeof(GLsizei), &length, params);
Bbuffer = (GLboolean*)malloc(sizeof(params[1]));
Bbuffer = (GLboolean*)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, params[0], sizeof(params[1]), GL_MAP_READ_BIT);
if(*(Bbuffer) != GL_TRUE || *(Bbuffer+1) != GL_TRUE || *(Bbuffer+2) != GL_TRUE || *(Bbuffer+3) != GL_TRUE)
{
printf("Returned wrong value");
}
printf(" size of Bool_buffer.d = %d type 0x%x Value =%d %d %d %d", sizeof(params[1]), params[1], (Bbuffer), *(Bbuffer+1), *(Bbuffer+2), *(Bbuffer+3));
output:
size of Bool_buffer.d = 4 type = 0x8b59 Value =1 0 0 0
On other hand if I print value of (*Bbuffer), *(Bbuffer+4) , *(Bbuffer+8), *(Bbuffer+12) it gives 1 1 1 1.
If the size of bvec4 is 4, how is it possible that it stores the value as
1 0 0 0
1 0 0 0
1 0 0 0
1 0 0 0
Working on opengl 4.3, Nvidia.
Can anyone please comment on it.