blob: 8be99113da30a0aab65fb0af0cde090d752c438d [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 Wu9fe3ec42014-10-17 09:49:16 +080035struct intel_pipeline_shader;
Chia-I Wue54854a2014-08-05 10:23:50 +080036struct intel_queue;
37struct intel_winsys;
38
Chia-I Wu9fe3ec42014-10-17 09:49:16 +080039enum intel_dev_meta_shader {
40 /*
Chia-I Wu0c87f472014-11-25 14:37:30 +080041 * This expects an ivec2 to be pushed:
42 *
43 * .x is memory offset
44 * .y is fill value
45 *
46 * as well as GEN6_VFCOMP_STORE_VID.
47 */
48 INTEL_DEV_META_VS_FILL_MEM,
49
50 /*
51 * These expect an ivec2 to be pushed:
52 *
53 * .x is dst memory offset
54 * .y is src memory offset
55 *
56 * as well as GEN6_VFCOMP_STORE_VID.
57 */
58 INTEL_DEV_META_VS_COPY_MEM,
59 INTEL_DEV_META_VS_COPY_MEM_UNALIGNED,
60
61 /*
Chia-I Wu4d344e62014-12-20 21:06:04 +080062 * This expects an ivec4 to be pushed:
63 *
64 * .xy is added to fargment coord to form (u, v)
65 * .z is extent width
66 * .w is dst memory offset
67 *
68 * as well as GEN6_VFCOMP_STORE_VID.
69 */
70 INTEL_DEV_META_VS_COPY_R8_TO_MEM,
71 INTEL_DEV_META_VS_COPY_R16_TO_MEM,
72 INTEL_DEV_META_VS_COPY_R32_TO_MEM,
73 INTEL_DEV_META_VS_COPY_R32G32_TO_MEM,
74 INTEL_DEV_META_VS_COPY_R32G32B32A32_TO_MEM,
75
76 /*
Chia-I Wu9fe3ec42014-10-17 09:49:16 +080077 * These expect an ivec4 to be pushed:
78 *
79 * .xy is added to fragment coord to form (u, v)
80 * .z is ai
81 * .w is lod
82 */
83 INTEL_DEV_META_FS_COPY_MEM, /* ld_lz(u) */
84 INTEL_DEV_META_FS_COPY_1D, /* ld(u, lod) */
85 INTEL_DEV_META_FS_COPY_1D_ARRAY, /* ld(u, lod, ai) */
86 INTEL_DEV_META_FS_COPY_2D, /* ld(u, lod, v) */
87 INTEL_DEV_META_FS_COPY_2D_ARRAY, /* ld(u, lod, v, ai) */
88 INTEL_DEV_META_FS_COPY_2D_MS, /* ld_mcs() + ld2dms() */
89
90 /*
91 * These expect a second ivec4 to be pushed:
92 *
93 * .x is memory offset
94 * .y is extent width
95 *
96 * The second ivec4 is to convert linear fragment coord to (u, v).
97 */
98 INTEL_DEV_META_FS_COPY_1D_TO_MEM, /* ld(u, lod) */
99 INTEL_DEV_META_FS_COPY_1D_ARRAY_TO_MEM, /* ld(u, lod, ai) */
100 INTEL_DEV_META_FS_COPY_2D_TO_MEM, /* ld(u, lod, v) */
101 INTEL_DEV_META_FS_COPY_2D_ARRAY_TO_MEM, /* ld(u, lod, v, ai) */
102 INTEL_DEV_META_FS_COPY_2D_MS_TO_MEM, /* ld_mcs() + ld2dms() */
103
104 /*
105 * This expects an ivec4 to be pushed:
106 *
107 * .xy is added to fargment coord to form (u, v)
108 * .z is extent width
109 *
110 * .z is used to linearize (u, v).
111 */
112 INTEL_DEV_META_FS_COPY_MEM_TO_IMG, /* ld_lz(u) */
113
114 /*
115 * These expect the clear value to be pushed, and set fragment color or
116 * depth to the clear value.
117 */
118 INTEL_DEV_META_FS_CLEAR_COLOR,
119 INTEL_DEV_META_FS_CLEAR_DEPTH,
120
121 /*
122 * These expect an ivec4 to be pushed:
123 *
124 * .xy is added to fragment coord to form (u, v)
125 *
126 * All samples are fetched and averaged. The fragment color is set to the
127 * averaged value.
128 */
129 INTEL_DEV_META_FS_RESOLVE_2X,
130 INTEL_DEV_META_FS_RESOLVE_4X,
131 INTEL_DEV_META_FS_RESOLVE_8X,
132 INTEL_DEV_META_FS_RESOLVE_16X,
133
134 INTEL_DEV_META_SHADER_COUNT,
135};
136
Chia-I Wue54854a2014-08-05 10:23:50 +0800137struct intel_dev_dbg_msg_filter {
138 XGL_INT msg_code;
139 XGL_DBG_MSG_FILTER filter;
140 bool triggered;
141
142 struct intel_dev_dbg_msg_filter *next;
143};
144
145struct intel_dev_dbg {
146 struct intel_base_dbg base;
147
Chia-I Wu069f30f2014-08-21 13:45:20 +0800148 XGL_VALIDATION_LEVEL validation_level;
149 bool disable_pipeline_loads;
150 bool force_object_memory_reqs;
151 bool force_large_image_alignment;
152
Chia-I Wue54854a2014-08-05 10:23:50 +0800153 struct intel_dev_dbg_msg_filter *filters;
154};
155
156struct intel_dev {
157 struct intel_base base;
158
Chia-I Wu1db76e02014-09-15 14:21:14 +0800159 bool exts[INTEL_EXT_COUNT];
160
Chia-I Wue54854a2014-08-05 10:23:50 +0800161 struct intel_gpu *gpu;
162 struct intel_winsys *winsys;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800163
Chia-I Wu0b784442014-08-25 22:54:16 +0800164 struct intel_bo *cmd_scratch_bo;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800165 struct intel_pipeline_shader *cmd_meta_shaders[INTEL_DEV_META_SHADER_COUNT];
Chia-I Wu0b784442014-08-25 22:54:16 +0800166
Chia-I Wue54854a2014-08-05 10:23:50 +0800167 struct intel_queue *queues[INTEL_GPU_ENGINE_COUNT];
168};
169
Chia-I Wue54854a2014-08-05 10:23:50 +0800170static inline struct intel_dev *intel_dev(XGL_DEVICE dev)
171{
172 return (struct intel_dev *) dev;
173}
174
175static inline struct intel_dev_dbg *intel_dev_dbg(struct intel_dev *dev)
176{
177 return (struct intel_dev_dbg *) dev->base.dbg;
178}
179
Chia-I Wue54854a2014-08-05 10:23:50 +0800180XGL_RESULT intel_dev_create(struct intel_gpu *gpu,
181 const XGL_DEVICE_CREATE_INFO *info,
182 struct intel_dev **dev_ret);
183void intel_dev_destroy(struct intel_dev *dev);
184
185void intel_dev_get_heap_props(const struct intel_dev *dev,
186 XGL_MEMORY_HEAP_PROPERTIES *props);
187
188XGL_RESULT intel_dev_add_msg_filter(struct intel_dev *dev,
189 XGL_INT msg_code,
190 XGL_DBG_MSG_FILTER filter);
191
192void intel_dev_remove_msg_filter(struct intel_dev *dev,
193 XGL_INT msg_code);
194
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,
Chia-I Wu82d3d8b2014-08-09 13:07:44 +0800199 XGL_SIZE location,
200 XGL_INT msg_code,
201 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 */