Search code examples
openglopengl-essamsung-galaxystride

glVertexAttribPointer and stride parameter requirements


I've been having a weird bug on an OpenGL/GLES application I'm developing. On a certain device (Samsung Galaxy S8), it seems glVertexAttribPointer results in jibberish if the stride parameter is set to 18 bytes. The jibberish disappears if I add two bytes of padding to each component (20 bytes in total).

Note that no glGetError is triggered regardless.

This bug does not occur on any other mobile device I've tested on, neither does it occur on my Windows computer running regular OpenGL.

My guess is that the stride is required to be a multiple four bytes, but I cannot seem to find any documentation verifying this.

Does anyone know if there are device specific requirements for the stride parameter?

(The 18 bytes consists of three float32 followed by three int16_t = 3*4bytes + 3*2 bytes)


Solution

  • Is the stride required by the specification to be aligned to 4 bytes? No.

    Is there hardware that effectively has that requirement anyway? Yes, as evidenced by the fact that Vulkan has this requirement. So you should avoid misaligned data.