<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 30, 2017 at 1:43 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 Fri, May 26, 2017 at 04:30:18PM -0700, Jason Ekstrand wrote:<br>
> This enum describes all of the states that a auxiliary compressed<br>
> surface can have. All of the states as well as normative language for<br>
> referring to each of the compression operations is provided in the<br>
> truly colossal comment for the new isl_aux_state enum. There is also<br>
> a diagram showing how surfaces move between the different states.<br>
> ---<br>
> src/intel/isl/isl.h | 142 ++++++++++++++++++++++++++++++<wbr>++++++++++++++++++++++<br>
> 1 file changed, 142 insertions(+)<br>
><br>
> diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h<br>
> index b9d8fa8..df6d3e3 100644<br>
> --- a/src/intel/isl/isl.h<br>
> +++ b/src/intel/isl/isl.h<br>
> @@ -560,6 +560,148 @@ enum isl_aux_usage {<br>
> ISL_AUX_USAGE_CCS_E,<br>
> };<br>
><br>
> +/**<br>
> + * Enum for keeping track of the state an auxiliary compressed surface.<br>
> + *<br>
> + * For any given auxiliary surface compression format (HiZ, CCS, or MCS), any<br>
> + * given slice (lod + array layer) can be in one of the six states described<br>
> + * by this enum. Draw and resolve operations may cause the slice to change<br>
> + * from one state to another. The six valid states are:<br>
> + *<br>
> + * 1) Clear: In this state, each block in the auxiliary surface contains a<br>
> + * magic value that indicates that the block is in the clear state. If<br>
> + * a block is in the clear state, it's values in the primary surface are<br>
> + * ignored and the color of the samples in the block is taken either the<br>
> + * RENDER_SURFACE_STATE packet for color or 3DSTATE_CLEAR_PARAMS for<br>
> + * depth. Since neither the primary surface nor the auxiliary surface<br>
> + * contains the clear value, the surface can be cleared to a different<br>
> + * color by simply changing the clear color without modifying either<br>
> + * surface.<br>
> + *<br>
> + * 2) Compressed w/ Clear: In this state, neither the auxiliary surface<br>
> + * nor the primary surface has a complete representation of the data.<br>
> + * Instead, both surfaces must be used together or else rendering<br>
> + * corruption may occur. Depending on the auxiliary compression format<br>
> + * and the data, any given block in the primary surface may contain all,<br>
> + * some, or none of the data required to reconstruct the actual sample<br>
> + * values. Blocks may also be in the clear state (see Clear) and have<br>
> + * their value taken from outside the surface.<br>
> + *<br>
> + * 3) Compressed w/o Clear: This state is identical to the state above<br>
> + * except that no blocks are in the clear state. In this state, all of<br>
> + * the data required to reconstruct the final sample values is contained<br>
> + * in the auxiliary and primary surface and the clear value is not<br>
> + * considered.<br>
> + *<br>
> + * 4) Resolved: In this state, the primary surface contains 100% of the<br>
> + * data. The auxiliary surface is also valid so the surface can be<br>
> + * validly used with or without aux enabled. The auxiliary surface may,<br>
> + * however, contain non-trivial data and any update to the primary<br>
> + * surface with aux disabled will cause the two to get out of sync.<br>
> + *<br>
> + * 5) Pass-through: In this state, the primary surface contains 100% of the<br>
> + * data and every block in the auxiliary surface contains a magic value<br>
> + * which indicates that the auxiliary surface should be ignored and the<br>
> + * only the primary surface should be considered. Updating the primary<br>
> + * surface without aux works fine and can be done repeatedly in this<br>
> + * mode. Writing to a surface in pass-through mode with aux enabled may<br>
> + * cause the auxiliary buffer to contain non-trivial data and no longer<br>
> + * be in the pass-through state.<br>
> + *<br>
> + * 5) Aux Invalid: In this state, the primary surface contains 100% of the<br>
> + * data and the auxiliary surface is completely bogus. Any attempt to<br>
> + * use the auxiliary surface is liable to result in rendering<br>
> + * corruption. The only thing that one can do to re-enable aux once<br>
> + * this state is reached is to use an ambiguate pass to transition into<br>
> + * the pass-through state.<br>
> + *<br>
> + * Drawing with or without aux enabled may implicitly cause the surface to<br>
> + * transition between these states. There are also four types of "resolve"<br>
> + * operations which cause an explicit transition:<br>
> + *<br>
> + * 1) Fast Clear: This operation writes the magic "clear" value to the<br>
> + * auxiliary surface. This operation will safely transition any slice<br>
> + * of a surface from any state to the clear state so long as the entire<br>
> + * slice is fast cleared at once.<br>
> + *<br>
> + * 2) Full Resolve: This operation combines the auxiliary surface data<br>
> + * with the primary surface data and writes the result to the primary.<br>
> + * For CCS resolves, this operation is destructive in the sense that it<br>
> + * also sets the auxiliary surface to the pass-through mode. For HiZ,<br>
<br>
</div></div>In the diagram below this ends up in "Resolved" state which in the diagram<br>
is not the same as "Passthrough". It stroke me odd that "Draw w/o Aux"<br>
transitions it to "Aux Invalid". This is true for HIZ but not for CCS. In case<br>
of CCS one should actually be in "Passthrough" where "Draw w/o Aux" maintains<br>
the state.<br></blockquote><div><br></div><div>Right. The CCS full resolve is not only a resolve but also an ambiguate. Does that make it make sense? I'm happy to document it better.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Other than that this is really nice piece of documentation!!<br><div><div class="h5"></div></div></blockquote><div><br></div><div>Thanks. It helped me quite a bit while trying to reason about all this.<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">
> + * it is not destructive.<br>
> + *<br>
> + * 3) Partial Resolve: This operation considers blocks which are in the<br>
> + * "clear" state and writes the clear value directly into the primary or<br>
> + * auxiliary surface. Once this operation completes, the surface is<br>
> + * still compressed but no longer references the clear color. This<br>
> + * operation is only available for CCS.<br>
> + *<br>
> + * 4) Ambiguate: This operation throws away the current auxiliary data and<br>
> + * replaces it with the magic pass-through value. If an ambiguate<br>
> + * operation is performed when the primary surface does not contain 100%<br>
> + * of the data, data will be lost. This operation is only implemented<br>
> + * in hardware for depth where it is called a HiZ resolve.<br>
> + *<br>
> + * Not all operations are valid or useful in all states. The diagram below<br>
> + * contains a complete description of the states and all valid and useful<br>
> + * transitions except clear.<br>
> + *<br>
> + * Draw w/ Aux<br>
> + * +----------+<br>
> + * | |<br>
> + * | +-------------+ Draw w/ Aux +-------------+<br>
> + * +------>| Compressed |<---------------------| Clear |<br>
> + * | w/ Clear | | |<br>
> + * +-------------+ +-------------+<br>
> + * | | |<br>
> + * Partial | | |<br>
> + * Resolve | | Full Resolve |<br>
> + * | +----------------------------+ | Full<br>
> + * | | | Resolve<br>
> + * Draw w/ aux | | |<br>
> + * +----------+ | | |<br>
> + * | | \|/ \|/ \|/<br>
> + * | +-------------+ Full Resolve +-------------+<br>
> + * +------>| Compressed |--------------------->| Resolved |<br>
> + * | w/o Clear |<---------------------| |<br>
> + * +-------------+ Draw w/ Aux +-------------+<br>
> + * /|\ | |<br>
> + * | Draw | | Draw<br>
> + * | w/ Aux | | w/o Aux<br>
> + * | Ambiguate | |<br>
> + * | +----------------------------+ |<br>
> + * Draw w/o Aux | | | Draw w/o Aux<br>
> + * +----------+ | | | +----------+<br>
> + * | | | \|/ \|/ | |<br>
> + * | +-------------+ Ambiguate +-------------+ |<br>
> + * +------>| Pass- |<---------------------| Aux |<------+<br>
> + * | through | | Invalid |<br>
> + * +-------------+ +-------------+<br>
> + *<br>
> + *<br>
> + * As referenced in the description of the different operations above, not all<br>
> + * auxiliary surface formats actually support all of the above modes. With<br>
> + * HiZ, for instance, does not have a partial resolve operation so the two<br>
> + * "compressed" modes are the same. With CCS, the resolve operation is<br>
> + * destructive and takes you directly to passthrough so the "resolved" state<br>
> + * doesn't really exist. However, if you consider the CCS resolve operation<br>
> + * as doing a resolve and then an ambiguate, the diagram is still accurate.<br>
> + */<br>
> +enum isl_aux_state {<br>
> + /** Describes the Clear state */<br>
> + ISL_AUX_STATE_CLEAR = 0,<br>
> + /** Describes the Compressed w/ Clear state */<br>
> + ISL_AUX_STATE_COMPRESSED_<wbr>CLEAR,<br>
> + /** Describes the Compressed w/o Clear state */<br>
> + ISL_AUX_STATE_COMPRESSED_NO_<wbr>CLEAR,<br>
> + /** Describes the Resolved state */<br>
> + ISL_AUX_STATE_RESOLVED,<br>
> + /** Describes the Pass-through state */<br>
> + ISL_AUX_STATE_PASS_THROUGH,<br>
> + /** Describes the Aux Invalid state */<br>
> + ISL_AUX_STATE_AUX_INVALID,<br>
> +};<br>
> +<br>
> /* TODO(chadv): Explain */<br>
> enum isl_array_pitch_span {<br>
> ISL_ARRAY_PITCH_SPAN_FULL,<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> ______________________________<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>
</blockquote></div><br></div></div>