clover/nir/spirv: Use uniform rather than shader_in for kernel inputs
authorJesse Natalie <jenatali@microsoft.com>
Fri, 28 Aug 2020 19:52:20 +0000 (12:52 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 31 Aug 2020 19:58:14 +0000 (19:58 +0000)
The semantics of inputs for CL are a closer match to the semantics of uniforms for graphics.
Rather than cross-stage data, it's data that every thread sees uniformly.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6497>

src/compiler/nir/nir_lower_io.c
src/compiler/spirv/spirv_to_nir.c
src/gallium/frontends/clover/nir/invocation.cpp

index 8f23f7c1391b9580225adfcfaa2b9105f307e236..be1cfdfef3876033d6f566f26ab397160915315f 100644 (file)
@@ -922,8 +922,9 @@ build_explicit_io_load(nir_builder *b, nir_intrinsic_instr *intrin,
       assert(addr_format_is_global(addr_format));
       op = nir_intrinsic_load_global;
       break;
       assert(addr_format_is_global(addr_format));
       op = nir_intrinsic_load_global;
       break;
-   case nir_var_shader_in:
+   case nir_var_uniform:
       assert(addr_format_is_offset(addr_format));
       assert(addr_format_is_offset(addr_format));
+      assert(b->shader->info.stage == MESA_SHADER_KERNEL);
       op = nir_intrinsic_load_kernel_input;
       break;
    case nir_var_mem_shared:
       op = nir_intrinsic_load_kernel_input;
       break;
    case nir_var_mem_shared:
@@ -1184,7 +1185,7 @@ nir_explicit_io_address_from_deref(nir_builder *b, nir_deref_instr *deref,
    assert(deref->dest.is_ssa);
    switch (deref->deref_type) {
    case nir_deref_type_var:
    assert(deref->dest.is_ssa);
    switch (deref->deref_type) {
    case nir_deref_type_var:
-      assert(deref->mode & (nir_var_shader_in | nir_var_mem_shared |
+      assert(deref->mode & (nir_var_uniform | nir_var_mem_shared |
                             nir_var_shader_temp | nir_var_function_temp));
       if (addr_format_is_global(addr_format)) {
          assert(nir_var_shader_temp | nir_var_function_temp);
                             nir_var_shader_temp | nir_var_function_temp));
       if (addr_format_is_global(addr_format)) {
          assert(nir_var_shader_temp | nir_var_function_temp);
index 604174bcaaa7007e3d5421ce81c4b280fcf2f026..6dd18075c847cb641807765fd355d43fa8909edc 100644 (file)
@@ -5475,7 +5475,7 @@ vtn_emit_kernel_entry_point_wrapper(struct vtn_builder *b,
 
       /* input variable */
       nir_variable *in_var = rzalloc(b->nb.shader, nir_variable);
 
       /* input variable */
       nir_variable *in_var = rzalloc(b->nb.shader, nir_variable);
-      in_var->data.mode = nir_var_shader_in;
+      in_var->data.mode = nir_var_uniform;
       in_var->data.read_only = true;
       in_var->data.location = i;
 
       in_var->data.read_only = true;
       in_var->data.location = i;
 
index 08dc78d18d9fa4ebc682d97bfccb50366d40f300..757ace61393a807045d932b76da98ce8e24aaf22 100644 (file)
@@ -104,9 +104,9 @@ clover_lower_nir_instr(nir_builder *b, nir_instr *instr, void *_state)
          const glsl_type *type = glsl_uint_type();
          for (uint32_t i = 0; i < 3; i++) {
             state->offset_vars[i] =
          const glsl_type *type = glsl_uint_type();
          for (uint32_t i = 0; i < 3; i++) {
             state->offset_vars[i] =
-               nir_variable_create(b->shader, nir_var_shader_in, type,
+               nir_variable_create(b->shader, nir_var_uniform, type,
                                    "global_invocation_id_offsets");
                                    "global_invocation_id_offsets");
-            state->offset_vars[i]->data.location = b->shader->num_inputs++;
+            state->offset_vars[i]->data.location = b->shader->num_uniforms++;
          }
       }
 
          }
       }
 
@@ -221,7 +221,7 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
 
       // Calculate input offsets.
       unsigned offset = 0;
 
       // Calculate input offsets.
       unsigned offset = 0;
-      nir_foreach_shader_in_variable(var, nir) {
+      nir_foreach_uniform_variable(var, nir) {
          offset = align(offset, glsl_get_cl_alignment(var->type));
          var->data.driver_location = offset;
          offset += glsl_get_cl_size(var->type);
          offset = align(offset, glsl_get_cl_alignment(var->type));
          var->data.driver_location = offset;
          offset += glsl_get_cl_size(var->type);
@@ -230,8 +230,8 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
       NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, nir_var_mem_shared,
                  glsl_get_cl_type_size_align);
 
       NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, nir_var_mem_shared,
                  glsl_get_cl_type_size_align);
 
-      /* use offsets for shader_in and shared memory */
-      NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_shader_in,
+      /* use offsets for uniform and shared memory */
+      NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_uniform,
                  nir_address_format_32bit_offset);
 
       NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared,
                  nir_address_format_32bit_offset);
 
       NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared,