juj / wasm_webgpu

System headers for interfacing WebGPU from C programs compiled via Emscripten to WebAssembly
BSD 3-Clause "New" or "Revised" License
331 stars 26 forks source link

wgpu_texture_create_view #5

Closed brendan-duncan closed 3 years ago

brendan-duncan commented 3 years ago

Calls wgpuStoreAndSetParent(view, t); but t doesn't have a derivedObjects member. I did a general fix by changing wgpuStoreAndSetParent to check for and add derivedObjects.

$wgpuStoreAndSetParent: function(object, parent) {
    var id = wgpuStore(object);
    if (!parent.derivedObjects) parent.derivedObjects = [];
    parent.derivedObjects.push(id);
    return id;
  }
juj commented 3 years ago

Pushed above fix that initializes the derivedObjects array for textures so they can accommodate textureviews created from them. That should cater for all parent->child chains (only GPUDevices and GPUTextures act as parents and have child objects created from them, other objects don't)