[Mesa-dev] [PATCH] anv: Don't resolve or ambiguate non-existent layers

Jason Ekstrand jason at jlekstrand.net
Mon Feb 12 21:41:44 UTC 2018


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.

Cc: Nanley Chery <nanley.g.chery at intel.com>
Fixes: de3be6180169f9 "anv/cmd_buffer: Rework aux tracking"
---
 src/intel/vulkan/genX_cmd_buffer.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 9a2ffb4..99854eb 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -931,8 +931,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,
@@ -1020,8 +1024,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;
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list