aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2016-01-26 14:07:16 +1300
committerMark Lobodzinski <mark@lunarg.com>2016-01-27 15:53:00 -0700
commitc2dc03298abc11ac7fdcd27417691cea9eb773f1 (patch)
tree2036412b92e7e497c6840ed7b18db68c0881e102
parent6aaed11e6533726eda774e1f64b26159109b76b9 (diff)
downloadusermoji-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.cpp17
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)