intel/blorp: Expose surf_fake_interleaved_msaa internally
[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 bool (*lookup_shader)(struct blorp_batch *batch,
49 const void *key, uint32_t key_size,
50 uint32_t *kernel_out, void *prog_data_out);
51 bool (*upload_shader)(struct blorp_batch *batch,
52 const void *key, uint32_t key_size,
53 const void *kernel, uint32_t kernel_size,
54 const struct brw_stage_prog_data *prog_data,
55 uint32_t prog_data_size,
56 uint32_t *kernel_out, void *prog_data_out);
57 void (*exec)(struct blorp_batch *batch, const struct blorp_params *params);
58 };
59
60 void blorp_init(struct blorp_context *blorp, void *driver_ctx,
61 struct isl_device *isl_dev);
62 void blorp_finish(struct blorp_context *blorp);
63
64 enum blorp_batch_flags {
65 /**
66 * This flag indicates that blorp should *not* re-emit the depth and
67 * stencil buffer packets. Instead, the driver guarantees that all depth
68 * and stencil images passed in will match what is currently set in the
69 * hardware.
70 */
71 BLORP_BATCH_NO_EMIT_DEPTH_STENCIL = (1 << 0),
72
73 /* This flag indicates that the blorp call should be predicated. */
74 BLORP_BATCH_PREDICATE_ENABLE = (1 << 1),
75
76 /* This flag indicates that blorp should *not* update the indirect clear
77 * color buffer.
78 */
79 BLORP_BATCH_NO_UPDATE_CLEAR_COLOR = (1 << 2),
80 };
81
82 struct blorp_batch {
83 struct blorp_context *blorp;
84 void *driver_batch;
85 enum blorp_batch_flags flags;
86 };
87
88 void blorp_batch_init(struct blorp_context *blorp, struct blorp_batch *batch,
89 void *driver_batch, enum blorp_batch_flags flags);
90 void blorp_batch_finish(struct blorp_batch *batch);
91
92 struct blorp_address {
93 void *buffer;
94 uint64_t offset;
95 unsigned reloc_flags;
96 uint32_t mocs;
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 * If set (bo != NULL), clear_color is ignored and the actual clear color
112 * is fetched from this address. On gen7-8, this is all of dword 7 of
113 * RENDER_SURFACE_STATE and is the responsibility of the caller to ensure
114 * that it contains a swizzle of RGBA and resource min LOD of 0.
115 */
116 struct blorp_address clear_color_addr;
117
118 /* Only allowed for simple 2D non-MSAA surfaces */
119 uint32_t tile_x_sa, tile_y_sa;
120 };
121
122 enum blorp_filter {
123 BLORP_FILTER_NONE,
124 BLORP_FILTER_NEAREST,
125 BLORP_FILTER_BILINEAR,
126 BLORP_FILTER_SAMPLE_0,
127 BLORP_FILTER_AVERAGE,
128 BLORP_FILTER_MIN_SAMPLE,
129 BLORP_FILTER_MAX_SAMPLE,
130 };
131
132 void
133 blorp_blit(struct blorp_batch *batch,
134 const struct blorp_surf *src_surf,
135 unsigned src_level, unsigned src_layer,
136 enum isl_format src_format, struct isl_swizzle src_swizzle,
137 const struct blorp_surf *dst_surf,
138 unsigned dst_level, unsigned dst_layer,
139 enum isl_format dst_format, struct isl_swizzle dst_swizzle,
140 float src_x0, float src_y0,
141 float src_x1, float src_y1,
142 float dst_x0, float dst_y0,
143 float dst_x1, float dst_y1,
144 enum blorp_filter filter,
145 bool mirror_x, bool mirror_y);
146
147 void
148 blorp_copy(struct blorp_batch *batch,
149 const struct blorp_surf *src_surf,
150 unsigned src_level, unsigned src_layer,
151 const struct blorp_surf *dst_surf,
152 unsigned dst_level, unsigned dst_layer,
153 uint32_t src_x, uint32_t src_y,
154 uint32_t dst_x, uint32_t dst_y,
155 uint32_t src_width, uint32_t src_height);
156
157 void
158 blorp_buffer_copy(struct blorp_batch *batch,
159 struct blorp_address src,
160 struct blorp_address dst,
161 uint64_t size);
162
163 union isl_color_value
164 swizzle_color_value(union isl_color_value src, struct isl_swizzle swizzle);
165
166 void
167 blorp_fast_clear(struct blorp_batch *batch,
168 const struct blorp_surf *surf, enum isl_format format,
169 uint32_t level, uint32_t start_layer, uint32_t num_layers,
170 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1);
171
172 void
173 blorp_clear(struct blorp_batch *batch,
174 const struct blorp_surf *surf,
175 enum isl_format format, struct isl_swizzle swizzle,
176 uint32_t level, uint32_t start_layer, uint32_t num_layers,
177 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
178 union isl_color_value clear_color,
179 const bool color_write_disable[4]);
180
181 void
182 blorp_clear_depth_stencil(struct blorp_batch *batch,
183 const struct blorp_surf *depth,
184 const struct blorp_surf *stencil,
185 uint32_t level, uint32_t start_layer,
186 uint32_t num_layers,
187 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
188 bool clear_depth, float depth_value,
189 uint8_t stencil_mask, uint8_t stencil_value);
190 bool
191 blorp_can_hiz_clear_depth(uint8_t gen, enum isl_format format,
192 uint32_t num_samples,
193 uint32_t x0, uint32_t y0,
194 uint32_t x1, uint32_t y1);
195 void
196 blorp_hiz_clear_depth_stencil(struct blorp_batch *batch,
197 const struct blorp_surf *depth,
198 const struct blorp_surf *stencil,
199 uint32_t level,
200 uint32_t start_layer, uint32_t num_layers,
201 uint32_t x0, uint32_t y0,
202 uint32_t x1, uint32_t y1,
203 bool clear_depth, float depth_value,
204 bool clear_stencil, uint8_t stencil_value);
205
206
207 void
208 blorp_gen8_hiz_clear_attachments(struct blorp_batch *batch,
209 uint32_t num_samples,
210 uint32_t x0, uint32_t y0,
211 uint32_t x1, uint32_t y1,
212 bool clear_depth, bool clear_stencil,
213 uint8_t stencil_value);
214 void
215 blorp_clear_attachments(struct blorp_batch *batch,
216 uint32_t binding_table_offset,
217 enum isl_format depth_format,
218 uint32_t num_samples,
219 uint32_t start_layer, uint32_t num_layers,
220 uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
221 bool clear_color, union isl_color_value color_value,
222 bool clear_depth, float depth_value,
223 uint8_t stencil_mask, uint8_t stencil_value);
224
225 void
226 blorp_ccs_resolve(struct blorp_batch *batch,
227 struct blorp_surf *surf, uint32_t level,
228 uint32_t start_layer, uint32_t num_layers,
229 enum isl_format format,
230 enum isl_aux_op resolve_op);
231
232 void
233 blorp_ccs_ambiguate(struct blorp_batch *batch,
234 struct blorp_surf *surf,
235 uint32_t level, uint32_t layer);
236
237 void
238 blorp_mcs_partial_resolve(struct blorp_batch *batch,
239 struct blorp_surf *surf,
240 enum isl_format format,
241 uint32_t start_layer, uint32_t num_layers);
242
243 void
244 blorp_hiz_op(struct blorp_batch *batch, struct blorp_surf *surf,
245 uint32_t level, uint32_t start_layer, uint32_t num_layers,
246 enum isl_aux_op op);
247
248 #ifdef __cplusplus
249 } /* end extern "C" */
250 #endif /* __cplusplus */
251
252 #endif /* BLORP_H */