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 gen8_blorp_exec(struct brw_context
*brw
, const struct brw_blorp_params
*params
);
202 struct brw_blorp_blit_prog_key
204 /* Number of samples per pixel that have been configured in the surface
205 * state for texturing from.
207 unsigned tex_samples
;
209 /* MSAA layout that has been configured in the surface state for texturing
212 enum isl_msaa_layout tex_layout
;
214 enum isl_aux_usage tex_aux_usage
;
216 /* Actual number of samples per pixel in the source image. */
217 unsigned src_samples
;
219 /* Actual MSAA layout used by the source image. */
220 enum isl_msaa_layout src_layout
;
222 /* Number of samples per pixel that have been configured in the render
227 /* MSAA layout that has been configured in the render target. */
228 enum isl_msaa_layout rt_layout
;
230 /* Actual number of samples per pixel in the destination image. */
231 unsigned dst_samples
;
233 /* Actual MSAA layout used by the destination image. */
234 enum isl_msaa_layout dst_layout
;
236 /* Type of the data to be read from the texture (one of
237 * nir_type_(int|uint|float)).
239 nir_alu_type texture_data_type
;
241 /* True if the source image is W tiled. If true, the surface state for the
242 * source image must be configured as Y tiled, and tex_samples must be 0.
246 /* True if the destination image is W tiled. If true, the surface state
247 * for the render target must be configured as Y tiled, and rt_samples must
252 /* True if all source samples should be blended together to produce each
253 * destination pixel. If true, src_tiled_w must be false, tex_samples must
254 * equal src_samples, and tex_samples must be nonzero.
258 /* True if the rectangle being sent through the rendering pipeline might be
259 * larger than the destination rectangle, so the WM program should kill any
260 * pixels that are outside the destination rectangle.
265 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
266 * than one sample per pixel.
268 bool persample_msaa_dispatch
;
270 /* True for scaled blitting. */
273 /* Scale factors between the pixel grid and the grid of samples. We're
274 * using grid of samples for bilinear filetring in multisample scaled blits.
279 /* True for blits with filter = GL_LINEAR. */
280 bool bilinear_filter
;
284 * \name BLORP internals
287 * Used internally by gen6_blorp_exec() and gen7_blorp_exec().
290 void brw_blorp_init_wm_prog_key(struct brw_wm_prog_key
*wm_key
);
293 brw_blorp_compile_nir_shader(struct brw_context
*brw
, struct nir_shader
*nir
,
294 const struct brw_wm_prog_key
*wm_key
,
296 struct brw_blorp_prog_data
*prog_data
,
297 unsigned *program_size
);
300 brw_blorp_emit_surface_state(struct brw_context
*brw
,
301 const struct brw_blorp_surface_info
*surface
,
302 uint32_t read_domains
, uint32_t write_domain
,
303 bool is_render_target
);
306 gen6_blorp_init(struct brw_context
*brw
);
309 gen6_blorp_emit_vertices(struct brw_context
*brw
,
310 const struct brw_blorp_params
*params
);
313 gen6_blorp_emit_blend_state(struct brw_context
*brw
,
314 const struct brw_blorp_params
*params
);
317 gen6_blorp_emit_cc_state(struct brw_context
*brw
);
320 gen6_blorp_emit_wm_constants(struct brw_context
*brw
,
321 const struct brw_blorp_params
*params
);
324 gen6_blorp_emit_binding_table(struct brw_context
*brw
,
325 uint32_t wm_surf_offset_renderbuffer
,
326 uint32_t wm_surf_offset_texture
);
329 gen6_blorp_emit_depth_stencil_state(struct brw_context
*brw
,
330 const struct brw_blorp_params
*params
);
333 gen6_blorp_emit_clip_disable(struct brw_context
*brw
);
336 gen6_blorp_emit_drawing_rectangle(struct brw_context
*brw
,
337 const struct brw_blorp_params
*params
);
340 gen6_blorp_emit_sampler_state(struct brw_context
*brw
,
341 unsigned tex_filter
, unsigned max_lod
,
342 bool non_normalized_coords
);
344 gen7_blorp_emit_urb_config(struct brw_context
*brw
,
345 const struct brw_blorp_params
*params
);
348 gen7_blorp_emit_blend_state_pointer(struct brw_context
*brw
,
349 uint32_t cc_blend_state_offset
);
352 gen7_blorp_emit_cc_state_pointer(struct brw_context
*brw
,
353 uint32_t cc_state_offset
);
356 gen7_blorp_emit_cc_viewport(struct brw_context
*brw
);
359 gen7_blorp_emit_te_disable(struct brw_context
*brw
);
362 gen7_blorp_emit_binding_table_pointers_ps(struct brw_context
*brw
,
363 uint32_t wm_bind_bo_offset
);
366 gen7_blorp_emit_sampler_state_pointers_ps(struct brw_context
*brw
,
367 uint32_t sampler_offset
);
370 gen7_blorp_emit_clear_params(struct brw_context
*brw
,
371 const struct brw_blorp_params
*params
);
374 gen7_blorp_emit_constant_ps(struct brw_context
*brw
,
375 uint32_t wm_push_const_offset
);
378 gen7_blorp_emit_constant_ps_disable(struct brw_context
*brw
);
381 gen7_blorp_emit_primitive(struct brw_context
*brw
,
382 const struct brw_blorp_params
*params
);
387 } /* end extern "C" */
388 #endif /* __cplusplus */