From ea4de4ad3d13af714db4f7956ed4262eafd6460b Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Wed, 30 Nov 2022 15:02:14 -0800 Subject: [PATCH] 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 Reviewed-by: Kenneth Graunke Part-of: --- src/intel/vulkan/genX_cmd_buffer.c | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 7de8ae039d3..38651d34fdb 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -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.