Transform Feedback - getBufferSubData

141 views
Skip to first unread message

Phil Endecott

unread,
Mar 5, 2021, 12:04:35 PM3/5/21
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.




Sam Clegg

unread,
Mar 5, 2021, 2:49:44 PM3/5/21
to emscripte...@googlegroups.com
I'm not a webgl expert but it looks like something that could/should be added to  library_webgl2.js.

Maybe could even just be added to the list of pass through functions at the end?

cheers,
sam 


Thanks, Phil.




--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/1614963871702%40dmwebmail.dmwebmail.chezphil.org.

Jukka Jylänki

unread,
Mar 26, 2021, 5:11:19 AM3/26/21
to emscripte...@googlegroups.com
Good find, added PR
https://github.com/emscripten-core/emscripten/pull/13776 to add the
missing function.

pe 5. maalisk. 2021 klo 21.49 'Sam Clegg' via emscripten-discuss
(emscripte...@googlegroups.com) kirjoitti:
> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29mMr-g0JHTdtRpgACdztJ7UVkyFrKv6kGG26sitB480Q%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages