[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Public WebGL] Ambiguity and Non-deterministicness in the WebGL Spec

The spec has changed to effectively require a clear each time the WebGL draw buffer is composited

WebGL presents its drawing buffer to the HTML page compositor immediately before a compositing operation, but only if the drawing buffer has been modified since the last compositing operation. Before the drawing buffer is presented for compositing the implementation shall ensure that all rendering operations have been flushed to the drawing buffer. By default, after compositing the contents of the drawing buffer shall be cleared to their default values. This includes the color buffer as well as the depth and stencil buffers if they are defined

As currently speced though, _javascript_ has no way of knowing when the drawing buffer will be composited and therefore when the buffer will be cleared. For example, if a tab is hidden there may be no compositing operation. If a _javascript_ program is assuming WebGL will clear the buffer for it each time it returns control the browser it may be wrong.

Should the spec be changed to require a clear each time _javascript_ passes control back to the browser rather than the arbitrary only when composited?

Also, the spec says they will be cleared to the default values. I thought there was some discussion about clearing them to whatever the current clear settings are. Was there some reason that was dropped?

I also don't quite understand this part

By setting the preserveDrawingBuffer attribute of the WebGLContextAttributes object to true, the contents of the drawing buffer can be preserved until the author either clears or overwrites them. If this flag is false attempting to perform operations using this context as a source image after the rendering function has returned can lead to undefined behavior. This includes readPixels or toDataURL calls, or using this context as the source image of another context's texImage2D or drawImage call.

That seems counter intuitive. The browser has the pixels. It has to be able to display them. Why do these functions have to have undefined behavior?