Skip to content

Commit

Permalink
head/tail and back to previous emsdk
Browse files Browse the repository at this point in the history
  • Loading branch information
CedricGuillemetMS committed Feb 1, 2023
1 parent 5cc7005 commit 4b01f21
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
cd ..
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk install 3.1.24
- name: Clone DepotTools
run: |
cd ..
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
- name: Build
run: |
cd ../emsdk
./emsdk activate latest
./emsdk activate 3.1.24
source "emsdk_env.sh"
cd ../depot_tools
export PATH=$(pwd):$PATH
Expand Down
2 changes: 2 additions & 0 deletions Core/twgsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ target_compile_options(twgsl PUBLIC "SHELL:-s ALLOW_MEMORY_GROWTH=1")
target_link_libraries(twgsl PRIVATE libtint)
target_link_options(twgsl PRIVATE -s EXPORTED_FUNCTIONS=["_test","_spirv_to_wgsl","_free","_malloc"])
target_link_options(twgsl PRIVATE -s --js-library ${CMAKE_CURRENT_SOURCE_DIR}/Source/callbacks.js)
target_link_options(twgsl PRIVATE --extern-pre-js ${CMAKE_CURRENT_SOURCE_DIR}/head.js)
target_link_options(twgsl PRIVATE --extern-post-js ${CMAKE_CURRENT_SOURCE_DIR}/tail.js)
target_link_options(twgsl PUBLIC "SHELL:-s ALLOW_MEMORY_GROWTH=1")
target_link_options(twgsl PRIVATE -Oz)
target_link_options(twgsl PRIVATE -flto)
2 changes: 2 additions & 0 deletions Core/twgsl/head.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var Module = function(Module) {
Module = Module || {};
49 changes: 49 additions & 0 deletions Core/twgsl/tail.js
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;
};
});
11 changes: 0 additions & 11 deletions Dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,3 @@ option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" OFF)
option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
add_subdirectory(tint EXCLUDE_FROM_ALL)

# Patch compile option
function(tint_patch_compile_options TARGET)
set(COMMON_CLANG_OPTIONS -Wno-unsafe-buffer-usage)
target_compile_options(${TARGET} PRIVATE ${COMMON_CLANG_OPTIONS})
endfunction()

tint_patch_compile_options(tint_diagnostic_utils)
tint_patch_compile_options(tint_utils_io)
tint_patch_compile_options(tint_val)
tint_patch_compile_options(libtint)
tint_patch_compile_options(tint)

0 comments on commit 4b01f21

Please sign in to comment.