Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +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 | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef GPU_H |
| 29 | #define GPU_H |
| 30 | |
| 31 | #include "intel.h" |
| 32 | |
Chia-I Wu | 9269d1c | 2014-08-16 12:47:47 +0800 | [diff] [blame] | 33 | #define INTEL_GPU_ASSERT(gpu, min_gen, max_gen) \ |
| 34 | assert(intel_gpu_gen(gpu) >= INTEL_GEN(min_gen) && \ |
| 35 | intel_gpu_gen(gpu) <= INTEL_GEN(max_gen)) |
| 36 | |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame] | 37 | enum intel_ext_type { |
| 38 | INTEL_EXT_WSI_X11, |
| 39 | |
| 40 | INTEL_EXT_COUNT, |
| 41 | INTEL_EXT_INVALID = INTEL_EXT_COUNT, |
| 42 | }; |
| 43 | |
Tobin Ehlis | 0ef6ec5 | 2015-04-16 12:51:37 -0600 | [diff] [blame] | 44 | /* |
| 45 | * No device-specific extensions at thie point, so this enum is a placeholder |
| 46 | */ |
| 47 | enum intel_physical_device_ext_type { |
| 48 | INTEL_PHY_DEV_EXT_COUNT, |
| 49 | INTEL_PHY_DEV_EXT_INVALID = INTEL_PHY_DEV_EXT_COUNT, |
| 50 | }; |
| 51 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 52 | enum intel_gpu_engine_type { |
| 53 | /* TODO BLT support */ |
| 54 | INTEL_GPU_ENGINE_3D, |
| 55 | |
| 56 | INTEL_GPU_ENGINE_COUNT |
| 57 | }; |
| 58 | |
Chia-I Wu | d71ff55 | 2015-02-20 12:50:12 -0700 | [diff] [blame] | 59 | struct intel_instance; |
Chia-I Wu | 8635e91 | 2015-04-09 14:13:57 +0800 | [diff] [blame] | 60 | struct intel_wsi_display; |
Chia-I Wu | d896593 | 2014-10-13 13:32:37 +0800 | [diff] [blame] | 61 | struct intel_winsys; |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame] | 62 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 63 | /* |
| 64 | * intel_gpu is the only object that does not inherit from intel_base. |
| 65 | */ |
| 66 | struct intel_gpu { |
Chia-I Wu | 924c1fc | 2015-01-19 11:14:00 +0800 | [diff] [blame] | 67 | struct intel_handle handle; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 68 | |
| 69 | struct intel_gpu *next; |
| 70 | |
| 71 | int devid; /* PCI device ID */ |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 72 | char *primary_node; /* path to the primary node */ |
| 73 | char *render_node; /* path to the render node */ |
| 74 | int gen_opaque; /* always read this with intel_gpu_gen() */ |
Chia-I Wu | 960f195 | 2014-08-28 23:27:10 +0800 | [diff] [blame] | 75 | int gt; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 76 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame^] | 77 | VkDeviceSize max_batch_buffer_size; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 78 | uint32_t batch_buffer_reloc_count; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 79 | |
| 80 | /* |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 81 | * The enabled hardware features could be limited by the kernel. These |
| 82 | * mutable fds allows us to talk to the kernel before the device is |
| 83 | * created. |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 84 | */ |
Chia-I Wu | f07865e | 2014-09-15 13:52:21 +0800 | [diff] [blame] | 85 | int primary_fd_internal; |
| 86 | int render_fd_internal; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 87 | |
Chia-I Wu | d896593 | 2014-10-13 13:32:37 +0800 | [diff] [blame] | 88 | struct intel_winsys *winsys; |
Chia-I Wu | 41858c8 | 2015-04-04 16:39:25 +0800 | [diff] [blame] | 89 | |
| 90 | void *wsi_data; |
Chia-I Wu | 8635e91 | 2015-04-09 14:13:57 +0800 | [diff] [blame] | 91 | |
| 92 | struct intel_wsi_display **displays; |
| 93 | uint32_t display_count; |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 94 | }; |
| 95 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame^] | 96 | static inline struct intel_gpu *intel_gpu(VkPhysicalDevice gpu) |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 97 | { |
| 98 | return (struct intel_gpu *) gpu; |
| 99 | } |
| 100 | |
| 101 | static inline int intel_gpu_gen(const struct intel_gpu *gpu) |
| 102 | { |
| 103 | #ifdef INTEL_GEN_SPECIALIZED |
| 104 | return INTEL_GEN(INTEL_GEN_SPECIALIZED); |
| 105 | #else |
| 106 | return gpu->gen_opaque; |
| 107 | #endif |
| 108 | } |
| 109 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 110 | VkResult intel_gpu_create(const struct intel_instance *instance, int devid, |
Chia-I Wu | d71ff55 | 2015-02-20 12:50:12 -0700 | [diff] [blame] | 111 | const char *primary_node, const char *render_node, |
| 112 | struct intel_gpu **gpu_ret); |
| 113 | void intel_gpu_destroy(struct intel_gpu *gpu); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 114 | |
| 115 | void intel_gpu_get_props(const struct intel_gpu *gpu, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame^] | 116 | VkPhysicalDeviceProperties *props); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 117 | void intel_gpu_get_perf(const struct intel_gpu *gpu, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame^] | 118 | VkPhysicalDevicePerformance *perf); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 119 | void intel_gpu_get_queue_props(const struct intel_gpu *gpu, |
| 120 | enum intel_gpu_engine_type engine, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame^] | 121 | VkPhysicalDeviceQueueProperties *props); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 122 | void intel_gpu_get_memory_props(const struct intel_gpu *gpu, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame^] | 123 | VkPhysicalDeviceMemoryProperties *props); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 124 | |
Chia-I Wu | 3f4bd10 | 2014-12-19 13:14:42 +0800 | [diff] [blame] | 125 | int intel_gpu_get_max_threads(const struct intel_gpu *gpu, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame^] | 126 | VkShaderStage stage); |
Chia-I Wu | 3f4bd10 | 2014-12-19 13:14:42 +0800 | [diff] [blame] | 127 | |
Chia-I Wu | 41858c8 | 2015-04-04 16:39:25 +0800 | [diff] [blame] | 128 | int intel_gpu_get_primary_fd(struct intel_gpu *gpu); |
| 129 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 130 | VkResult intel_gpu_init_winsys(struct intel_gpu *gpu); |
Chia-I Wu | 41858c8 | 2015-04-04 16:39:25 +0800 | [diff] [blame] | 131 | void intel_gpu_cleanup_winsys(struct intel_gpu *gpu); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 132 | |
Chia-I Wu | 1db76e0 | 2014-09-15 14:21:14 +0800 | [diff] [blame] | 133 | enum intel_ext_type intel_gpu_lookup_extension(const struct intel_gpu *gpu, |
| 134 | const char *ext); |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 135 | |
Chia-I Wu | 214dac6 | 2014-08-05 11:07:40 +0800 | [diff] [blame] | 136 | #endif /* GPU_H */ |