blob: 05bcd9ceade03b52101433ad9c706a7909985650 [file] [log] [blame]
Chia-I Wue54854a2014-08-05 10:23:50 +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 Wue54854a2014-08-05 10:23:50 +080026 */
27
28#ifndef DEV_H
29#define DEV_H
30
Chia-I Wue09b5362014-08-07 09:25:14 +080031#include "intel.h"
Chia-I Wue54854a2014-08-05 10:23:50 +080032#include "gpu.h"
Chia-I Wua2161db2014-08-15 16:34:34 +080033#include "obj.h"
Chia-I Wue54854a2014-08-05 10:23:50 +080034
Chia-I Wuf8385062015-01-04 16:27:24 +080035struct intel_desc_pool;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +080036struct intel_pipeline_shader;
Chia-I Wue54854a2014-08-05 10:23:50 +080037struct intel_queue;
38struct intel_winsys;
39
Chia-I Wu9fe3ec42014-10-17 09:49:16 +080040enum intel_dev_meta_shader {
41 /*
Chia-I Wu0c87f472014-11-25 14:37:30 +080042 * This expects an ivec2 to be pushed:
43 *
44 * .x is memory offset
45 * .y is fill value
46 *
47 * as well as GEN6_VFCOMP_STORE_VID.
48 */
49 INTEL_DEV_META_VS_FILL_MEM,
50
51 /*
52 * These expect an ivec2 to be pushed:
53 *
54 * .x is dst memory offset
55 * .y is src memory offset
56 *
57 * as well as GEN6_VFCOMP_STORE_VID.
58 */
59 INTEL_DEV_META_VS_COPY_MEM,
60 INTEL_DEV_META_VS_COPY_MEM_UNALIGNED,
61
62 /*
Chia-I Wu4d344e62014-12-20 21:06:04 +080063 * This expects an ivec4 to be pushed:
64 *
65 * .xy is added to fargment coord to form (u, v)
66 * .z is extent width
67 * .w is dst memory offset
68 *
69 * as well as GEN6_VFCOMP_STORE_VID.
70 */
71 INTEL_DEV_META_VS_COPY_R8_TO_MEM,
72 INTEL_DEV_META_VS_COPY_R16_TO_MEM,
73 INTEL_DEV_META_VS_COPY_R32_TO_MEM,
74 INTEL_DEV_META_VS_COPY_R32G32_TO_MEM,
75 INTEL_DEV_META_VS_COPY_R32G32B32A32_TO_MEM,
76
77 /*
Chia-I Wu9fe3ec42014-10-17 09:49:16 +080078 * These expect an ivec4 to be pushed:
79 *
80 * .xy is added to fragment coord to form (u, v)
81 * .z is ai
82 * .w is lod
83 */
84 INTEL_DEV_META_FS_COPY_MEM, /* ld_lz(u) */
85 INTEL_DEV_META_FS_COPY_1D, /* ld(u, lod) */
86 INTEL_DEV_META_FS_COPY_1D_ARRAY, /* ld(u, lod, ai) */
87 INTEL_DEV_META_FS_COPY_2D, /* ld(u, lod, v) */
88 INTEL_DEV_META_FS_COPY_2D_ARRAY, /* ld(u, lod, v, ai) */
89 INTEL_DEV_META_FS_COPY_2D_MS, /* ld_mcs() + ld2dms() */
90
91 /*
92 * These expect a second ivec4 to be pushed:
93 *
94 * .x is memory offset
95 * .y is extent width
96 *
97 * The second ivec4 is to convert linear fragment coord to (u, v).
98 */
99 INTEL_DEV_META_FS_COPY_1D_TO_MEM, /* ld(u, lod) */
100 INTEL_DEV_META_FS_COPY_1D_ARRAY_TO_MEM, /* ld(u, lod, ai) */
101 INTEL_DEV_META_FS_COPY_2D_TO_MEM, /* ld(u, lod, v) */
102 INTEL_DEV_META_FS_COPY_2D_ARRAY_TO_MEM, /* ld(u, lod, v, ai) */
103 INTEL_DEV_META_FS_COPY_2D_MS_TO_MEM, /* ld_mcs() + ld2dms() */
104
105 /*
106 * This expects an ivec4 to be pushed:
107 *
108 * .xy is added to fargment coord to form (u, v)
109 * .z is extent width
110 *
111 * .z is used to linearize (u, v).
112 */
113 INTEL_DEV_META_FS_COPY_MEM_TO_IMG, /* ld_lz(u) */
114
115 /*
116 * These expect the clear value to be pushed, and set fragment color or
117 * depth to the clear value.
118 */
119 INTEL_DEV_META_FS_CLEAR_COLOR,
120 INTEL_DEV_META_FS_CLEAR_DEPTH,
121
122 /*
123 * These expect an ivec4 to be pushed:
124 *
125 * .xy is added to fragment coord to form (u, v)
126 *
127 * All samples are fetched and averaged. The fragment color is set to the
128 * averaged value.
129 */
130 INTEL_DEV_META_FS_RESOLVE_2X,
131 INTEL_DEV_META_FS_RESOLVE_4X,
132 INTEL_DEV_META_FS_RESOLVE_8X,
133 INTEL_DEV_META_FS_RESOLVE_16X,
134
135 INTEL_DEV_META_SHADER_COUNT,
136};
137
Chia-I Wue54854a2014-08-05 10:23:50 +0800138struct intel_dev_dbg_msg_filter {
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600139 int32_t msg_code;
Chia-I Wue54854a2014-08-05 10:23:50 +0800140 XGL_DBG_MSG_FILTER filter;
141 bool triggered;
142
143 struct intel_dev_dbg_msg_filter *next;
144};
145
146struct intel_dev_dbg {
147 struct intel_base_dbg base;
148
Chia-I Wu069f30f2014-08-21 13:45:20 +0800149 XGL_VALIDATION_LEVEL validation_level;
150 bool disable_pipeline_loads;
151 bool force_object_memory_reqs;
152 bool force_large_image_alignment;
153
Chia-I Wue54854a2014-08-05 10:23:50 +0800154 struct intel_dev_dbg_msg_filter *filters;
155};
156
157struct intel_dev {
158 struct intel_base base;
159
Chia-I Wu1db76e02014-09-15 14:21:14 +0800160 bool exts[INTEL_EXT_COUNT];
161
Chia-I Wue54854a2014-08-05 10:23:50 +0800162 struct intel_gpu *gpu;
163 struct intel_winsys *winsys;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800164
Chia-I Wu0b784442014-08-25 22:54:16 +0800165 struct intel_bo *cmd_scratch_bo;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800166 struct intel_pipeline_shader *cmd_meta_shaders[INTEL_DEV_META_SHADER_COUNT];
Chia-I Wu0b784442014-08-25 22:54:16 +0800167
Chia-I Wuf8385062015-01-04 16:27:24 +0800168 struct intel_desc_pool *desc_pool;
169
Chia-I Wue54854a2014-08-05 10:23:50 +0800170 struct intel_queue *queues[INTEL_GPU_ENGINE_COUNT];
171};
172
Chia-I Wue54854a2014-08-05 10:23:50 +0800173static inline struct intel_dev *intel_dev(XGL_DEVICE dev)
174{
175 return (struct intel_dev *) dev;
176}
177
178static inline struct intel_dev_dbg *intel_dev_dbg(struct intel_dev *dev)
179{
180 return (struct intel_dev_dbg *) dev->base.dbg;
181}
182
Chia-I Wue54854a2014-08-05 10:23:50 +0800183XGL_RESULT intel_dev_create(struct intel_gpu *gpu,
184 const XGL_DEVICE_CREATE_INFO *info,
185 struct intel_dev **dev_ret);
186void intel_dev_destroy(struct intel_dev *dev);
187
Chia-I Wue54854a2014-08-05 10:23:50 +0800188XGL_RESULT intel_dev_add_msg_filter(struct intel_dev *dev,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600189 int32_t msg_code,
Chia-I Wue54854a2014-08-05 10:23:50 +0800190 XGL_DBG_MSG_FILTER filter);
191
192void intel_dev_remove_msg_filter(struct intel_dev *dev,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600193 int32_t msg_code);
Chia-I Wue54854a2014-08-05 10:23:50 +0800194
Chia-I Wu82d3d8b2014-08-09 13:07:44 +0800195void intel_dev_log(struct intel_dev *dev,
196 XGL_DBG_MSG_TYPE msg_type,
197 XGL_VALIDATION_LEVEL validation_level,
Chia-I Wuaabb3602014-08-19 14:18:23 +0800198 struct intel_base *src_object,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600199 size_t location,
200 int32_t msg_code,
Chia-I Wu82d3d8b2014-08-09 13:07:44 +0800201 const char *format, ...);
202
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800203static inline const struct intel_pipeline_shader *intel_dev_get_meta_shader(const struct intel_dev *dev,
204 enum intel_dev_meta_shader id)
205{
206 assert(id < INTEL_DEV_META_SHADER_COUNT);
207 return dev->cmd_meta_shaders[id];
208}
209
Chia-I Wue54854a2014-08-05 10:23:50 +0800210#endif /* DEV_H */