Commit Graph
62 Commits
Author SHA1 Message Date
Ben Polinsky b15211474d Add opt-in WebGL builds that do not use eval()/new Function()
With the default DYNAMIC_EXECUTION=1, embind generates its invokers at
runtime with new Function(). A Content-Security-Policy without
'unsafe-eval' blocks this, so the transcoder and encoder fail to start
with an EvalError.

Add two CMake options to webgl/transcoder and webgl/encoder:

- NO_DYNAMIC_EXECUTION (default OFF) adds -s DYNAMIC_EXECUTION=0.
- EMBIND_AOT (default ON, only used with NO_DYNAMIC_EXECUTION) adds
  -s EMBIND_AOT=1. This generates the invokers at build time, so
  embind calls stay as fast as with the default build.

The default build does not change. The .wasm output is byte-identical
in all configurations; only the JS glue changes.

Fixes #464
2026-10-19 09:51:05 -04:00
Ben Polinsky 25e094e81d Fix missing cPackUASTC* constants in the WebGL encoder
The cPackUASTC* values are members of an anonymous enum. embind's
constant() registers a constant against the type of its value, and no
binding exists for an anonymous enum type. embind therefore waits for
that type forever, and the constants never appear on the module.
Module.cPackUASTCLevelDefault and the others are undefined in the
shipped basis_encoder.js.

Cast the values to uint32_t so that they bind as plain numbers.
EMBIND_AOT=1 makes this a link error ("Missing binding for type"), so
this change is also necessary to build the encoder with that flag.
2026-10-19 09:51:05 -04:00
Richard Geldreich 38168767f4 rebuilt artifacts 2026-07-18 18:11:39 -04:00
Richard Geldreich fecef375e7 Compression parameter rename: renaming m_xuastc_ldr_channel_weights[] to m_ldr_channel_weights[] (it's no longer XUASTC/ASTC specific, it's also used for XUBC7 and DDS creation) 2026-07-03 22:03:05 -04:00
Richard Geldreich 77677a5fd9 rebuilt artifacts 2026-07-01 13:52:13 -04:00
Richard Geldreich 6bec299da1 modified for v2.5 2026-07-01 12:59:35 -04:00
Richard Geldreich 1e9ab1f575 rebuilt artifacts 2026-04-20 03:21:02 -04:00
Richard Geldreich 2280b753ce rebuilt artifacts 2026-04-20 03:00:48 -04:00
Richard Geldreich b642cfa07b rebuilt all artifacts 2026-04-03 22:20:27 -04:00
Richard Geldreich 08fabab89f - fixing tinydds so it writes the correct flags, so dds-ktx can view our DDS files
- upping WebGL KTX2 encoder/transcoder testbed so its max Memory64/WASM64 heap size is 15GB, so 4096x4096 textures can be encoded
2026-03-20 17:34:22 -04:00
Richard Geldreich ab824725f9 rebuilt artifacts 2026-03-06 17:44:20 -05:00
Richard Geldreich 4209505964 rebuild artifacts 2026-02-28 22:27:18 -05:00
Richard Geldreich 81a4186404 v2.1 update for KTX-Software and Khronos file format KTX2 compatibility.
This update impacts the UASTC HDR 4x4, UASTC HDR 6x6i, and XUASTC LDR formats. New KTX2 files in these specific formats using v2.1 can't be loaded using v2.0, however we've kept backwards compatibility with all of our previously written KTX2 files. (v2.1 can transcode all previously written files.)
This is part of our effort to be compatible with Khronos's specification.
bc6hf encoder's smooth block path updated to handle inputs with texels close to MAX_HALF_FLOAT.
Adding command line options to basisu tool so it can write either v2.0 or v1.6 compatible UASTC HDR 6x6i files. The default is v1.6.
Updating WebGL KTX2 testbed so on ASTC devices it automatically switches between sRGB or linear internal formats for the created texture.
2026-02-24 20:35:11 -05:00
Rich Geldreich 136ac0185c Update README.md 2026-02-19 18:14:24 -05:00
Rich Geldreich 7cb7d1560e Update README.md 2026-02-19 18:13:57 -05:00
Rich Geldreich df1677b716 Update README.md 2026-02-19 18:13:07 -05:00
Richard Geldreich a6bf1c00f2 rebuilt 2026-01-19 02:22:47 -05:00
Richard Geldreich e93d3beb36 merging v2.0 from xuastc_private 2026-01-19 01:59:54 -05:00
Aaron Franke f3a63a3f54 Remove trailing space characters 2025-11-21 11:52:38 -08:00
Richard Geldreich 5179a06343 rebuild WASM 2025-11-18 17:24:25 -05:00
Richard Geldreich b1110111d4 adding -O3 to wasm linker options 2025-09-20 10:41:16 -04:00
Rich Geldreich 1e8fbb14fb Merge pull request #401 from needle-tools/fix/add-link-flags-o3
Fix: bring back -O3 in LINK_FLAGS for 150kB smaller JS+WASM build
2025-09-20 10:34:30 -04:00
Richard Geldreich e8855f8840 Compiler warning fixes.
Cleaning up handling of 8-byte lengths/offsets in KTX2 files. (In practice, we don't currently accept files this large anyway.)
2025-09-20 10:10:08 -04:00
hybridherbst 3393721250 Fix: bring back -O3 in LINK_FLAGS for 150kB smaller JS+WASM build 2025-09-11 10:24:46 +02:00
Richard Geldreich 100ace82d2 emcc warning fixes, fixing warnings in WASM cmakelists.txt files, changing ETC1S encoder to use std::map vs. std::unordered_map for hopefully more cross platform determinism 2025-06-24 17:22:05 -04:00
Richard Geldreich 1fda84839f disabling asserts 2025-01-21 12:26:18 -05:00
Richard Geldreich 1ba75b4e34 ASTC 6x6 HDR/6x6 HDR intermediate update 2025-01-21 11:01:08 -05:00
Richard Geldreich be46a0e4c2 UASTC HDR changes 2024-09-10 14:31:34 -04:00
Richard Geldreich 89b682b97d removing old files 2024-09-10 14:22:07 -04:00
Richard Geldreich 7a2094b807 Adding SAN option to CMakeLists.txt, to make it easier to use clang's address/undefined behavior sanitizer on codebase
Fixing overflow issue on extreme colors in color_distance().
Explicitly disabling unaligned addressing in miniz and transcoder when UBSAN is enabled
Disabling a needless optimization in transcoder causing ubsan issues (that could have easily been worked around in a different way, but it was an unnecessary optimization to begin with)
Rebuild wasm builds
2022-02-24 19:45:01 -05:00
Richard Geldreich deeb5acb56 v1.16 release: OpenCL support, removing global selector palette code (it was unused/dead code), ETC1S encoding optimizations, -parallel command line option 2022-01-28 08:32:54 -05:00
Rich Geldreich 7f0a00afe1 Adding KTX2 transcoding/encoding/decompression to PNG/KTX1 support to the transcoder, encoder, JavaScript wrappers. This is also adding Zstandard to the repo, which is optional. Set BASISD_SUPPORT_KTX2_ZSTD=0 when compiling the encoder/transcoder to disable it, or from cmake set KTX2_ZSTANDARD=FALSE. 2021-04-12 13:30:45 -04:00
Rich Geldreich 2d4fe933b2 Basis Universal v1.13:
- Optimized ETC1S encoder (3-4.5x faster)
- Added optional SSE 4.1 support to encoder
- Switched from std::vector to a custom vector in the encoder and transcoder
- Added CppSPMD (SSE only for now)
- UASTC RDO is now more effective, but the command line parameter controlling qualiy has changed (to "lambda")
2021-03-09 11:00:25 -05:00
Rich Geldreich 85fa18ec94 Adding encoder WebAssembly support, encode_test sample
Encoder is now a library in the "encoder" directory
JavaScript wrappers now expose the entire codec: encoder, transcoder, container independent transcoding, and .basis file information
2020-12-17 14:26:28 -05:00
Andre Brisco 1d66c98c32 Ran ./format.sh 2020-10-07 19:13:04 -07:00
Aaron Franke 409d9a502e Commit files changed by the formatting script 2020-04-25 00:21:48 -04:00
Brandon Jones 171a38483f Fix a couple minor errors 2020-04-06 16:38:25 -07:00
Brandon Jones fc1183c412 Added basis_loader.js for WebGL 2020-04-06 14:55:45 -07:00
Aaron Franke 2a58642381 Make file formatting comply with POSIX and Unix standards
UTF-8, LF, no BOM, and newlines at end of files
2020-03-21 02:44:10 -04:00
Rich Geldreich 5b6eb565e4 - Adding UASTC support to encoder, transcoder, .basis file format
- Removing BC7 mode 6 support from transcoder (will alway use the much smaller mode 5 tables now)
- Adding BMP support
- Adding -bench mode, for development
- CMakeLists.txt file now compatible with Visual Studio 2019 (MSVC)
2020-03-20 02:00:34 -04:00
Richard Geldreich 1cae1d5726 Rebuilt transcoder 2019-09-29 20:02:20 -07:00
richgel999 01d391cc2a PVRTC1 apparently always use wrap addressing when fetching the adjacent block colors (even when clamp texture addressing is being used), so we don't need the wrap vs. clamp option anymore. It's always wrap and that's that. 2019-09-29 19:34:00 -07:00
richgel999 2af4f74533 Transcoder wrappers compilation fixes, rebuilt WebAssembly transcoder 2019-09-26 23:03:26 -07:00
richgel999 54304fa014 - Adding PVRTC2 RGB/RGBA and ETC2 EAC R11 and RG11
- Renaming -no_auto_global_sel_pal to -auto_global_sel_pal, disabling global selector palette usage by default to speed up compression on small images
- Renaming texture format enums
- Fixing uninitialized memory issue in front end - it wouldn't have affected the correctness of the output, or output quality
- Bumping command line tool up to v1.10
2019-09-26 22:35:14 -07:00
richgel999 b57a362f65 Reducing the WebAssembly transcoder size by disabling ATC and disabling the 8-bit ASTC tables. Rebuilt the transcoder. 2019-09-20 11:45:03 -07:00
richgel999 c2869ffecc Adding uncompressed pixel support to transcoder wrappers in webgl/transcoder/basis_wrappers.cpp. Note uncompressed hasn't been tested yet, but I've verified that compressed still works. 2019-09-19 21:39:57 -07:00
richgel999 8545341b4b Rebuild transcoder in WebAssembly on OSX 2019-09-19 15:03:17 -07:00
richgel999 2cb6bdadc1 Checking in new webgl files. Note that the WebAssembly transcoder has gotten bloated with BC7 support, which I'm working on fixing right now. (The wasm went from ~200k to 900k, because of a transcoder macro configuration issue.) 2019-09-19 14:34:39 -07:00
Preston Tamkin 39b5c5bc42 Modularize emscripten build.
By default, emscripten's generated javascript modules lives in the global object "Module'.

This makes it impossible to load multiple emscripten modules on the same page.

In attempt to avoid namespace collision, this change modularizes the emscripten build so the Module is instead called 'BASIS'.

Many target applications for Basis are likely to already be using other emscripten modules.

Testing:

The existing webgl/(texture|gltf) pages have been updated to use the new name and seem to operate as before
2019-06-11 23:42:49 -07:00
Rich Geldreich 5e8ad71036 Merge pull request #27 from zeux/wasmopt
Fix webgl CMakeLists.txt setup
2019-06-11 10:59:56 -07:00