Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/tests/unit/u_prim_verts_test.c
4565 views
1
#include <stdlib.h>
2
#include <stdio.h>
3
4
#include "util/u_prim.h"
5
6
struct test_info {
7
enum pipe_prim_type prim_type;
8
uint32_t count;
9
uint32_t expected;
10
};
11
12
struct test_info tests[] = {
13
{ PIPE_PRIM_POINTS, 0, 0 },
14
{ PIPE_PRIM_POINTS, 1, 1 },
15
{ PIPE_PRIM_POINTS, 2, 2 },
16
17
{ PIPE_PRIM_LINES, 0, 0 },
18
{ PIPE_PRIM_LINES, 1, 2 },
19
{ PIPE_PRIM_LINES, 2, 4 },
20
21
{ PIPE_PRIM_TRIANGLES, 0, 0 },
22
{ PIPE_PRIM_TRIANGLES, 1, 3 },
23
{ PIPE_PRIM_TRIANGLES, 2, 6 },
24
25
{ PIPE_PRIM_QUADS, 0, 0 },
26
{ PIPE_PRIM_QUADS, 1, 4 },
27
{ PIPE_PRIM_QUADS, 2, 8 },
28
};
29
30
int
31
main(int argc, char **argv)
32
{
33
for(int i = 0; i < ARRAY_SIZE(tests); i++) {
34
struct test_info *info = &tests[i];
35
uint32_t n = u_vertices_for_prims(info->prim_type, info->count);
36
if (n != info->expected) {
37
printf("Failure! Expected %u vertices for %u x %s, but got %u.\n",
38
info->expected, info->count, u_prim_name(info->prim_type), n);
39
return 1;
40
}
41
}
42
43
printf("Success!\n");
44
return 0;
45
}
46
47