KhronosGroup / WebGL

The Official Khronos WebGL Repository
Other
2.65k stars 670 forks source link

WebGL Compositing under specified? #3015

Open greggman opened 4 years ago

greggman commented 4 years ago

I'm probably missing it but the WebGL 2.0 spec doesn't mention compositing at all or at least a search for "compositing" doesn't get any hits.

The WebGL 1.0 spec says

WebGL presents its drawing buffer to the HTML page compositor immediately before a compositing operation, but only if at least one of the following has occurred since the previous compositing operation:

  • Context creation
  • Canvas resize
  • clear, drawArrays, or drawElements has been called while the drawing buffer is the currently bound framebuffer

and later

5.14.11 Writing to the drawing buffer

OpenGL ES 2.0 has 3 calls which can render to the drawing buffer: clear, drawArrays and drawElements. Furthermore rendering can be directed to the drawing buffer or to a Framebuffer object. When rendering is directed to the drawing buffer, making any of the 3 rendering calls shall cause the drawing buffer to be presented to the HTML page compositor at the start of the next compositing operation.

cases not covered include the other forms of draw in WebGL2 drawArraysInstanced, drawElementsInstanced, drawRangeElements, also blitFrambuffer.

Also maybe not ambigous in the spec but if rasterization is disabled. For example gl.colorMask(false, false, false, false) or gl.enable(gl.RASTERIZER_DISCARD) or gl.drawBuffers([gl.NONE]) whether or not compositing should be triggered. As it is it seems like the spec says it should be triggered but it seem counter inituitive that not actually drawing to the canvas would cause a composite operation to be scheduled

kdashg commented 4 years ago

HTML spec talks in terms of "presentation" instead of "compositing", fwiw.

Absent spec language otherwise, colorMask/RASTERIZER_DISCARD/drawBuffers([NONE]) don't prevent draw commands marking a canvas for presentation/composition.

It would be good to spec that drawArrays, drawElements, clear, clearBuffer, blitFramebuffer, and probably invalidate*Framebuffer act the same in this regard.

kenrussell commented 4 years ago

Agreed - it would also be feasible to avoid marking the canvas as needing presentation if RASTERIZER_DISCARD is enabled. However, until reftests are added to the WebGL conformance suite (using the wpt harness), it won't be possible to verify such spec language. Effort should probably first be expended in getting such reftests in place. This would expose issues and prevent regressions in handling of things like the premultipliedAlpha context creation attribute.