Page MenuHome

fix T54020: Avoiding an error in openGL's glDrawArrays
Needs ReviewPublic

Authored by Jürgen Tschandl (JuergenT) on Apr 15 2018, 10:24 PM.

Details

Summary

This patch is avoiding an error in an openGL driver, but the comment a few lines lower
in the code: "/* (ton) this code crashes for me when resolv is 86 or higher... no clue */"
tells me that this might not be a problem with my computer only.

I found out, that the error occured in the 228th array-line, just when bit 15 is set for
the first time after calculating row*48*3 (48 vertexes in U-direction, 3 for x, y and z):
227*48*3 = 32688 = 0b0111 1111 1011 0000 (glDrawArrays gets executed correctly)
228*48*3 = 32832 = 0b1000 0000 0100 0000 (crashes)
If this gets expanded to an int64 the upper 48 bits get set, resulting
in an invalid pointer (this is a guess, I do not have the source of the openGL driver).
This error only occurs sometimes in selection mode, never in drawing mode.

I am avoiding the error by adjusting the pointer with "glVertexPointer" every
iteration of the loop (hoping that it just copies the pointer and is not too slow).
On the other hand there is no more dereferencing or multiplication or conditional
branch in the first loop; hoping to speed it up.

Diff Detail

Repository
rB Blender