<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 6, 2016 at 12:28 AM, Topi Pohjolainen <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">such as we do for compressed msaa. In case of non-compressed simgle<br>
sampled buffers the allocation of mcs is deferred until there is<br>
actually a clear operation that needs the mcs.<br>
In case of render buffer compression the mcs buffer always needed<br>
and there is no real reason to defer the allocation. By doing it<br>
directly allows to drop quite a bit unnecessary complexity.<br>
<br>
Patch leaves brw_predraw_set_aux_buffers() a no-op. Subsequent<br>
patches will re-use it and it seemed cleaner to leave it instead<br>
of removing and re-introducing.<br>
<br>
Signed-off-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_<wbr>blorp.c | 10 ++--<br>
src/mesa/drivers/dri/i965/brw_<wbr>draw.c | 4 +-<br>
src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 68 +++++++--------------------<br>
src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h | 7 +--<br>
4 files changed, 26 insertions(+), 63 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
index b0fbb64..fdaf429 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_blorp.c<br>
@@ -287,8 +287,6 @@ brw_blorp_blit_miptrees(struct brw_context *brw,<br>
intel_miptree_slice_resolve_<wbr>depth(brw, src_mt, src_level, src_layer);<br>
intel_miptree_slice_resolve_<wbr>depth(brw, dst_mt, dst_level, dst_layer);<br>
<br>
- intel_miptree_prepare_mcs(brw, dst_mt);<br>
-<br>
DBG("%s from %dx %s mt %p %d %d (%f,%f) (%f,%f)"<br>
"to %dx %s mt %p %d %d (%f,%f) (%f,%f) (flip %d,%d)\n",<br>
__func__,<br>
@@ -689,6 +687,9 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
!brw_is_color_fast_clear_<wbr>compatible(brw, irb->mt, &ctx->Color.ClearColor))<br>
can_fast_clear = false;<br>
<br>
+ const bool is_lossless_compressed = intel_miptree_is_lossless_<wbr>compressed(<br>
+ brw, irb->mt);<br>
+<br>
if (can_fast_clear) {<br>
/* Record the clear color in the miptree so that it will be<br>
* programmed in SURFACE_STATE by later rendering and resolve<br>
@@ -708,7 +709,8 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
* it now.<br>
*/<br>
if (!irb->mt->mcs_mt) {<br>
- if (!intel_miptree_alloc_non_<wbr>msrt_mcs(brw, irb->mt)) {<br>
+ assert(!is_lossless_<wbr>compressed);<br>
+ if (!intel_miptree_alloc_non_<wbr>msrt_mcs(brw, irb->mt, false)) {<br>
/* MCS allocation failed--probably this will only happen in<br>
* out-of-memory conditions. But in any case, try to recover<br>
* by falling back to a non-blorp clear technique.<br>
@@ -757,7 +759,7 @@ do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,<br>
clear_color, color_write_disable);<br>
blorp_batch_finish(&batch);<br>
<br>
- if (intel_miptree_is_lossless_<wbr>compressed(brw, irb->mt)) {<br>
+ if (is_lossless_compressed) {<br>
/* Compressed buffers can be cleared also using normal rep-clear. In<br>
* such case they behave such as if they were drawn using normal 3D<br>
* render pipeline, and we simply mark the mcs as dirty.<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_draw.c b/src/mesa/drivers/dri/i965/<wbr>brw_draw.c<br>
index 9b1e18c..cab67c9 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_draw.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_draw.c<br>
@@ -409,8 +409,8 @@ brw_predraw_set_aux_buffers(<wbr>struct brw_context *brw)<br>
struct intel_renderbuffer *irb =<br>
intel_renderbuffer(fb->_<wbr>ColorDrawBuffers[i]);<br>
<br>
- if (irb) {<br>
- intel_miptree_prepare_mcs(brw, irb->mt);<br>
+ if (!irb) {<br>
+ continue;<br>
}<br>
}<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 7b97183..427657c 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>
@@ -789,6 +789,20 @@ intel_miptree_create(struct brw_context *brw,<br>
intel_miptree_supports_non_<wbr>msrt_fast_clear(brw, mt)) {<br>
mt->fast_clear_state = INTEL_FAST_CLEAR_STATE_<wbr>RESOLVED;<br>
assert(brw->gen < 8 || mt->halign == 16 || num_samples <= 1);<br>
+<br>
+ /* On Gen9+ clients are not currently capable of consuming compressed<br>
+ * single-sampled buffers. Disabling compression allows us to skip<br>
+ * resolves.<br>
+ */<br>
+ const bool lossless_compression_disabled = INTEL_DEBUG & DEBUG_NO_RBC;<br>
+ const bool is_lossless_compressed =<br>
+ unlikely(!lossless_<wbr>compression_disabled) &&<br>
+ brw->gen >= 9 && !mt->is_scanout &&<br>
+ intel_miptree_supports_<wbr>lossless_compressed(brw, mt);<br>
+<br>
+ if (is_lossless_compressed) {<br>
+ intel_miptree_alloc_non_msrt_<wbr>mcs(brw, mt, is_lossless_compressed);<br>
+ }<br>
}<br>
<br>
return mt;<br>
@@ -1563,7 +1577,8 @@ intel_miptree_alloc_mcs(struct brw_context *brw,<br>
<br>
bool<br>
intel_miptree_alloc_non_msrt_<wbr>mcs(struct brw_context *brw,<br>
- struct intel_mipmap_tree *mt)<br>
+ struct intel_mipmap_tree *mt,<br>
+ bool is_lossless_compressed)<br>
{<br>
assert(mt->mcs_mt == NULL);<br>
assert(!mt->disable_aux_<wbr>buffers);<br>
@@ -1605,16 +1620,6 @@ intel_miptree_alloc_non_msrt_<wbr>mcs(struct brw_context *brw,<br>
layout_flags |= MIPTREE_LAYOUT_FORCE_HALIGN16;<br>
}<br>
<br>
- /* On Gen9+ clients are not currently capable of consuming compressed<br>
- * single-sampled buffers. Disabling compression allows us to skip<br>
- * resolves.<br>
- */<br>
- const bool lossless_compression_disabled = INTEL_DEBUG & DEBUG_NO_RBC;<br>
- const bool is_lossless_compressed =<br>
- unlikely(!lossless_<wbr>compression_disabled) &&<br>
- brw->gen >= 9 && !mt->is_scanout &&<br>
- intel_miptree_supports_<wbr>lossless_compressed(brw, mt);<br>
-<br>
/* In case of compression mcs buffer needs to be initialised requiring the<br>
* buffer to be immediately mapped to cpu space for writing. Therefore do<br>
* not use the gpu access flag which can cause an unnecessary delay if the<br>
@@ -1656,47 +1661,6 @@ intel_miptree_alloc_non_msrt_<wbr>mcs(struct brw_context *brw,<br>
return mt->mcs_mt;<br>
}<br>
<br>
-void<br>
-intel_miptree_prepare_mcs(<wbr>struct brw_context *brw,<br>
- struct intel_mipmap_tree *mt)<br>
-{<br>
- if (mt->mcs_mt)<br>
- return;<br>
-<br>
- if (brw->gen < 9)<br>
- return;<br>
-<br>
- /* Single sample compression is represented re-using msaa compression<br>
- * layout type: "Compressed Multisampled Surfaces".<br>
- */<br>
- if (mt->msaa_layout != INTEL_MSAA_LAYOUT_CMS || mt->num_samples > 1)<br>
- return;<br>
-<br>
- /* Clients are not currently capable of consuming compressed<br>
- * single-sampled buffers.<br>
- */<br>
- if (mt->is_scanout)<br>
- return;<br>
-<br>
- assert(intel_tiling_supports_<wbr>non_msrt_mcs(brw, mt->tiling) ||<br>
- intel_miptree_supports_<wbr>lossless_compressed(brw, mt));<br>
-<br>
- /* Consider if lossless compression is supported but the needed<br>
- * auxiliary buffer doesn't exist yet.<br>
- *<br>
- * Failing to allocate the auxiliary buffer means running out of<br>
- * memory. The pointer to the aux miptree is left NULL which should<br>
- * signal non-compressed behavior.<br>
- */<br>
- if (!intel_miptree_alloc_non_<wbr>msrt_mcs(brw, mt)) {<br>
- _mesa_warning(NULL,<br>
- "Failed to allocated aux buffer for lossless"<br>
- " compressed %p %u:%u %s\n",<br>
- mt, mt->logical_width0, mt->logical_height0,<br>
- _mesa_get_format_name(mt-><wbr>format));<br>
- }<br>
-}<br>
-<br>
/**<br>
* Helper for intel_miptree_alloc_hiz() that sets<br>
* \c mt->level[level].has_hiz. Return true if and only if<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
index 07db51b..2f1b8eb 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
@@ -709,11 +709,8 @@ intel_miptree_supports_<wbr>lossless_compressed(struct brw_context *brw,<br>
<br>
bool<br>
intel_miptree_alloc_non_msrt_<wbr>mcs(struct brw_context *brw,<br>
- struct intel_mipmap_tree *mt);<br>
-<br>
-void<br>
-intel_miptree_prepare_mcs(<wbr>struct brw_context *brw,<br>
- struct intel_mipmap_tree *mt);<br>
+ struct intel_mipmap_tree *mt,<br>
+ bool is_lossless_compressed);<br>
<br>
enum {<br>
MIPTREE_LAYOUT_ACCELERATED_<wbr>UPLOAD = 1 << 0,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.5<br>
<br>
______________________________<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>
</font></span></blockquote></div><br></div>