What is the size of the GLSL boolean

There is a bool type for shader variables that I would like to use, but I could not find what size it has. This matters because when setting the vertex attribute pointer I specify a data type that may be

 GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, or GL_DOUBLE 

In C ++, usually bool should be the same size as 4 int bytes, but can I assume the same for GLSL or does it only have 1 byte?

+6
source share
1 answer

This is due to the fact that when setting the vertex attribute pointer, I specify the data type, which can be

This does not matter, since the attributes of the vertices cannot be logical. From the GLSL 3.30 specification:

Vertex shader inputs can only be float, floating point vectors, matrices, unsigned integers and integer vectors. Vertex shader inputs can also form arrays of these types, but not structures.

Booleans are not listed on this list.

However, if you want to know what size the GLSL bool corresponds to uniform blocks , it has the same size as uint : 32-bit.

+11
source

Source: https://habr.com/ru/post/909214/


All Articles