Skip to content

Commit

Permalink
Use zeroMemory over HEAPU8.fill. NFC
Browse files Browse the repository at this point in the history
Also, add missing return statement to the legacy path in zeroMemory.
  • Loading branch information
sbc100 committed Oct 10, 2024
1 parent 9e37a10 commit 2b2bcc5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ addToLibrary({
for (var i = 0; i < size; i++) {
HEAPU8[address + i] = 0;
}
return;
return address;
}
#endif
HEAPU8.fill(0, address, address + size);
return address;
return HEAPU8.fill(0, address, address + size);
},

#if SAFE_HEAP
Expand Down
4 changes: 2 additions & 2 deletions src/library_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ var LibraryWebGPU = {
// In webgpu.h offset and size are passed in as size_t.
// And library_webgpu assumes that size_t is always 32bit in emscripten.
wgpuBufferGetMappedRange__deps: ['$warnOnce', 'memalign', 'free'],
wgpuBufferGetMappedRange__deps: ['$warnOnce', '$zeroMemory', 'memalign', 'free'],
wgpuBufferGetMappedRange: (bufferId, offset, size) => {
var bufferWrapper = WebGPU.mgrBuffer.objects[bufferId];
{{{ gpu.makeCheckDefined('bufferWrapper') }}}
Expand Down Expand Up @@ -2052,7 +2052,7 @@ var LibraryWebGPU = {
}
var data = _memalign(16, mapped.byteLength);
HEAPU8.fill(0, data, mapped.byteLength);
zeroMemory(data, mapped.byteLength);
bufferWrapper.onUnmap.push(() => {
new Uint8Array(mapped).set(HEAPU8.subarray(data, data + mapped.byteLength));
_free(data);
Expand Down

0 comments on commit 2b2bcc5

Please sign in to comment.