4 ms·
Accommodating how? Everything goes through JS, what they share is basically an ArrayBuffer (if we're talking command buffers) which you can build directly in JS
by 3cats-in-a-coat 3y ago
Accommodating how? Everything goes through JS, what they share is basically an ArrayBuffer (if we're talking command buffers) which you can build directly in JS with the same JIT backend that powers WASM. I went through your article but it doesn't describe how is WASM more "accomodating" to this.
One way or another, the command buffers are an encoding process. They're not WASM code nor JS code, they're GPU code. You need to build them from one platform for another platform. There's no any direct correspondence between WASM and WebGPU, let alone WebGL.
- paulgb 3y agoAccommodating in the sense that in a language where you control the memory layout of objects, you don’t have to explicitly do an explicit encoding step, you can just specify a memory layout that the GPU can understand. This makes it a lot nicer to work with in my experience. Here’s an example of a Rust object with a layout that can be sent directly to a GPU buffer: https://github.com/paulgb/webgl2-glyph/blob/ef5a64a708856d67fe8222da69f6b7754cdd5321/src/vertex.rs#L7 https://github.com/paulgb/webgl2-glyph/blob/ef5a64a708856d67...
- 3cats-in-a-coat 3y agoI wonder if you have an object whose state has that same schema tied to a DataView offset if it'd be much different tbh.
- paulgb 3y agoYou could create a JS object with accessor functions that stores an offset, but the object itself still takes up heap space. In Rust, it would just be a (typed) pointer to the position in the buffer and wouldn't require an allocation.
- 3cats-in-a-coat 3y agoIt's trivial to fix with an ECS layout, but the point is does it matter.