~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/util/tests/format/srgb.c

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <stdio.h>
2
 
#include <stdlib.h>
3
 
 
4
 
#include "util/macros.h"
5
 
#include "util/format/u_format.h"
6
 
#include "pipe/p_format.h"
7
 
 
8
 
int main(void)
9
 
{
10
 
   for (enum pipe_format format = 0; format < PIPE_FORMAT_COUNT; format++)
11
 
   {
12
 
      if (!util_format_is_srgb(format)) {
13
 
         const enum pipe_format linear = util_format_linear(format);
14
 
         if (format != linear) {
15
 
            fprintf(stderr, "%s converted to linear is %s\n",
16
 
                    util_format_name(format),
17
 
                    util_format_name(linear));
18
 
            return EXIT_FAILURE;
19
 
         }
20
 
         continue;
21
 
      }
22
 
 
23
 
      const enum pipe_format linear = util_format_linear(format);
24
 
      if (format == linear) {
25
 
         fprintf(stderr, "%s can't be converted to a linear equivalent\n",
26
 
                 util_format_name(format));
27
 
         return EXIT_FAILURE;
28
 
      }
29
 
 
30
 
      const enum pipe_format srgb = util_format_srgb(linear);
31
 
      if (format != srgb) {
32
 
         fprintf(stderr, "%s converted to linear and back to srgb becomes %s\n",
33
 
                 util_format_name(format),
34
 
                 util_format_name(srgb));
35
 
         return EXIT_FAILURE;
36
 
      }
37
 
   }
38
 
 
39
 
   return EXIT_SUCCESS;
40
 
}