KhronosGroup/WebGL — pull request #673 by Oletus (2014-08-25 13:57:45+00:00)
Title: Make sure buffer access is synchronized in WebGL 2

Performing reads and writes on a buffer that is currently bound for
transform feedback causes undefined results in GLES3.0 and OpenGL 4.5. In
practice results of reads and writes might be consistent as long as
transform feedback objects are not active, but neither GLES3.0 nor OpenGL
4.5 spec guarantees this - just being bound for transform feedback is
sufficient to cause undefined results.

Address this by adding an error for getBufferSubData when the buffer is
bound to a transform feedback binding point and any transform feedback
object is active. With this error in place, an underlying OpenGL-based
WebGL implementation can ensure correct behavior by unbinding the buffer
from transform feedback prior to mapping it for reading, and then binding
it again for transform feedback once being done with reading.

Also add an error for binding a buffer that is bound to a transform
feedback binding point to another binding point, so that other kinds of
buffer reads and writes with undefined results are not possible. We might
try to relax this rule later if it seems necessary, but it's simpler to
start with some behavior disallowed and later allowing it rather than the
other way around, which could cause backwards compatibility issues.

Also clarify that getBufferSubData returns data that is consistent with
the execution of all prior GL commands. This is technically covered by
GLES3.0 spec section 2.1, but this specific case is hard enough to
interpret that a clarification is warranted.

Related to issue #669.