Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 1 | /* |
| 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 Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 23 | * |
| 24 | * Authors: |
| 25 | * Chia-I Wu <olv@lunarg.com> |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef ICD_FORMAT_H |
| 29 | #define ICD_FORMAT_H |
| 30 | |
| 31 | #include <stdbool.h> |
| 32 | #include "icd.h" |
| 33 | |
| 34 | static inline bool icd_format_is_undef(XGL_FORMAT format) |
| 35 | { |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 36 | return (format == XGL_FMT_UNDEFINED); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 37 | } |
| 38 | |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 39 | bool icd_format_is_ds(XGL_FORMAT format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 40 | |
| 41 | static inline bool icd_format_is_color(XGL_FORMAT format) |
| 42 | { |
| 43 | return !(icd_format_is_undef(format) || icd_format_is_ds(format)); |
| 44 | } |
| 45 | |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 46 | bool icd_format_is_norm(XGL_FORMAT format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 47 | |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 48 | bool icd_format_is_int(XGL_FORMAT format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 49 | |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 50 | bool icd_format_is_float(XGL_FORMAT format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 51 | |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 52 | bool icd_format_is_srgb(XGL_FORMAT format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 53 | |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 54 | bool icd_format_is_compressed(XGL_FORMAT format); |
Chia-I Wu | 6320abc | 2014-10-20 13:50:43 +0800 | [diff] [blame] | 55 | |
Courtney Goeltzenleuchter | 74deb37 | 2014-10-14 18:14:31 -0600 | [diff] [blame] | 56 | static inline int icd_format_get_block_width(XGL_FORMAT format) |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 57 | { |
| 58 | /* all compressed formats use 4x4 blocks */ |
| 59 | return (icd_format_is_compressed(format)) ? 4 : 1; |
| 60 | } |
| 61 | |
Courtney Goeltzenleuchter | df13a4d | 2015-02-11 14:14:45 -0700 | [diff] [blame^] | 62 | static inline bool icd_blend_mode_is_dual_src(XGL_BLEND mode) |
| 63 | { |
| 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 | |
| 70 | static inline bool icd_pipeline_cb_att_needs_dual_source_blending(const XGL_PIPELINE_CB_ATTACHMENT_STATE *att) |
| 71 | { |
| 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 Wu | 54ed079 | 2014-12-27 14:14:50 +0800 | [diff] [blame] | 81 | size_t icd_format_get_size(XGL_FORMAT format); |
Chia-I Wu | 40ee55b | 2014-10-08 09:12:58 +0800 | [diff] [blame] | 82 | |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 83 | XGL_IMAGE_FORMAT_CLASS icd_format_get_class(XGL_FORMAT format); |
| 84 | |
Jeremy Hayes | 4c329eb | 2015-01-14 14:58:37 -0700 | [diff] [blame] | 85 | unsigned int icd_format_get_channel_count(XGL_FORMAT format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 86 | |
Chia-I Wu | 92096a9 | 2014-12-21 23:07:08 +0800 | [diff] [blame] | 87 | void icd_format_get_raw_value(XGL_FORMAT format, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 88 | const uint32_t color[4], |
Chia-I Wu | 92096a9 | 2014-12-21 23:07:08 +0800 | [diff] [blame] | 89 | void *value); |
| 90 | |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 91 | #endif /* ICD_FORMAT_H */ |