Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"official" support for building msc_basis_transcoder as asm.js instead of wasm? #332

Open
likangning93 opened this issue Oct 16, 2020 · 5 comments

Comments

@likangning93
Copy link

likangning93 commented Oct 16, 2020

Draco includes documentation for building their encoder/decoder to asm.js as a fallback for use cases where WebAssembly isn't available, for example, if a user is required to use Internet Explorer 11: https://github.com/google/draco/blob/master/BUILDING.md#javascript-encoderdecoder

Can this project add official support too? I was able to build a working (in my testing) transcoder by modifying the cmake variable KTX_EMC_LINK_FLAGS to include flags WASM=0 LEGACY_VM_SUPPORT=1 --memory-init-file 0:

    set(
        KTX_EMC_LINK_FLAGS
        --bind
        "SHELL:--source-map-base ./"
        "SHELL:-s ALLOW_MEMORY_GROWTH=1"
        "SHELL:-s ASSERTIONS=0"
        "SHELL:-s MALLOC=emmalloc"
        "SHELL:-s MODULARIZE=1"
        "SHELL:-s FULL_ES3=1"
        "SHELL:-s WASM=0" # for asm.js
        "SHELL:-s LEGACY_VM_SUPPORT=1" # for asm.js
        "SHELL: --memory-init-file 0" # for asm.js
    )

However, this prevents the rest of the build from completing, since it seems there's testing code that still expects the wasm files to exist:

kangning@Emmer:~/src/KTX-Software/build_asm$ cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/kangning/src/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" && cmake --build .
-- Found Bash: /usr/bin/bash  
-- Found Perl: /usr/bin/perl (found version "5.30.0") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kangning/src/KTX-Software/build_asm
Scanning dependencies of target mkvkformatfiles
[  1%] Built target mkvkformatfiles
Scanning dependencies of target ktx_version
[  3%] Generate lib/version.h
[  3%] Built target ktx_version
[  5%] Generate lib/version.h
Scanning dependencies of target ktx
[  6%] Building CXX object CMakeFiles/ktx.dir/lib/basis_transcode.cpp.o
[  8%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/transcoder/basisu_transcoder.cpp.o
[ 10%] Building C object CMakeFiles/ktx.dir/lib/checkheader.c.o
[ 12%] Building C object CMakeFiles/ktx.dir/lib/dfdutils/createdfd.c.o
[ 13%] Building C object CMakeFiles/ktx.dir/lib/dfdutils/colourspaces.c.o
[ 15%] Building C object CMakeFiles/ktx.dir/lib/dfdutils/interpretdfd.c.o
[ 17%] Building C object CMakeFiles/ktx.dir/lib/dfdutils/printdfd.c.o
[ 18%] Building C object CMakeFiles/ktx.dir/lib/dfdutils/queries.c.o
[ 20%] Building C object CMakeFiles/ktx.dir/lib/dfdutils/vk2dfd.c.o
[ 22%] Building CXX object CMakeFiles/ktx.dir/lib/etcdec.cxx.o
[ 24%] Building CXX object CMakeFiles/ktx.dir/lib/etcunpack.cxx.o
[ 25%] Building C object CMakeFiles/ktx.dir/lib/filestream.c.o
[ 27%] Building C object CMakeFiles/ktx.dir/lib/gl_funcs.c.o
[ 29%] Building C object CMakeFiles/ktx.dir/lib/glloader.c.o
[ 31%] Building C object CMakeFiles/ktx.dir/lib/hashlist.c.o
[ 32%] Building C object CMakeFiles/ktx.dir/lib/info.c.o
[ 34%] Building C object CMakeFiles/ktx.dir/lib/memstream.c.o
[ 36%] Building C object CMakeFiles/ktx.dir/lib/strings.c.o
[ 37%] Building C object CMakeFiles/ktx.dir/lib/swap.c.o
[ 39%] Building C object CMakeFiles/ktx.dir/lib/texture.c.o
[ 41%] Building C object CMakeFiles/ktx.dir/lib/texture2.c.o
[ 43%] Building C object CMakeFiles/ktx.dir/lib/vkformat_check.c.o
[ 44%] Building C object CMakeFiles/ktx.dir/lib/vkformat_str.c.o
[ 46%] Building C object CMakeFiles/ktx.dir/lib/texture1.c.o
[ 48%] Building CXX object CMakeFiles/ktx.dir/lib/basis_encode.cpp.o
[ 50%] Building C object CMakeFiles/ktx.dir/lib/basisu/apg_bmp.c.o
[ 51%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_astc_decomp.cpp.o
[ 53%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_backend.cpp.o
[ 55%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_basis_file.cpp.o
[ 56%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_bc7enc.cpp.o
[ 58%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_comp.cpp.o
[ 60%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_enc.cpp.o
[ 62%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_etc.cpp.o
[ 63%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_frontend.cpp.o
[ 65%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_global_selector_palette_helpers.cpp.o
[ 67%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_gpu_texture.cpp.o
[ 68%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_pvrtc1_4.cpp.o
[ 70%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_resample_filters.cpp.o
[ 72%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_resampler.cpp.o
[ 74%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_ssim.cpp.o
[ 75%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/basisu_uastc_enc.cpp.o
[ 77%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/jpgd.cpp.o
[ 79%] Building CXX object CMakeFiles/ktx.dir/lib/basisu/lodepng.cpp.o
[ 81%] Building C object CMakeFiles/ktx.dir/lib/writer1.c.o
[ 82%] Building C object CMakeFiles/ktx.dir/lib/writer2.c.o
[ 84%] Building C object CMakeFiles/ktx.dir/lib/zstddeclib.c.o
[ 86%] Linking CXX static library libktx.a
[ 89%] Built target ktx
Scanning dependencies of target msc_basis_transcoder_js
[ 91%] Building CXX object CMakeFiles/msc_basis_transcoder_js.dir/interface/js_binding/transcoder_wrapper.cpp.o
[ 93%] Linking CXX executable msc_basis_transcoder.js
[ 93%] Built target msc_basis_transcoder_js
Scanning dependencies of target ktx_js
[ 94%] Building CXX object CMakeFiles/ktx_js.dir/interface/js_binding/ktx_wrapper.cpp.o
[ 96%] Linking CXX executable libktx.js
Copy libktx.js and libktx.wasm to tests/webgl
Error copying file "/home/kangning/src/KTX-Software/build_asm/libktx.wasm" to "/home/kangning/src/KTX-Software/tests/webgl".
make[2]: *** [CMakeFiles/ktx_js.dir/build.make:91: libktx.js] Error 1
make[2]: *** Deleting file 'libktx.js'
make[1]: *** [CMakeFiles/Makefile2:157: CMakeFiles/ktx_js.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Ideally for our use case we also wouldn't want to have to monkeypatch KTX-Software every time we update our copy of the transcoder.

@likangning93
Copy link
Author

Ah. Looks like the Draco documentation may be a little bit outdated, but their cmake checks for an IE_COMPATIBLE flag (toggleable as DIE_COMPATIBLE=true on the command line, which is amusing) that adds the legacy support flags.

@atteneder
Copy link
Contributor

Poor souls that have to support IE11 or other legacy browsers (via asm.js) can test the web_legacy_asm_js branch :)

I tested it successfully with Emscripten 1.38.48 fastcomp. Not tested with Emscripten upstream yet.

@likangning93 If this works for you I can create a PR

@atteneder
Copy link
Contributor

atteneder commented Nov 19, 2020

Make sure you follow the asm.js build instructions

@MarkCallow
Copy link
Collaborator

@likangning93 is this still an issue for you? If so, did you test @atteneder 's branch?

@MarkCallow
Copy link
Collaborator

Ping @likangning93. If I don't here from you in a couple of days I'm going to close this as not planned.

KaperD pushed a commit to KaperD/KTX-Software that referenced this issue Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants