Phil Endecott
unread,Mar 5, 2021, 12:04:35 PM3/5/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to emscripte...@googlegroups.com
Dear Experts,
Has anyone tried to use OpenGL transform feedback in Emscripten?
In case you are unfamiliar, transform feedback is a way of
storing the output of a vertex shader into a buffer. This is
useful for a couple of purposes: you can store updated vertex
data and feed that back into the vertex shader for the next
frame (e.g. particle systems), or you can get something like
a compute shader by disabling rasterisation and reading the
transform feedback output buffer's data to the CPU. I'm trying
to do the latter.
I've got something that basically works but I'm unsure how
best to read the results from the transform feedback output
buffer.
I believe OpenGL ES has only glMapBufferRange; WebGL2 has only
getBufferSubData. Emscripten provides glMapBufferRange when
FULL_ES3 is enabled, but that seems only to be for writing to
the buffer, not for reading from it. Currently I have a bit
of EM_JS to wrap getBufferSubData - is this the best solution?:
EM_JS(void, getBufferSubData, (intptr_t addr, size_t length), {
// must length be scaled, as well as addr?
GLctx.getBufferSubData(GLctx.TRANSFORM_FEEDBACK_BUFFER, 0, HEAPF32,
addr >> 2, length);
});
Thanks, Phil.