aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2016-02-01 14:29:51 +1300
committerTobin Ehlis <tobine@google.com>2016-02-12 07:45:52 -0700
commit29edfc201aab612f0d6488f00cd9bc07ce343dec (patch)
treefe5bd5d0e97486e5077ddd7f853eea82e858343d
parentd2ccbedbb5b5752da5b083e446b67310be9748ce (diff)
downloadusermoji-29edfc201aab612f0d6488f00cd9bc07ce343dec.tar.xz
layers: Use entrypoint interface specification to collect variables
The module may contain many others -- only the variables listed in the OpEntryPoint are part of the interface. Note that the shader resource interface is NOT listed in OpEntryPoint. For now we continue to conservatively assume every OpVariable in the module with a suitable storage class is in every entrypoint's shader resource interface -- that is, we're not walking the static call tree from each entrypoint to determine what is and is not used by it. Signed-off-by: Chris Forbes <chrisforbes@google.com>
-rw-r--r--layers/draw_state.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index 81b9bb68..fb8fafd7 100644
--- a/layers/draw_state.cpp
+++ b/layers/draw_state.cpp
@@ -394,6 +394,11 @@ build_def_index(shader_module *module)
module->def_index[insn.word(2)] = insn.offset();
break;
+ /* Variables */
+ case spv::OpVariable:
+ module->def_index[insn.word(2)] = insn.offset();
+ break;
+
default:
/* We don't care about any other defs for now. */
break;
@@ -730,12 +735,27 @@ collect_interface_by_location(layer_data *my_data, VkDevice dev,
blocks[insn.word(1)] = 1;
}
}
+ }
/* TODO: handle grouped decorations */
/* TODO: handle index=1 dual source outputs from FS -- two vars will
* have the same location, and we DONT want to clobber. */
- else if (insn.opcode() == spv::OpVariable && insn.word(3) == sinterface) {
+ /* find the end of the entrypoint's name string. additional zero bytes follow the actual null
+ terminator, to fill out the rest of the word - so we only need to look at the last byte in
+ the word to determine which word contains the terminator. */
+ auto word = 3;
+ while (entrypoint.word(word) & 0xff000000u) {
+ ++word;
+ }
+ ++word;
+
+ for (; word < entrypoint.len(); word++) {
+ auto insn = src->get_def(entrypoint.word(word));
+ assert(insn != src->end());
+ assert(insn.opcode() == spv::OpVariable);
+
+ if (insn.word(3) == sinterface) {
unsigned id = insn.word(2);
unsigned type = insn.word(1);