blob: 4cc139d4e7ec2696180ec7ee2b2ca56ba3593877 [file] [log] [blame]
Chia-I Wu214dac62014-08-05 11:07:40 +08001/*
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 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 Wu214dac62014-08-05 11:07:40 +080037enum intel_gpu_engine_type {
38 /* TODO BLT support */
39 INTEL_GPU_ENGINE_3D,
40
41 INTEL_GPU_ENGINE_COUNT
42};
43
44/*
45 * intel_gpu is the only object that does not inherit from intel_base.
46 */
47struct intel_gpu {
48 const struct icd_dispatch_table *dispatch;
49
50 struct intel_gpu *next;
51
52 int devid; /* PCI device ID */
53 char *path; /* path to the render or legacy node, or NULL */
54 int gen_opaque; /* always read with intel_gpu_gen() */
Chia-I Wu960f1952014-08-28 23:27:10 +080055 int gt;
Courtney Goeltzenleuchter073e83c2014-08-29 16:21:22 -060056 int max_vs_threads;
57 int max_gs_threads;
58 int max_fs_threads;
Chia-I Wu214dac62014-08-05 11:07:40 +080059
Chia-I Wubd657942014-08-21 14:37:35 +080060 XGL_GPU_SIZE max_batch_buffer_size;
Chia-I Wud6109bb2014-08-21 09:12:19 +080061 XGL_UINT batch_buffer_reloc_count;
Chia-I Wu214dac62014-08-05 11:07:40 +080062
63 /*
64 * The enabled hardware features could be limited by the kernel. This
65 * mutable internal fd allows us to talk to the kernel when we need to.
66 */
67 int fd_internal;
68
69 int fd;
70};
71
72static inline struct intel_gpu *intel_gpu(XGL_PHYSICAL_GPU gpu)
73{
74 return (struct intel_gpu *) gpu;
75}
76
77static inline int intel_gpu_gen(const struct intel_gpu *gpu)
78{
79#ifdef INTEL_GEN_SPECIALIZED
80 return INTEL_GEN(INTEL_GEN_SPECIALIZED);
81#else
82 return gpu->gen_opaque;
83#endif
84}
85
86bool intel_gpu_is_valid(const struct intel_gpu *gpu);
87
88XGL_RESULT intel_gpu_add(int devid, const char *path,
89 struct intel_gpu **gpu_ret);
90void intel_gpu_remove_all(void);
91struct intel_gpu *intel_gpu_get_list(void);
92
93void intel_gpu_get_props(const struct intel_gpu *gpu,
94 XGL_PHYSICAL_GPU_PROPERTIES *props);
95void intel_gpu_get_perf(const struct intel_gpu *gpu,
96 XGL_PHYSICAL_GPU_PERFORMANCE *perf);
97void intel_gpu_get_queue_props(const struct intel_gpu *gpu,
98 enum intel_gpu_engine_type engine,
99 XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *props);
100void intel_gpu_get_memory_props(const struct intel_gpu *gpu,
101 XGL_PHYSICAL_GPU_MEMORY_PROPERTIES *props);
102
103XGL_RESULT intel_gpu_open(struct intel_gpu *gpu);
104void intel_gpu_close(struct intel_gpu *gpu);
105
106bool intel_gpu_has_extension(const struct intel_gpu *gpu, const char *ext);
107
Chia-I Wubec90a02014-08-06 12:33:03 +0800108XGL_RESULT XGLAPI intelGetGpuInfo(
109 XGL_PHYSICAL_GPU gpu,
110 XGL_PHYSICAL_GPU_INFO_TYPE infoType,
111 XGL_SIZE* pDataSize,
112 XGL_VOID* pData);
113
114XGL_RESULT XGLAPI intelGetExtensionSupport(
115 XGL_PHYSICAL_GPU gpu,
116 const XGL_CHAR* pExtName);
117
Chia-I Wu251e7d92014-08-19 13:35:42 +0800118XGL_RESULT XGLAPI intelGetMultiGpuCompatibility(
119 XGL_PHYSICAL_GPU gpu0,
120 XGL_PHYSICAL_GPU gpu1,
121 XGL_GPU_COMPATIBILITY_INFO* pInfo);
122
Chia-I Wu214dac62014-08-05 11:07:40 +0800123#endif /* GPU_H */