blob: fac16bcae036b3063ccfbc59cb7a13f482ee790c [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.
23 */
24
25#ifndef GPU_H
26#define GPU_H
27
28#include "intel.h"
29
Chia-I Wu9269d1c2014-08-16 12:47:47 +080030#define INTEL_GPU_ASSERT(gpu, min_gen, max_gen) \
31 assert(intel_gpu_gen(gpu) >= INTEL_GEN(min_gen) && \
32 intel_gpu_gen(gpu) <= INTEL_GEN(max_gen))
33
Chia-I Wu214dac62014-08-05 11:07:40 +080034enum intel_gpu_engine_type {
35 /* TODO BLT support */
36 INTEL_GPU_ENGINE_3D,
37
38 INTEL_GPU_ENGINE_COUNT
39};
40
41/*
42 * intel_gpu is the only object that does not inherit from intel_base.
43 */
44struct intel_gpu {
45 const struct icd_dispatch_table *dispatch;
46
47 struct intel_gpu *next;
48
49 int devid; /* PCI device ID */
50 char *path; /* path to the render or legacy node, or NULL */
51 int gen_opaque; /* always read with intel_gpu_gen() */
52
53 int batch_buffer_size;
54
55 /*
56 * The enabled hardware features could be limited by the kernel. This
57 * mutable internal fd allows us to talk to the kernel when we need to.
58 */
59 int fd_internal;
60
61 int fd;
62};
63
64static inline struct intel_gpu *intel_gpu(XGL_PHYSICAL_GPU gpu)
65{
66 return (struct intel_gpu *) gpu;
67}
68
69static inline int intel_gpu_gen(const struct intel_gpu *gpu)
70{
71#ifdef INTEL_GEN_SPECIALIZED
72 return INTEL_GEN(INTEL_GEN_SPECIALIZED);
73#else
74 return gpu->gen_opaque;
75#endif
76}
77
78bool intel_gpu_is_valid(const struct intel_gpu *gpu);
79
80XGL_RESULT intel_gpu_add(int devid, const char *path,
81 struct intel_gpu **gpu_ret);
82void intel_gpu_remove_all(void);
83struct intel_gpu *intel_gpu_get_list(void);
84
85void intel_gpu_get_props(const struct intel_gpu *gpu,
86 XGL_PHYSICAL_GPU_PROPERTIES *props);
87void intel_gpu_get_perf(const struct intel_gpu *gpu,
88 XGL_PHYSICAL_GPU_PERFORMANCE *perf);
89void intel_gpu_get_queue_props(const struct intel_gpu *gpu,
90 enum intel_gpu_engine_type engine,
91 XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *props);
92void intel_gpu_get_memory_props(const struct intel_gpu *gpu,
93 XGL_PHYSICAL_GPU_MEMORY_PROPERTIES *props);
94
95XGL_RESULT intel_gpu_open(struct intel_gpu *gpu);
96void intel_gpu_close(struct intel_gpu *gpu);
97
98bool intel_gpu_has_extension(const struct intel_gpu *gpu, const char *ext);
99
Chia-I Wubec90a02014-08-06 12:33:03 +0800100XGL_RESULT XGLAPI intelGetGpuInfo(
101 XGL_PHYSICAL_GPU gpu,
102 XGL_PHYSICAL_GPU_INFO_TYPE infoType,
103 XGL_SIZE* pDataSize,
104 XGL_VOID* pData);
105
106XGL_RESULT XGLAPI intelGetExtensionSupport(
107 XGL_PHYSICAL_GPU gpu,
108 const XGL_CHAR* pExtName);
109
Chia-I Wu251e7d92014-08-19 13:35:42 +0800110XGL_RESULT XGLAPI intelGetMultiGpuCompatibility(
111 XGL_PHYSICAL_GPU gpu0,
112 XGL_PHYSICAL_GPU gpu1,
113 XGL_GPU_COMPATIBILITY_INFO* pInfo);
114
Chia-I Wu214dac62014-08-05 11:07:40 +0800115#endif /* GPU_H */