Skip to content

Commit

Permalink
Improve gltfpack code coverage further
Browse files Browse the repository at this point in the history
We haven't really used scan=true in a while and it's not a very
interesting mode anyway, so debugMeshlets doesn't need it.

Also add a few more gltfpack options to coverage build; -tl just tests
option parsing but we were missing some actual processing code paths due
to lack of keep flags.
  • Loading branch information
zeux committed Oct 30, 2024
1 parent 5e6feb6 commit d93419c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ jobs:
./gltfpack -test demo/pirate.obj -vp 16 -vt 16 -vn 16 -vc 16
./gltfpack -test demo/pirate.obj -vpf -vtf -vnf
./gltfpack -test glTF-Sample-Assets/Models/ABeautifulGame/glTF/ABeautifulGame.gltf -mi -c
./gltfpack -test glTF-Sample-Assets/Models/ABeautifulGame/glTF/ABeautifulGame.gltf -kn -km -ke
./gltfpack -test glTF-Sample-Assets/Models/BoxTextured/glTF/BoxTextured.gltf -vpf -vtf -c
./gltfpack -test glTF-Sample-Assets/Models/BoxTextured/glTF/BoxTextured.gltf -vpf -vtf -cc
./gltfpack -test glTF-Sample-Assets/Models/BoxTextured/glTF/BoxTextured.gltf -tc
./gltfpack -test glTF-Sample-Assets/Models/BoxTextured/glTF/BoxTextured.gltf -tc -tq color 10 -tu normal,attrib -ts attrib 0.5
./gltfpack -test glTF-Sample-Assets/Models/BoxTextured/glTF/BoxTextured.gltf -tc -tq color 10 -tu normal,attrib -ts attrib 0.5 -tl color 512
./gltfpack -test glTF-Sample-Assets/Models/BoxTextured/glTF/BoxTextured.gltf -tr
./gltfpack -test glTF-Sample-Assets/Models/BoxTextured/glTF/BoxTextured.gltf -tc -ts 0.5 -tl 64
./gltfpack -test glTF-Sample-Assets/Models/BoxTextured/glTF/BoxTextured.gltf -tc color -tfy -tq 4 -tj 1
Expand Down
2 changes: 1 addition & 1 deletion gltf/gltfpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ static void process(cgltf_data* data, const char* input_path, const char* output
if (settings.meshlet_debug > 0)
{
Mesh meshlets = {};
debugMeshlets(mesh, meshlets, settings.meshlet_debug, /* scan= */ false);
debugMeshlets(mesh, meshlets, settings.meshlet_debug);
debug_meshes.push_back(meshlets);
}
}
Expand Down
2 changes: 1 addition & 1 deletion gltf/gltfpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void processAnimation(Animation& animation, const Settings& settings);
void processMesh(Mesh& mesh, const Settings& settings);

void debugSimplify(const Mesh& mesh, Mesh& kinds, Mesh& loops, float ratio, float error, bool attributes, bool quantize_tbn);
void debugMeshlets(const Mesh& mesh, Mesh& meshlets, int max_vertices, bool scan);
void debugMeshlets(const Mesh& mesh, Mesh& meshlets, int max_vertices);

bool compareMeshTargets(const Mesh& lhs, const Mesh& rhs);
bool compareMeshVariants(const Mesh& lhs, const Mesh& rhs);
Expand Down
11 changes: 2 additions & 9 deletions gltf/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,16 +1114,13 @@ void debugSimplify(const Mesh& source, Mesh& kinds, Mesh& loops, float ratio, fl
loops.streams.push_back(colors);
}

void debugMeshlets(const Mesh& source, Mesh& meshlets, int max_vertices, bool scan)
void debugMeshlets(const Mesh& source, Mesh& meshlets, int max_vertices)
{
Mesh mesh = source;
assert(mesh.type == cgltf_primitive_type_triangles);

reindexMesh(mesh, /* quantize_tbn= */ true);

if (scan)
optimizeMesh(mesh, false);

const Stream* positions = getStream(mesh, cgltf_attribute_type_position);
assert(positions);

Expand All @@ -1135,11 +1132,7 @@ void debugMeshlets(const Mesh& source, Mesh& meshlets, int max_vertices, bool sc
std::vector<meshopt_Meshlet> ml(max_meshlets);
std::vector<unsigned int> mlv(max_meshlets * max_vertices);
std::vector<unsigned char> mlt(max_meshlets * max_triangles * 3);

if (scan)
ml.resize(meshopt_buildMeshletsScan(&ml[0], &mlv[0], &mlt[0], &mesh.indices[0], mesh.indices.size(), positions->data.size(), max_vertices, max_triangles));
else
ml.resize(meshopt_buildMeshlets(&ml[0], &mlv[0], &mlt[0], &mesh.indices[0], mesh.indices.size(), positions->data[0].f, positions->data.size(), sizeof(Attr), max_vertices, max_triangles, cone_weight));
ml.resize(meshopt_buildMeshlets(&ml[0], &mlv[0], &mlt[0], &mesh.indices[0], mesh.indices.size(), positions->data[0].f, positions->data.size(), sizeof(Attr), max_vertices, max_triangles, cone_weight));

// generate meshlet meshes, using unique colors
meshlets.nodes = mesh.nodes;
Expand Down

0 comments on commit d93419c

Please sign in to comment.