Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +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 INTEL_H |
| 26 | #define INTEL_H |
| 27 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 28 | #include <stdlib.h> |
Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 29 | #include <stdbool.h> |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 30 | #include <string.h> |
Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 31 | #include <assert.h> |
| 32 | |
| 33 | #include <xgl.h> |
| 34 | #include <xglDbg.h> |
| 35 | |
| 36 | #include "icd.h" |
| 37 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 38 | #define INTEL_API_VERSION XGL_MAKE_VERSION(0, 22, 0) |
| 39 | #define INTEL_DRIVER_VERSION 0 |
| 40 | |
| 41 | #define INTEL_GEN(gen) ((int) ((gen) * 100)) |
| 42 | |
Chia-I Wu | e54854a | 2014-08-05 10:23:50 +0800 | [diff] [blame] | 43 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 44 | |
Chia-I Wu | 2132b56 | 2014-08-08 21:52:26 +0800 | [diff] [blame] | 45 | /** |
| 46 | * Return true if val is power of two, or zero. |
| 47 | */ |
| 48 | static inline bool u_is_pow2(unsigned int val) |
Chia-I Wu | a02cd52 | 2014-08-07 13:36:04 +0800 | [diff] [blame] | 49 | { |
Chia-I Wu | 2132b56 | 2014-08-08 21:52:26 +0800 | [diff] [blame] | 50 | return ((val & (val - 1)) == 0); |
| 51 | } |
| 52 | |
| 53 | static inline unsigned int u_align(unsigned int val, unsigned alignment) |
| 54 | { |
| 55 | assert(alignment && u_is_pow2(alignment)); |
Chia-I Wu | a02cd52 | 2014-08-07 13:36:04 +0800 | [diff] [blame] | 56 | return (val + alignment - 1) & ~(alignment - 1); |
| 57 | } |
| 58 | |
Chia-I Wu | 2132b56 | 2014-08-08 21:52:26 +0800 | [diff] [blame] | 59 | static inline unsigned int u_minify(unsigned int val, unsigned level) |
| 60 | { |
| 61 | return (val >> level) ? val >> level : 1; |
| 62 | } |
| 63 | |
Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 64 | #endif /* INTEL_H */ |