2 * Copyright © 2012 Intel Corporation
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:
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
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
28 #include "compiler/nir/nir.h"
37 * Binding table indices used by BLORP.
40 BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX
,
41 BRW_BLORP_TEXTURE_BINDING_TABLE_INDEX
,
42 BRW_BLORP_NUM_BINDING_TABLE_ENTRIES
45 struct brw_blorp_surface_info
51 struct isl_surf aux_surf
;
54 enum isl_aux_usage aux_usage
;
56 union isl_color_value clear_color
;
60 /* Z offset into a 3-D texture or slice of a 2-D array texture. */
63 uint32_t tile_x_sa
, tile_y_sa
;
67 brw_blorp_surface_info_init(struct brw_context
*brw
,
68 struct brw_blorp_surface_info
*info
,
69 const struct brw_blorp_surf
*surf
,
70 unsigned int level
, unsigned int layer
,
71 enum isl_format format
, bool is_render_target
);
74 struct brw_blorp_coord_transform
81 * Bounding rectangle telling pixel discard which pixels are not to be
82 * touched. This is needed in when surfaces are configured as something else
83 * what they really are:
85 * - writing W-tiled stencil as Y-tiled
86 * - writing interleaved multisampled as single sampled.
88 * See blorp_nir_discard_if_outside_rect().
90 struct brw_blorp_discard_rect
99 * Grid needed for blended and scaled blits of integer formats, see
100 * blorp_nir_manual_blend_bilinear().
102 struct brw_blorp_rect_grid
109 struct brw_blorp_wm_inputs
111 struct brw_blorp_discard_rect discard_rect
;
112 struct brw_blorp_rect_grid rect_grid
;
113 struct brw_blorp_coord_transform coord_transform
[2];
115 /* Minimum layer setting works for all the textures types but texture_3d
116 * for which the setting has no effect. Use the z-coordinate instead.
120 /* Pad out to an integral number of registers */
124 struct brw_blorp_prog_data
129 uint8_t first_curbe_grf_0
;
130 uint8_t first_curbe_grf_2
;
132 uint32_t ksp_offset_2
;
135 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
136 * than one sample per pixel.
138 bool persample_msaa_dispatch
;
141 * Mask of which FS inputs are marked flat by the shader source. This is
142 * needed for setting up 3DSTATE_SF/SBE.
144 uint32_t flat_inputs
;
145 unsigned num_varying_inputs
;
146 GLbitfield64 inputs_read
;
149 static inline unsigned
150 brw_blorp_get_urb_length(const struct brw_blorp_prog_data
*prog_data
)
152 if (prog_data
== NULL
)
155 /* From the BSpec: 3D Pipeline - Strips and Fans - 3DSTATE_SBE
157 * read_length = ceiling((max_source_attr+1)/2)
159 return MAX2((prog_data
->num_varying_inputs
+ 1) / 2, 1);
162 struct brw_blorp_params
168 struct brw_blorp_surface_info depth
;
169 uint32_t depth_format
;
170 struct brw_blorp_surface_info src
;
171 struct brw_blorp_surface_info dst
;
172 enum gen6_hiz_op hiz_op
;
174 unsigned fast_clear_op
;
175 unsigned resolve_type
;
177 bool color_write_disable
[4];
178 struct brw_blorp_wm_inputs wm_inputs
;
179 unsigned num_draw_buffers
;
181 uint32_t wm_prog_kernel
;
182 struct brw_blorp_prog_data
*wm_prog_data
;
186 brw_blorp_params_init(struct brw_blorp_params
*params
);
189 brw_blorp_exec(struct brw_context
*brw
, const struct brw_blorp_params
*params
);
192 gen6_blorp_exec(struct brw_context
*brw
,
193 const struct brw_blorp_params
*params
);
196 gen7_blorp_exec(struct brw_context
*brw
,
197 const struct brw_blorp_params
*params
);
200 gen75_blorp_exec(struct brw_context
*brw
,
201 const struct brw_blorp_params
*params
);
204 gen8_blorp_exec(struct brw_context
*brw
, const struct brw_blorp_params
*params
);
207 gen9_blorp_exec(struct brw_context
*brw
, const struct brw_blorp_params
*params
);
209 struct brw_blorp_blit_prog_key
211 /* Number of samples per pixel that have been configured in the surface
212 * state for texturing from.
214 unsigned tex_samples
;
216 /* MSAA layout that has been configured in the surface state for texturing
219 enum isl_msaa_layout tex_layout
;
221 enum isl_aux_usage tex_aux_usage
;
223 /* Actual number of samples per pixel in the source image. */
224 unsigned src_samples
;
226 /* Actual MSAA layout used by the source image. */
227 enum isl_msaa_layout src_layout
;
229 /* Number of samples per pixel that have been configured in the render
234 /* MSAA layout that has been configured in the render target. */
235 enum isl_msaa_layout rt_layout
;
237 /* Actual number of samples per pixel in the destination image. */
238 unsigned dst_samples
;
240 /* Actual MSAA layout used by the destination image. */
241 enum isl_msaa_layout dst_layout
;
243 /* Type of the data to be read from the texture (one of
244 * nir_type_(int|uint|float)).
246 nir_alu_type texture_data_type
;
248 /* True if the source image is W tiled. If true, the surface state for the
249 * source image must be configured as Y tiled, and tex_samples must be 0.
253 /* True if the destination image is W tiled. If true, the surface state
254 * for the render target must be configured as Y tiled, and rt_samples must
259 /* True if all source samples should be blended together to produce each
260 * destination pixel. If true, src_tiled_w must be false, tex_samples must
261 * equal src_samples, and tex_samples must be nonzero.
265 /* True if the rectangle being sent through the rendering pipeline might be
266 * larger than the destination rectangle, so the WM program should kill any
267 * pixels that are outside the destination rectangle.
272 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
273 * than one sample per pixel.
275 bool persample_msaa_dispatch
;
277 /* True for scaled blitting. */
280 /* Scale factors between the pixel grid and the grid of samples. We're
281 * using grid of samples for bilinear filetring in multisample scaled blits.
286 /* True for blits with filter = GL_LINEAR. */
287 bool bilinear_filter
;
291 * \name BLORP internals
294 * Used internally by gen6_blorp_exec() and gen7_blorp_exec().
297 void brw_blorp_init_wm_prog_key(struct brw_wm_prog_key
*wm_key
);
300 brw_blorp_compile_nir_shader(struct brw_context
*brw
, struct nir_shader
*nir
,
301 const struct brw_wm_prog_key
*wm_key
,
303 struct brw_blorp_prog_data
*prog_data
,
304 unsigned *program_size
);
307 brw_blorp_emit_surface_state(struct brw_context
*brw
,
308 const struct brw_blorp_surface_info
*surface
,
309 uint32_t read_domains
, uint32_t write_domain
,
310 bool is_render_target
);
315 } /* end extern "C" */
316 #endif /* __cplusplus */