summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2020-09-02 18:19:35 -0500
committerKarol Herbst <kherbst@redhat.com>2020-10-20 23:46:42 +0200
commit5e31fad8c9c07d984837a07010c6a9dcd2a2aa97 (patch)
treeba67383f5d49373775a9e404a704f797ef864e20
parentf6c46e8408ba0d3a14da113b8db679616f22b04b (diff)
clover/nir: Calculate sizes of images and samplers properly
Clover uses very specific sizes and alignments for images and samplers to pass various bits of data. We need to add a new size/align helper for inputs which matches the standard CL size/align for most types but also has the right size/align for images and samplers. v2 (Karol): use sizeof(cl_mem) instead of 8 to fix 32 bit runtimes. Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7069>
-rw-r--r--src/gallium/frontends/clover/nir/invocation.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/gallium/frontends/clover/nir/invocation.cpp b/src/gallium/frontends/clover/nir/invocation.cpp
index 8528057b593..6e57301a349 100644
--- a/src/gallium/frontends/clover/nir/invocation.cpp
+++ b/src/gallium/frontends/clover/nir/invocation.cpp
@@ -69,6 +69,20 @@ static void debug_function(void *private_data,
*r_log += message;
}
+static void
+clover_arg_size_align(const glsl_type *type, unsigned *size, unsigned *align)
+{
+ if (type == glsl_type::sampler_type) {
+ *size = 0;
+ *align = 1;
+ } else if (type->is_image()) {
+ *size = *align = sizeof(cl_mem);
+ } else {
+ *size = type->cl_size();
+ *align = type->cl_alignment();
+ }
+}
+
struct clover_lower_nir_state {
std::vector<module::argument> &args;
uint32_t global_dims;
@@ -298,8 +312,10 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
dev.address_bits());
NIR_PASS_V(nir, nir_lower_vars_to_explicit_types,
- nir_var_uniform | nir_var_mem_shared |
- nir_var_mem_global | nir_var_function_temp,
+ nir_var_uniform, clover_arg_size_align);
+ NIR_PASS_V(nir, nir_lower_vars_to_explicit_types,
+ nir_var_mem_shared | nir_var_mem_global |
+ nir_var_function_temp,
glsl_get_cl_type_size_align);
NIR_PASS_V(nir, nir_lower_memcpy);