blob: 41997306e8a1af21bfab4889b309b7cc1a416a5a [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;
Courtney Goeltzenleuchter073e83c2014-08-29 16:21:22 -060053 int max_vs_threads;
54 int max_gs_threads;
55 int max_fs_threads;
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 */