nir: Support load/store of temps as scratch in nir_lower_explicit_io
authorJesse Natalie <jenatali@microsoft.com>
Tue, 26 May 2020 19:21:33 +0000 (12:21 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 14 Jul 2020 18:15:40 +0000 (18:15 +0000)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5889>

src/compiler/nir/nir_lower_io.c

index be18f79cdc0a389882632ce46e6cfc0fc6856bf5..c27646d7166dd6653542a66c5a01f0d555b60590 100644 (file)
@@ -852,6 +852,11 @@ build_explicit_io_load(nir_builder *b, nir_intrinsic_instr *intrin,
       assert(addr_format_is_offset(addr_format));
       op = nir_intrinsic_load_shared;
       break;
+   case nir_var_shader_temp:
+   case nir_var_function_temp:
+      assert(addr_format_is_offset(addr_format));
+      op = nir_intrinsic_load_scratch;
+      break;
    default:
       unreachable("Unsupported explicit IO variable mode");
    }
@@ -868,7 +873,7 @@ build_explicit_io_load(nir_builder *b, nir_intrinsic_instr *intrin,
       load->src[1] = nir_src_for_ssa(addr_to_offset(b, addr, addr_format));
    }
 
-   if (mode != nir_var_shader_in && mode != nir_var_mem_shared)
+   if (mode == nir_var_mem_ssbo || mode == nir_var_mem_global || mode == nir_var_mem_ubo)
       nir_intrinsic_set_access(load, nir_intrinsic_access(intrin));
 
    unsigned bit_size = intrin->dest.ssa.bit_size;
@@ -947,6 +952,11 @@ build_explicit_io_store(nir_builder *b, nir_intrinsic_instr *intrin,
       assert(addr_format_is_offset(addr_format));
       op = nir_intrinsic_store_shared;
       break;
+   case nir_var_shader_temp:
+   case nir_var_function_temp:
+      assert(addr_format_is_offset(addr_format));
+      op = nir_intrinsic_store_scratch;
+      break;
    default:
       unreachable("Unsupported explicit IO variable mode");
    }
@@ -979,7 +989,7 @@ build_explicit_io_store(nir_builder *b, nir_intrinsic_instr *intrin,
 
    nir_intrinsic_set_write_mask(store, write_mask);
 
-   if (mode != nir_var_mem_shared)
+   if (mode == nir_var_mem_ssbo || mode == nir_var_mem_global)
       nir_intrinsic_set_access(store, nir_intrinsic_access(intrin));
 
    /* TODO: We should try and provide a better alignment.  For OpenCL, we need
@@ -1084,7 +1094,8 @@ 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->mode & (nir_var_shader_in | nir_var_mem_shared));
+      assert(deref->mode & (nir_var_shader_in | nir_var_mem_shared |
+                            nir_var_shader_temp | nir_var_function_temp));
       return nir_imm_intN_t(b, deref->var->data.driver_location,
                             deref->dest.ssa.bit_size);