nir: add is_in_ubo/ssbo/block helpers
authorAlejandro Piñeiro <apinheiro@igalia.com>
Tue, 11 Sep 2018 10:40:08 +0000 (12:40 +0200)
committerArcady Goldmints-Orlov <agoldmints@igalia.com>
Sun, 30 Jun 2019 21:58:26 +0000 (16:58 -0500)
Equivalent to the already existing ir_variable is_in_buffer_block and
is_in_shader_storage_block, adding the uniform buffer object one. I'm
using the short forms (ssbo, ubo) to avoid having method names too
long.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/nir/nir.h

index 9b0d13910d4645294e78010179599f8c00561626..df6dc5ba904b69d289926f1696c0f4a68b4b8bec 100644 (file)
@@ -3665,6 +3665,26 @@ gl_system_value nir_system_value_from_intrinsic(nir_intrinsic_op intrin);
 
 bool nir_lower_sincos(nir_shader *shader);
 
+static inline bool
+nir_variable_is_in_ubo(const nir_variable *var)
+{
+   return (var->data.mode == nir_var_mem_ubo &&
+           var->interface_type != NULL);
+}
+
+static inline bool
+nir_variable_is_in_ssbo(const nir_variable *var)
+{
+   return (var->data.mode == nir_var_mem_ssbo &&
+           var->interface_type != NULL);
+}
+
+static inline bool
+nir_variable_is_in_block(const nir_variable *var)
+{
+   return nir_variable_is_in_ubo(var) || nir_variable_is_in_ssbo(var);
+}
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif