spirv: Add vtn_mode_uses_ssa_offset()
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 3 May 2019 05:11:31 +0000 (22:11 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 20 May 2019 17:53:38 +0000 (10:53 -0700)
Just the mode is needed to decide whether SSA offsets are needed, so
make a function that takes that and reuse it for
vtn_pointer_uses_ssa_offset().

This will be used for constant null pointers, that won't have a
vtn_pointer handy.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c

index 9fb508734a21749e4fcb5e55b3238ef2416a8061..55cd0c2786c17f7af1d330ba75a90f6af883e664 100644 (file)
@@ -473,8 +473,15 @@ struct vtn_pointer {
    enum gl_access_qualifier access;
 };
 
-bool vtn_pointer_uses_ssa_offset(struct vtn_builder *b,
-                                 struct vtn_pointer *ptr);
+bool vtn_mode_uses_ssa_offset(struct vtn_builder *b,
+                              enum vtn_variable_mode mode);
+
+static inline bool vtn_pointer_uses_ssa_offset(struct vtn_builder *b,
+                                               struct vtn_pointer *ptr)
+{
+   return vtn_mode_uses_ssa_offset(b, ptr->mode);
+}
+
 
 struct vtn_variable {
    enum vtn_variable_mode mode;
index bc6b0ebedcc036cfe8ffbce79cf2ea61fa9fc57b..0d7a6b54766f5e13b3dafd8f33ed7686dfcd8924 100644 (file)
@@ -45,14 +45,14 @@ vtn_access_chain_create(struct vtn_builder *b, unsigned length)
 }
 
 bool
-vtn_pointer_uses_ssa_offset(struct vtn_builder *b,
-                            struct vtn_pointer *ptr)
+vtn_mode_uses_ssa_offset(struct vtn_builder *b,
+                         enum vtn_variable_mode mode)
 {
-   return ((ptr->mode == vtn_variable_mode_ubo ||
-            ptr->mode == vtn_variable_mode_ssbo) &&
+   return ((mode == vtn_variable_mode_ubo ||
+            mode == vtn_variable_mode_ssbo) &&
            b->options->lower_ubo_ssbo_access_to_offsets) ||
-          ptr->mode == vtn_variable_mode_push_constant ||
-          (ptr->mode == vtn_variable_mode_workgroup &&
+          mode == vtn_variable_mode_push_constant ||
+          (mode == vtn_variable_mode_workgroup &&
            b->options->lower_workgroup_access_to_offsets);
 }