Add tg3_validate() glTF 2.0 validation API to tiny_gltf_v3#545
Add tg3_validate() glTF 2.0 validation API to tiny_gltf_v3#545
Conversation
|
@copilot review deeply |
…uffer bounds, OOM dangling pointer Agent-Logs-Url: https://github.com/syoyo/tinygltf/sessions/93d57405-0fe2-43ef-a8fa-87f7bdd8447d Co-authored-by: syoyo <[email protected]>
Deep review found and fixed three bugs (commit Bug 1 — Bug 2 — False-positive buffer-view bounds errors on unloaded buffers Bug 3 — Dangling stack pointer on arena OOM in Two regression tests were added covering Bugs 1 and 2. All 24 v3 tests (58 assertions) pass; existing 303/321 tests are unaffected. |
tinygltf v3 had error codes and an error stack for validation but no post-parse validation function. This adds
tg3_validate()— a standalone validator that checks a parsedtg3_modelagainst the glTF 2.0 spec.API
Typical usage: parse first, then validate independently (or validate after programmatic model construction).
Validation coverage
versionrequired, warns if not"2.0"byteOffset+byteLengthwithin buffer bounds,byteStriderange [4,252] and 4-alignment (per spec §3.6.2.4)componentType/type,count ≥ 1, byte bounds and alignment within buffer view, sparse sub-structure refstranslation|rotation|scale|weightsalphaModeenum, all texture info indicestyperequired, perspectiveyfov/znear > 0, orthographicxmag/ymag ≠ 0,znear ≥ 0,zfar > znearbufferViewindex, warns on missing URI/bufferView/dataError message lifetime fix
tg3_error_stackgains an internalmsg_arena_field.tg3_validate()allocates both message andjson_pathstrings into this arena so they remain valid after the function returns.tg3_error_stack_free()destroys it. No change to existing parser behaviour.Tests
New
tests/v3/tester_v3.cc(22 test cases, 53 assertions) and correspondingtester_v3CMake target.Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.