diff options
| author | Chris Forbes <chrisforbes@google.com> | 2016-08-22 14:58:35 +1200 |
|---|---|---|
| committer | Chris Forbes <chrisforbes@google.com> | 2016-08-23 13:12:40 +1200 |
| commit | 45a1ba195f27fefae738e600c89d70bacc4bfa74 (patch) | |
| tree | a7463b93d763744cf801ee2870e60243132b9c37 /layers/core_validation.cpp | |
| parent | 960c4cc440d57eca865485fe9682aa51232a57c0 (diff) | |
| download | usermoji-45a1ba195f27fefae738e600c89d70bacc4bfa74.tar.xz | |
layers: Add helper to collect shader's use of input attachments
Signed-off-by: Chris Forbes <chrisforbes@google.com>
Diffstat (limited to 'layers/core_validation.cpp')
| -rw-r--r-- | layers/core_validation.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index bce28742..aa305d0e 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -1550,6 +1550,38 @@ static void collect_interface_by_location(shader_module const *src, spirv_inst_i } } +static void collect_interface_by_input_attachment_index(debug_report_data *report_data, shader_module const *src, + std::unordered_set<uint32_t> const &accessible_ids, + std::vector<std::pair<uint32_t, interface_var>> &out) { + + for (auto insn : *src) { + if (insn.opcode() == spv::OpDecorate) { + if (insn.word(2) == spv::DecorationInputAttachmentIndex) { + auto attachment_index = insn.word(3); + auto id = insn.word(1); + + if (accessible_ids.count(id)) { + auto def = src->get_def(id); + 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); + } + } + } + } + } +} + static void collect_interface_by_descriptor_slot(debug_report_data *report_data, shader_module const *src, std::unordered_set<uint32_t> const &accessible_ids, std::vector<std::pair<descriptor_slot_t, interface_var>> &out) { |
