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 "brw_context.h"
30 #include "intel_mipmap_tree.h"
39 brw_blorp_blit_miptrees(struct brw_context
*brw
,
40 struct intel_mipmap_tree
*src_mt
,
41 unsigned src_level
, unsigned src_layer
,
42 struct intel_mipmap_tree
*dst_mt
,
43 unsigned dst_level
, unsigned dst_layer
,
44 float src_x0
, float src_y0
,
45 float src_x1
, float src_y1
,
46 float dst_x0
, float dst_y0
,
47 float dst_x1
, float dst_y1
,
48 GLenum filter
, bool mirror_x
, bool mirror_y
);
51 brw_blorp_clear_color(struct brw_context
*brw
, struct gl_framebuffer
*fb
,
52 GLbitfield mask
, bool partial_clear
);
55 brw_blorp_resolve_color(struct brw_context
*brw
,
56 struct intel_mipmap_tree
*mt
);
59 } /* end extern "C" */
62 * Binding table indices used by BLORP.
65 BRW_BLORP_TEXTURE_BINDING_TABLE_INDEX
,
66 BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX
,
67 BRW_BLORP_NUM_BINDING_TABLE_ENTRIES
71 class brw_blorp_mip_info
76 void set(struct intel_mipmap_tree
*mt
,
77 unsigned int level
, unsigned int layer
);
79 struct intel_mipmap_tree
*mt
;
82 * The miplevel to use.
87 * The 2D layer within the miplevel. Combined, level and layer define the
88 * 2D miptree slice to use.
90 * Note: if mt is a 2D multisample array texture on Gen7+ using
91 * INTEL_MSAA_LAYOUT_UMS or INTEL_MSAA_LAYOUT_CMS, layer is the physical
92 * layer holding sample 0. So, for example, if mt->num_samples == 4, then
93 * logical layer n corresponds to layer == 4*n.
98 * Width of the miplevel to be used. For surfaces using
99 * INTEL_MSAA_LAYOUT_IMS, this is measured in samples, not pixels.
104 * Height of the miplevel to be used. For surfaces using
105 * INTEL_MSAA_LAYOUT_IMS, this is measured in samples, not pixels.
110 * X offset within the surface to texture from (or render to). For
111 * surfaces using INTEL_MSAA_LAYOUT_IMS, this is measured in samples, not
117 * Y offset within the surface to texture from (or render to). For
118 * surfaces using INTEL_MSAA_LAYOUT_IMS, this is measured in samples, not
124 class brw_blorp_surface_info
: public brw_blorp_mip_info
127 brw_blorp_surface_info();
129 void set(struct brw_context
*brw
,
130 struct intel_mipmap_tree
*mt
,
131 unsigned int level
, unsigned int layer
,
132 bool is_render_target
);
134 uint32_t compute_tile_offsets(uint32_t *tile_x
, uint32_t *tile_y
) const;
136 /* Setting this flag indicates that the buffer's contents are W-tiled
137 * stencil data, but the surface state should be set up for Y tiled
138 * MESA_FORMAT_R_UNORM8 data (this is necessary because surface states don't
141 * Since W tiles are 64 pixels wide by 64 pixels high, whereas Y tiles of
142 * MESA_FORMAT_R_UNORM8 data are 128 pixels wide by 32 pixels high, the width and
143 * pitch stored in the surface state will be multiplied by 2, and the
144 * height will be halved. Also, since W and Y tiles store their data in a
145 * different order, the width and height will be rounded up to a multiple
146 * of the tile size, to ensure that the WM program can access the full
147 * width and height of the buffer.
149 bool map_stencil_as_y_tiled
;
151 unsigned num_samples
;
153 /* Setting this flag indicates that the surface should be set up in
154 * ARYSPC_LOD0 mode. Ignored prior to Gen7.
156 bool array_spacing_lod0
;
159 * Format that should be used when setting up the surface state for this
160 * surface. Should correspond to one of the BRW_SURFACEFORMAT_* enums.
162 uint32_t brw_surfaceformat
;
165 * For MSAA surfaces, MSAA layout that should be used when setting up the
166 * surface state for this surface.
168 intel_msaa_layout msaa_layout
;
172 struct brw_blorp_coord_transform_params
174 void setup(GLfloat src0
, GLfloat src1
, GLfloat dst0
, GLfloat dst1
,
182 struct brw_blorp_wm_push_constants
188 /* Top right coordinates of the rectangular grid used for scaled blitting */
191 brw_blorp_coord_transform_params x_transform
;
192 brw_blorp_coord_transform_params y_transform
;
193 /* Pad out to an integral number of registers */
197 /* Every 32 bytes of push constant data constitutes one GEN register. */
198 const unsigned int BRW_BLORP_NUM_PUSH_CONST_REGS
=
199 sizeof(brw_blorp_wm_push_constants
) / 32;
201 struct brw_blorp_prog_data
203 unsigned int first_curbe_grf
;
206 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
207 * than one sample per pixel.
209 bool persample_msaa_dispatch
;
213 enum gen7_fast_clear_op
{
214 GEN7_FAST_CLEAR_OP_NONE
,
215 GEN7_FAST_CLEAR_OP_FAST_CLEAR
,
216 GEN7_FAST_CLEAR_OP_RESOLVE
,
220 class brw_blorp_params
225 virtual uint32_t get_wm_prog(struct brw_context
*brw
,
226 brw_blorp_prog_data
**prog_data
) const = 0;
232 brw_blorp_mip_info depth
;
233 uint32_t depth_format
;
234 brw_blorp_surface_info src
;
235 brw_blorp_surface_info dst
;
236 enum gen6_hiz_op hiz_op
;
237 enum gen7_fast_clear_op fast_clear_op
;
239 brw_blorp_wm_push_constants wm_push_consts
;
240 bool color_write_disable
[4];
245 brw_blorp_exec(struct brw_context
*brw
, const brw_blorp_params
*params
);
249 * Parameters for a HiZ or depth resolve operation.
251 * For an overview of HiZ ops, see the following sections of the Sandy Bridge
252 * PRM, Volume 1, Part 2:
253 * - 7.5.3.1 Depth Buffer Clear
254 * - 7.5.3.2 Depth Buffer Resolve
255 * - 7.5.3.3 Hierarchical Depth Buffer Resolve
257 class brw_hiz_op_params
: public brw_blorp_params
260 brw_hiz_op_params(struct intel_mipmap_tree
*mt
,
261 unsigned int level
, unsigned int layer
,
264 virtual uint32_t get_wm_prog(struct brw_context
*brw
,
265 brw_blorp_prog_data
**prog_data
) const;
268 struct brw_blorp_blit_prog_key
270 /* Number of samples per pixel that have been configured in the surface
271 * state for texturing from.
273 unsigned tex_samples
;
275 /* MSAA layout that has been configured in the surface state for texturing
278 intel_msaa_layout tex_layout
;
280 /* Actual number of samples per pixel in the source image. */
281 unsigned src_samples
;
283 /* Actual MSAA layout used by the source image. */
284 intel_msaa_layout src_layout
;
286 /* Number of samples per pixel that have been configured in the render
291 /* MSAA layout that has been configured in the render target. */
292 intel_msaa_layout rt_layout
;
294 /* Actual number of samples per pixel in the destination image. */
295 unsigned dst_samples
;
297 /* Actual MSAA layout used by the destination image. */
298 intel_msaa_layout dst_layout
;
300 /* Type of the data to be read from the texture (one of
301 * BRW_REGISTER_TYPE_{UD,D,F}).
303 enum brw_reg_type texture_data_type
;
305 /* True if the source image is W tiled. If true, the surface state for the
306 * source image must be configured as Y tiled, and tex_samples must be 0.
310 /* True if the destination image is W tiled. If true, the surface state
311 * for the render target must be configured as Y tiled, and rt_samples must
316 /* True if all source samples should be blended together to produce each
317 * destination pixel. If true, src_tiled_w must be false, tex_samples must
318 * equal src_samples, and tex_samples must be nonzero.
322 /* True if the rectangle being sent through the rendering pipeline might be
323 * larger than the destination rectangle, so the WM program should kill any
324 * pixels that are outside the destination rectangle.
329 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
330 * than one sample per pixel.
332 bool persample_msaa_dispatch
;
334 /* True for scaled blitting. */
337 /* Scale factors between the pixel grid and the grid of samples. We're
338 * using grid of samples for bilinear filetring in multisample scaled blits.
343 /* True for blits with filter = GL_LINEAR. */
344 bool bilinear_filter
;
347 class brw_blorp_blit_params
: public brw_blorp_params
350 brw_blorp_blit_params(struct brw_context
*brw
,
351 struct intel_mipmap_tree
*src_mt
,
352 unsigned src_level
, unsigned src_layer
,
353 struct intel_mipmap_tree
*dst_mt
,
354 unsigned dst_level
, unsigned dst_layer
,
355 GLfloat src_x0
, GLfloat src_y0
,
356 GLfloat src_x1
, GLfloat src_y1
,
357 GLfloat dst_x0
, GLfloat dst_y0
,
358 GLfloat dst_x1
, GLfloat dst_y1
,
359 GLenum filter
, bool mirror_x
, bool mirror_y
);
361 virtual uint32_t get_wm_prog(struct brw_context
*brw
,
362 brw_blorp_prog_data
**prog_data
) const;
365 brw_blorp_blit_prog_key wm_prog_key
;
369 * \name BLORP internals
372 * Used internally by gen6_blorp_exec() and gen7_blorp_exec().
376 gen6_blorp_init(struct brw_context
*brw
);
379 gen6_blorp_emit_state_base_address(struct brw_context
*brw
,
380 const brw_blorp_params
*params
);
383 gen6_blorp_emit_vertices(struct brw_context
*brw
,
384 const brw_blorp_params
*params
);
387 gen6_blorp_emit_blend_state(struct brw_context
*brw
,
388 const brw_blorp_params
*params
);
391 gen6_blorp_emit_cc_state(struct brw_context
*brw
,
392 const brw_blorp_params
*params
);
395 gen6_blorp_emit_wm_constants(struct brw_context
*brw
,
396 const brw_blorp_params
*params
);
399 gen6_blorp_emit_vs_disable(struct brw_context
*brw
,
400 const brw_blorp_params
*params
);
403 gen6_blorp_emit_binding_table(struct brw_context
*brw
,
404 const brw_blorp_params
*params
,
405 uint32_t wm_surf_offset_renderbuffer
,
406 uint32_t wm_surf_offset_texture
);
409 gen6_blorp_emit_depth_stencil_state(struct brw_context
*brw
,
410 const brw_blorp_params
*params
);
413 gen6_blorp_emit_gs_disable(struct brw_context
*brw
,
414 const brw_blorp_params
*params
);
417 gen6_blorp_emit_clip_disable(struct brw_context
*brw
,
418 const brw_blorp_params
*params
);
421 gen6_blorp_emit_drawing_rectangle(struct brw_context
*brw
,
422 const brw_blorp_params
*params
);
425 gen6_blorp_emit_sampler_state(struct brw_context
*brw
,
426 const brw_blorp_params
*params
);
429 #endif /* __cplusplus */