From c2dc03298abc11ac7fdcd27417691cea9eb773f1 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 26 Jan 2016 14:07:16 +1300 Subject: layers: MR159, Add helper to get the value of an assumed integral constant We need this in a bunch of array-handling code. --- layers/draw_state.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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) -- cgit v1.2.3