- Home /
So what's Mesh.UploadMeshData do exactly?
I'm generating a mesh from code. Once I create the mesh it does not get modified; only destroyed and replaced. Should I be calling this function after creating the mesh?
What does it do exactly? Does it immediately upload the data from the RAM to VRAM? Does it clear RAM buffers so as to not waste memory? Isn't this done automatically?
Try to avoid pure speculation, thanks.
Answer by Slight0 · Oct 22, 2014 at 10:11 PM
A dev responded to my forum thread.
His response:
it looks like a documentation bug! Thanks for pointing that out.
It copies the mesh to the GPU memory and frees it from the main memory. Therefore, you will not be able to modify it once it's "uploaded".
[...]
It will only free main memory it occupies if you pass in "true".
Answer by Graham-Dunnett · Oct 21, 2014 at 12:34 PM
Please don't link me to my own thread so that you can get credit for the answer. That's just low. (Unless you were the person in the thread who answered me)
@Slight0: Well you crosslinked this question in the forum thread but you didn't link the forum thread here in your question. So it's quite normal to add the crosslink. Also accepting your own answer won't give you any karma ;)
@Graham Dunnet Yes, but I did the work, so why should you get any credit? Not just that, but I was planning on updating this answer once the forum thread got a response. It had only been a day...
$$anonymous$$y answer also includes the devs response so people don't need to follow some link and parse the thread.
Answer by Bunny83 · Oct 20, 2014 at 10:02 PM
There's no way around pure speculation. Even UploadMeshData has already a doc page (however with a typo in the parameter name), it doesn't have any description and isn't listed in the docs.
It might be an internal method and might be removed or it might become a documented method in the future. Until then we can just guess what exactly it does. Sometimes a Unity staff member explains some internal stuff in the forum, so you might ask the question there. If you have the time to do some benchmarking / testing feel free to try it out.
As for the clearing of the RAM Unity most likely will keep the mesh data in the RAM, even when it got uploaded to the VRAM. The parameter of "UploadMeshData" suggests that when you pass true to markNoLongerReadable might actually clear the RAM, but again that's all speculation since we simply don't know (yet).
I figured someone with inside knowledge might find this question. Like someone who heard it from a dev or someone with full unity source access.
I'll give the forums a shot.