layout: restructure into src/ tests/ android/ scripts/ tools/
- extension/src/{port,platform,codepage} -> src/; native_render -> src/host
(+ dxt, shaders/); libgr2 -> src/gr2; extension/third_party -> third_party
- extension/tests -> tests/port, libgr2/tests -> tests/gr2
- android-native -> android (build.sh, push-client.sh moved in)
- script -> scripts; tools/40250 -> tools/server; oracle -> tools/granny-oracle;
perf tools -> tools/perf
- all build trees under build/ (native, release, android, port-gate)
- xrender:: CMake aliases -> mt::; port-map ledger impl paths rewritten
No code changes. ctest 15/15, port_gate macos+android PASS, port_map check 0 errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
70710477cf
commit
a46093104c
@@ -0,0 +1,56 @@
|
||||
#include <gr2/types.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
int main() {
|
||||
// ScaleShearCurve uses 9 values per control point. A quadratic span reads
|
||||
// three control points, so this is the regression case for the former 3*4
|
||||
// stack buffer in Curve::eval().
|
||||
gr2::Curve curve;
|
||||
curve.degree = 2;
|
||||
curve.dim = 9;
|
||||
curve.knots = {0.0f, 1.0f, 2.0f};
|
||||
curve.controls.resize(27);
|
||||
for (size_t i = 0; i < curve.controls.size(); ++i) {
|
||||
curve.controls[i] = 1.0f + static_cast<float>(i) * 0.01f;
|
||||
}
|
||||
|
||||
float out[9] = {};
|
||||
curve.eval(0.5f, out);
|
||||
for (float value : out) {
|
||||
if (!std::isfinite(value)) {
|
||||
std::fprintf(stderr, "non-finite 9D curve output\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// BoneTrack::sample fills SRT components and flags; sample_local = compose(sample).
|
||||
gr2::BoneTrack track;
|
||||
track.position.degree = 1;
|
||||
track.position.dim = 3;
|
||||
track.position.knots = {0.0f, 1.0f};
|
||||
track.position.controls = {0.0f, 0.0f, 0.0f, 2.0f, 4.0f, 6.0f};
|
||||
track.orientation.degree = 0;
|
||||
track.orientation.dim = 4;
|
||||
track.orientation.knots = {0.0f};
|
||||
track.orientation.controls = {0.0f, 0.0f, 0.70710678f, 0.70710678f}; // 90 deg about Z
|
||||
gr2::Transform x;
|
||||
track.sample(0.5f, x);
|
||||
if (x.flags != 3 || std::fabs(x.position[0] - 1.0f) > 1e-5f || std::fabs(x.position[2] - 3.0f) > 1e-5f) {
|
||||
std::fprintf(stderr, "BoneTrack::sample flags=%u pos=%f,%f,%f\n", x.flags, x.position[0], x.position[1], x.position[2]);
|
||||
return 1;
|
||||
}
|
||||
gr2::Animation anim;
|
||||
anim.tracks.push_back(track);
|
||||
std::vector<gr2::Mat4> local;
|
||||
anim.sample_local(0.5f, local);
|
||||
const gr2::Mat4 m = gr2::compose(x);
|
||||
// Row-major composite: row 0 is the rotated X axis (0,1,0); translation in 12..14.
|
||||
if (local.size() != 1 || local[0] != m || std::fabs(m[1] - 1.0f) > 1e-5f || std::fabs(m[12] - 1.0f) > 1e-5f) {
|
||||
std::fprintf(stderr, "compose mismatch m[1]=%f m[12]=%f\n", m[1], m[12]);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <gr2/gr2.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
void wr32(std::vector<uint8_t> &bytes, size_t off, uint32_t value) {
|
||||
bytes[off + 0] = uint8_t(value);
|
||||
bytes[off + 1] = uint8_t(value >> 8);
|
||||
bytes[off + 2] = uint8_t(value >> 16);
|
||||
bytes[off + 3] = uint8_t(value >> 24);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> granny_header(size_t size, uint32_t section_count) {
|
||||
std::vector<uint8_t> bytes(size, 0);
|
||||
const uint32_t magic[] = { 0xCAB067B8, 0x0FB16DF8, 0x7E8C7284, 0x1E00195E };
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
wr32(bytes, size_t(i) * 4, magic[i]);
|
||||
}
|
||||
constexpr size_t h = 32;
|
||||
wr32(bytes, h + 0, 6); // Version
|
||||
wr32(bytes, h + 4, uint32_t(size));
|
||||
wr32(bytes, h + 12, 40); // section table starts at byte 72
|
||||
wr32(bytes, h + 16, section_count);
|
||||
// Root type/object remain section 0, offset 0. With no section this must be
|
||||
// rejected by the FileInfo stage rather than returned as an empty File.
|
||||
return bytes;
|
||||
}
|
||||
|
||||
bool expect_failure(const std::vector<uint8_t> &bytes, const char *stage) {
|
||||
gr2::LoadError err;
|
||||
auto file = gr2::File::load(bytes.data(), bytes.size(), &err);
|
||||
if (file || err.stage != stage) {
|
||||
std::fprintf(stderr, "expected failure stage '%s', got file=%d stage='%s' message='%s'\n",
|
||||
stage, file.has_value(), err.stage.c_str(), err.message.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
bool ok = true;
|
||||
ok &= expect_failure(std::vector<uint8_t>(80, 0), "header");
|
||||
ok &= expect_failure(granny_header(80, 0), "fileinfo");
|
||||
|
||||
auto unsupported = granny_header(160, 1);
|
||||
constexpr size_t section = 72;
|
||||
wr32(unsupported, section + 0, 4); // unsupported BitKnit
|
||||
wr32(unsupported, section + 4, uint32_t(unsupported.size()));
|
||||
wr32(unsupported, section + 12, 1); // non-empty expanded section
|
||||
ok &= expect_failure(unsupported, "section");
|
||||
|
||||
auto bad_offset = granny_header(160, 1);
|
||||
wr32(bad_offset, section + 4, UINT32_MAX);
|
||||
ok &= expect_failure(bad_offset, "section");
|
||||
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
Reference in New Issue
Block a user