blob: ea227c13ab7934786f4bf3d2c312041cd76353ed [file] [log] [blame]
Chia-I Wub5a1add2014-08-16 12:46:32 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wub5a1add2014-08-16 12:46:32 +08003 *
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
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060034static inline bool icd_format_is_undef(VK_FORMAT format)
Chia-I Wub5a1add2014-08-16 12:46:32 +080035{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060036 return (format == VK_FMT_UNDEFINED);
Chia-I Wub5a1add2014-08-16 12:46:32 +080037}
38
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060039bool icd_format_is_ds(VK_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080040
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060041static inline bool icd_format_is_color(VK_FORMAT format)
Chia-I Wub5a1add2014-08-16 12:46:32 +080042{
43 return !(icd_format_is_undef(format) || icd_format_is_ds(format));
44}
45
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060046bool icd_format_is_norm(VK_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080047
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060048bool icd_format_is_int(VK_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080049
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060050bool icd_format_is_float(VK_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080051
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060052bool icd_format_is_srgb(VK_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080053
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060054bool icd_format_is_compressed(VK_FORMAT format);
Chia-I Wu6320abc2014-10-20 13:50:43 +080055
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060056static inline int icd_format_get_block_width(VK_FORMAT format)
Chia-I Wub5a1add2014-08-16 12:46:32 +080057{
58 /* all compressed formats use 4x4 blocks */
59 return (icd_format_is_compressed(format)) ? 4 : 1;
60}
61
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060062static inline bool icd_blend_mode_is_dual_src(VK_BLEND mode)
Courtney Goeltzenleuchterdf13a4d2015-02-11 14:14:45 -070063{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060064 return (mode == VK_BLEND_SRC1_COLOR) ||
65 (mode == VK_BLEND_SRC1_ALPHA) ||
66 (mode == VK_BLEND_ONE_MINUS_SRC1_COLOR) ||
67 (mode == VK_BLEND_ONE_MINUS_SRC1_ALPHA);
Courtney Goeltzenleuchterdf13a4d2015-02-11 14:14:45 -070068}
69
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060070static inline bool icd_pipeline_cb_att_needs_dual_source_blending(const VK_PIPELINE_CB_ATTACHMENT_STATE *att)
Courtney Goeltzenleuchterdf13a4d2015-02-11 14:14:45 -070071{
72 if (icd_blend_mode_is_dual_src(att->srcBlendColor) ||
73 icd_blend_mode_is_dual_src(att->srcBlendAlpha) ||
74 icd_blend_mode_is_dual_src(att->destBlendColor) ||
75 icd_blend_mode_is_dual_src(att->destBlendAlpha)) {
76 return true;
77 }
78 return false;
79}
80
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060081size_t icd_format_get_size(VK_FORMAT format);
Chia-I Wu40ee55b2014-10-08 09:12:58 +080082
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060083VK_IMAGE_FORMAT_CLASS icd_format_get_class(VK_FORMAT format);
Jon Ashburnc6ae13d2015-01-19 15:00:26 -070084
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060085unsigned int icd_format_get_channel_count(VK_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080086
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060087void icd_format_get_raw_value(VK_FORMAT format,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060088 const uint32_t color[4],
Chia-I Wu92096a92014-12-21 23:07:08 +080089 void *value);
90
Chia-I Wub5a1add2014-08-16 12:46:32 +080091#endif /* ICD_FORMAT_H */