Aeva / dream_machine

Aeva's Dream Machine ✨
Apache License 2.0
3 stars 0 forks source link

User Data Uploading #17

Open Aeva opened 4 years ago

Aeva commented 4 years ago

A mechanism for user applications to upload data on the fly during rendering.

One possibility is it generates a function per resource, which the user passes in the data they want to upload. The new data probably should just be uploaded into a new buffer, and the results switched out when it is safe to do so. For WebGL, don't think it's possible for user code to run during the animation frame callback, so, that might simplify things.

An alternative interface is there's an uploader function per resource type (eg per struct, and whatever granularity textures might need), and an enum arg is needed as well to route to the right handle or whatever. We already have the uploader functions, so wrapping them in per-resource functions might be fine too.

Next thing is arrays of resources, like VBOs, SSBOs, texture arrays, etc. There isn't an uploader for these because they don't exist yet in any backend. Probably best to just expect a standard container to be used or something.

Lastly, I was previously thinking you'd specify the upload step in the renderer, but that increasingly makes no sense, so maybe that syntax should just be removed.

Aeva commented 4 years ago

Ok, ended up going with something really simple, but I think this will do just fine. Commit d4e227014cb380006de908262bd820de691b68ed implements it. I opted to just generate a single upload function per buffer, which should be called during the user frame callback to push new data. There is no special magic to fake variable length arrays or anything like that.

There's two followups I want to do before I close this: 1) is to remove the render upload syntax object etc, and 2) is to produce a similar interface for texture upload.

Stuff like VBOs and SSBOs should be addressed in separate issues.

Aeva commented 4 years ago

Also the WebGL backend should have something like this before closing this.