1 #include "tests.h"
2 
3 static const char *luts[] = {
4 
5     "TITLE \"1D LUT example\"   \n"
6     "LUT_1D_SIZE 11             \n"
7     "# Random comment           \n"
8     "0.0 0.0 0.0                \n"
9     "0.1 0.1 0.1                \n"
10     "0.2 0.2 0.2                \n"
11     "0.3 0.3 0.3                \n"
12     "0.4 0.4 0.4                \n"
13     "0.5 0.5 0.5                \n"
14     "0.6 0.6 0.6                \n"
15     "0.7 0.7 0.7                \n"
16     "0.8 0.8 0.8                \n"
17     "0.9 0.9 0.9                \n"
18     "0.10 0.10 0.10             \n",
19 
20     "LUT_3D_SIZE 3              \n"
21     "TITLE \"3D LUT example\"   \n"
22     "0.0 0.0 0.0                \n"
23     "0.5 0.0 0.0                \n"
24     "1.0 0.0 0.0                \n"
25     "0.0 0.5 0.0                \n"
26     "0.5 0.5 0.0                \n"
27     "1.0 0.5 0.0                \n"
28     "0.0 1.0 0.0                \n"
29     "0.5 1.0 0.0                \n"
30     "1.0 1.0 0.0                \n"
31     "0.0 0.0 0.5                \n"
32     "0.5 0.0 0.5                \n"
33     "1.0 0.0 0.5                \n"
34     "0.0 0.5 0.5                \n"
35     "0.5 0.5 0.5                \n"
36     "1.0 0.5 0.5                \n"
37     "0.0 1.0 0.5                \n"
38     "0.5 1.0 0.5                \n"
39     "1.0 1.0 0.5                \n"
40     "0.0 0.0 1.0                \n"
41     "0.5 0.0 1.0                \n"
42     "1.0 0.0 1.0                \n"
43     "0.0 0.5 1.0                \n"
44     "0.5 0.5 1.0                \n"
45     "1.0 0.5 1.0                \n"
46     "0.0 1.0 1.0                \n"
47     "0.5 1.0 1.0                \n"
48     "1.0 1.0 1.0                \n",
49 
50     "LUT_1D_SIZE 3              \n"
51     "TITLE \"custom domain\"    \n"
52     "DOMAIN_MAX 255 255 255     \n"
53     "0 0 0                      \n"
54     "128 128 128                \n"
55     "255 255 255                \n"
56 
57 };
58 
main()59 int main()
60 {
61     pl_log log = pl_test_logger();
62     pl_gpu gpu = pl_gpu_dummy_create(log, NULL);
63     pl_shader sh = pl_shader_alloc(log, NULL);
64     pl_shader_obj obj = NULL;
65 
66     for (int i = 0; i < PL_ARRAY_SIZE(luts); i++) {
67         struct pl_custom_lut *lut;
68         lut = pl_lut_parse_cube(log, luts[i], strlen(luts[i]));
69         REQUIRE(lut);
70 
71         pl_shader_reset(sh, &(struct pl_shader_params) { .gpu = gpu});
72         pl_shader_custom_lut(sh, lut, &obj);
73         const struct pl_shader_res *res = pl_shader_finalize(sh);
74         REQUIRE(res);
75         printf("Generated LUT shader:\n%s\n", res->glsl);
76         pl_lut_free(&lut);
77     }
78 
79     pl_shader_obj_destroy(&obj);
80     pl_shader_free(&sh);
81     pl_log_destroy(&log);
82 }
83