<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 17, 2017 at 2:47 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.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 Wed, Jul 12, 2017 at 09:23:21PM -0700, Jason Ekstrand wrote:<br>
> From: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
><br>
> This code will disable actually creating these buffers for the scanout,<br>
> but it puts the allocation in place.<br>
><br>
> Primarily this patch is split out for review, it can be squashed in<br>
> later if preferred.<br>
><br>
> v2:<br>
> assert(mt->offset == 0) in ccs creation (as requested by Topi)<br>
> Remove bogus is_scanout check in miptree_release<br>
><br>
> v3:<br>
> Remove is_scanout assert in intel_miptree_create. It doesn't work with<br>
> latest codebase - not sure it ever should have worked.<br>
><br>
> v4:<br>
> assert(mt->last_level == 0) and assert(mt->first_level == 0) in ccs setup<br>
> (Topi)<br>
><br>
> v5 (Jason Ekstrand):<br>
> - Base the decision to allocate a CCS on the image modifier<br>
><br>
> Signed-off-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
> Acked-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
> Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
> ---<br>
> src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 102 ++++++++++++++++++++++++--<br>
> 1 file changed, 95 insertions(+), 7 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> index dbdec90..71bae09 100644<br>
> --- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> +++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
> @@ -982,6 +982,57 @@ miptree_create_for_planar_<wbr>image(struct brw_context *brw,<br>
> return planar_mt;<br>
> }<br>
><br>
> +static bool<br>
> +create_ccs_buf_for_image(<wbr>struct brw_context *brw,<br>
> + __DRIimage *image,<br>
> + struct intel_mipmap_tree *mt,<br>
> + enum isl_aux_state initial_state)<br>
> +{<br>
> + struct isl_surf temp_main_surf, temp_ccs_surf;<br>
> +<br>
> + /* CCS is only supported for very simple miptrees */<br>
> + assert(image->aux_offset != 0 && image->aux_pitch != 0);<br>
> + assert(image->tile_x == 0 && image->tile_y == 0);<br>
> + assert(mt->num_samples <= 1);<br>
> + assert(mt->first_level == 0);<br>
> + assert(mt->last_level == 0);<br>
> + assert(mt->logical_depth0 == 1);<br>
> +<br>
> + /* We shouldn't already have a CCS */<br>
> + assert(!mt->mcs_buf);<br>
> +<br>
> + intel_miptree_get_isl_surf(<wbr>brw, mt, &temp_main_surf);<br>
> + if (!isl_surf_get_ccs_surf(&brw-><wbr>isl_dev, &temp_main_surf, &temp_ccs_surf,<br>
> + image->aux_pitch))<br>
> + return false;<br>
> +<br>
> + assert(image->aux_offset < image->bo->size);<br>
> + assert(temp_ccs_surf.size <= image->bo->size - image->aux_offset);<br>
> +<br>
> + mt->mcs_buf = calloc(sizeof(*mt->mcs_buf), 1);<br>
> + if (mt->mcs_buf == NULL)<br>
> + return false;<br>
> +<br>
> + mt->aux_state = create_aux_state_map(mt, initial_state);<br>
> + if (!mt->aux_state) {<br>
> + free(mt->mcs_buf);<br>
> + mt->mcs_buf = NULL;<br>
> + return false;<br>
> + }<br>
> +<br>
> + mt->mcs_buf->bo = image->bo;<br>
> + brw_bo_reference(image->bo);<br>
> +<br>
> + mt->mcs_buf->offset = image->aux_offset;<br>
> + mt->mcs_buf->size = image->bo->size - image->aux_offset;<br>
> + mt->mcs_buf->pitch = image->aux_pitch;<br>
> + mt->mcs_buf->qpitch = 0;<br>
> +<br>
> + mt->msaa_layout = INTEL_MSAA_LAYOUT_CMS;<br>
<br>
</div></div>This doesn't belong here anymore, right? You stopped setting this for single<br>
sampled in earlier patches.<br><div class="HOEnZb"><div class="h5"></div></div></blockquote><div><br></div><div>Good catch! I've deleted it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
> +<br>
> + return true;<br>
> +}<br>
> +<br>
> struct intel_mipmap_tree *<br>
> intel_miptree_create_for_dri_<wbr>image(struct brw_context *brw,<br>
> __DRIimage *image, GLenum target,<br>
> @@ -1028,15 +1079,26 @@ intel_miptree_create_for_dri_<wbr>image(struct brw_context *brw,<br>
> if (!brw->ctx.<wbr>TextureFormatSupported[format]<wbr>)<br>
> return NULL;<br>
><br>
> + const struct isl_drm_modifier_info *mod_info =<br>
> + isl_drm_modifier_get_info(<wbr>image->modifier);<br>
> +<br>
> + uint32_t mt_layout_flags = 0;<br>
> +<br>
> + /* If this image comes in from a window system, then it may get promoted to<br>
> + * scanout at any time so we need to set the flag accordingly.<br>
> + */<br>
> + if (is_winsys_image)<br>
> + mt_layout_flags |= MIPTREE_LAYOUT_FOR_SCANOUT;<br>
> +<br>
> /* If this image comes in from a window system, we have different<br>
> * requirements than if it comes in via an EGL import operation. Window<br>
> * system images can use any form of auxiliary compression we wish because<br>
> * they get "flushed" before being handed off to the window system and we<br>
> - * have the opportunity to do resolves. Window system buffers also may be<br>
> - * used for scanout so we need to flag that appropriately.<br>
> + * have the opportunity to do resolves.<br>
> */<br>
> - const uint32_t mt_layout_flags =<br>
> - is_winsys_image ? MIPTREE_LAYOUT_FOR_SCANOUT : MIPTREE_LAYOUT_DISABLE_AUX;<br>
> + if (!is_winsys_image &&<br>
> + (!mod_info || mod_info->aux_usage == ISL_AUX_USAGE_NONE))<br>
> + mt_layout_flags |= MIPTREE_LAYOUT_DISABLE_AUX;<br>
><br>
> /* Disable creation of the texture's aux buffers because the driver exposes<br>
> * no EGL API to manage them. That is, there is no API for resolving the aux<br>
> @@ -1073,9 +1135,35 @@ intel_miptree_create_for_dri_<wbr>image(struct brw_context *brw,<br>
> }<br>
> }<br>
><br>
> - if (!intel_miptree_alloc_aux(brw, mt)) {<br>
> - intel_miptree_release(&mt);<br>
> - return NULL;<br>
> + if (mod_info && mod_info->aux_usage != ISL_AUX_USAGE_NONE) {<br>
> + assert(mod_info->aux_usage == ISL_AUX_USAGE_CCS_E);<br>
> +<br>
> + mt->aux_usage = mod_info->aux_usage;<br>
> + /* If we are a window system buffer, then we can support fast-clears<br>
> + * even if the modifier doesn't support them by doing a partial resolve<br>
> + * as part of the flush operation.<br>
> + */<br>
> + mt->supports_fast_clear =<br>
> + is_winsys_image || mod_info->supports_clear_<wbr>color;<br>
> +<br>
> + /* We don't know the actual state of the surface when we get it but we<br>
> + * can make a pretty good guess based on the modifier. What we do know<br>
> + * for sure is that it isn't in the AUX_INVALID state, so we just assume<br>
> + * a worst case of compression.<br>
> + */<br>
> + enum isl_aux_state initial_state =<br>
> + mod_info->supports_clear_color ? ISL_AUX_STATE_COMPRESSED_CLEAR :<br>
> + ISL_AUX_STATE_COMPRESSED_NO_<wbr>CLEAR;<br>
> +<br>
> + if (!create_ccs_buf_for_image(<wbr>brw, image, mt, initial_state)) {<br>
> + intel_miptree_release(&mt);<br>
> + return NULL;<br>
> + }<br>
> + } else {<br>
> + if (!intel_miptree_alloc_aux(brw, mt)) {<br>
> + intel_miptree_release(&mt);<br>
> + return NULL;<br>
> + }<br>
> }<br>
><br>
> return mt;<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> ______________________________<wbr>_________________<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/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>