Skip to content

Commit aeb470f

Browse files
committed
demo: Add a basic unit test for partitioning
This simply validates that we can partition a 2x2 cluster grid in 1, 2 or 4 partitions.
1 parent d673fef commit aeb470f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

demo/tests.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,33 @@ static void meshletsSparse()
10841084
assert(memcmp(tri1, ibd + 3, 3 * sizeof(unsigned int)) == 0);
10851085
}
10861086

1087+
static void partitionBasic()
1088+
{
1089+
// 0 1 2
1090+
// 3
1091+
// 4 5 6 7 8
1092+
// 9
1093+
// 10 11 12
1094+
const unsigned int ci[] = {
1095+
0, 1, 3, 4, 5, 6, //
1096+
1, 2, 3, 6, 7, 8, //
1097+
4, 5, 6, 9, 10, 11, //
1098+
6, 7, 8, 9, 11, 12, //
1099+
};
1100+
1101+
const unsigned int cc[4] = {6, 6, 6, 6};
1102+
unsigned int part[4];
1103+
1104+
assert(meshopt_partitionClusters(part, ci, sizeof(ci) / sizeof(ci[0]), cc, 4, 13, 1) == 4);
1105+
assert(part[0] == 0 && part[1] == 1 && part[2] == 2 && part[3] == 3);
1106+
1107+
assert(meshopt_partitionClusters(part, ci, sizeof(ci) / sizeof(ci[0]), cc, 4, 13, 2) == 2);
1108+
assert(part[0] == 0 && part[1] == 0 && part[2] == 1 && part[3] == 1);
1109+
1110+
assert(meshopt_partitionClusters(part, ci, sizeof(ci) / sizeof(ci[0]), cc, 4, 13, 4) == 1);
1111+
assert(part[0] == 0 && part[1] == 0 && part[2] == 0 && part[3] == 0);
1112+
}
1113+
10871114
static size_t allocCount;
10881115
static size_t freeCount;
10891116

@@ -2142,6 +2169,8 @@ void runTests()
21422169
meshletsDense();
21432170
meshletsSparse();
21442171

2172+
partitionBasic();
2173+
21452174
customAllocator();
21462175

21472176
emptyMesh();

0 commit comments

Comments
 (0)