<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 23, 2016 at 1:16 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">One can now also delete intel_get_non_msrt_mcs_<wbr>alignment().<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/<wbr>intel_mipmap_tree.c | 138 +++++++-------------------<br>
src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h | 4 -<br>
2 files changed, 38 insertions(+), 104 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 a4a7ee0..9428e7b 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>
@@ -101,66 +101,6 @@ compute_msaa_layout(struct brw_context *brw, mesa_format format,<br>
}<br>
}<br>
<br>
-<br>
-/**<br>
- * For single-sampled render targets ("non-MSRT"), the MCS buffer is a<br>
- * scaled-down bitfield representation of the color buffer which is capable of<br>
- * recording when blocks of the color buffer are equal to the clear value.<br>
- * This function returns the block size that will be used by the MCS buffer<br>
- * corresponding to a certain color miptree.<br>
- *<br>
- * From the Ivy Bridge PRM, Vol2 Part1 11.7 "MCS Buffer for Render Target(s)",<br>
- * beneath the "Fast Color Clear" bullet (p327):<br>
- *<br>
- * The following table describes the RT alignment<br>
- *<br>
- * Pixels Lines<br>
- * TiledY RT CL<br>
- * bpp<br>
- * 32 8 4<br>
- * 64 4 4<br>
- * 128 2 4<br>
- * TiledX RT CL<br>
- * bpp<br>
- * 32 16 2<br>
- * 64 8 2<br>
- * 128 4 2<br>
- *<br>
- * This alignment has the following uses:<br>
- *<br>
- * - For figuring out the size of the MCS buffer. Each 4k tile in the MCS<br>
- * buffer contains 128 blocks horizontally and 256 blocks vertically.<br>
- *<br>
- * - For figuring out alignment restrictions for a fast clear operation. Fast<br>
- * clear operations must always clear aligned multiples of 16 blocks<br>
- * horizontally and 32 blocks vertically.<br>
- *<br>
- * - For scaling down the coordinates sent through the render pipeline during<br>
- * a fast clear. X coordinates must be scaled down by 8 times the block<br>
- * width, and Y coordinates by 16 times the block height.<br>
- *<br>
- * - For scaling down the coordinates sent through the render pipeline during<br>
- * a "Render Target Resolve" operation. X coordinates must be scaled down<br>
- * by half the block width, and Y coordinates by half the block height.<br>
- */<br>
-void<br>
-intel_get_non_msrt_mcs_<wbr>alignment(const struct intel_mipmap_tree *mt,<br>
- unsigned *width_px, unsigned *height)<br>
-{<br>
- switch (mt->tiling) {<br>
- default:<br>
- unreachable("Non-MSRT MCS requires X or Y tiling");<br>
- /* In release builds, fall through */<br>
- case I915_TILING_Y:<br>
- *width_px = 32 / mt->cpp;<br>
- *height = 4;<br>
- break;<br>
- case I915_TILING_X:<br>
- *width_px = 64 / mt->cpp;<br>
- *height = 2;<br>
- }<br>
-}<br>
-<br>
bool<br>
intel_tiling_supports_non_<wbr>msrt_mcs(const struct brw_context *brw,<br>
unsigned tiling)<br>
@@ -1654,55 +1594,53 @@ intel_miptree_alloc_non_msrt_<wbr>mcs(struct brw_context *brw,<br>
assert(!mt->disable_aux_<wbr>buffers);<br>
assert(!mt->no_ccs);<br>
<br>
- /* The format of the MCS buffer is opaque to the driver; all that matters<br>
- * is that we get its size and pitch right. We'll pretend that the format<br>
- * is R32. Since an MCS tile covers 128 blocks horizontally, and a Y-tiled<br>
- * R32 buffer is 32 pixels across, we'll need to scale the width down by<br>
- * the block width and then a further factor of 4. Since an MCS tile<br>
- * covers 256 blocks vertically, and a Y-tiled R32 buffer is 32 rows high,<br>
- * we'll need to scale the height down by the block height and then a<br>
- * further factor of 8.<br>
- */<br>
- const mesa_format format = MESA_FORMAT_R_UINT32;<br>
- unsigned block_width_px;<br>
- unsigned block_height;<br>
- intel_get_non_msrt_mcs_<wbr>alignment(mt, &block_width_px, &block_height);<br>
- unsigned width_divisor = block_width_px * 4;<br>
- unsigned height_divisor = block_height * 8;<br>
-<br>
- /* The Skylake MCS is twice as tall as the Broadwell MCS.<br>
- *<br>
- * In pre-Skylake, each bit in the MCS contained the state of 2 cachelines<br>
- * in the main surface. In Skylake, it's two bits. The extra bit<br>
- * doubles the MCS height, not width, because in Skylake the MCS is always<br>
- * Y-tiled.<br>
+ struct intel_miptree_aux_buffer *buf = calloc(sizeof(*buf), 1);<br>
+ if (!buf)<br>
+ return false;<br>
+<br>
+ struct isl_surf temp_main_surf;<br>
+ struct isl_surf temp_ccs_surf;<br>
+<br>
+ /* Create first an ISL presentation for the main color surface and let ISL<br>
+ * calculate equivalent CCS surface against it.<br>
*/<br>
- if (brw->gen >= 9)<br>
- height_divisor /= 2;<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>
+ return false;<br></blockquote><div><br></div><div>You're leaking the aux_buffer here. Maybe move this to before allocating the aux_buffer?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- unsigned mcs_width =<br>
- ALIGN(mt->logical_width0, width_divisor) / width_divisor;<br>
- unsigned mcs_height =<br>
- ALIGN(mt->logical_height0, height_divisor) / height_divisor;<br>
- assert(mt->logical_depth0 == 1);<br>
+ assert(temp_ccs_surf.size &&<br>
+ (temp_ccs_surf.size % temp_ccs_surf.row_pitch == 0));<br>
+<br>
+ buf->size = temp_ccs_surf.size;<br>
+ buf->pitch = temp_ccs_surf.row_pitch;<br>
+ buf->qpitch = isl_surf_get_array_pitch_sa_<wbr>rows(&temp_ccs_surf);<br>
<br>
- uint32_t layout_flags =<br>
- (brw->gen >= 8) ? MIPTREE_LAYOUT_FORCE_HALIGN16 : 0;<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>
* backing pages happened to be just used by the GPU.<br>
*/<br>
- if (!is_lossless_compressed)<br>
- layout_flags |= MIPTREE_LAYOUT_ACCELERATED_<wbr>UPLOAD;<br>
-<br>
- mt->mcs_buf = intel_mcs_miptree_buf_create(<wbr>brw, mt,<br>
- format,<br>
- mcs_width,<br>
- mcs_height,<br>
- layout_flags);<br>
- if (!mt->mcs_buf)<br>
+ const uint32_t alloc_flags =<br>
+ is_lossless_compressed ? 0 : BO_ALLOC_FOR_RENDER;<br>
+ uint32_t tiling = I915_TILING_Y;<br>
+ unsigned long pitch;<br>
+<br>
+ /* ISL has stricter set of alignment rules then the drm allocator.<br>
+ * Therefore one can pass the ISL dimensions in terms of bytes instead of<br>
+ * trying to recalculate based on different format block sizes.<br>
+ */<br>
+ buf->bo = drm_intel_bo_alloc_tiled(brw-><wbr>bufmgr, "ccs-miptree",<br>
+ buf->pitch, buf->size / buf->pitch,<br>
+ 1, &tiling, &pitch, alloc_flags);<br>
+ if (buf->bo) {<br>
+ assert(pitch == buf->pitch);<br>
+ assert(tiling == I915_TILING_Y);<br>
+ } else {<br>
+ free(buf);<br>
return false;<br>
+ }<br>
+<br>
+ mt->mcs_buf = buf;<br>
<br>
/* From Gen9 onwards single-sampled (non-msrt) auxiliary buffers are<br>
* used for lossless compression which requires similar initialisation<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 51ab664..38c00f8 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>
@@ -656,10 +656,6 @@ struct intel_mipmap_tree<br>
GLuint refcount;<br>
};<br>
<br>
-void<br>
-intel_get_non_msrt_mcs_<wbr>alignment(const struct intel_mipmap_tree *mt,<br>
- unsigned *width_px, unsigned *height);<br>
-<br>
bool<br>
intel_miptree_is_lossless_<wbr>compressed(const struct brw_context *brw,<br>
const struct intel_mipmap_tree *mt);<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></div>