<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 23, 2016 at 8:11 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@intel.com" target="_blank">topi.pohjolainen@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Apr 22, 2016 at 04:19:14PM -0700, Jason Ekstrand wrote:<br>
> This commit is mostly mechanical except that it changes where we set the<br>
> swizzle. Previously, the blorp_surface_info constructor defaulted the<br>
> swizzle to SWIZZLE_XYZW. Now, we memset to zero and fill out the swizzle<br>
> when we setup the rest of the struct.<br>
> ---<br>
> src/mesa/drivers/dri/i965/brw_blorp.cpp | 77 ++++++++++++---------------<br>
> src/mesa/drivers/dri/i965/brw_blorp.h | 32 +++++------<br>
> src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 6 ++-<br>
> src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 6 ++-<br>
> src/mesa/drivers/dri/i965/gen6_blorp.cpp | 4 +-<br>
> src/mesa/drivers/dri/i965/gen7_blorp.cpp | 6 +--<br>
> src/mesa/drivers/dri/i965/gen8_blorp.cpp | 7 +--<br>
> 7 files changed, 69 insertions(+), 69 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp b/src/mesa/drivers/dri/i965/brw_blorp.cpp<br>
> index e501818..cd37922 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_blorp.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp<br>
> @@ -30,22 +30,9 @@<br>
><br>
> #define FILE_DEBUG_FLAG DEBUG_BLORP<br>
><br>
> -brw_blorp_surface_info::brw_blorp_surface_info()<br>
> - : mt(NULL),<br>
> - level(0),<br>
> - layer(0),<br>
> - width(0),<br>
> - height(0),<br>
> - x_offset(0),<br>
> - y_offset(0),<br>
> - map_stencil_as_y_tiled(false),<br>
> - num_samples(0),<br>
> - swizzle(SWIZZLE_XYZW)<br>
> -{<br>
> -}<br>
> -<br>
> void<br>
> -brw_blorp_surface_info::set(struct brw_context *brw,<br>
> +brw_blorp_surface_info_init(struct brw_context *brw,<br>
> + struct brw_blorp_surface_info *info,<br>
> struct intel_mipmap_tree *mt,<br>
> unsigned int level, unsigned int layer,<br>
> mesa_format format, bool is_render_target)<br>
> @@ -61,18 +48,20 @@ brw_blorp_surface_info::set(struct brw_context *brw,<br>
><br>
> intel_miptree_check_level_layer(mt, level, layer);<br>
><br>
> - this->mt = mt;<br>
> - this->level = level;<br>
> - this->layer = layer;<br>
> - this->width = minify(mt->physical_width0, level - mt->first_level);<br>
> - this->height = minify(mt->physical_height0, level - mt->first_level);<br>
> + info->mt = mt;<br>
> + info->level = level;<br>
> + info->layer = layer;<br>
> + info->width = minify(mt->physical_width0, level - mt->first_level);<br>
> + info->height = minify(mt->physical_height0, level - mt->first_level);<br>
><br>
> - intel_miptree_get_image_offset(mt, level, layer, &x_offset, &y_offset);<br>
> + intel_miptree_get_image_offset(mt, level, layer,<br>
> + &info->x_offset, &info->y_offset);<br>
><br>
> - this->num_samples = mt->num_samples;<br>
> - this->array_layout = mt->array_layout;<br>
> - this->map_stencil_as_y_tiled = false;<br>
> - this->msaa_layout = mt->msaa_layout;<br>
> + info->num_samples = mt->num_samples;<br>
> + info->array_layout = mt->array_layout;<br>
> + info->map_stencil_as_y_tiled = false;<br>
> + info->msaa_layout = mt->msaa_layout;<br>
> + info->swizzle = SWIZZLE_XYZW;<br>
><br>
> if (format == MESA_FORMAT_NONE)<br>
> format = mt->format;<br>
> @@ -83,8 +72,8 @@ brw_blorp_surface_info::set(struct brw_context *brw,<br>
> * up for W tiling, so we'll need to use Y tiling and have the WM<br>
> * program swizzle the coordinates.<br>
> */<br>
> - this->map_stencil_as_y_tiled = true;<br>
> - this->brw_surfaceformat = brw->gen >= 8 ? BRW_SURFACEFORMAT_R8_UINT :<br>
> + info->map_stencil_as_y_tiled = true;<br>
> + info->brw_surfaceformat = brw->gen >= 8 ? BRW_SURFACEFORMAT_R8_UINT :<br>
> BRW_SURFACEFORMAT_R8_UNORM;<br>
> break;<br>
> case MESA_FORMAT_Z24_UNORM_X8_UINT:<br>
> @@ -98,20 +87,20 @@ brw_blorp_surface_info::set(struct brw_context *brw,<br>
> * pattern as long as we copy the right amount of data, so just map it<br>
> * as 8-bit BGRA.<br>
> */<br>
> - this->brw_surfaceformat = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;<br>
> + info->brw_surfaceformat = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;<br>
> break;<br>
> case MESA_FORMAT_Z_FLOAT32:<br>
> - this->brw_surfaceformat = BRW_SURFACEFORMAT_R32_FLOAT;<br>
> + info->brw_surfaceformat = BRW_SURFACEFORMAT_R32_FLOAT;<br>
> break;<br>
> case MESA_FORMAT_Z_UNORM16:<br>
> - this->brw_surfaceformat = BRW_SURFACEFORMAT_R16_UNORM;<br>
> + info->brw_surfaceformat = BRW_SURFACEFORMAT_R16_UNORM;<br>
> break;<br>
> default: {<br>
> if (is_render_target) {<br>
> assert(brw->format_supported_as_render_target[format]);<br>
> - this->brw_surfaceformat = brw->render_target_format[format];<br>
> + info->brw_surfaceformat = brw->render_target_format[format];<br>
> } else {<br>
> - this->brw_surfaceformat = brw_format_for_mesa_format(format);<br>
> + info->brw_surfaceformat = brw_format_for_mesa_format(format);<br>
> }<br>
> break;<br>
> }<br>
> @@ -127,21 +116,21 @@ brw_blorp_surface_info::set(struct brw_context *brw,<br>
> * directly from the adjusted offsets.<br>
> */<br>
> uint32_t<br>
> -brw_blorp_surface_info::compute_tile_offsets(uint32_t *tile_x,<br>
> - uint32_t *tile_y) const<br>
> +brw_blorp_compute_tile_offsets(const struct brw_blorp_surface_info *info,<br>
> + uint32_t *tile_x, uint32_t *tile_y)<br>
> {<br>
> uint32_t mask_x, mask_y;<br>
><br>
> - intel_get_tile_masks(mt->tiling, mt->tr_mode, mt->cpp,<br>
> - map_stencil_as_y_tiled,<br>
> + intel_get_tile_masks(info->mt->tiling, info->mt->tr_mode, info->mt->cpp,<br>
> + info->map_stencil_as_y_tiled,<br>
> &mask_x, &mask_y);<br>
><br>
> - *tile_x = x_offset & mask_x;<br>
> - *tile_y = y_offset & mask_y;<br>
> + *tile_x = info->x_offset & mask_x;<br>
> + *tile_y = info->y_offset & mask_y;<br>
><br>
> - return intel_miptree_get_aligned_offset(mt, x_offset & ~mask_x,<br>
> - y_offset & ~mask_y,<br>
> - map_stencil_as_y_tiled);<br>
> + return intel_miptree_get_aligned_offset(info->mt, info->x_offset & ~mask_x,<br>
> + info->y_offset & ~mask_y,<br>
> + info->map_stencil_as_y_tiled);<br>
> }<br>
><br>
><br>
> @@ -159,6 +148,9 @@ brw_blorp_params::brw_blorp_params()<br>
> wm_prog_kernel(BRW_BLORP_NO_WM_PROG),<br>
> wm_prog_data(NULL)<br>
> {<br>
> + memset(&src, 0, sizeof(src));<br>
> + memset(&dst, 0, sizeof(dst));<br>
> + memset(&depth, 0, sizeof(depth));<br>
<br>
</div></div>I suppose you want to play it safe and keep it the way it was. In practise<br>
though this would suffice:<br>
<br>
<a href="http://src.mt" rel="noreferrer" target="_blank">src.mt</a> = NULL;<br>
<a href="http://dst.mt" rel="noreferrer" target="_blank">dst.mt</a> = NULL;<br>
<a href="http://depth.mt" rel="noreferrer" target="_blank">depth.mt</a> = NULL;<br>
<br>
Any logic trying to access the surface checks for the existence of the miptree<br>
pointer first - if it isn't there, the surface is regarded unused.<br></blockquote><div><br></div><div>Right. A few patches later, we end up just mesetting all of brw_blorp_params so unless we want to change that I don't think it makes a difference.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
> color_write_disable[0] = false;<br>
> color_write_disable[1] = false;<br>
> color_write_disable[2] = false;<br>
> @@ -304,7 +296,8 @@ gen6_blorp_hiz_exec(struct brw_context *brw, struct intel_mipmap_tree *mt,<br>
><br>
> params.hiz_op = op;<br>
><br>
> - params.depth.set(brw, mt, level, layer, mt->format, true);<br>
> + brw_blorp_surface_info_init(brw, ¶ms.depth, mt, level, layer,<br>
> + mt->format, true);<br>
><br>
> /* Align the rectangle primitive to 8x4 pixels.<br>
> *<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
> index e08693f..be5485c 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_blorp.h<br>
> +++ b/src/mesa/drivers/dri/i965/brw_blorp.h<br>
> @@ -69,18 +69,8 @@ enum {<br>
> BRW_BLORP_NUM_BINDING_TABLE_ENTRIES<br>
> };<br>
><br>
> -class brw_blorp_surface_info<br>
> +struct brw_blorp_surface_info<br>
> {<br>
> -public:<br>
> - brw_blorp_surface_info();<br>
> -<br>
> - void set(struct brw_context *brw,<br>
> - struct intel_mipmap_tree *mt,<br>
> - unsigned int level, unsigned int layer,<br>
> - mesa_format format, bool is_render_target);<br>
> -<br>
> - uint32_t compute_tile_offsets(uint32_t *tile_x, uint32_t *tile_y) const;<br>
> -<br>
> struct intel_mipmap_tree *mt;<br>
><br>
> /**<br>
> @@ -161,7 +151,7 @@ public:<br>
> * For MSAA surfaces, MSAA layout that should be used when setting up the<br>
> * surface state for this surface.<br>
> */<br>
> - intel_msaa_layout msaa_layout;<br>
> + enum intel_msaa_layout msaa_layout;<br>
><br>
> /**<br>
> * In order to support cases where RGBA format is backing client requested<br>
> @@ -172,6 +162,18 @@ public:<br>
> int swizzle;<br>
> };<br>
><br>
> +void<br>
> +brw_blorp_surface_info_init(struct brw_context *brw,<br>
> + struct brw_blorp_surface_info *info,<br>
> + struct intel_mipmap_tree *mt,<br>
> + unsigned int level, unsigned int layer,<br>
> + mesa_format format, bool is_render_target);<br>
> +<br>
> +uint32_t<br>
> +brw_blorp_compute_tile_offsets(const struct brw_blorp_surface_info *info,<br>
> + uint32_t *tile_x, uint32_t *tile_y);<br>
> +<br>
> +<br>
><br>
> struct brw_blorp_coord_transform_params<br>
> {<br>
> @@ -230,10 +232,10 @@ public:<br>
> uint32_t y0;<br>
> uint32_t x1;<br>
> uint32_t y1;<br>
> - brw_blorp_surface_info depth;<br>
> + struct brw_blorp_surface_info depth;<br>
> uint32_t depth_format;<br>
> - brw_blorp_surface_info src;<br>
> - brw_blorp_surface_info dst;<br>
> + struct brw_blorp_surface_info src;<br>
> + struct brw_blorp_surface_info dst;<br>
> enum gen6_hiz_op hiz_op;<br>
> unsigned fast_clear_op;<br>
> bool color_write_disable[4];<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
> index 56f6ced..00e9e3c 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp<br>
> @@ -1897,8 +1897,10 @@ brw_blorp_blit_miptrees(struct brw_context *brw,<br>
><br>
> brw_blorp_params params;<br>
><br>
> - params.src.set(brw, src_mt, src_level, src_layer, src_format, false);<br>
> - params.dst.set(brw, dst_mt, dst_level, dst_layer, dst_format, true);<br>
> + brw_blorp_surface_info_init(brw, ¶ms.src, src_mt, src_level,<br>
> + src_layer, src_format, false);<br>
> + brw_blorp_surface_info_init(brw, ¶ms.dst, dst_mt, dst_level,<br>
> + dst_layer, dst_format, true);<br>
><br>
> /* Even though we do multisample resolves at the time of the blit, OpenGL<br>
> * specification defines them as if they happen at the time of rendering,<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
> index b16102c..3c97ad6 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp<br>
> @@ -213,7 +213,8 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
> if (!encode_srgb && _mesa_get_format_color_encoding(format) == GL_SRGB)<br>
> format = _mesa_get_srgb_format_linear(format);<br>
><br>
> - params.dst.set(brw, irb->mt, irb->mt_level, layer, format, true);<br>
> + brw_blorp_surface_info_init(brw, ¶ms.dst, irb->mt, irb->mt_level,<br>
> + layer, format, true);<br>
><br>
> /* Override the surface format according to the context's sRGB rules. */<br>
> params.dst.brw_surfaceformat = brw->render_target_format[format];<br>
> @@ -381,7 +382,8 @@ brw_blorp_resolve_color(struct brw_context *brw, struct intel_mipmap_tree *mt)<br>
><br>
> brw_blorp_params params;<br>
><br>
> - params.dst.set(brw, mt, 0 /* level */, 0 /* layer */, format, true);<br>
> + brw_blorp_surface_info_init(brw, ¶ms.dst, mt,<br>
> + 0 /* level */, 0 /* layer */, format, true);<br>
><br>
> brw_get_resolve_rect(brw, mt, ¶ms.x0, ¶ms.y0,<br>
> ¶ms.x1, ¶ms.y1);<br>
> diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.cpp b/src/mesa/drivers/dri/i965/gen6_blorp.cpp<br>
> index 2d2195e..d4f271d 100644<br>
> --- a/src/mesa/drivers/dri/i965/gen6_blorp.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/gen6_blorp.cpp<br>
> @@ -372,7 +372,7 @@ gen6_blorp_emit_wm_constants(struct brw_context *brw,<br>
> static uint32_t<br>
> gen6_blorp_emit_surface_state(struct brw_context *brw,<br>
> const brw_blorp_params *params,<br>
> - const brw_blorp_surface_info *surface,<br>
> + const struct brw_blorp_surface_info *surface,<br>
> uint32_t read_domains, uint32_t write_domain)<br>
> {<br>
> uint32_t wm_surf_offset;<br>
> @@ -399,7 +399,7 @@ gen6_blorp_emit_surface_state(struct brw_context *brw,<br>
> surface->brw_surfaceformat << BRW_SURFACE_FORMAT_SHIFT);<br>
><br>
> /* reloc */<br>
> - surf[1] = (surface->compute_tile_offsets(&tile_x, &tile_y) +<br>
> + surf[1] = (brw_blorp_compute_tile_offsets(surface, &tile_x, &tile_y) +<br>
> mt->bo->offset64);<br>
><br>
> surf[2] = (0 << BRW_SURFACE_LOD_SHIFT |<br>
> diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
> index 52fb89c..80545c2 100644<br>
> --- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp<br>
> @@ -160,7 +160,7 @@ gen7_blorp_emit_depth_stencil_state_pointers(struct brw_context *brw,<br>
> */<br>
> static uint32_t<br>
> gen7_blorp_emit_surface_state(struct brw_context *brw,<br>
> - const brw_blorp_surface_info *surface,<br>
> + const struct brw_blorp_surface_info *surface,<br>
> uint32_t read_domains, uint32_t write_domain,<br>
> bool is_render_target)<br>
> {<br>
> @@ -198,8 +198,8 @@ gen7_blorp_emit_surface_state(struct brw_context *brw,<br>
> surf[0] |= GEN7_SURFACE_ARYSPC_FULL;<br>
><br>
> /* reloc */<br>
> - surf[1] =<br>
> - surface->compute_tile_offsets(&tile_x, &tile_y) + mt->bo->offset64;<br>
> + surf[1] = brw_blorp_compute_tile_offsets(surface, &tile_x, &tile_y) +<br>
> + mt->bo->offset64;<br>
><br>
> /* Note that the low bits of these fields are missing, so<br>
> * there's the possibility of getting in trouble.<br>
> diff --git a/src/mesa/drivers/dri/i965/gen8_blorp.cpp b/src/mesa/drivers/dri/i965/gen8_blorp.cpp<br>
> index d94a17a..fd3bfa1 100644<br>
> --- a/src/mesa/drivers/dri/i965/gen8_blorp.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/gen8_blorp.cpp<br>
> @@ -39,7 +39,7 @@<br>
> */<br>
> static uint32_t<br>
> gen8_blorp_emit_surface_state(struct brw_context *brw,<br>
> - const brw_blorp_surface_info *surface,<br>
> + const struct brw_blorp_surface_info *surface,<br>
> uint32_t read_domains, uint32_t write_domain,<br>
> bool is_render_target)<br>
> {<br>
> @@ -90,7 +90,8 @@ gen8_blorp_emit_surface_state(struct brw_context *brw,<br>
><br>
> /* reloc */<br>
> *((uint64_t *)&surf[8]) =<br>
> - surface->compute_tile_offsets(&tile_x, &tile_y) + mt->bo->offset64;<br>
> + brw_blorp_compute_tile_offsets(surface, &tile_x, &tile_y) +<br>
> + mt->bo->offset64;<br>
><br>
> /* Note that the low bits of these fields are missing, so there's the<br>
> * possibility of getting in trouble.<br>
> @@ -597,7 +598,7 @@ gen8_blorp_emit_surface_states(struct brw_context *brw,<br>
> I915_GEM_DOMAIN_RENDER,<br>
> true /* is_render_target */);<br>
> if (params-><a href="http://src.mt" rel="noreferrer" target="_blank">src.mt</a>) {<br>
> - const brw_blorp_surface_info *surface = ¶ms->src;<br>
> + const struct brw_blorp_surface_info *surface = ¶ms->src;<br>
> intel_mipmap_tree *mt = surface->mt;<br>
><br>
> /* Textures are always sampled as 2D. */<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>