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