WEBGL_get_buffer_sub_data_async
WebGL working group (public_webgl 'at' khronos.org)
Kai Ninomiya, Google Inc.
Members of the WebGL working group
Last modified date: May 04, 2018
Revision: 2
WebGL extension #34
Written against the WebGL API 2.0 specification.
This extension allows asynchronous buffer readback in WebGL 2.0.
When this extension is enabled:
getBufferSubData
but returns a Promise
instead of an immediate readback result.
[Exposed=(Window,Worker), LegacyNoInterfaceObject] interface WEBGL_get_buffer_sub_data_async { // Asynchronous version of getBufferSubData which fulfills the returned promise when the data becomes available. Promise<ArrayBuffer> getBufferSubDataAsync(GLenum target, GLintptr srcByteOffset, ArrayBufferView dstBuffer, optional GLuint dstOffset = 0, optional GLuint length = 0); // May throw DOMException };
dstBuffer
.
buf
be the buffer bound to target
at the time
getBufferSubDataAsync
is called.
If length
is 0, let copyLength
be
dstBuffer.length - dstOffset
; otherwise, let
copyLength
be length
.
copyLength
is greater than zero,
copy copyLength
typed elements (each of size dstBuffer.BYTES_PER_ELEMENT
)
from buf
into dstBuffer
,
reading buf
starting at byte index srcByteOffset
and
writing into dstBuffer
starting at element index dstOffset
.
If copyLength
is 0, no data is written to dstBuffer
, but
this does not cause a GL error to be generated.
target
,
an INVALID_OPERATION
error is generated.
target
is TRANSFORM_FEEDBACK_BUFFER
,
and any transform feedback object is currently active,
an INVALID_OPERATION
error is generated.
dstOffset
is greater than dstBuffer.length
,
an INVALID_VALUE
error is generated.
dstOffset + copyLength
is greater than dstBuffer.length
,
an INVALID_VALUE
error is generated.
srcByteOffset
is less than zero,
an INVALID_VALUE
error is generated.
srcByteOffset + copyLength*dstBuffer.BYTES_PER_ELEMENT
is larger than the length of buf
,
an INVALID_OPERATION
is generated.
getBufferSubDataAsync
must run these steps:
promise
be a Promise to be returned.
promise
with an InvalidStateError
.
buf
into the GL command stream, using the range
defined above.
promise
, but continue running these steps in parallel.
dstBuffer
has been neutered,
reject
promise
with an InvalidStateError
. In this case, no GL
error is generated.
dstBuffer
, using the range defined
above.
promise
with dstBuffer
.
dstBuffer
.
getBufferSubDataAsync
is called multiple times in a row with the same
dstBuffer
, then
callbacks added synchronously will never see
results of subsequent getBufferSubDataAsync
calls.
getBufferSubData
, this version may
impose less overhead on applications. Intended use cases include reading pixels into a
pixel buffer object and examining that data on the CPU. It does not force the graphics
pipeline to be stalled as getBufferSubData
does.
Revision 1, 2016/12/13
Revision 2, 2018/05/04