1 /*
2 * Copyright © 2016 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #ifndef VK_FORMAT_INFO_H
25 #define VK_FORMAT_INFO_H
26
27 #include <stdbool.h>
28 #include <vulkan/vulkan.h>
29
30 #include "util/format/u_format.h"
31 #include "vulkan/util/vk_format.h"
32
33 /* FIXME: from freedreno vk_format.h, common place?*/
34 static inline bool
vk_format_is_int(VkFormat format)35 vk_format_is_int(VkFormat format)
36 {
37 return util_format_is_pure_integer(vk_format_to_pipe_format(format));
38 }
39
40 static inline bool
vk_format_is_sint(VkFormat format)41 vk_format_is_sint(VkFormat format)
42 {
43 return util_format_is_pure_sint(vk_format_to_pipe_format(format));
44 }
45
46 static inline bool
vk_format_is_uint(VkFormat format)47 vk_format_is_uint(VkFormat format)
48 {
49 return util_format_is_pure_uint(vk_format_to_pipe_format(format));
50 }
51
52 static inline bool
vk_format_is_unorm(VkFormat format)53 vk_format_is_unorm(VkFormat format)
54 {
55 return util_format_is_unorm(vk_format_to_pipe_format(format));
56 }
57
58 static inline bool
vk_format_is_snorm(VkFormat format)59 vk_format_is_snorm(VkFormat format)
60 {
61 return util_format_is_snorm(vk_format_to_pipe_format(format));
62 }
63
64 static inline bool
vk_format_is_float(VkFormat format)65 vk_format_is_float(VkFormat format)
66 {
67 return util_format_is_float(vk_format_to_pipe_format(format));
68 }
69
70 static inline bool
vk_format_is_srgb(VkFormat format)71 vk_format_is_srgb(VkFormat format)
72 {
73 return util_format_is_srgb(vk_format_to_pipe_format(format));
74 }
75
76 static inline unsigned
vk_format_get_blocksize(VkFormat format)77 vk_format_get_blocksize(VkFormat format)
78 {
79 return util_format_get_blocksize(vk_format_to_pipe_format(format));
80 }
81
82 static inline unsigned
vk_format_get_blockwidth(VkFormat format)83 vk_format_get_blockwidth(VkFormat format)
84 {
85 return util_format_get_blockwidth(vk_format_to_pipe_format(format));
86 }
87
88 static inline unsigned
vk_format_get_blockheight(VkFormat format)89 vk_format_get_blockheight(VkFormat format)
90 {
91 return util_format_get_blockheight(vk_format_to_pipe_format(format));
92 }
93
94 static inline bool
vk_format_is_compressed(VkFormat format)95 vk_format_is_compressed(VkFormat format)
96 {
97 return util_format_is_compressed(vk_format_to_pipe_format(format));
98 }
99
100 static inline const struct util_format_description *
vk_format_description(VkFormat format)101 vk_format_description(VkFormat format)
102 {
103 return util_format_description(vk_format_to_pipe_format(format));
104 }
105
106 #endif /* VK_FORMAT_INFO_H */
107