LCOV - code coverage report
Current view: top level - src/tests - lut.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 18 18 100.0 %
Date: 2025-03-29 09:04:10 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 6 66.7 %

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

Generated by: LCOV version 1.16