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 BLORP_RENDERBUFFER_BT_INDEX
,
41 BLORP_TEXTURE_BT_INDEX
,
45 struct brw_blorp_surface_info
48 struct blorp_address addr
;
50 struct isl_surf aux_surf
;
51 struct blorp_address aux_addr
;
52 enum isl_aux_usage aux_usage
;
54 union isl_color_value clear_color
;
58 /* Z offset into a 3-D texture or slice of a 2-D array texture. */
61 uint32_t tile_x_sa
, tile_y_sa
;
65 brw_blorp_surface_info_init(struct blorp_context
*blorp
,
66 struct brw_blorp_surface_info
*info
,
67 const struct brw_blorp_surf
*surf
,
68 unsigned int level
, unsigned int layer
,
69 enum isl_format format
, bool is_render_target
);
72 struct brw_blorp_coord_transform
79 * Bounding rectangle telling pixel discard which pixels are not to be
80 * touched. This is needed in when surfaces are configured as something else
81 * what they really are:
83 * - writing W-tiled stencil as Y-tiled
84 * - writing interleaved multisampled as single sampled.
86 * See blorp_nir_discard_if_outside_rect().
88 struct brw_blorp_discard_rect
97 * Grid needed for blended and scaled blits of integer formats, see
98 * blorp_nir_manual_blend_bilinear().
100 struct brw_blorp_rect_grid
107 struct brw_blorp_wm_inputs
109 struct brw_blorp_discard_rect discard_rect
;
110 struct brw_blorp_rect_grid rect_grid
;
111 struct brw_blorp_coord_transform coord_transform
[2];
113 /* Minimum layer setting works for all the textures types but texture_3d
114 * for which the setting has no effect. Use the z-coordinate instead.
118 /* Pad out to an integral number of registers */
122 struct brw_blorp_prog_data
127 uint8_t first_curbe_grf_0
;
128 uint8_t first_curbe_grf_2
;
130 uint32_t ksp_offset_2
;
133 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
134 * than one sample per pixel.
136 bool persample_msaa_dispatch
;
139 * Mask of which FS inputs are marked flat by the shader source. This is
140 * needed for setting up 3DSTATE_SF/SBE.
142 uint32_t flat_inputs
;
143 unsigned num_varying_inputs
;
144 uint64_t inputs_read
;
147 static inline unsigned
148 brw_blorp_get_urb_length(const struct brw_blorp_prog_data
*prog_data
)
150 if (prog_data
== NULL
)
153 /* From the BSpec: 3D Pipeline - Strips and Fans - 3DSTATE_SBE
155 * read_length = ceiling((max_source_attr+1)/2)
157 return MAX2((prog_data
->num_varying_inputs
+ 1) / 2, 1);
160 struct brw_blorp_params
166 struct brw_blorp_surface_info depth
;
167 uint32_t depth_format
;
168 struct brw_blorp_surface_info src
;
169 struct brw_blorp_surface_info dst
;
170 enum gen6_hiz_op hiz_op
;
172 unsigned fast_clear_op
;
173 unsigned resolve_type
;
175 bool color_write_disable
[4];
176 struct brw_blorp_wm_inputs wm_inputs
;
177 unsigned num_draw_buffers
;
179 uint32_t wm_prog_kernel
;
180 struct brw_blorp_prog_data
*wm_prog_data
;
184 brw_blorp_params_init(struct brw_blorp_params
*params
);
186 struct brw_blorp_blit_prog_key
188 /* Number of samples per pixel that have been configured in the surface
189 * state for texturing from.
191 unsigned tex_samples
;
193 /* MSAA layout that has been configured in the surface state for texturing
196 enum isl_msaa_layout tex_layout
;
198 enum isl_aux_usage tex_aux_usage
;
200 /* Actual number of samples per pixel in the source image. */
201 unsigned src_samples
;
203 /* Actual MSAA layout used by the source image. */
204 enum isl_msaa_layout src_layout
;
206 /* Number of samples per pixel that have been configured in the render
211 /* MSAA layout that has been configured in the render target. */
212 enum isl_msaa_layout rt_layout
;
214 /* Actual number of samples per pixel in the destination image. */
215 unsigned dst_samples
;
217 /* Actual MSAA layout used by the destination image. */
218 enum isl_msaa_layout dst_layout
;
220 /* Type of the data to be read from the texture (one of
221 * nir_type_(int|uint|float)).
223 nir_alu_type texture_data_type
;
225 /* True if the source image is W tiled. If true, the surface state for the
226 * source image must be configured as Y tiled, and tex_samples must be 0.
230 /* True if the destination image is W tiled. If true, the surface state
231 * for the render target must be configured as Y tiled, and rt_samples must
236 /* True if all source samples should be blended together to produce each
237 * destination pixel. If true, src_tiled_w must be false, tex_samples must
238 * equal src_samples, and tex_samples must be nonzero.
242 /* True if the rectangle being sent through the rendering pipeline might be
243 * larger than the destination rectangle, so the WM program should kill any
244 * pixels that are outside the destination rectangle.
249 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
250 * than one sample per pixel.
252 bool persample_msaa_dispatch
;
254 /* True for scaled blitting. */
257 /* Scale factors between the pixel grid and the grid of samples. We're
258 * using grid of samples for bilinear filetring in multisample scaled blits.
263 /* True for blits with filter = GL_LINEAR. */
264 bool bilinear_filter
;
268 * \name BLORP internals
271 * Used internally by gen6_blorp_exec() and gen7_blorp_exec().
274 void brw_blorp_init_wm_prog_key(struct brw_wm_prog_key
*wm_key
);
277 brw_blorp_compile_nir_shader(struct blorp_context
*blorp
, struct nir_shader
*nir
,
278 const struct brw_wm_prog_key
*wm_key
,
280 struct brw_blorp_prog_data
*prog_data
,
281 unsigned *program_size
);
286 } /* end extern "C" */
287 #endif /* __cplusplus */