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_buffer_get_mapped_range #12

Closed brendan-duncan closed 3 years ago

brendan-duncan commented 3 years ago

If size is not provided, it passes void 0 to getMappedRange, but that doesn't seem to work and results in a 0 sized range. An option is to conditionally call getMappedRange on size being set or not.

if (size)
    gpuBuffer.mappedRanges[offset] = gpuBuffer["getMappedRange"](offset, size);
else
    gpuBuffer.mappedRanges[offset] = gpuBuffer["getMappedRange"](offset);
juj commented 3 years ago

Thanks - some other APIs have this same issue. Marking these kinds of issues with a common label "Awkward polymorphism" to find them easier, maybe the spec might be able to adapt to accommodate for some of these.

Btw, pushed a breaking commit that completes renaming of GPUCanvasContext to GPUPresentationContext, so the function wgpu_canvas_get_canvas_context() is now renamed to wgpu_canvas_get_gpupresent_context().