<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 13, 2018 at 9:49 AM Karol Herbst <<a href="mailto:kherbst@redhat.com">kherbst@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">the naming is a bit confusing no matter how you look at it. Within OpenCL<br>
"global" memory is memory accessible from all threads. glsl "global" memory<br>
normally refers to shader thread private memory declared at global scope. As<br>
we already use "shared" for memory shared across all thrads of a work group<br>
the solution where everybody could be happy with is to rename "global" to<br>
"private" and use "global" later for memory usually stored within system<br>
accessible memory (be it VRAM or system RAM if keeping SVM in mind).<br>
</blockquote><div><br></div><div>Yeah.... There's just no good way to pick these names.  It's been kicking around in my brain for a while and I still don't have anything I like.  One thing I will say, though, is that if we're going to rename global to private, I think I'd like to rename local to function at the same time.  That way, it's clear that they map to the SPIR-V thing and we're no longer using the "global/local" terminology from C.  If we do that, then I think I'm fine with this change.</div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Signed-off-by: Karol Herbst <<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>><br>
---<br>
 src/compiler/glsl/glsl_to_nir.cpp                |  4 ++--<br>
 src/compiler/nir/nir.c                           |  2 +-<br>
 src/compiler/nir/nir.h                           |  2 +-<br>
 src/compiler/nir/nir_linking_helpers.c           |  2 +-<br>
 .../nir/nir_lower_constant_initializers.c        |  2 +-<br>
 .../nir/nir_lower_global_vars_to_local.c         |  4 ++--<br>
 src/compiler/nir/nir_lower_io_to_temporaries.c   |  2 +-<br>
 src/compiler/nir/nir_opt_copy_prop_vars.c        |  4 ++--<br>
 src/compiler/nir/nir_opt_dead_write_vars.c       |  2 +-<br>
 src/compiler/nir/nir_print.c                     |  4 ++--<br>
 src/compiler/nir/nir_remove_dead_variables.c     |  4 ++--<br>
 src/compiler/nir/nir_split_vars.c                | 16 ++++++++--------<br>
 src/compiler/nir/tests/vars_tests.cpp            |  2 +-<br>
 src/compiler/spirv/vtn_private.h                 |  2 +-<br>
 src/compiler/spirv/vtn_variables.c               |  6 +++---<br>
 src/gallium/auxiliary/nir/tgsi_to_nir.c          |  2 +-<br>
 src/mesa/state_tracker/st_glsl_to_nir.cpp        |  2 +-<br>
 17 files changed, 31 insertions(+), 31 deletions(-)<br>
<br>
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp<br>
index 0479f8fcfe4..8564cd89b5a 100644<br>
--- a/src/compiler/glsl/glsl_to_nir.cpp<br>
+++ b/src/compiler/glsl/glsl_to_nir.cpp<br>
@@ -312,7 +312,7 @@ nir_visitor::visit(ir_variable *ir)<br>
    case ir_var_auto:<br>
    case ir_var_temporary:<br>
       if (is_global)<br>
-         var->data.mode = nir_var_global;<br>
+         var->data.mode = nir_var_private;<br>
       else<br>
          var->data.mode = nir_var_local;<br>
       break;<br>
@@ -1433,7 +1433,7 @@ nir_visitor::visit(ir_expression *ir)<br>
           * sense, we'll just turn it into a load which will probably<br>
           * eventually end up as an SSA definition.<br>
           */<br>
-         assert(this->deref->mode == nir_var_global);<br>
+         assert(this->deref->mode == nir_var_private);<br>
          op = nir_intrinsic_load_deref;<br>
       }<br>
<br>
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c<br>
index 249b9357c3f..27f5d1b7bca 100644<br>
--- a/src/compiler/nir/nir.c<br>
+++ b/src/compiler/nir/nir.c<br>
@@ -129,7 +129,7 @@ nir_shader_add_variable(nir_shader *shader, nir_variable *var)<br>
       assert(!"nir_shader_add_variable cannot be used for local variables");<br>
       break;<br>
<br>
-   case nir_var_global:<br>
+   case nir_var_private:<br>
       exec_list_push_tail(&shader->globals, &var->node);<br>
       break;<br>
<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index 89c28e36618..78f3204d3e2 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -96,7 +96,7 @@ typedef struct {<br>
 typedef enum {<br>
    nir_var_shader_in       = (1 << 0),<br>
    nir_var_shader_out      = (1 << 1),<br>
-   nir_var_global          = (1 << 2),<br>
+   nir_var_private         = (1 << 2),<br>
    nir_var_local           = (1 << 3),<br>
    nir_var_uniform         = (1 << 4),<br>
    nir_var_shader_storage  = (1 << 5),<br>
diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c<br>
index a05890ada43..d8358e08e5a 100644<br>
--- a/src/compiler/nir/nir_linking_helpers.c<br>
+++ b/src/compiler/nir/nir_linking_helpers.c<br>
@@ -134,7 +134,7 @@ nir_remove_unused_io_vars(nir_shader *shader, struct exec_list *var_list,<br>
       if (!(other_stage & get_variable_io_mask(var, shader->info.stage))) {<br>
          /* This one is invalid, make it a global variable instead */<br>
          var->data.location = 0;<br>
-         var->data.mode = nir_var_global;<br>
+         var->data.mode = nir_var_private;<br>
<br>
          exec_node_remove(&var->node);<br>
          exec_list_push_tail(&shader->globals, &var->node);<br>
diff --git a/src/compiler/nir/nir_lower_constant_initializers.c b/src/compiler/nir/nir_lower_constant_initializers.c<br>
index 4e9cea46157..932a32b3c9c 100644<br>
--- a/src/compiler/nir/nir_lower_constant_initializers.c<br>
+++ b/src/compiler/nir/nir_lower_constant_initializers.c<br>
@@ -98,7 +98,7 @@ nir_lower_constant_initializers(nir_shader *shader, nir_variable_mode modes)<br>
    if (modes & nir_var_shader_out)<br>
       progress |= lower_const_initializer(&builder, &shader->outputs);<br>
<br>
-   if (modes & nir_var_global)<br>
+   if (modes & nir_var_private)<br>
       progress |= lower_const_initializer(&builder, &shader->globals);<br>
<br>
    if (modes & nir_var_system_value)<br>
diff --git a/src/compiler/nir/nir_lower_global_vars_to_local.c b/src/compiler/nir/nir_lower_global_vars_to_local.c<br>
index be99cf9ad02..6c6d9a9d25c 100644<br>
--- a/src/compiler/nir/nir_lower_global_vars_to_local.c<br>
+++ b/src/compiler/nir/nir_lower_global_vars_to_local.c<br>
@@ -36,7 +36,7 @@ static void<br>
 register_var_use(nir_variable *var, nir_function_impl *impl,<br>
                  struct hash_table *var_func_table)<br>
 {<br>
-   if (var->data.mode != nir_var_global)<br>
+   if (var->data.mode != nir_var_private)<br>
       return;<br>
<br>
    struct hash_entry *entry =<br>
@@ -89,7 +89,7 @@ nir_lower_global_vars_to_local(nir_shader *shader)<br>
       nir_variable *var = (void *)entry->key;<br>
       nir_function_impl *impl = entry->data;<br>
<br>
-      assert(var->data.mode == nir_var_global);<br>
+      assert(var->data.mode == nir_var_private);<br>
<br>
       if (impl != NULL) {<br>
          exec_node_remove(&var->node);<br>
diff --git a/src/compiler/nir/nir_lower_io_to_temporaries.c b/src/compiler/nir/nir_lower_io_to_temporaries.c<br>
index b83aaf46e6a..2487add33ed 100644<br>
--- a/src/compiler/nir/nir_lower_io_to_temporaries.c<br>
+++ b/src/compiler/nir/nir_lower_io_to_temporaries.c<br>
@@ -134,7 +134,7 @@ create_shadow_temp(struct lower_io_state *state, nir_variable *var)<br>
    /* Give the original a new name with @<mode>-temp appended */<br>
    const char *mode = (temp->data.mode == nir_var_shader_in) ? "in" : "out";<br>
    temp->name = ralloc_asprintf(var, "%s@%s-temp", mode, nvar->name);<br>
-   temp->data.mode = nir_var_global;<br>
+   temp->data.mode = nir_var_private;<br>
    temp->data.read_only = false;<br>
    temp->data.fb_fetch_output = false;<br>
    temp->data.compact = false;<br>
diff --git a/src/compiler/nir/nir_opt_copy_prop_vars.c b/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
index 48070cd5e31..95f0bbd5b77 100644<br>
--- a/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
+++ b/src/compiler/nir/nir_opt_copy_prop_vars.c<br>
@@ -134,7 +134,7 @@ gather_vars_written(struct copy_prop_var_state *state,<br>
       nir_foreach_instr(instr, block) {<br>
          if (instr->type == nir_instr_type_call) {<br>
             written->modes |= nir_var_shader_out |<br>
-                              nir_var_global |<br>
+                              nir_var_private |<br>
                               nir_var_local |<br>
                               nir_var_shader_storage |<br>
                               nir_var_shared;<br>
@@ -603,7 +603,7 @@ copy_prop_vars_block(struct copy_prop_var_state *state,<br>
    nir_foreach_instr_safe(instr, block) {<br>
       if (instr->type == nir_instr_type_call) {<br>
          apply_barrier_for_modes(copies, nir_var_shader_out |<br>
-                                         nir_var_global |<br>
+                                         nir_var_private |<br>
                                          nir_var_local |<br>
                                          nir_var_shader_storage |<br>
                                          nir_var_shared);<br>
diff --git a/src/compiler/nir/nir_opt_dead_write_vars.c b/src/compiler/nir/nir_opt_dead_write_vars.c<br>
index dd949998cc8..0fbbe63f436 100644<br>
--- a/src/compiler/nir/nir_opt_dead_write_vars.c<br>
+++ b/src/compiler/nir/nir_opt_dead_write_vars.c<br>
@@ -120,7 +120,7 @@ remove_dead_write_vars_local(void *mem_ctx, nir_block *block)<br>
    nir_foreach_instr_safe(instr, block) {<br>
       if (instr->type == nir_instr_type_call) {<br>
          clear_unused_for_modes(&unused_writes, nir_var_shader_out |<br>
-                                                nir_var_global |<br>
+                                                nir_var_private |<br>
                                                 nir_var_local |<br>
                                                 nir_var_shader_storage |<br>
                                                 nir_var_shared);<br>
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c<br>
index 0de82800f8c..88f91087134 100644<br>
--- a/src/compiler/nir/nir_print.c<br>
+++ b/src/compiler/nir/nir_print.c<br>
@@ -416,8 +416,8 @@ get_variable_mode_str(nir_variable_mode mode, bool want_local_global_mode)<br>
       return "system";<br>
    case nir_var_shared:<br>
       return "shared";<br>
-   case nir_var_global:<br>
-      return want_local_global_mode ? "global" : "";<br>
+   case nir_var_private:<br>
+      return want_local_global_mode ? "private" : "";<br>
    case nir_var_local:<br>
       return want_local_global_mode ? "local" : "";<br>
    default:<br>
diff --git a/src/compiler/nir/nir_remove_dead_variables.c b/src/compiler/nir/nir_remove_dead_variables.c<br>
index fadc51a6977..d09e823c517 100644<br>
--- a/src/compiler/nir/nir_remove_dead_variables.c<br>
+++ b/src/compiler/nir/nir_remove_dead_variables.c<br>
@@ -71,7 +71,7 @@ add_var_use_deref(nir_deref_instr *deref, struct set *live)<br>
     * all means we need to keep it alive.<br>
     */<br>
    assert(deref->mode == deref->var->data.mode);<br>
-   if (!(deref->mode & (nir_var_local | nir_var_global | nir_var_shared)) ||<br>
+   if (!(deref->mode & (nir_var_local | nir_var_private | nir_var_shared)) ||<br>
        deref_used_for_not_store(deref))<br>
       _mesa_set_add(live, deref->var);<br>
 }<br>
@@ -175,7 +175,7 @@ nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes)<br>
    if (modes & nir_var_shader_out)<br>
       progress = remove_dead_vars(&shader->outputs, live) || progress;<br>
<br>
-   if (modes & nir_var_global)<br>
+   if (modes & nir_var_private)<br>
       progress = remove_dead_vars(&shader->globals, live) || progress;<br>
<br>
    if (modes & nir_var_system_value)<br>
diff --git a/src/compiler/nir/nir_split_vars.c b/src/compiler/nir/nir_split_vars.c<br>
index bf9205c5150..9d1a096268c 100644<br>
--- a/src/compiler/nir/nir_split_vars.c<br>
+++ b/src/compiler/nir/nir_split_vars.c<br>
@@ -259,10 +259,10 @@ nir_split_struct_vars(nir_shader *shader, nir_variable_mode modes)<br>
       _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,<br>
                               _mesa_key_pointer_equal);<br>
<br>
-   assert((modes & (nir_var_global | nir_var_local)) == modes);<br>
+   assert((modes & (nir_var_private | nir_var_local)) == modes);<br>
<br>
    bool has_global_splits = false;<br>
-   if (modes & nir_var_global) {<br>
+   if (modes & nir_var_private) {<br>
       has_global_splits = split_var_list_structs(shader, NULL,<br>
                                                  &shader->globals,<br>
                                                  var_field_map, mem_ctx);<br>
@@ -795,10 +795,10 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)<br>
       _mesa_hash_table_create(mem_ctx, _mesa_hash_pointer,<br>
                               _mesa_key_pointer_equal);<br>
<br>
-   assert((modes & (nir_var_global | nir_var_local)) == modes);<br>
+   assert((modes & (nir_var_private | nir_var_local)) == modes);<br>
<br>
    bool has_global_array = false;<br>
-   if (modes & nir_var_global) {<br>
+   if (modes & nir_var_private) {<br>
       has_global_array = init_var_list_array_infos(&shader->globals,<br>
                                                    var_info_map, mem_ctx);<br>
    }<br>
@@ -827,7 +827,7 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)<br>
    }<br>
<br>
    bool has_global_splits = false;<br>
-   if (modes & nir_var_global) {<br>
+   if (modes & nir_var_private) {<br>
       has_global_splits = split_var_list_arrays(shader, NULL,<br>
                                                 &shader->globals,<br>
                                                 var_info_map, mem_ctx);<br>
@@ -1494,7 +1494,7 @@ function_impl_has_vars_with_modes(nir_function_impl *impl,<br>
 {<br>
    nir_shader *shader = impl->function->shader;<br>
<br>
-   if ((modes & nir_var_global) && !exec_list_is_empty(&shader->globals))<br>
+   if ((modes & nir_var_private) && !exec_list_is_empty(&shader->globals))<br>
       return true;<br>
<br>
    if ((modes & nir_var_local) && !exec_list_is_empty(&impl->locals))<br>
@@ -1515,7 +1515,7 @@ function_impl_has_vars_with_modes(nir_function_impl *impl,<br>
 bool<br>
 nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes)<br>
 {<br>
-   assert((modes & (nir_var_global | nir_var_local)) == modes);<br>
+   assert((modes & (nir_var_private | nir_var_local)) == modes);<br>
<br>
    void *mem_ctx = ralloc_context(NULL);<br>
<br>
@@ -1544,7 +1544,7 @@ nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes)<br>
    }<br>
<br>
    bool globals_shrunk = false;<br>
-   if (modes & nir_var_global)<br>
+   if (modes & nir_var_private)<br>
       globals_shrunk = shrink_vec_var_list(&shader->globals, var_usage_map);<br>
<br>
    bool progress = false;<br>
diff --git a/src/compiler/nir/tests/vars_tests.cpp b/src/compiler/nir/tests/vars_tests.cpp<br>
index 32763d2db64..666d22643dd 100644<br>
--- a/src/compiler/nir/tests/vars_tests.cpp<br>
+++ b/src/compiler/nir/tests/vars_tests.cpp<br>
@@ -191,7 +191,7 @@ TEST_F(nir_redundant_load_vars_test, invalidate_inside_if_block)<br>
     * if statement.  They should be invalidated accordingly.<br>
     */<br>
<br>
-   nir_variable **g = create_many_int(nir_var_global, "g", 3);<br>
+   nir_variable **g = create_many_int(nir_var_private, "g", 3);<br>
    nir_variable **out = create_many_int(nir_var_shader_out, "out", 3);<br>
<br>
    nir_load_var(b, g[0]);<br>
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h<br>
index d7d5b8db198..86f98083f58 100644<br>
--- a/src/compiler/spirv/vtn_private.h<br>
+++ b/src/compiler/spirv/vtn_private.h<br>
@@ -418,7 +418,7 @@ struct vtn_access_chain {<br>
<br>
 enum vtn_variable_mode {<br>
    vtn_variable_mode_local,<br>
-   vtn_variable_mode_global,<br>
+   vtn_variable_mode_private,<br>
    vtn_variable_mode_uniform,<br>
    vtn_variable_mode_ubo,<br>
    vtn_variable_mode_ssbo,<br>
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c<br>
index e7654b768af..5738941ffb6 100644<br>
--- a/src/compiler/spirv/vtn_variables.c<br>
+++ b/src/compiler/spirv/vtn_variables.c<br>
@@ -1556,8 +1556,8 @@ vtn_storage_class_to_mode(struct vtn_builder *b,<br>
       nir_mode = nir_var_shader_out;<br>
       break;<br>
    case SpvStorageClassPrivate:<br>
-      mode = vtn_variable_mode_global;<br>
-      nir_mode = nir_var_global;<br>
+      mode = vtn_variable_mode_private;<br>
+      nir_mode = nir_var_private;<br>
       break;<br>
    case SpvStorageClassFunction:<br>
       mode = vtn_variable_mode_local;<br>
@@ -1721,7 +1721,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,<br>
<br>
    switch (var->mode) {<br>
    case vtn_variable_mode_local:<br>
-   case vtn_variable_mode_global:<br>
+   case vtn_variable_mode_private:<br>
    case vtn_variable_mode_uniform:<br>
       /* For these, we create the variable normally */<br>
       var->var = rzalloc(b->shader, nir_variable);<br>
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c<br>
index b108c05d895..c95c45279f3 100644<br>
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c<br>
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c<br>
@@ -182,7 +182,7 @@ ttn_emit_declaration(struct ttn_compile *c)<br>
          nir_variable *var = rzalloc(b->shader, nir_variable);<br>
<br>
          var->type = glsl_array_type(glsl_vec4_type(), array_size);<br>
-         var->data.mode = nir_var_global;<br>
+         var->data.mode = nir_var_private;<br>
          var->name = ralloc_asprintf(var, "arr_%d", decl->Array.ArrayID);<br>
<br>
          exec_list_push_tail(&b->shader->globals, &var->node);<br>
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp<br>
index d0475fb538a..0152fe6d7ff 100644<br>
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp<br>
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp<br>
@@ -103,7 +103,7 @@ st_nir_assign_vs_in_locations(struct gl_program *prog, nir_shader *nir)<br>
           * set.<br>
           */<br>
          exec_node_remove(&var->node);<br>
-         var->data.mode = nir_var_global;<br>
+         var->data.mode = nir_var_private;<br>
          exec_list_push_tail(&nir->globals, &var->node);<br>
       }<br>
    }<br>
-- <br>
2.19.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div>