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. |
| 23 | */ |
| 24 | |
| 25 | #ifndef ICD_FORMAT_H |
| 26 | #define ICD_FORMAT_H |
| 27 | |
| 28 | #include <stdbool.h> |
| 29 | #include "icd.h" |
| 30 | |
| 31 | static inline bool icd_format_is_undef(XGL_FORMAT format) |
| 32 | { |
| 33 | return (format.numericFormat == XGL_NUM_FMT_UNDEFINED); |
| 34 | } |
| 35 | |
| 36 | static inline bool icd_format_is_ds(XGL_FORMAT format) |
| 37 | { |
| 38 | return (format.numericFormat == XGL_NUM_FMT_DS); |
| 39 | } |
| 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 | |
| 46 | static inline bool icd_format_is_norm(XGL_FORMAT format) |
| 47 | { |
| 48 | return (format.numericFormat == XGL_NUM_FMT_UNORM || |
| 49 | format.numericFormat == XGL_NUM_FMT_SNORM); |
| 50 | }; |
| 51 | |
| 52 | static inline bool icd_format_is_int(XGL_FORMAT format) |
| 53 | { |
| 54 | return (format.numericFormat == XGL_NUM_FMT_UINT || |
| 55 | format.numericFormat == XGL_NUM_FMT_SINT); |
| 56 | } |
| 57 | |
| 58 | static inline bool icd_format_is_float(XGL_FORMAT format) |
| 59 | { |
| 60 | return (format.numericFormat == XGL_NUM_FMT_FLOAT); |
| 61 | } |
| 62 | |
| 63 | static inline bool icd_format_is_srgb(XGL_FORMAT format) |
| 64 | { |
| 65 | return (format.numericFormat == XGL_NUM_FMT_SRGB); |
| 66 | } |
| 67 | |
| 68 | static inline bool icd_format_is_compressed(XGL_FORMAT format) |
| 69 | { |
| 70 | switch (format.channelFormat) { |
| 71 | case XGL_CH_FMT_BC1: |
| 72 | case XGL_CH_FMT_BC2: |
| 73 | case XGL_CH_FMT_BC3: |
| 74 | case XGL_CH_FMT_BC4: |
| 75 | case XGL_CH_FMT_BC5: |
| 76 | case XGL_CH_FMT_BC6U: |
| 77 | case XGL_CH_FMT_BC6S: |
| 78 | case XGL_CH_FMT_BC7: |
| 79 | return true; |
| 80 | default: |
| 81 | return false; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | static inline bool icd_format_get_block_width(XGL_FORMAT format) |
| 86 | { |
| 87 | /* all compressed formats use 4x4 blocks */ |
| 88 | return (icd_format_is_compressed(format)) ? 4 : 1; |
| 89 | } |
| 90 | |
| 91 | unsigned int icd_format_get_size(XGL_FORMAT format); |
| 92 | |
| 93 | #endif /* ICD_FORMAT_H */ |