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. |
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 | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef INTEL_H |
| 29 | #define INTEL_H |
| 30 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 31 | #include <stdlib.h> |
Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 32 | #include <stdbool.h> |
Chia-I Wu | aabb360 | 2014-08-19 14:18:23 +0800 | [diff] [blame] | 33 | #include <stdint.h> |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 34 | #include <string.h> |
Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 35 | #include <assert.h> |
| 36 | |
| 37 | #include <xgl.h> |
| 38 | #include <xglDbg.h> |
Chia-I Wu | b8dceae | 2014-09-23 10:37:23 +0800 | [diff] [blame] | 39 | #include <xglWsiX11Ext.h> |
Chia-I Wu | 924c1fc | 2015-01-19 11:14:00 +0800 | [diff] [blame^] | 40 | #include <xglIcd.h> |
Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 41 | |
| 42 | #include "icd.h" |
Chia-I Wu | 900364b | 2015-01-03 13:55:22 +0800 | [diff] [blame] | 43 | #include "icd-alloc.h" |
Chia-I Wu | 4115c89 | 2014-08-28 11:56:29 +0800 | [diff] [blame] | 44 | #include "icd-bil.h" |
Chia-I Wu | 1bf06df | 2014-08-16 12:33:13 +0800 | [diff] [blame] | 45 | #include "icd-format.h" |
Chia-I Wu | 8e270b5 | 2015-01-03 14:47:32 +0800 | [diff] [blame] | 46 | #include "icd-log.h" |
Chia-I Wu | 69abeac | 2014-08-16 12:43:53 +0800 | [diff] [blame] | 47 | #include "icd-utils.h" |
Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 48 | |
Courtney Goeltzenleuchter | 211cc54 | 2015-02-23 17:40:15 -0700 | [diff] [blame] | 49 | #define INTEL_API_VERSION XGL_API_VERSION |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 50 | #define INTEL_DRIVER_VERSION 0 |
| 51 | |
| 52 | #define INTEL_GEN(gen) ((int) ((gen) * 100)) |
| 53 | |
Chia-I Wu | 2469371 | 2014-11-08 11:54:47 +0800 | [diff] [blame] | 54 | #define INTEL_MAX_VERTEX_BINDING_COUNT 33 |
| 55 | #define INTEL_MAX_VERTEX_ELEMENT_COUNT (INTEL_MAX_VERTEX_BINDING_COUNT + 1) |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 56 | #define INTEL_MAX_RENDER_TARGETS 8 |
| 57 | |
Chia-I Wu | 1c52701 | 2014-08-23 14:57:35 +0800 | [diff] [blame] | 58 | enum intel_debug_flags { |
| 59 | INTEL_DEBUG_BATCH = 1 << 0, |
Chia-I Wu | 93ada31 | 2014-08-23 15:02:25 +0800 | [diff] [blame] | 60 | |
| 61 | INTEL_DEBUG_NOHW = 1 << 20, |
Chia-I Wu | 3fb47ce | 2014-10-28 11:19:36 +0800 | [diff] [blame] | 62 | INTEL_DEBUG_NOCACHE = 1 << 21, |
Chia-I Wu | c45db53 | 2015-02-19 11:20:38 -0700 | [diff] [blame] | 63 | INTEL_DEBUG_NOHIZ = 1 << 22, |
| 64 | INTEL_DEBUG_HANG = 1 << 23, |
Chia-I Wu | 1c52701 | 2014-08-23 14:57:35 +0800 | [diff] [blame] | 65 | }; |
| 66 | |
Chia-I Wu | 924c1fc | 2015-01-19 11:14:00 +0800 | [diff] [blame^] | 67 | struct intel_handle { |
| 68 | /* the loader expects a "void *" at the beginning */ |
| 69 | void *loader_data; |
| 70 | |
| 71 | uint32_t magic; |
| 72 | }; |
| 73 | |
Chia-I Wu | 1c52701 | 2014-08-23 14:57:35 +0800 | [diff] [blame] | 74 | extern int intel_debug; |
| 75 | |
Chia-I Wu | 924c1fc | 2015-01-19 11:14:00 +0800 | [diff] [blame^] | 76 | static const uint32_t intel_handle_magic = 0x494e544c; |
| 77 | |
| 78 | static inline void intel_handle_init(struct intel_handle *handle, |
| 79 | XGL_DBG_OBJECT_TYPE type) |
| 80 | { |
| 81 | set_loader_magic_value(handle); |
| 82 | |
| 83 | handle->magic = intel_handle_magic + type; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Return true if \p handle is a valid intel_handle. This assumes the first |
| 88 | * sizeof(intel_handle) bytes are readable, and they does not happen to have |
| 89 | * our magic values. |
| 90 | */ |
| 91 | static inline bool intel_handle_validate(const void *handle) |
| 92 | { |
| 93 | const uint32_t handle_type = |
| 94 | ((const struct intel_handle *) handle)->magic - intel_handle_magic; |
| 95 | |
| 96 | return (handle_type <= XGL_DBG_OBJECT_TYPE_END_RANGE); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Return true if \p handle is a valid intel_handle of \p type. |
| 101 | * |
| 102 | * \see intel_handle_validate(). |
| 103 | */ |
| 104 | static inline bool intel_handle_validate_type(const void *handle, |
| 105 | XGL_DBG_OBJECT_TYPE type) |
| 106 | { |
| 107 | const uint32_t handle_type = |
| 108 | ((const struct intel_handle *) handle)->magic - intel_handle_magic; |
| 109 | |
| 110 | return (handle_type == (uint32_t) type); |
| 111 | } |
| 112 | |
Chia-I Wu | c6fb9af | 2014-08-04 11:28:43 +0800 | [diff] [blame] | 113 | #endif /* INTEL_H */ |