Revert "Remove SIMD for now (#1025)"

This reverts commit f779e13bc8.
This commit is contained in:
Ingvar Stepanyan
2021-05-25 12:04:10 +00:00
committed by Ingvar Stepanyan
parent 31b263fc27
commit dd0adba6b1
4 changed files with 69 additions and 7 deletions

View File

@@ -14,12 +14,18 @@ import type { WebPModule } from 'codecs/webp/enc/webp_enc';
import type { EncodeOptions } from '../shared/meta';
import { initEmscriptenModule } from 'features/worker-utils';
import { simd } from 'wasm-feature-detect';
import wasmUrl from 'url:codecs/webp/enc/webp_enc.wasm';
import wasmUrlWithSIMD from 'url:codecs/webp/enc/webp_enc_simd.wasm';
let emscriptenModule: Promise<WebPModule>;
async function init() {
if (await simd()) {
const webpEncoder = await import('codecs/webp/enc/webp_enc_simd');
return initEmscriptenModule(webpEncoder.default, wasmUrlWithSIMD);
}
const webpEncoder = await import('codecs/webp/enc/webp_enc');
return initEmscriptenModule(webpEncoder.default, wasmUrl);
}