Skip to content

Commit 507e7d8

Browse files
SunrisepeakSunrisepeak
andauthored
mcpplibs.mwrap.acl 2.1.0: acl-m (the Animation Compression Library and Realtime Math, skeletal clips compressed within a stated error, as a C++23 module) (#790)
Co-authored-by: Sunrisepeak <speakshen@outlook.com>
1 parent 9d053b7 commit 507e7d8

8 files changed

Lines changed: 213 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Add mcpplibs.mwrap.acl (acl-m 2.1.0)
2+
3+
## Form
4+
5+
- Third-party upstreams [nfrechette/acl](https://github.com/nfrechette/acl), release v2.1.0, MIT, and the
6+
[nfrechette/rtm](https://github.com/nfrechette/rtm) v2.2.0 it pins (its submodule at that tag), MIT. Both are
7+
header-only.
8+
- Form A external mwrap module repository [mcpplibs/acl-m](https://github.com/mcpplibs/acl-m), package
9+
`mcpplibs.mwrap.acl`, version 2.1.0 (the first indexed release of the identity), tag `mwrap-2.1.0`; release asset
10+
`acl-m-2.1.0.tar.gz` (`b974ddb9…11a4`), CN mirror `gitcode.com/mcpp-res/mwrap-acl` with identical bytes.
11+
- Implementation ownership: this index has no `compat` package of ACL or RTM. The wrapper vendors the headers of both
12+
from their release archives (checksums of every file in `upstream/documents.json`), ACL's `io` directory included
13+
only because `acl/fwd.h` includes its forward declarations (it is not in the module). One upstream fix is applied
14+
(`patches/0001-move-deprecated-attribute.patch`, upstream commit 0b06bd1: an attribute clang 23 refuses where 2.1.0
15+
places it). It deploys both upstreams' README and LICENSE with its own LICENSE/NOTICE (`runtime.deploy`).
16+
- Configuration: `RTM_NO_INTRINSICS` and `ACL_NO_INTRINSICS`, `-ffp-contract=off`, no fast math, in every profile.
17+
RTM's NEON paths fuse multiply and add and its SSE paths use approximate reciprocals, so a SIMD build gives other
18+
bits on other platforms; the scalar build gives the same compressed bytes and the same poses everywhere. Measured
19+
cost on x86-64 (GCC 16, `-O2`): 26.8 ns a joint to decompress a 64-joint pose, against 17.2 ns with SSE.
20+
21+
## Module
22+
23+
- `mcpplibs.mwrap.acl`: every name of the public headers under `acl/` (compression, decompression, core, math) and
24+
`rtm/`, in the namespaces upstream declares them in (`acl`, `rtm`, `rtm::constants`), by `export using` (197 types,
25+
454 functions). Implementation namespaces (`*_impl`) are not exported.
26+
- Internal-linkage adaptation: 15 `constexpr` objects (`k_invalid_track_index`, `k_num_quality_tiers`,
27+
`k_highest_bit_rate`, `k_bit_rate_num_bits` …) are declared again under their names, with their types and values,
28+
in `mcpplibs::mwrap::acl`.
29+
- No `.macros` module: neither library has macros a program spells.
30+
- The export list is derived by `tools/surface.py` from the headers as clang reads them (its JSON AST), recorded in
31+
`tools/surface.json`, and audited in CI: the module is the record on every row, and on the Linux LLVM row the record
32+
is derived again and compared.
33+
34+
## Verification
35+
36+
- Wrapper CI (Linux x86_64 and arm64 with GCC 16.1 and LLVM 23.1.3, macOS LLVM, Windows LLVM, each in the dev and
37+
release profiles; wasm32-emscripten under node): a five-joint chain compressed twice to the same bytes, its error
38+
measured against the raw clip (below 0.15 mm for a precision of 0.1 mm at 3 cm), poses at five times; the
39+
compressed bytes and the poses pinned and the same on every row; the adapted constants; the export audit; the
40+
default template from an installed copy with a strict build.
41+
- This index: consumer `tests/mwrap/acl-clip` (the same pinned hashes); the installed-template check with
42+
`--deploy` (`STATIC_NOTICES`).

‎.github/workflows/validate.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,11 @@ jobs:
17431743
shell: bash
17441744
run: python3 tests/mwrap/check_installed_template.py --mcpp "$MCPP" --package mcpplibs.mwrap.recastnavigation@1.6.0 --deploy
17451745

1746+
- name: Installed ACL wrapper archive, actual default clip template and its relocated notices
1747+
if: contains(format(' {0} ', env.MEMBERS), ' acl-clip ') && matrix.toolchain == 'default'
1748+
shell: bash
1749+
run: python3 tests/mwrap/check_installed_template.py --mcpp "$MCPP" --package mcpplibs.mwrap.acl@2.1.0 --deploy
1750+
17461751
- name: Installed libjpeg-turbo wrapper archive, actual default decoding template and its relocated notices
17471752
if: contains(format(' {0} ', env.MEMBERS), ' libjpeg-turbo-decode ') && matrix.toolchain == 'default'
17481753
shell: bash

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141

4242
### Added
4343

44+
- **mcpplibs.mwrap.acl 2.1.0(新包)。** acl-m:Animation Compression Library 2.1.0(在给定误差内压缩骨骼动画片段与标量轨道,
45+
并在任意时刻回放)及其固定的 Realtime Math 2.2.0 的 C++23 模块,以 `export using` 在上游的命名空间 `acl`、`rtm`、`rtm::constants`
46+
里导出两库头文件的全部公开名字(197 个类型、454 个函数);15 个内部链接的 `constexpr` 常量(`k_invalid_track_index`、
47+
`k_num_quality_tiers` 等)以原名、原类型和原值位于 `mcpplibs::mwrap::acl`。导出清单由 clang 读头文件推出并在 CI 中审计。封装仓库
48+
从上游发布包取源码(应用上游提交 0b06bd1 的一处修复),以 `RTM_NO_INTRINSICS`、`ACL_NO_INTRINSICS`、`-ffp-contract=off`、不用快速
49+
数学构建:同一个片段在 Linux x86-64 与 arm64、macOS、Windows、wasm32 上,dev 与 release,压缩字节与回放姿态的哈希相同(钉住)。
50+
不含 `io`(SJSON 读写)与引擎插件。消费者测试 `tests/mwrap/acl-clip`,安装后模板检查带 `--deploy`。GLOBAL 为 GitHub 发布资产,
51+
CN 为 GitCode `mcpp-res/mwrap-acl` 镜像,sha256 相同。
4452
- **mcpplibs.mwrap.recastnavigation 1.6.0(新包)。** recastnavigation-m:Recast & Detour 1.6.0(由三角形构建导航网格、寻路、群体、
4553
带障碍物的分块网格)的 C++23 模块,以 `export using` 在全局命名空间导出 Recast、Detour、DetourCrowd、DetourTileCache 头文件的
4654
全部公开名字(99 个类型、75 个无作用域枚举的枚举项、170 个函数);52 个内部链接的 `static const` 常量(`DT_VERTS_PER_POLYGON`、

‎mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ members = [
4040
"tests/mwrap/manifold-boolean",
4141
"tests/mwrap/jolt-world",
4242
"tests/mwrap/recastnavigation-path",
43+
"tests/mwrap/acl-clip",
4344
"tests/mwrap/basis-universal-transcode",
4445
"tests/mwrap/libjpeg-turbo-decode",
4546
"tests/mwrap/libarchive-bundle",

‎pkgs/mwrap/acl.lua‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
-- Immutable upstream-aligned mwrap source release (acl-m mwrap-2.1.0, the first release of upstream
2+
-- 2.1.0); GLOBAL and CN bytes are identical.
3+
--
4+
-- The wrapper is Apache-2.0; the header-only libraries it vendors, the
5+
-- Animation Compression Library 2.1.0 and the Realtime Math 2.2.0 it pins,
6+
-- are MIT: the package deploys their READMEs and LICENSEs beside programs
7+
-- (runtime.deploy).
8+
package = {
9+
spec = "1",
10+
namespace = "mcpplibs.mwrap",
11+
name = "acl",
12+
description = "acl-m: the Animation Compression Library 2.1.0 and Realtime Math 2.2.0 (skeletal clips compressed within a stated error, played back at any time) as a C++23 module",
13+
licenses = { "Apache-2.0" },
14+
repo = "https://github.com/mcpplibs/acl-m",
15+
type = "package",
16+
extensions = {
17+
autoupdate = {
18+
tag = "mwrap-${version}",
19+
url = "https://github.com/mcpplibs/acl-m/releases/download/${tag}/acl-m-${version}.tar.gz",
20+
},
21+
},
22+
xpm = {
23+
linux = {
24+
["2.1.0"] = {
25+
url = {
26+
GLOBAL = "https://github.com/mcpplibs/acl-m/releases/download/mwrap-2.1.0/acl-m-2.1.0.tar.gz",
27+
CN = "https://gitcode.com/mcpp-res/mwrap-acl/releases/download/2.1.0/acl-m-2.1.0.tar.gz",
28+
},
29+
sha256 = "b974ddb90229593ce20dc8ef86f529720bc7983e09700db8cd67a326069a11a4",
30+
},
31+
},
32+
macosx = {
33+
["2.1.0"] = {
34+
url = {
35+
GLOBAL = "https://github.com/mcpplibs/acl-m/releases/download/mwrap-2.1.0/acl-m-2.1.0.tar.gz",
36+
CN = "https://gitcode.com/mcpp-res/mwrap-acl/releases/download/2.1.0/acl-m-2.1.0.tar.gz",
37+
},
38+
sha256 = "b974ddb90229593ce20dc8ef86f529720bc7983e09700db8cd67a326069a11a4",
39+
},
40+
},
41+
windows = {
42+
["2.1.0"] = {
43+
url = {
44+
GLOBAL = "https://github.com/mcpplibs/acl-m/releases/download/mwrap-2.1.0/acl-m-2.1.0.tar.gz",
45+
CN = "https://gitcode.com/mcpp-res/mwrap-acl/releases/download/2.1.0/acl-m-2.1.0.tar.gz",
46+
},
47+
sha256 = "b974ddb90229593ce20dc8ef86f529720bc7983e09700db8cd67a326069a11a4",
48+
},
49+
},
50+
},
51+
}

‎tests/mwrap/acl-clip/mcpp.toml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "acl-clip"
3+
version = "2.1.0"
4+
description = "Consume the immutable ACL wrapper: a five-joint chain compressed within its error twice to the same bytes and played back at five times; the compressed bytes and the poses pinned"
5+
6+
[indices]
7+
# Use the complete candidate built-in index prepared by tests/run_members.sh.
8+
# An explicit empty table overrides the legacy workspace redirect.
9+
10+
[dependencies]
11+
mcpplibs.mwrap.acl = "2.1.0"
12+
13+
# RTM's inline math compiled here too, as the library is built.
14+
[build]
15+
cxxflags = ["-ffp-contract=off"]
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// The installed ACL wrapper: a chain of five joints turning and moving over two seconds at 30 samples a second,
2+
// compressed with ACL's default settings twice to the same bytes, its error measured against the raw clip, and
3+
// played back at five times. The compressed bytes and the poses are pinned, as the wrapper's CI pins them on every
4+
// platform; the adapted constants.
5+
import std;
6+
import mcpplibs.mwrap.acl;
7+
8+
namespace {
9+
10+
int failures = 0;
11+
void check(bool held) { failures += held ? 0 : 1; }
12+
13+
constexpr std::uint32_t joints = 5, samples = 61;
14+
constexpr float rate = 30.0f;
15+
16+
std::uint64_t fnv(const void* data, std::size_t size, std::uint64_t hash = 0xcbf29ce484222325ull) {
17+
const auto* bytes = static_cast<const unsigned char*>(data);
18+
for (std::size_t index = 0; index < size; ++index) hash = (hash ^ bytes[index]) * 0x100000001b3ull;
19+
return hash;
20+
}
21+
22+
// Each joint's rotation a normalised quaternion of polynomials in time, its translation along its parent's x.
23+
acl::track_array_qvvf raw(acl::iallocator& allocator) {
24+
acl::track_array_qvvf tracks(allocator, joints);
25+
for (std::uint32_t joint = 0; joint < joints; ++joint) {
26+
acl::track_desc_transformf desc;
27+
desc.output_index = joint;
28+
desc.parent_index = joint == 0 ? mcpplibs::mwrap::acl::k_invalid_track_index : joint - 1;
29+
desc.precision = 0.0001f;
30+
desc.shell_distance = 0.03f;
31+
acl::track_qvvf track = acl::track_qvvf::make_reserve(desc, allocator, samples, rate);
32+
for (std::uint32_t sample = 0; sample < samples; ++sample) {
33+
const float time = static_cast<float>(sample) / rate, turn = 0.3f * time - 0.1f * time * time + 0.05f * static_cast<float>(joint);
34+
const rtm::quatf rotation = rtm::quat_normalize(rtm::quat_set(turn, 0.2f * turn * turn, 0.1f * static_cast<float>(joint), 1.0f));
35+
const rtm::vector4f translation = rtm::vector_set(joint == 0 ? 0.5f * time : 0.25f, joint == 0 ? 0.1f * time * time : 0.0f, 0.0f);
36+
track[sample] = rtm::qvv_set(rotation, translation, rtm::vector_set(1.0f));
37+
}
38+
tracks[joint] = std::move(track);
39+
}
40+
return tracks;
41+
}
42+
43+
struct Pose : acl::track_writer {
44+
std::array<float, joints * 10> values{};
45+
void write_rotation(std::uint32_t joint, rtm::quatf_arg0 rotation) { rtm::quat_store(rotation, &values[joint * 10]); }
46+
void write_translation(std::uint32_t joint, rtm::vector4f_arg0 translation) { rtm::vector_store3(translation, &values[joint * 10 + 4]); }
47+
void write_scale(std::uint32_t joint, rtm::vector4f_arg0 scale) { rtm::vector_store3(scale, &values[joint * 10 + 7]); }
48+
};
49+
50+
} // namespace
51+
52+
int main() {
53+
acl::ansi_allocator allocator;
54+
const acl::track_array_qvvf tracks = raw(allocator);
55+
acl::compression_settings settings = acl::get_default_compression_settings();
56+
acl::qvvf_transform_error_metric metric;
57+
settings.error_metric = &metric;
58+
const auto compress = [&] {
59+
acl::output_stats stats;
60+
acl::compressed_tracks* compressed = nullptr;
61+
check(acl::compress_track_list(allocator, tracks, settings, compressed, stats).empty() && compressed);
62+
return compressed;
63+
};
64+
acl::compressed_tracks* compressed = compress();
65+
acl::compressed_tracks* again = compress();
66+
if (!compressed || !again) return 1;
67+
check(compressed->is_valid(true).empty());
68+
check(compressed->get_size() == again->get_size() && std::memcmp(compressed, again, compressed->get_size()) == 0);
69+
70+
acl::decompression_context<acl::default_transform_decompression_settings> context;
71+
check(context.initialize(*compressed));
72+
const acl::track_error error = acl::calculate_compression_error(allocator, tracks, context, metric);
73+
check(error.error < 0.00015f);
74+
std::uint64_t poses = 0xcbf29ce484222325ull;
75+
for (const float time : {0.0f, 0.37f, 1.0f, 1.5f, 2.0f}) {
76+
Pose pose;
77+
context.seek(time, acl::sample_rounding_policy::none);
78+
context.decompress_tracks(pose);
79+
poses = fnv(pose.values.data(), sizeof(pose.values), poses);
80+
}
81+
const std::uint64_t bytes = fnv(compressed, compressed->get_size());
82+
check(bytes == 0x7bbb0daa9b0e5fa6ull && poses == 0x0c6e1a02a38a29a5ull);
83+
check(mcpplibs::mwrap::acl::k_invalid_track_index == 0xFFFFFFFFu && mcpplibs::mwrap::acl::k_num_quality_tiers == 3u);
84+
std::println("ACL 2.1.0 through import mcpplibs.mwrap.acl: {} raw bytes compressed to {} within {:.3f} mm; the bytes {:#018x}, the poses {:#018x}{}",
85+
joints * samples * 10 * sizeof(float), compressed->get_size(), error.error * 1000.0f, bytes, poses,
86+
failures ? std::format(" — {} checks failed", failures) : "");
87+
allocator.deallocate(compressed, compressed->get_size());
88+
allocator.deallocate(again, again->get_size());
89+
return failures;
90+
}

‎tests/mwrap/check_installed_template.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"mcpplibs.mwrap.cgltf": ("cgltf.cppm", "upstream/cgltf/LICENSE", b"Permission is hereby granted", b"Kuhlmann"),
2525
"mcpplibs.mwrap.manifold": ("manifold.cppm", "upstream/manifold/LICENSE", b"Apache License", b"The Manifold Authors"),
2626
"mcpplibs.mwrap.recastnavigation": ("recastnavigation.cppm", "upstream/recastnavigation/License.txt", b"This software is provided 'as-is'", b"Recast & Detour is Copyright (c) 2009 Mikko"),
27+
"mcpplibs.mwrap.acl": ("acl.cppm", "upstream/acl/LICENSE", b"Permission is hereby granted", b"Copyright (c) 2017 Nicholas Frechette & Animation Compression Library"),
2728
"mcpplibs.mwrap.jolt": ("jolt.cppm", "upstream/jolt/LICENSE", b"Permission is hereby granted", b"Jolt Physics is Copyright (c) 2021 Jorrit"),
2829
"mcpplibs.mwrap.libjpeg_turbo": ("libjpeg_turbo.cppm", "upstream/libjpeg-turbo/README.ijg", b"Independent JPEG Group", b"libjpeg-turbo Project"),
2930
"mcpplibs.mwrap.basis_universal": ("basis_universal.cppm", "upstream/basis_universal/NOTICE", b"Binomial LLC", b"Basis Universal"),

0 commit comments

Comments
 (0)