blob: eeb2d649d9c8ab27522de11b3306328c521b9010 [file] [log] [blame]
Chia-I Wu214dac62014-08-05 11:07:40 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wu214dac62014-08-05 11:07:40 +08003 *
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 Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wu214dac62014-08-05 11:07:40 +080026 */
27
28#ifndef GPU_H
29#define GPU_H
30
31#include "intel.h"
32
Chia-I Wu9269d1c2014-08-16 12:47:47 +080033#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 Wu1db76e02014-09-15 14:21:14 +080037enum intel_ext_type {
Chia-I Wu5b66aa52015-04-16 22:02:10 +080038 INTEL_EXT_WSI_LUNARG,
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060039 INTEL_EXT_DEBUG_REPORT,
40 INTEL_EXT_DEBUG_MARKER,
Chia-I Wu1db76e02014-09-15 14:21:14 +080041
42 INTEL_EXT_COUNT,
43 INTEL_EXT_INVALID = INTEL_EXT_COUNT,
44};
45
Tobin Ehlis0ef6ec52015-04-16 12:51:37 -060046/*
47 * No device-specific extensions at thie point, so this enum is a placeholder
48 */
49enum intel_physical_device_ext_type {
50 INTEL_PHY_DEV_EXT_COUNT,
51 INTEL_PHY_DEV_EXT_INVALID = INTEL_PHY_DEV_EXT_COUNT,
52};
53
Chia-I Wu214dac62014-08-05 11:07:40 +080054enum intel_gpu_engine_type {
55 /* TODO BLT support */
56 INTEL_GPU_ENGINE_3D,
57
58 INTEL_GPU_ENGINE_COUNT
59};
60
Chia-I Wud71ff552015-02-20 12:50:12 -070061struct intel_instance;
Chia-I Wu8635e912015-04-09 14:13:57 +080062struct intel_wsi_display;
Chia-I Wud8965932014-10-13 13:32:37 +080063struct intel_winsys;
Chia-I Wu1db76e02014-09-15 14:21:14 +080064
Chia-I Wu214dac62014-08-05 11:07:40 +080065/*
66 * intel_gpu is the only object that does not inherit from intel_base.
67 */
68struct intel_gpu {
Chia-I Wu924c1fc2015-01-19 11:14:00 +080069 struct intel_handle handle;
Chia-I Wu214dac62014-08-05 11:07:40 +080070
71 struct intel_gpu *next;
72
73 int devid; /* PCI device ID */
Chia-I Wuf07865e2014-09-15 13:52:21 +080074 char *primary_node; /* path to the primary node */
75 char *render_node; /* path to the render node */
76 int gen_opaque; /* always read this with intel_gpu_gen() */
Chia-I Wu960f1952014-08-28 23:27:10 +080077 int gt;
Chia-I Wu214dac62014-08-05 11:07:40 +080078
Tony Barbour8205d902015-04-16 15:59:00 -060079 VkDeviceSize max_batch_buffer_size;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060080 uint32_t batch_buffer_reloc_count;
Chia-I Wu214dac62014-08-05 11:07:40 +080081
82 /*
Chia-I Wuf07865e2014-09-15 13:52:21 +080083 * The enabled hardware features could be limited by the kernel. These
84 * mutable fds allows us to talk to the kernel before the device is
85 * created.
Chia-I Wu214dac62014-08-05 11:07:40 +080086 */
Chia-I Wuf07865e2014-09-15 13:52:21 +080087 int primary_fd_internal;
88 int render_fd_internal;
Chia-I Wu214dac62014-08-05 11:07:40 +080089
Chia-I Wud8965932014-10-13 13:32:37 +080090 struct intel_winsys *winsys;
Chia-I Wu41858c82015-04-04 16:39:25 +080091
Chia-I Wu8635e912015-04-09 14:13:57 +080092 struct intel_wsi_display **displays;
93 uint32_t display_count;
Chia-I Wu214dac62014-08-05 11:07:40 +080094};
95
Tony Barbour8205d902015-04-16 15:59:00 -060096static inline struct intel_gpu *intel_gpu(VkPhysicalDevice gpu)
Chia-I Wu214dac62014-08-05 11:07:40 +080097{
98 return (struct intel_gpu *) gpu;
99}
100
101static 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 Goeltzenleuchter382489d2015-04-10 08:34:15 -0600110VkResult intel_gpu_create(const struct intel_instance *instance, int devid,
Chia-I Wud71ff552015-02-20 12:50:12 -0700111 const char *primary_node, const char *render_node,
112 struct intel_gpu **gpu_ret);
113void intel_gpu_destroy(struct intel_gpu *gpu);
Chia-I Wu214dac62014-08-05 11:07:40 +0800114
115void intel_gpu_get_props(const struct intel_gpu *gpu,
Tony Barbour8205d902015-04-16 15:59:00 -0600116 VkPhysicalDeviceProperties *props);
Chia-I Wu214dac62014-08-05 11:07:40 +0800117void intel_gpu_get_perf(const struct intel_gpu *gpu,
Tony Barbour8205d902015-04-16 15:59:00 -0600118 VkPhysicalDevicePerformance *perf);
Chia-I Wu214dac62014-08-05 11:07:40 +0800119void intel_gpu_get_queue_props(const struct intel_gpu *gpu,
120 enum intel_gpu_engine_type engine,
Tony Barbour8205d902015-04-16 15:59:00 -0600121 VkPhysicalDeviceQueueProperties *props);
Chia-I Wu214dac62014-08-05 11:07:40 +0800122void intel_gpu_get_memory_props(const struct intel_gpu *gpu,
Tony Barbour8205d902015-04-16 15:59:00 -0600123 VkPhysicalDeviceMemoryProperties *props);
Chia-I Wu214dac62014-08-05 11:07:40 +0800124
Chia-I Wu3f4bd102014-12-19 13:14:42 +0800125int intel_gpu_get_max_threads(const struct intel_gpu *gpu,
Tony Barbour8205d902015-04-16 15:59:00 -0600126 VkShaderStage stage);
Chia-I Wu3f4bd102014-12-19 13:14:42 +0800127
Chia-I Wu41858c82015-04-04 16:39:25 +0800128int intel_gpu_get_primary_fd(struct intel_gpu *gpu);
129
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600130VkResult intel_gpu_init_winsys(struct intel_gpu *gpu);
Chia-I Wu41858c82015-04-04 16:39:25 +0800131void intel_gpu_cleanup_winsys(struct intel_gpu *gpu);
Chia-I Wu214dac62014-08-05 11:07:40 +0800132
Chia-I Wu1db76e02014-09-15 14:21:14 +0800133enum intel_ext_type intel_gpu_lookup_extension(const struct intel_gpu *gpu,
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600134 const VkExtensionProperties *ext);
Chia-I Wu214dac62014-08-05 11:07:40 +0800135
Chia-I Wu214dac62014-08-05 11:07:40 +0800136#endif /* GPU_H */