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