Skip to content

Commit 58572d1

Browse files
committed
demo: Add a unit test to exercise 256v meshlets
This ensures that we properly support meshlets up to 256v.
1 parent 1923ec0 commit 58572d1

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

demo/tests.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,41 @@ static void meshletsFlex()
12031203
assert(ml[1].vertex_count == 4);
12041204
}
12051205

1206+
static void meshletsMax()
1207+
{
1208+
float vb[16 * 16 * 3];
1209+
unsigned int ib[15 * 15 * 2 * 3];
1210+
1211+
// 16x16 grid of vertices, 15x15 grid of triangles
1212+
for (int y = 0; y < 16; ++y)
1213+
for (int x = 0; x < 16; ++x)
1214+
{
1215+
vb[(y * 16 + x) * 3 + 0] = float(x);
1216+
vb[(y * 16 + x) * 3 + 1] = float(y);
1217+
vb[(y * 16 + x) * 3 + 2] = 0;
1218+
}
1219+
1220+
for (int y = 0; y < 15; ++y)
1221+
for (int x = 0; x < 15; ++x)
1222+
{
1223+
ib[(y * 15 + x) * 2 * 3 + 0] = (y + 0) * 16 + (x + 0);
1224+
ib[(y * 15 + x) * 2 * 3 + 1] = (y + 0) * 16 + (x + 1);
1225+
ib[(y * 15 + x) * 2 * 3 + 2] = (y + 1) * 16 + (x + 0);
1226+
ib[(y * 15 + x) * 2 * 3 + 3] = (y + 1) * 16 + (x + 0);
1227+
ib[(y * 15 + x) * 2 * 3 + 4] = (y + 0) * 16 + (x + 1);
1228+
ib[(y * 15 + x) * 2 * 3 + 5] = (y + 1) * 16 + (x + 1);
1229+
}
1230+
1231+
meshopt_Meshlet ml[1];
1232+
unsigned int mv[16 * 16];
1233+
unsigned char mt[15 * 15 * 2 * 3 + 3];
1234+
1235+
size_t mc = meshopt_buildMeshlets(ml, mv, mt, ib, sizeof(ib) / sizeof(ib[0]), vb, 16 * 16, sizeof(float) * 3, 256, 512, 0.f);
1236+
assert(mc == 1);
1237+
assert(ml[0].triangle_count == 450);
1238+
assert(ml[0].vertex_count == 256);
1239+
}
1240+
12061241
static void partitionBasic()
12071242
{
12081243
// 0 1 2
@@ -2292,6 +2327,7 @@ void runTests()
22922327
meshletsDense();
22932328
meshletsSparse();
22942329
meshletsFlex();
2330+
meshletsMax();
22952331

22962332
partitionBasic();
22972333

0 commit comments

Comments
 (0)