diff options
| author | Chris Forbes <chrisforbes@google.com> | 2016-01-26 14:07:16 +1300 |
|---|---|---|
| committer | Mark Lobodzinski <mark@lunarg.com> | 2016-01-27 15:53:00 -0700 |
| commit | c2dc03298abc11ac7fdcd27417691cea9eb773f1 (patch) | |
| tree | 2036412b92e7e497c6840ed7b18db68c0881e102 | |
| parent | 6aaed11e6533726eda774e1f64b26159109b76b9 (diff) | |
| download | usermoji-c2dc03298abc11ac7fdcd27417691cea9eb773f1.tar.xz | |
layers: MR159, Add helper to get the value of an assumed integral constant
We need this in a bunch of array-handling code.
| -rw-r--r-- | layers/draw_state.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index d265a62c..46b6d8fa 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -425,6 +425,23 @@ storage_class_name(unsigned sc) } } +/* get the value of an integral constant */ +unsigned +get_constant_value(shader_module const *src, unsigned id) +{ + auto value = src->get_def(id); + assert(value != src->end()); + + if (value.opcode() != spv::OpConstant) { + /* TODO: Either ensure that the specialization transform is already performed on a module we're + considering here, OR -- specialize on the fly now. + */ + return 1; + } + + return value.word(3); +} + /* returns ptr to null terminator */ static char * describe_type(char *dst, shader_module const *src, unsigned type) |
