intel: Rewrite the world of push/pull params
[mesa.git] / src / intel / blorp / blorp.h
1 /*
2 * Copyright © 2012 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #ifndef BLORP_H
25 #define BLORP_H
26
27 #include <stdint.h>
28 #include <stdbool.h>
29
30 #include "isl/isl.h"
31
32 struct brw_stage_prog_data;
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 struct blorp_batch;
39 struct blorp_params;
40
41 struct blorp_context {
42 void *driver_ctx;
43
44 const struct isl_device *isl_dev;
45
46 const struct brw_compiler *compiler;
47
48 struct {
49 uint32_t tex;
50 uint32_t rb;
51 uint32_t vb;
52 } mocs;
53
54 bool (*lookup_shader)(struct blorp_context *blorp,
55 const void *key, uint32_t key_size,
56 uint32_t *kernel_out, void *prog_data_out);
57 bool (*upload_shader)(struct blorp_context *blorp,
58 const void *key, uint32_t key_size,
59 const void *kernel, uint32_t kernel_size,
60 const struct brw_stage_prog_data *prog_data,
61 uint32_t prog_data_size,
62 uint32_t *kernel_out, void *prog_data_out);
63 void (*exec)(struct blorp_batch *batch, const struct blorp_params *params);
64 };
65
66 void blorp_init(struct blorp_context *blorp, void *driver_ctx,
67 struct isl_device *isl_dev);
68 void blorp_finish(struct blorp_context *blorp);
69
70 enum blorp_batch_flags {
71 /**
72 * This flag indicates that blorp should *not* re-emit the depth and
73 * stencil buffer packets. Instead, the driver guarantees that all depth
74 * and stencil images passed in will match what is currently set in the
75 * hardware.
76 */
77 BLORP_BATCH_NO_EMIT_DEPTH_STENCIL = (1 << 0),
78
79 /* This flag indicates that the blorp call should be predicated. */
80 BLORP_BATCH_PREDICATE_ENABLE = (1 << 1),
81 };
82
83 struct blorp_batch {
84 struct blorp_context *blorp;
85 void *driver_batch;
86 enum blorp_batch_flags flags;
87 };
88
89 void blorp_batch_init(struct blorp_context *blorp, struct blorp_batch *batch,
90 void *driver_batch, enum blorp_batch_flags flags);
91 void blorp_batch_finish(struct blorp_batch *batch);
92
93 struct blorp_address {
94 void *buffer;
95 unsigned reloc_flags;
96 uint32_t offset;
97 };
98
99 struct blorp_surf
100 {
101 const struct isl_surf *surf;
102 struct blorp_address addr;
103
104 const struct isl_surf *aux_surf;
105 struct blorp_address aux_addr;
106 enum isl_aux_usage aux_usage;
107
108 union isl_color_value clear_color;
109 };
110
111 void
112 blorp_blit(struct blorp_batch *batch,
113 const struct blorp_surf *src_surf,
114 unsigned src_level, unsigned src_layer,
115 enum isl_format src_format, struct isl_swizzle src_swizzle,
116 const struct blorp_surf *dst_surf,
117 unsigned dst_level, unsigned dst_layer,
118 enum isl_format dst_format, struct isl_swizzle dst_swizzle,
119 float src_x0, float src_y0,
120 float src_x1, float src_y1,
121 float dst_x0, float dst_y0,
122 float dst_x1, float dst_y1,
123 uint32_t filter, bool mirror_x, bool mirror_y);
124
125 void
126 blorp_copy(struct blorp_batch *batch,
127 const struct blorp_surf *src_surf,
128 unsigned src_level, unsigned src_layer,
129 const struct blorp_surf *dst_surf,
130 unsigned dst_level, unsigned dst_layer,
131 uint32_t src_x, uint32_t src_y,
132 uint32_t dst_x, uint32_t dst_y,
133 uint32_t src_width, uint32_t src_height);
134
135 void
136 blorp_buffer_copy(struct blorp_batch *batch,
137 struct blorp_address src,
138 struct blorp_address dst,
139 uint64_t size);
140
141 void
142 blorp_fast_clear(struct blorp_batch *batch,
143 const struct blorp_surf *surf, enum isl_format format,
144 uint32_t level, uint32_t start_layer, uint32_t num_layers,
145 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1);
146
147 void
148 blorp_clear(struct blorp_batch *batch,
149 const struct blorp_surf *surf,
150 enum isl_format format, struct isl_swizzle swizzle,
151 uint32_t level, uint32_t start_layer, uint32_t num_layers,
152 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
153 union isl_color_value clear_color,
154 const bool color_write_disable[4]);
155
156 void
157 blorp_clear_depth_stencil(struct blorp_batch *batch,
158 const struct blorp_surf *depth,
159 const struct blorp_surf *stencil,
160 uint32_t level, uint32_t start_layer,
161 uint32_t num_layers,
162 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
163 bool clear_depth, float depth_value,
164 uint8_t stencil_mask, uint8_t stencil_value);
165 bool
166 blorp_can_hiz_clear_depth(uint8_t gen, enum isl_format format,
167 uint32_t num_samples,
168 uint32_t x0, uint32_t y0,
169 uint32_t x1, uint32_t y1);
170
171 void
172 blorp_gen8_hiz_clear_attachments(struct blorp_batch *batch,
173 uint32_t num_samples,
174 uint32_t x0, uint32_t y0,
175 uint32_t x1, uint32_t y1,
176 bool clear_depth, bool clear_stencil,
177 uint8_t stencil_value);
178 void
179 blorp_clear_attachments(struct blorp_batch *batch,
180 uint32_t binding_table_offset,
181 enum isl_format depth_format,
182 uint32_t num_samples,
183 uint32_t start_layer, uint32_t num_layers,
184 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
185 bool clear_color, union isl_color_value color_value,
186 bool clear_depth, float depth_value,
187 uint8_t stencil_mask, uint8_t stencil_value);
188
189 enum blorp_fast_clear_op {
190 BLORP_FAST_CLEAR_OP_NONE = 0,
191 BLORP_FAST_CLEAR_OP_CLEAR,
192 BLORP_FAST_CLEAR_OP_RESOLVE_PARTIAL,
193 BLORP_FAST_CLEAR_OP_RESOLVE_FULL,
194 };
195
196 void
197 blorp_ccs_resolve(struct blorp_batch *batch,
198 struct blorp_surf *surf, uint32_t level, uint32_t layer,
199 enum isl_format format,
200 enum blorp_fast_clear_op resolve_op);
201
202 /* Resolves subresources of the image subresource range specified in the
203 * binding table.
204 */
205 void
206 blorp_ccs_resolve_attachment(struct blorp_batch *batch,
207 const uint32_t binding_table_offset,
208 struct blorp_surf * const surf,
209 const uint32_t level, const uint32_t num_layers,
210 const enum isl_format format,
211 const enum blorp_fast_clear_op resolve_op);
212
213 void
214 blorp_mcs_partial_resolve(struct blorp_batch *batch,
215 struct blorp_surf *surf,
216 enum isl_format format,
217 uint32_t start_layer, uint32_t num_layers);
218
219 /**
220 * For an overview of the HiZ operations, see the following sections of the
221 * Sandy Bridge PRM, Volume 1, Part2:
222 * - 7.5.3.1 Depth Buffer Clear
223 * - 7.5.3.2 Depth Buffer Resolve
224 * - 7.5.3.3 Hierarchical Depth Buffer Resolve
225 *
226 * Of these, two get entered in the resolve map as needing to be done to the
227 * buffer: depth resolve and hiz resolve.
228 */
229 enum blorp_hiz_op {
230 BLORP_HIZ_OP_NONE,
231 BLORP_HIZ_OP_DEPTH_CLEAR,
232 BLORP_HIZ_OP_DEPTH_RESOLVE,
233 BLORP_HIZ_OP_HIZ_RESOLVE,
234 };
235
236 void
237 blorp_hiz_op(struct blorp_batch *batch, struct blorp_surf *surf,
238 uint32_t level, uint32_t start_layer, uint32_t num_layers,
239 enum blorp_hiz_op op);
240
241 #ifdef __cplusplus
242 } /* end extern "C" */
243 #endif /* __cplusplus */
244
245 #endif /* BLORP_H */