+ struct vtn_value *val = vtn_value(b, value_id, vtn_value_type_constant);
+
+ vtn_fail_if(val->type->base_type != vtn_base_type_scalar ||
+ !glsl_type_is_integer(val->type->type),
+ "Expected id %u to be an integer constant", value_id);
+
+ switch (glsl_get_bit_size(val->type->type)) {
+ case 8: return val->constant->values[0].i8;
+ case 16: return val->constant->values[0].i16;
+ case 32: return val->constant->values[0].i32;
+ case 64: return val->constant->values[0].i64;
+ default: unreachable("Invalid bit size");
+ }
+}
+
+static inline struct vtn_type *
+vtn_get_value_type(struct vtn_builder *b, uint32_t value_id)
+{
+ struct vtn_value *val = vtn_untyped_value(b, value_id);
+ vtn_fail_if(val->type == NULL, "Value %u does not have a type", value_id);
+ return val->type;
+}
+
+static inline struct vtn_type *
+vtn_get_type(struct vtn_builder *b, uint32_t value_id)
+{
+ return vtn_value(b, value_id, vtn_value_type_type)->type;