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
29 #include "intel_mipmap_tree.h"
32 struct brw_wm_prog_key
;
39 brw_blorp_blit_miptrees(struct brw_context
*brw
,
40 struct intel_mipmap_tree
*src_mt
,
41 unsigned src_level
, unsigned src_layer
,
42 mesa_format src_format
, int src_swizzle
,
43 struct intel_mipmap_tree
*dst_mt
,
44 unsigned dst_level
, unsigned dst_layer
,
45 mesa_format dst_format
,
46 float src_x0
, float src_y0
,
47 float src_x1
, float src_y1
,
48 float dst_x0
, float dst_y0
,
49 float dst_x1
, float dst_y1
,
50 GLenum filter
, bool mirror_x
, bool mirror_y
,
51 bool decode_srgb
, bool encode_srgb
);
54 brw_blorp_clear_color(struct brw_context
*brw
, struct gl_framebuffer
*fb
,
55 GLbitfield mask
, bool partial_clear
, bool encode_srgb
);
58 brw_blorp_resolve_color(struct brw_context
*brw
,
59 struct intel_mipmap_tree
*mt
);
62 * Binding table indices used by BLORP.
65 BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX
,
66 BRW_BLORP_TEXTURE_BINDING_TABLE_INDEX
,
67 BRW_BLORP_NUM_BINDING_TABLE_ENTRIES
70 struct brw_blorp_surface_info
76 struct isl_surf aux_surf
;
79 enum isl_aux_usage aux_usage
;
81 union isl_color_value clear_color
;
85 /* Z offset into a 3-D texture or slice of a 2-D array texture. */
88 uint32_t tile_x_sa
, tile_y_sa
;
92 brw_blorp_surface_info_init(struct brw_context
*brw
,
93 struct brw_blorp_surface_info
*info
,
94 struct intel_mipmap_tree
*mt
,
95 unsigned int level
, unsigned int layer
,
96 mesa_format format
, bool is_render_target
);
99 struct brw_blorp_coord_transform
106 * Bounding rectangle telling pixel discard which pixels are not to be
107 * touched. This is needed in when surfaces are configured as something else
108 * what they really are:
110 * - writing W-tiled stencil as Y-tiled
111 * - writing interleaved multisampled as single sampled.
113 * See blorp_nir_discard_if_outside_rect().
115 struct brw_blorp_discard_rect
124 * Grid needed for blended and scaled blits of integer formats, see
125 * blorp_nir_manual_blend_bilinear().
127 struct brw_blorp_rect_grid
134 struct brw_blorp_wm_inputs
136 struct brw_blorp_discard_rect discard_rect
;
137 struct brw_blorp_rect_grid rect_grid
;
138 struct brw_blorp_coord_transform coord_transform
[2];
140 /* Minimum layer setting works for all the textures types but texture_3d
141 * for which the setting has no effect. Use the z-coordinate instead.
145 /* Pad out to an integral number of registers */
149 struct brw_blorp_prog_data
154 uint8_t first_curbe_grf_0
;
155 uint8_t first_curbe_grf_2
;
157 uint32_t ksp_offset_2
;
160 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
161 * than one sample per pixel.
163 bool persample_msaa_dispatch
;
166 * Mask of which FS inputs are marked flat by the shader source. This is
167 * needed for setting up 3DSTATE_SF/SBE.
169 uint32_t flat_inputs
;
170 unsigned num_varying_inputs
;
171 GLbitfield64 inputs_read
;
174 static inline unsigned
175 brw_blorp_get_urb_length(const struct brw_blorp_prog_data
*prog_data
)
177 if (prog_data
== NULL
)
180 /* From the BSpec: 3D Pipeline - Strips and Fans - 3DSTATE_SBE
182 * read_length = ceiling((max_source_attr+1)/2)
184 return MAX2((prog_data
->num_varying_inputs
+ 1) / 2, 1);
187 struct brw_blorp_params
193 struct brw_blorp_surface_info depth
;
194 uint32_t depth_format
;
195 struct brw_blorp_surface_info src
;
196 struct brw_blorp_surface_info dst
;
197 enum gen6_hiz_op hiz_op
;
199 unsigned fast_clear_op
;
200 unsigned resolve_type
;
202 bool color_write_disable
[4];
203 struct brw_blorp_wm_inputs wm_inputs
;
204 unsigned num_draw_buffers
;
206 uint32_t wm_prog_kernel
;
207 struct brw_blorp_prog_data
*wm_prog_data
;
211 brw_blorp_params_init(struct brw_blorp_params
*params
);
214 brw_blorp_exec(struct brw_context
*brw
, const struct brw_blorp_params
*params
);
217 gen6_blorp_hiz_exec(struct brw_context
*brw
, struct intel_mipmap_tree
*mt
,
218 unsigned level
, unsigned layer
, enum gen6_hiz_op op
);
221 gen6_blorp_exec(struct brw_context
*brw
,
222 const struct brw_blorp_params
*params
);
225 gen7_blorp_exec(struct brw_context
*brw
,
226 const struct brw_blorp_params
*params
);
229 gen8_blorp_exec(struct brw_context
*brw
, const struct brw_blorp_params
*params
);
231 struct brw_blorp_blit_prog_key
233 /* Number of samples per pixel that have been configured in the surface
234 * state for texturing from.
236 unsigned tex_samples
;
238 /* MSAA layout that has been configured in the surface state for texturing
241 enum isl_msaa_layout tex_layout
;
243 enum isl_aux_usage tex_aux_usage
;
245 /* Actual number of samples per pixel in the source image. */
246 unsigned src_samples
;
248 /* Actual MSAA layout used by the source image. */
249 enum isl_msaa_layout src_layout
;
251 /* Number of samples per pixel that have been configured in the render
256 /* MSAA layout that has been configured in the render target. */
257 enum isl_msaa_layout rt_layout
;
259 /* Actual number of samples per pixel in the destination image. */
260 unsigned dst_samples
;
262 /* Actual MSAA layout used by the destination image. */
263 enum isl_msaa_layout dst_layout
;
265 /* Type of the data to be read from the texture (one of
266 * BRW_REGISTER_TYPE_{UD,D,F}).
268 enum brw_reg_type texture_data_type
;
270 /* True if the source image is W tiled. If true, the surface state for the
271 * source image must be configured as Y tiled, and tex_samples must be 0.
275 /* True if the destination image is W tiled. If true, the surface state
276 * for the render target must be configured as Y tiled, and rt_samples must
281 /* True if all source samples should be blended together to produce each
282 * destination pixel. If true, src_tiled_w must be false, tex_samples must
283 * equal src_samples, and tex_samples must be nonzero.
287 /* True if the rectangle being sent through the rendering pipeline might be
288 * larger than the destination rectangle, so the WM program should kill any
289 * pixels that are outside the destination rectangle.
294 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
295 * than one sample per pixel.
297 bool persample_msaa_dispatch
;
299 /* True for scaled blitting. */
302 /* Scale factors between the pixel grid and the grid of samples. We're
303 * using grid of samples for bilinear filetring in multisample scaled blits.
308 /* True for blits with filter = GL_LINEAR. */
309 bool bilinear_filter
;
313 * \name BLORP internals
316 * Used internally by gen6_blorp_exec() and gen7_blorp_exec().
319 void brw_blorp_init_wm_prog_key(struct brw_wm_prog_key
*wm_key
);
322 brw_blorp_compile_nir_shader(struct brw_context
*brw
, struct nir_shader
*nir
,
323 const struct brw_wm_prog_key
*wm_key
,
325 struct brw_blorp_prog_data
*prog_data
,
326 unsigned *program_size
);
329 blorp_get_image_offset_sa(struct isl_device
*dev
, const struct isl_surf
*surf
,
330 uint32_t level
, uint32_t layer
,
331 uint32_t *x_offset_sa
,
332 uint32_t *y_offset_sa
);
335 brw_blorp_emit_surface_state(struct brw_context
*brw
,
336 const struct brw_blorp_surface_info
*surface
,
337 uint32_t read_domains
, uint32_t write_domain
,
338 bool is_render_target
);
341 gen6_blorp_init(struct brw_context
*brw
);
344 gen6_blorp_emit_vertices(struct brw_context
*brw
,
345 const struct brw_blorp_params
*params
);
348 gen6_blorp_emit_blend_state(struct brw_context
*brw
,
349 const struct brw_blorp_params
*params
);
352 gen6_blorp_emit_cc_state(struct brw_context
*brw
);
355 gen6_blorp_emit_wm_constants(struct brw_context
*brw
,
356 const struct brw_blorp_params
*params
);
359 gen6_blorp_emit_vs_disable(struct brw_context
*brw
,
360 const struct brw_blorp_params
*params
);
363 gen6_blorp_emit_binding_table(struct brw_context
*brw
,
364 uint32_t wm_surf_offset_renderbuffer
,
365 uint32_t wm_surf_offset_texture
);
368 gen6_blorp_emit_depth_stencil_state(struct brw_context
*brw
,
369 const struct brw_blorp_params
*params
);
372 gen6_blorp_emit_gs_disable(struct brw_context
*brw
,
373 const struct brw_blorp_params
*params
);
376 gen6_blorp_emit_clip_disable(struct brw_context
*brw
);
379 gen6_blorp_emit_drawing_rectangle(struct brw_context
*brw
,
380 const struct brw_blorp_params
*params
);
383 gen6_blorp_emit_sampler_state(struct brw_context
*brw
,
384 unsigned tex_filter
, unsigned max_lod
,
385 bool non_normalized_coords
);
387 gen7_blorp_emit_urb_config(struct brw_context
*brw
,
388 const struct brw_blorp_params
*params
);
391 gen7_blorp_emit_blend_state_pointer(struct brw_context
*brw
,
392 uint32_t cc_blend_state_offset
);
395 gen7_blorp_emit_cc_state_pointer(struct brw_context
*brw
,
396 uint32_t cc_state_offset
);
399 gen7_blorp_emit_cc_viewport(struct brw_context
*brw
);
402 gen7_blorp_emit_te_disable(struct brw_context
*brw
);
405 gen7_blorp_emit_binding_table_pointers_ps(struct brw_context
*brw
,
406 uint32_t wm_bind_bo_offset
);
409 gen7_blorp_emit_sampler_state_pointers_ps(struct brw_context
*brw
,
410 uint32_t sampler_offset
);
413 gen7_blorp_emit_clear_params(struct brw_context
*brw
,
414 const struct brw_blorp_params
*params
);
417 gen7_blorp_emit_constant_ps(struct brw_context
*brw
,
418 uint32_t wm_push_const_offset
);
421 gen7_blorp_emit_constant_ps_disable(struct brw_context
*brw
);
424 gen7_blorp_emit_primitive(struct brw_context
*brw
,
425 const struct brw_blorp_params
*params
);
430 } /* end extern "C" */
431 #endif /* __cplusplus */