I have tried and failed to find some documentation about using emscripten::val to transfer data in an ArrayBuffer to a c++ function compiled to .wasm.
I found an example from which I took the lines shown below
static texture createFromMemory(const emscripten::val& data)
{
std::vector<uint8_t> bytes{};
bytes.resize(data["byteLength"].as<size_t>());
emscripten::val memory = emscripten::val::module_property("HEAP8")["buffer"];
emscripten::val memoryView = data["constructor"].new_(memory, reinterpret_cast<uintptr_t>(bytes.data()), data["length"].as<uint32_t>());
memoryView.call<void>("set", data);
…
}
but it looks to me as if this is copying that data from the ArrayBuffer to the std::vector.
Is is possible to get a pointer to the data for use by the c++ side without copying, either with embind or with the idl binder? The textures I’m working with here can be *very* large.
Regards
-Mark