This extension allows asynchronous buffer readback in WebGL 2.0.
getBufferSubData
but returns a Promise
instead of an immediate readback result.
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.