forked from haasn/libplacebo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lut.c
86 lines (76 loc) · 2.58 KB
/
lut.c
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "tests.h"
#include <libplacebo/dummy.h>
#include <libplacebo/shaders/lut.h>
static const char *luts[] = {
"TITLE \"1D LUT example\" \n"
"LUT_1D_SIZE 11 \n"
"# Random comment \n"
"0.0 0.0 0.0 \n"
"0.1 0.1 0.1 \n"
"0.2 0.2 0.2 \n"
"0.3 0.3 0.3 \n"
"0.4 0.4 0.4 \n"
"0.5 0.5 0.5 \n"
"0.6 0.6 0.6 \n"
"0.7 0.7 0.7 \n"
"0.8 0.8 0.8 \n"
"0.9 0.9 0.9 \n"
"0.10 0.10 0.10 \n",
"LUT_3D_SIZE 3 \n"
"TITLE \"3D LUT example\" \n"
"0.0 0.0 0.0 \n"
"0.5 0.0 0.0 \n"
"1.0 0.0 0.0 \n"
"0.0 0.5 0.0 \n"
"0.5 0.5 0.0 \n"
"1.0 0.5 0.0 \n"
"0.0 1.0 0.0 \n"
"0.5 1.0 0.0 \n"
"1.0 1.0 0.0 \n"
"0.0 0.0 0.5 \n"
"0.5 0.0 0.5 \n"
"1.0 0.0 0.5 \n"
"0.0 0.5 0.5 \n"
"0.5 0.5 0.5 \n"
"1.0 0.5 0.5 \n"
"0.0 1.0 0.5 \n"
"0.5 1.0 0.5 \n"
"1.0 1.0 0.5 \n"
"0.0 0.0 1.0 \n"
"0.5 0.0 1.0 \n"
"1.0 0.0 1.0 \n"
"0.0 0.5 1.0 \n"
"0.5 0.5 1.0 \n"
"1.0 0.5 1.0 \n"
"0.0 1.0 1.0 \n"
"0.5 1.0 1.0 \n"
"1.0 1.0 1.0 \n",
"LUT_1D_SIZE 3 \n"
"TITLE \"custom domain\" \n"
"DOMAIN_MAX 255 255 255 \n"
"0 0 0 \n"
"128 128 128 \n"
"255 255 255 \n"
};
int main()
{
pl_log log = pl_test_logger();
pl_gpu gpu = pl_gpu_dummy_create(log, NULL);
pl_shader sh = pl_shader_alloc(log, NULL);
pl_shader_obj obj = NULL;
for (int i = 0; i < PL_ARRAY_SIZE(luts); i++) {
struct pl_custom_lut *lut;
lut = pl_lut_parse_cube(log, luts[i], strlen(luts[i]));
REQUIRE(lut);
pl_shader_reset(sh, pl_shader_params( .gpu = gpu ));
pl_shader_custom_lut(sh, lut, &obj);
const struct pl_shader_res *res = pl_shader_finalize(sh);
REQUIRE(res);
printf("Generated LUT shader:\n%s\n", res->glsl);
pl_lut_free(&lut);
}
pl_shader_obj_destroy(&obj);
pl_shader_free(&sh);
pl_gpu_dummy_destroy(&gpu);
pl_log_destroy(&log);
}