blob: 28c2dcae80e025d78dc66d0d5d8972ae8c18e951 [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
Ian Elliotta742a622015-02-18 12:38:04 -070034static inline bool icd_format_is_undef(XGL_FORMAT format)
Chia-I Wub5a1add2014-08-16 12:46:32 +080035{
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -070036 return (format == XGL_FMT_UNDEFINED);
Chia-I Wub5a1add2014-08-16 12:46:32 +080037}
38
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -070039bool icd_format_is_ds(XGL_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080040
Ian Elliotta742a622015-02-18 12:38:04 -070041static inline bool icd_format_is_color(XGL_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
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -070046bool icd_format_is_norm(XGL_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080047
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -070048bool icd_format_is_int(XGL_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080049
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -070050bool icd_format_is_float(XGL_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080051
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -070052bool icd_format_is_srgb(XGL_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080053
Jeremy Hayes2b7e88a2015-01-23 08:51:43 -070054bool icd_format_is_compressed(XGL_FORMAT format);
Chia-I Wu6320abc2014-10-20 13:50:43 +080055
Ian Elliotta742a622015-02-18 12:38:04 -070056static inline int icd_format_get_block_width(XGL_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
Ian Elliotta742a622015-02-18 12:38:04 -070062static inline bool icd_blend_mode_is_dual_src(XGL_BLEND mode)
Courtney Goeltzenleuchterdf13a4d2015-02-11 14:14:45 -070063{
64 return (mode == XGL_BLEND_SRC1_COLOR) ||
65 (mode == XGL_BLEND_SRC1_ALPHA) ||
66 (mode == XGL_BLEND_ONE_MINUS_SRC1_COLOR) ||
67 (mode == XGL_BLEND_ONE_MINUS_SRC1_ALPHA);
68}
69
Ian Elliotta742a622015-02-18 12:38:04 -070070static inline bool icd_pipeline_cb_att_needs_dual_source_blending(const XGL_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
Chia-I Wu54ed0792014-12-27 14:14:50 +080081size_t icd_format_get_size(XGL_FORMAT format);
Chia-I Wu40ee55b2014-10-08 09:12:58 +080082
Jon Ashburnc6ae13d2015-01-19 15:00:26 -070083XGL_IMAGE_FORMAT_CLASS icd_format_get_class(XGL_FORMAT format);
84
Jeremy Hayes4c329eb2015-01-14 14:58:37 -070085unsigned int icd_format_get_channel_count(XGL_FORMAT format);
Chia-I Wub5a1add2014-08-16 12:46:32 +080086
Chia-I Wu92096a92014-12-21 23:07:08 +080087void icd_format_get_raw_value(XGL_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 */