layers: Correctly handle input attachment collection w/ arrays
authorChris Forbes <chrisforbes@google.com>
Mon, 22 Aug 2016 03:31:18 +0000 (15:31 +1200)
committerChris Forbes <chrisforbes@google.com>
Tue, 23 Aug 2016 01:12:40 +0000 (13:12 +1200)
Fixes the test added in the previous commit

Signed-off-by: Chris Forbes <chrisforbes@google.com>
layers/core_validation.cpp

index cf772cf..80e0549 100644 (file)
@@ -1565,16 +1565,16 @@ static void collect_interface_by_input_attachment_index(debug_report_data *repor
                     assert(def != src->end());
 
                     if (def.opcode() == spv::OpVariable && insn.word(3) == spv::StorageClassUniformConstant) {
-                        /* TODO: arrays of input attachments: the descriptor
-                         * side only consumes one binding, but each array
-                         * element will consume an additional attachment index */
-                        interface_var v;
-                        v.id = id;
-                        v.type_id = def.word(1);
-                        v.offset = 0;
-                        v.is_patch = false;
-                        v.is_block_member = false;
-                        out.emplace_back(attachment_index, v);
+                        auto num_locations = get_locations_consumed_by_type(src, def.word(1), false);
+                        for (unsigned int offset = 0; offset < num_locations; offset++) {
+                            interface_var v;
+                            v.id = id;
+                            v.type_id = def.word(1);
+                            v.offset = offset;
+                            v.is_patch = false;
+                            v.is_block_member = false;
+                            out.emplace_back(attachment_index + offset, v);
+                        }
                     }
                 }
             }