layers: MR159, Add helper to get the value of an assumed integral constant
We need this in a bunch of array-handling code.
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index d265a62..46b6d8f 100644
--- a/layers/draw_state.cpp
+++ b/layers/draw_state.cpp
@@ -425,6 +425,23 @@
}
}
+/* 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)