anv: Don't ambiguate for undefined layouts on TGL+

For Tiger Lake and onward, we generally don't need to ambiguate the CCS
before accessing it. This is safe for two reasons:

- Tiger Lake and onward treat all CCS values as legal.
- We enable compression on all writable image layouts. The CCS will
  receive all writes and will therefore always be valid.

When dealing with modifiers, we continue to allow ambiguates in some
instances.

Before this patch, I found ~19.5k ambiguates in Wolfenstein:
Youngblood's Riverside benchmark (note that this includes manually
entering the benchmark and exiting the app). With this patch, the number
of ambiguates goes down to zero.

Improves performance of Fallout 4 at 1080p/High settings on Arc A380 by
around 22%.

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20118>
This commit is contained in:
Nanley Chery 2022-11-30 15:02:14 -08:00 committed by Marge Bot
parent 5c84b31891
commit ea4de4ad3d

View file

@ -1101,7 +1101,42 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,
* data.
*/
must_init_fast_clear_state = true;
must_init_aux_surface = true;
if (image->planes[plane].aux_usage == ISL_AUX_USAGE_MCS ||
devinfo->has_illegal_ccs_values) {
must_init_aux_surface = true;
} else {
assert(image->planes[plane].aux_usage == ISL_AUX_USAGE_CCS_E);
/* We can start using the CCS immediately without ambiguating. The
* two conditions that enable this are:
*
* 1) The device treats all possible CCS values as legal. In other
* words, we can't confuse the hardware with random bits in the
* CCS.
*
* 2) We enable compression on all writable image layouts. The CCS
* will receive all writes and will therefore always be in sync
* with the main surface.
*
* If we were to disable compression on some writable layouts, the
* CCS could get out of sync with the main surface and the app
* could lose the data it wrote previously. For example, this
* could happen if an app: transitions from UNDEFINED w/o
* ambiguating -> renders with AUX_NONE -> samples with AUX_CCS.
*
* The second condition is asserted below, but could be moved
* elsewhere for more coverage (we're only checking transitions from
* an undefined layout).
*/
assert(vk_image_layout_is_read_only(final_layout, aspect) ||
(final_aux_usage != ISL_AUX_USAGE_NONE));
must_init_aux_surface = false;
}
} else if (private_binding_acquire) {
/* The fast clear state lives in a driver-private bo, and therefore the
* external/foreign queue is unaware of it.