clover/nir: Use the correct address mode for shared
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 19 Aug 2020 17:15:23 +0000 (12:15 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 19 Aug 2020 18:11:42 +0000 (18:11 +0000)
Shared memory needs to have 64-bit pointers but we want 32-bit offsets
most of the time.  This is exactly what 32bit_offset_as_64bit is for.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6367>

src/gallium/frontends/clover/nir/invocation.cpp

index 713ab3c48770e214e27984a07d5ceed66440940e..3d7fda8119ba5358b294d9b3c8f079800eca281c 100644 (file)
@@ -64,11 +64,11 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
    struct spirv_to_nir_options spirv_options = {};
    spirv_options.environment = NIR_SPIRV_OPENCL;
    if (dev.address_bits() == 32u) {
-      spirv_options.shared_addr_format = nir_address_format_32bit_global;
+      spirv_options.shared_addr_format = nir_address_format_32bit_offset;
       spirv_options.global_addr_format = nir_address_format_32bit_global;
       spirv_options.temp_addr_format = nir_address_format_32bit_global;
    } else {
-      spirv_options.shared_addr_format = nir_address_format_64bit_global;
+      spirv_options.shared_addr_format = nir_address_format_32bit_offset_as_64bit;
       spirv_options.global_addr_format = nir_address_format_64bit_global;
       spirv_options.temp_addr_format = nir_address_format_64bit_global;
    }
@@ -148,10 +148,11 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
                  glsl_get_cl_type_size_align);
 
       /* use offsets for shader_in and shared memory */
-      nir_variable_mode modes = (nir_variable_mode)(
-         nir_var_shader_in |
-         nir_var_mem_shared);
-      NIR_PASS_V(nir, nir_lower_explicit_io, modes, nir_address_format_32bit_offset);
+      NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_shader_in,
+                 nir_address_format_32bit_offset);
+
+      NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared,
+                 spirv_options.shared_addr_format);
 
       NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_global,
                  spirv_options.global_addr_format);