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"
29 #include "brw_compiler.h"
38 * Binding table indices used by BLORP.
41 BLORP_RENDERBUFFER_BT_INDEX
,
42 BLORP_TEXTURE_BT_INDEX
,
46 enum blorp_fast_clear_op
{
47 BLORP_FAST_CLEAR_OP_NONE
= 0,
48 BLORP_FAST_CLEAR_OP_CLEAR
,
49 BLORP_FAST_CLEAR_OP_RESOLVE_PARTIAL
,
50 BLORP_FAST_CLEAR_OP_RESOLVE_FULL
,
53 struct brw_blorp_surface_info
56 struct blorp_address addr
;
58 struct isl_surf aux_surf
;
59 struct blorp_address aux_addr
;
60 enum isl_aux_usage aux_usage
;
62 union isl_color_value clear_color
;
66 /* Z offset into a 3-D texture or slice of a 2-D array texture. */
69 uint32_t tile_x_sa
, tile_y_sa
;
73 brw_blorp_surface_info_init(struct blorp_context
*blorp
,
74 struct brw_blorp_surface_info
*info
,
75 const struct blorp_surf
*surf
,
76 unsigned int level
, unsigned int layer
,
77 enum isl_format format
, bool is_render_target
);
80 struct brw_blorp_coord_transform
87 * Bounding rectangle telling pixel discard which pixels are not to be
88 * touched. This is needed in when surfaces are configured as something else
89 * what they really are:
91 * - writing W-tiled stencil as Y-tiled
92 * - writing interleaved multisampled as single sampled.
94 * See blorp_nir_discard_if_outside_rect().
96 struct brw_blorp_discard_rect
105 * Grid needed for blended and scaled blits of integer formats, see
106 * blorp_nir_manual_blend_bilinear().
108 struct brw_blorp_rect_grid
115 struct brw_blorp_wm_inputs
117 struct brw_blorp_discard_rect discard_rect
;
118 struct brw_blorp_rect_grid rect_grid
;
119 struct brw_blorp_coord_transform coord_transform
[2];
121 /* Minimum layer setting works for all the textures types but texture_3d
122 * for which the setting has no effect. Use the z-coordinate instead.
126 /* Pad out to an integral number of registers */
130 struct brw_blorp_prog_data
135 uint8_t first_curbe_grf_0
;
136 uint8_t first_curbe_grf_2
;
138 uint32_t ksp_offset_2
;
141 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
142 * than one sample per pixel.
144 bool persample_msaa_dispatch
;
147 * Mask of which FS inputs are marked flat by the shader source. This is
148 * needed for setting up 3DSTATE_SF/SBE.
150 uint32_t flat_inputs
;
151 unsigned num_varying_inputs
;
152 uint64_t inputs_read
;
155 static inline unsigned
156 brw_blorp_get_urb_length(const struct brw_blorp_prog_data
*prog_data
)
158 if (prog_data
== NULL
)
161 /* From the BSpec: 3D Pipeline - Strips and Fans - 3DSTATE_SBE
163 * read_length = ceiling((max_source_attr+1)/2)
165 return MAX2((prog_data
->num_varying_inputs
+ 1) / 2, 1);
174 struct brw_blorp_surface_info depth
;
175 uint32_t depth_format
;
176 struct brw_blorp_surface_info src
;
177 struct brw_blorp_surface_info dst
;
178 enum blorp_hiz_op hiz_op
;
179 enum blorp_fast_clear_op fast_clear_op
;
180 bool color_write_disable
[4];
181 struct brw_blorp_wm_inputs wm_inputs
;
182 unsigned num_draw_buffers
;
184 uint32_t wm_prog_kernel
;
185 struct brw_blorp_prog_data
*wm_prog_data
;
188 void blorp_params_init(struct blorp_params
*params
);
190 struct brw_blorp_blit_prog_key
192 /* Number of samples per pixel that have been configured in the surface
193 * state for texturing from.
195 unsigned tex_samples
;
197 /* MSAA layout that has been configured in the surface state for texturing
200 enum isl_msaa_layout tex_layout
;
202 enum isl_aux_usage tex_aux_usage
;
204 /* Actual number of samples per pixel in the source image. */
205 unsigned src_samples
;
207 /* Actual MSAA layout used by the source image. */
208 enum isl_msaa_layout src_layout
;
210 /* Number of samples per pixel that have been configured in the render
215 /* MSAA layout that has been configured in the render target. */
216 enum isl_msaa_layout rt_layout
;
218 /* Actual number of samples per pixel in the destination image. */
219 unsigned dst_samples
;
221 /* Actual MSAA layout used by the destination image. */
222 enum isl_msaa_layout dst_layout
;
224 /* Type of the data to be read from the texture (one of
225 * nir_type_(int|uint|float)).
227 nir_alu_type texture_data_type
;
229 /* True if the source image is W tiled. If true, the surface state for the
230 * source image must be configured as Y tiled, and tex_samples must be 0.
234 /* True if the destination image is W tiled. If true, the surface state
235 * for the render target must be configured as Y tiled, and rt_samples must
240 /* True if all source samples should be blended together to produce each
241 * destination pixel. If true, src_tiled_w must be false, tex_samples must
242 * equal src_samples, and tex_samples must be nonzero.
246 /* True if the rectangle being sent through the rendering pipeline might be
247 * larger than the destination rectangle, so the WM program should kill any
248 * pixels that are outside the destination rectangle.
253 * True if the WM program should be run in MSDISPMODE_PERSAMPLE with more
254 * than one sample per pixel.
256 bool persample_msaa_dispatch
;
258 /* True for scaled blitting. */
261 /* Scale factors between the pixel grid and the grid of samples. We're
262 * using grid of samples for bilinear filetring in multisample scaled blits.
267 /* True for blits with filter = GL_LINEAR. */
268 bool bilinear_filter
;
272 * \name BLORP internals
275 * Used internally by gen6_blorp_exec() and gen7_blorp_exec().
278 void brw_blorp_init_wm_prog_key(struct brw_wm_prog_key
*wm_key
);
281 brw_blorp_compile_nir_shader(struct blorp_context
*blorp
, struct nir_shader
*nir
,
282 const struct brw_wm_prog_key
*wm_key
,
284 struct brw_blorp_prog_data
*prog_data
,
285 unsigned *program_size
);
290 } /* end extern "C" */
291 #endif /* __cplusplus */