-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
head/tail and back to previous emsdk
- Loading branch information
1 parent
5cc7005
commit 4b01f21
Showing
5 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var Module = function(Module) { | ||
Module = Module || {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
return Module; | ||
}; | ||
(function tryToExport(root, factory) { | ||
if (typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if (typeof define === 'function' && define.amd) | ||
define("twgsl", [], factory); | ||
else if (typeof exports === 'object') | ||
exports["twgsl"] = factory(); | ||
else root["twgsl"] = factory(); | ||
})(typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this, () => { | ||
const initialize = (wasmPath) => { | ||
wasmPath = wasmPath || 'twgsl.wasm' return new Promise(resolve => { | ||
Module({ | ||
locateFile() { | ||
return wasmPath; | ||
}, | ||
onRuntimeInitialized() { | ||
var twgsl = this; | ||
var wgsl = ""; | ||
var textDecoder = new TextDecoder(); | ||
var convertSpirV2WGSL = (code) => { | ||
if (!twgsl._return_string_callback) { | ||
twgsl._return_string_callback = (data, length) => { | ||
const bytes = new Uint8ClampedArray(twgsl.HEAPU8.subarray(data, data + length)); | ||
wgsl = textDecoder.decode(bytes); | ||
}; | ||
} | ||
let addr = twgsl._malloc(code.byteLength); | ||
twgsl.HEAPU32.set(code, addr / 4); | ||
twgsl._spirv_to_wgsl(addr, code.byteLength); | ||
twgsl._free(addr); | ||
return wgsl; | ||
}; | ||
resolve({ | ||
convertSpirV2WGSL: convertSpirV2WGSL, | ||
}); | ||
}, | ||
}); | ||
}); | ||
}; | ||
let instance; | ||
return (wasmPath) => { | ||
if (!instance) { | ||
instance = initialize(wasmPath); | ||
} | ||
return instance; | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters