blob: beed81507c8f1347bc35cfde5e7e6cfefcef7a5e [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
Tobin Ehlis0ef6ec52015-04-16 12:51:37 -060037/*
38 * No device-specific extensions at thie point, so this enum is a placeholder
39 */
Courtney Goeltzenleuchter95b73722015-06-08 18:08:35 -060040enum intel_phy_dev_ext_type {
41 INTEL_PHY_DEV_EXT_DEBUG_REPORT,
42 INTEL_PHY_DEV_EXT_DEBUG_MARKER,
43
Tobin Ehlis0ef6ec52015-04-16 12:51:37 -060044 INTEL_PHY_DEV_EXT_COUNT,
45 INTEL_PHY_DEV_EXT_INVALID = INTEL_PHY_DEV_EXT_COUNT,
46};
47
Chia-I Wu214dac62014-08-05 11:07:40 +080048enum intel_gpu_engine_type {
49 /* TODO BLT support */
50 INTEL_GPU_ENGINE_3D,
51
52 INTEL_GPU_ENGINE_COUNT
53};
54
Chia-I Wud71ff552015-02-20 12:50:12 -070055struct intel_instance;
Chia-I Wu8635e912015-04-09 14:13:57 +080056struct intel_wsi_display;
Chia-I Wud8965932014-10-13 13:32:37 +080057struct intel_winsys;
Chia-I Wu1db76e02014-09-15 14:21:14 +080058
Chia-I Wu214dac62014-08-05 11:07:40 +080059/*
60 * intel_gpu is the only object that does not inherit from intel_base.
61 */
62struct intel_gpu {
Chia-I Wu924c1fc2015-01-19 11:14:00 +080063 struct intel_handle handle;
Chia-I Wu214dac62014-08-05 11:07:40 +080064
65 struct intel_gpu *next;
66
67 int devid; /* PCI device ID */
Chia-I Wuf07865e2014-09-15 13:52:21 +080068 char *primary_node; /* path to the primary node */
69 char *render_node; /* path to the render node */
70 int gen_opaque; /* always read this with intel_gpu_gen() */
Chia-I Wu960f1952014-08-28 23:27:10 +080071 int gt;
Chia-I Wu214dac62014-08-05 11:07:40 +080072
Tony Barbour8205d902015-04-16 15:59:00 -060073 VkDeviceSize max_batch_buffer_size;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060074 uint32_t batch_buffer_reloc_count;
Chia-I Wu214dac62014-08-05 11:07:40 +080075
76 /*
Chia-I Wuf07865e2014-09-15 13:52:21 +080077 * The enabled hardware features could be limited by the kernel. These
78 * mutable fds allows us to talk to the kernel before the device is
79 * created.
Chia-I Wu214dac62014-08-05 11:07:40 +080080 */
Chia-I Wuf07865e2014-09-15 13:52:21 +080081 int primary_fd_internal;
82 int render_fd_internal;
Chia-I Wu214dac62014-08-05 11:07:40 +080083
Chia-I Wud8965932014-10-13 13:32:37 +080084 struct intel_winsys *winsys;
Chia-I Wu41858c82015-04-04 16:39:25 +080085
Chia-I Wu8635e912015-04-09 14:13:57 +080086 struct intel_wsi_display **displays;
87 uint32_t display_count;
Chia-I Wu214dac62014-08-05 11:07:40 +080088};
89
Tony Barbour8205d902015-04-16 15:59:00 -060090static inline struct intel_gpu *intel_gpu(VkPhysicalDevice gpu)
Chia-I Wu214dac62014-08-05 11:07:40 +080091{
92 return (struct intel_gpu *) gpu;
93}
94
95static inline int intel_gpu_gen(const struct intel_gpu *gpu)
96{
97#ifdef INTEL_GEN_SPECIALIZED
98 return INTEL_GEN(INTEL_GEN_SPECIALIZED);
99#else
100 return gpu->gen_opaque;
101#endif
102}
103
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600104VkResult intel_gpu_create(const struct intel_instance *instance, int devid,
Chia-I Wud71ff552015-02-20 12:50:12 -0700105 const char *primary_node, const char *render_node,
106 struct intel_gpu **gpu_ret);
107void intel_gpu_destroy(struct intel_gpu *gpu);
Chia-I Wu214dac62014-08-05 11:07:40 +0800108
109void intel_gpu_get_props(const struct intel_gpu *gpu,
Tony Barbour8205d902015-04-16 15:59:00 -0600110 VkPhysicalDeviceProperties *props);
Chia-I Wu214dac62014-08-05 11:07:40 +0800111void intel_gpu_get_perf(const struct intel_gpu *gpu,
Tony Barbour8205d902015-04-16 15:59:00 -0600112 VkPhysicalDevicePerformance *perf);
Chia-I Wu214dac62014-08-05 11:07:40 +0800113void intel_gpu_get_queue_props(const struct intel_gpu *gpu,
114 enum intel_gpu_engine_type engine,
Tony Barbour8205d902015-04-16 15:59:00 -0600115 VkPhysicalDeviceQueueProperties *props);
Chia-I Wu214dac62014-08-05 11:07:40 +0800116void intel_gpu_get_memory_props(const struct intel_gpu *gpu,
Tony Barbour8205d902015-04-16 15:59:00 -0600117 VkPhysicalDeviceMemoryProperties *props);
Chia-I Wu214dac62014-08-05 11:07:40 +0800118
Chia-I Wu3f4bd102014-12-19 13:14:42 +0800119int intel_gpu_get_max_threads(const struct intel_gpu *gpu,
Tony Barbour8205d902015-04-16 15:59:00 -0600120 VkShaderStage stage);
Chia-I Wu3f4bd102014-12-19 13:14:42 +0800121
Chia-I Wu41858c82015-04-04 16:39:25 +0800122int intel_gpu_get_primary_fd(struct intel_gpu *gpu);
123
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600124VkResult intel_gpu_init_winsys(struct intel_gpu *gpu);
Chia-I Wu41858c82015-04-04 16:39:25 +0800125void intel_gpu_cleanup_winsys(struct intel_gpu *gpu);
Chia-I Wu214dac62014-08-05 11:07:40 +0800126
Courtney Goeltzenleuchter95b73722015-06-08 18:08:35 -0600127enum intel_phy_dev_ext_type intel_gpu_lookup_phy_dev_extension(
128 const struct intel_gpu *gpu,
129 const VkExtensionProperties *ext);
Chia-I Wu214dac62014-08-05 11:07:40 +0800130
Chia-I Wu214dac62014-08-05 11:07:40 +0800131#endif /* GPU_H */