blob: ebf7d5da2a2c1c3910116f900ebbbd0a67ac2e1a [file] [log] [blame]
Chia-I Wub5a1add2014-08-16 12:46:32 +08001/*
2 * XGL
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
Chia-I Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wub5a1add2014-08-16 12:46:32 +080026 */
27
28#ifndef ICD_FORMAT_H
29#define ICD_FORMAT_H
30
31#include <stdbool.h>
32#include "icd.h"
33
34static inline bool icd_format_is_undef(XGL_FORMAT format)
35{
36 return (format.numericFormat == XGL_NUM_FMT_UNDEFINED);
37}
38
39static inline bool icd_format_is_ds(XGL_FORMAT format)
40{
41 return (format.numericFormat == XGL_NUM_FMT_DS);
42}
43
44static inline bool icd_format_is_color(XGL_FORMAT format)
45{
46 return !(icd_format_is_undef(format) || icd_format_is_ds(format));
47}
48
49static inline bool icd_format_is_norm(XGL_FORMAT format)
50{
51 return (format.numericFormat == XGL_NUM_FMT_UNORM ||
52 format.numericFormat == XGL_NUM_FMT_SNORM);
53};
54
55static inline bool icd_format_is_int(XGL_FORMAT format)
56{
57 return (format.numericFormat == XGL_NUM_FMT_UINT ||
58 format.numericFormat == XGL_NUM_FMT_SINT);
59}
60
61static inline bool icd_format_is_float(XGL_FORMAT format)
62{
63 return (format.numericFormat == XGL_NUM_FMT_FLOAT);
64}
65
66static inline bool icd_format_is_srgb(XGL_FORMAT format)
67{
68 return (format.numericFormat == XGL_NUM_FMT_SRGB);
69}
70
71static inline bool icd_format_is_compressed(XGL_FORMAT format)
72{
73 switch (format.channelFormat) {
74 case XGL_CH_FMT_BC1:
75 case XGL_CH_FMT_BC2:
76 case XGL_CH_FMT_BC3:
77 case XGL_CH_FMT_BC4:
78 case XGL_CH_FMT_BC5:
79 case XGL_CH_FMT_BC6U:
80 case XGL_CH_FMT_BC6S:
81 case XGL_CH_FMT_BC7:
82 return true;
83 default:
84 return false;
85 }
86}
87
88static inline bool icd_format_get_block_width(XGL_FORMAT format)
89{
90 /* all compressed formats use 4x4 blocks */
91 return (icd_format_is_compressed(format)) ? 4 : 1;
92}
93
94unsigned int icd_format_get_size(XGL_FORMAT format);
95
96#endif /* ICD_FORMAT_H */