nir: Add nir_foreach_shader_in/out_variable helpers
[mesa.git] / src / compiler / nir / nir.h
index 281e290f447ed0e051d95eb686423c4bf618a141..b15de3b5dd304cc6b07580675317d94e0abd1d0e 100644 (file)
@@ -624,6 +624,18 @@ typedef struct nir_variable {
 #define nir_foreach_variable_safe(var, var_list) \
    foreach_list_typed_safe(nir_variable, var, node, var_list)
 
+#define nir_foreach_shader_in_variable(var, shader) \
+   nir_foreach_variable(var, &(shader)->inputs)
+
+#define nir_foreach_shader_in_variable_safe(var, shader) \
+   nir_foreach_variable_safe(var, &(shader)->inputs)
+
+#define nir_foreach_shader_out_variable(var, shader) \
+   nir_foreach_variable(var, &(shader)->outputs)
+
+#define nir_foreach_shader_out_variable_safe(var, shader) \
+   nir_foreach_variable_safe(var, &(shader)->outputs)
+
 static inline bool
 nir_variable_is_global(const nir_variable *var)
 {
@@ -3941,7 +3953,7 @@ void nir_assign_var_locations(struct exec_list *var_list, unsigned *size,
 
 /* Some helpers to do very simple linking */
 bool nir_remove_unused_varyings(nir_shader *producer, nir_shader *consumer);
-bool nir_remove_unused_io_vars(nir_shader *shader, struct exec_list *var_list,
+bool nir_remove_unused_io_vars(nir_shader *shader, nir_variable_mode mode,
                                uint64_t *used_by_other_stage,
                                uint64_t *used_by_other_stage_patches);
 void nir_compact_varyings(nir_shader *producer, nir_shader *consumer,
@@ -4465,6 +4477,8 @@ bool nir_lower_interpolation(nir_shader *shader,
 
 bool nir_lower_discard_to_demote(nir_shader *shader);
 
+bool nir_lower_memory_model(nir_shader *shader);
+
 bool nir_normalize_cubemap_coords(nir_shader *shader);
 
 void nir_live_ssa_defs_impl(nir_function_impl *impl);
@@ -4590,21 +4604,6 @@ bool nir_opt_load_store_vectorize(nir_shader *shader, nir_variable_mode modes,
                                   nir_should_vectorize_mem_func callback,
                                   nir_variable_mode robust_modes);
 
-typedef struct nir_schedule_options {
-   /* On some hardware with some stages the inputs and outputs to the shader
-    * share the same memory. In that case scheduler needs to ensure that all
-    * output writes are scheduled after all of the input writes to avoid
-    * overwriting them. This is a bitmask of stages that need that.
-    */
-   unsigned stages_with_shared_io_memory;
-   /* The approximate amount of register pressure at which point the scheduler
-    * will try to reduce register usage.
-    */
-   int threshold;
-} nir_schedule_options;
-
-void nir_schedule(nir_shader *shader, const nir_schedule_options *options);
-
 void nir_strip(nir_shader *shader);
 
 void nir_sweep(nir_shader *shader);
@@ -4636,6 +4635,26 @@ nir_variable_is_in_block(const nir_variable *var)
    return nir_variable_is_in_ubo(var) || nir_variable_is_in_ssbo(var);
 }
 
+typedef struct nir_unsigned_upper_bound_config {
+   unsigned min_subgroup_size;
+   unsigned max_subgroup_size;
+   unsigned max_work_group_invocations;
+   unsigned max_work_group_count[3];
+   unsigned max_work_group_size[3];
+
+   uint32_t vertex_attrib_max[32];
+} nir_unsigned_upper_bound_config;
+
+uint32_t
+nir_unsigned_upper_bound(nir_shader *shader, struct hash_table *range_ht,
+                         nir_ssa_scalar scalar,
+                         const nir_unsigned_upper_bound_config *config);
+
+bool
+nir_addition_might_overflow(nir_shader *shader, struct hash_table *range_ht,
+                            nir_ssa_scalar ssa, unsigned const_val,
+                            const nir_unsigned_upper_bound_config *config);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif