aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/tests/format/srgb.c
blob: 9b3c15e65cee2732f8c16bdf7830158eab767be8 (plain)
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
#include <stdio.h>
#include <stdlib.h>

#include "util/macros.h"
#include "util/format/u_format.h"
#include "pipe/p_format.h"

int main(void)
{
   for (enum pipe_format format = 0; format < PIPE_FORMAT_COUNT; format++)
   {
      if (!util_format_is_srgb(format)) {
         const enum pipe_format linear = util_format_linear(format);
         if (format != linear) {
            fprintf(stderr, "%s converted to linear is %s\n",
                    util_format_name(format),
                    util_format_name(linear));
            return EXIT_FAILURE;
         }
         continue;
      }

      const enum pipe_format linear = util_format_linear(format);
      if (format == linear) {
         fprintf(stderr, "%s can't be converted to a linear equivalent\n",
                 util_format_name(format));
         return EXIT_FAILURE;
      }

      const enum pipe_format srgb = util_format_srgb(linear);
      if (format != srgb) {
         fprintf(stderr, "%s converted to linear and back to srgb becomes %s\n",
                 util_format_name(format),
                 util_format_name(srgb));
         return EXIT_FAILURE;
      }
   }

   return EXIT_SUCCESS;
}