From f37bd726c7211e8680f4a903b2167dacc4de94f2 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 12 Feb 2018 09:48:12 -0800 Subject: anv: Don't resolve or ambiguate non-existent layers The previous code was trying to avoid non-existent layers by taking a MAX with anv_image_aux_layers. Unfortunately, it wasn't taking into account that layer_count starts at base_layer which may not be zero. Instead, we need to subtract base_layer from anv_image_aux_layers with a guard against roll-over. Fixes: de3be6180169f9 "anv/cmd_buffer: Rework aux tracking" Reviewed-by: Nanley Chery --- src/intel/vulkan/genX_cmd_buffer.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index f42860b411a..ce47b8a1cc0 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -883,8 +883,12 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer, if (image->samples == 1) { for (uint32_t l = 0; l < level_count; l++) { const uint32_t level = base_level + l; + + uint32_t aux_layers = anv_image_aux_layers(image, aspect, level); + if (base_layer >= aux_layers) + break; /* We will only get fewer layers as level increases */ uint32_t level_layer_count = - MIN2(layer_count, anv_image_aux_layers(image, aspect, level)); + MIN2(layer_count, aux_layers - base_layer); anv_image_ccs_op(cmd_buffer, image, aspect, level, base_layer, level_layer_count, @@ -972,8 +976,12 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer, for (uint32_t l = 0; l < level_count; l++) { uint32_t level = base_level + l; + + uint32_t aux_layers = anv_image_aux_layers(image, aspect, level); + if (base_layer >= aux_layers) + break; /* We will only get fewer layers as level increases */ uint32_t level_layer_count = - MIN2(layer_count, anv_image_aux_layers(image, aspect, level)); + MIN2(layer_count, aux_layers - base_layer); for (uint32_t a = 0; a < level_layer_count; a++) { uint32_t array_layer = base_layer + a; -- cgit v1.2.3