Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 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 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 34 | static inline bool icd_format_is_undef(VkFormat format) |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 35 | { |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 36 | return (format == VK_FORMAT_UNDEFINED); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 37 | } |
| 38 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 39 | bool icd_format_is_ds(VkFormat format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 40 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 41 | static inline bool icd_format_is_color(VkFormat format) |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 42 | { |
| 43 | return !(icd_format_is_undef(format) || icd_format_is_ds(format)); |
| 44 | } |
| 45 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 46 | bool icd_format_is_norm(VkFormat format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 47 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 48 | bool icd_format_is_int(VkFormat format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 49 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 50 | bool icd_format_is_float(VkFormat format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 51 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 52 | bool icd_format_is_srgb(VkFormat format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 53 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 54 | bool icd_format_is_compressed(VkFormat format); |
Chia-I Wu | 6320abc | 2014-10-20 13:50:43 +0800 | [diff] [blame] | 55 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 56 | static inline int icd_format_get_block_width(VkFormat 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 | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 62 | static inline bool icd_blend_mode_is_dual_src(VkBlend mode) |
Courtney Goeltzenleuchter | df13a4d | 2015-02-11 14:14:45 -0700 | [diff] [blame] | 63 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 64 | 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 Goeltzenleuchter | df13a4d | 2015-02-11 14:14:45 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 70 | static inline bool icd_pipeline_cb_att_needs_dual_source_blending(const VkPipelineCbAttachmentState *att) |
Courtney Goeltzenleuchter | df13a4d | 2015-02-11 14:14:45 -0700 | [diff] [blame] | 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 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 81 | size_t icd_format_get_size(VkFormat format); |
Chia-I Wu | 40ee55b | 2014-10-08 09:12:58 +0800 | [diff] [blame] | 82 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 83 | unsigned int icd_format_get_channel_count(VkFormat format); |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 84 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 85 | void icd_format_get_raw_value(VkFormat format, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 86 | const uint32_t color[4], |
Chia-I Wu | 92096a9 | 2014-12-21 23:07:08 +0800 | [diff] [blame] | 87 | void *value); |
| 88 | |
Chia-I Wu | b5a1add | 2014-08-16 12:46:32 +0800 | [diff] [blame] | 89 | #endif /* ICD_FORMAT_H */ |