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

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/B97FFC45-FAED-4413-9558-4A6A0BF7287B%40callow.im.

Attachment: signature.asc
Description: Message signed with OpenPGP

Reply via email to