-
Notifications
You must be signed in to change notification settings - Fork 511
/
Copy pathsimplifyfuzz.cpp
42 lines (31 loc) · 1.21 KB
/
simplifyfuzz.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "../src/meshoptimizer.h"
#include <float.h>
#include <stdint.h>
#include <stdlib.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* buffer, size_t size)
{
if (size == 0)
return 0;
srand(buffer[0]);
float vb[100][4];
for (int i = 0; i < 100; ++i)
{
vb[i][0] = rand() % 10;
vb[i][1] = rand() % 10;
vb[i][2] = rand() % 10;
vb[i][3] = rand() % 10;
}
unsigned int ib[999];
int indices = (size - 1) < 999 ? (size - 1) / 3 * 3 : 999;
for (int i = 0; i < indices; ++i)
ib[i] = buffer[1 + i] % 100;
unsigned int res[999];
meshopt_simplify(res, ib, indices, vb[0], 100, sizeof(float) * 4, 0, 1e-1f, 0, NULL);
meshopt_simplify(res, ib, indices, vb[0], 100, sizeof(float) * 4, 0, FLT_MAX, 0, NULL);
meshopt_simplify(res, ib, indices, vb[0], 100, sizeof(float) * 4, 0, FLT_MAX, meshopt_SimplifyLockBorder, NULL);
meshopt_simplify(res, ib, indices, vb[0], 100, sizeof(float) * 4, 0, FLT_MAX, meshopt_SimplifySparse, NULL);
meshopt_simplify(res, ib, indices, vb[0], 100, sizeof(float) * 4, 0, FLT_MAX, meshopt_SimplifyPrune, NULL);
float aw = 1;
meshopt_simplifyWithAttributes(res, ib, indices, vb[0], 100, sizeof(float) * 4, vb[0] + 3, sizeof(float) * 4, &aw, 1, NULL, 0, FLT_MAX, 0, NULL);
return 0;
}