blob: acccfc5cbb3c3abe1d24fbeae6aea036bfd8c7d6 [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;
Chia-I Wu214dac62014-08-05 11:07:40 +080056
Chia-I Wubd657942014-08-21 14:37:35 +080057 XGL_GPU_SIZE max_batch_buffer_size;
Chia-I Wud6109bb2014-08-21 09:12:19 +080058 XGL_UINT batch_buffer_reloc_count;
Chia-I Wu214dac62014-08-05 11:07:40 +080059
60 /*
61 * The enabled hardware features could be limited by the kernel. This
62 * mutable internal fd allows us to talk to the kernel when we need to.
63 */
64 int fd_internal;
65
66 int fd;
67};
68
69static inline struct intel_gpu *intel_gpu(XGL_PHYSICAL_GPU gpu)
70{
71 return (struct intel_gpu *) gpu;
72}
73
74static inline int intel_gpu_gen(const struct intel_gpu *gpu)
75{
76#ifdef INTEL_GEN_SPECIALIZED
77 return INTEL_GEN(INTEL_GEN_SPECIALIZED);
78#else
79 return gpu->gen_opaque;
80#endif
81}
82
83bool intel_gpu_is_valid(const struct intel_gpu *gpu);
84
85XGL_RESULT intel_gpu_add(int devid, const char *path,
86 struct intel_gpu **gpu_ret);
87void intel_gpu_remove_all(void);
88struct intel_gpu *intel_gpu_get_list(void);
89
90void intel_gpu_get_props(const struct intel_gpu *gpu,
91 XGL_PHYSICAL_GPU_PROPERTIES *props);
92void intel_gpu_get_perf(const struct intel_gpu *gpu,
93 XGL_PHYSICAL_GPU_PERFORMANCE *perf);
94void intel_gpu_get_queue_props(const struct intel_gpu *gpu,
95 enum intel_gpu_engine_type engine,
96 XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *props);
97void intel_gpu_get_memory_props(const struct intel_gpu *gpu,
98 XGL_PHYSICAL_GPU_MEMORY_PROPERTIES *props);
99
100XGL_RESULT intel_gpu_open(struct intel_gpu *gpu);
101void intel_gpu_close(struct intel_gpu *gpu);
102
103bool intel_gpu_has_extension(const struct intel_gpu *gpu, const char *ext);
104
Chia-I Wubec90a02014-08-06 12:33:03 +0800105XGL_RESULT XGLAPI intelGetGpuInfo(
106 XGL_PHYSICAL_GPU gpu,
107 XGL_PHYSICAL_GPU_INFO_TYPE infoType,
108 XGL_SIZE* pDataSize,
109 XGL_VOID* pData);
110
111XGL_RESULT XGLAPI intelGetExtensionSupport(
112 XGL_PHYSICAL_GPU gpu,
113 const XGL_CHAR* pExtName);
114
Chia-I Wu251e7d92014-08-19 13:35:42 +0800115XGL_RESULT XGLAPI intelGetMultiGpuCompatibility(
116 XGL_PHYSICAL_GPU gpu0,
117 XGL_PHYSICAL_GPU gpu1,
118 XGL_GPU_COMPATIBILITY_INFO* pInfo);
119
Chia-I Wu214dac62014-08-05 11:07:40 +0800120#endif /* GPU_H */