summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2020-11-03 11:34:18 -0600
committerMarge Bot <eric+marge@anholt.net>2020-11-18 04:05:37 +0000
commitc730ace12b51d46585fac6710fbe57dccd67071c (patch)
tree298e78867b53ea45508d66257b4669c5a200ef81
parent2e8e275075fa6301094e73c1ceda68585f3ae64a (diff)
nir,clover: Drop nir_lower_mem_constant_vars
We have a more generic helper now so clover doesn't need quite as many special paths. Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7565>
-rw-r--r--src/compiler/nir/nir_lower_io.c36
-rw-r--r--src/gallium/frontends/clover/nir/invocation.cpp9
2 files changed, 11 insertions, 34 deletions
diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c
index 948b657d2c7..dae9a2da9f5 100644
--- a/src/compiler/nir/nir_lower_io.c
+++ b/src/compiler/nir/nir_lower_io.c
@@ -2298,7 +2298,7 @@ nir_lower_vars_to_explicit_types(nir_shader *shader,
* - interface types
*/
ASSERTED nir_variable_mode supported =
- nir_var_mem_shared | nir_var_mem_global |
+ nir_var_mem_shared | nir_var_mem_global | nir_var_mem_constant |
nir_var_shader_temp | nir_var_function_temp | nir_var_uniform;
assert(!(modes & ~supported) && "unsupported");
@@ -2310,6 +2310,8 @@ nir_lower_vars_to_explicit_types(nir_shader *shader,
progress |= lower_vars_to_explicit(shader, &shader->variables, nir_var_mem_shared, type_info);
if (modes & nir_var_shader_temp)
progress |= lower_vars_to_explicit(shader, &shader->variables, nir_var_shader_temp, type_info);
+ if (modes & nir_var_mem_constant)
+ progress |= lower_vars_to_explicit(shader, &shader->variables, nir_var_mem_constant, type_info);
nir_foreach_function(function, shader) {
if (function->impl) {
@@ -2395,38 +2397,6 @@ nir_gather_explicit_io_initializers(nir_shader *shader,
}
}
-bool
-nir_lower_mem_constant_vars(nir_shader *shader,
- glsl_type_size_align_func type_info)
-{
- bool progress = false;
-
- unsigned old_constant_data_size = shader->constant_data_size;
- if (lower_vars_to_explicit(shader, &shader->variables,
- nir_var_mem_constant, type_info)) {
- assert(shader->constant_data_size > old_constant_data_size);
- shader->constant_data = rerzalloc_size(shader, shader->constant_data,
- old_constant_data_size,
- shader->constant_data_size);
- nir_gather_explicit_io_initializers(shader, shader->constant_data,
- shader->constant_data_size,
- nir_var_mem_constant);
- progress = true;
- }
-
- nir_foreach_function(function, shader) {
- if (!function->impl)
- continue;
-
- if (nir_lower_vars_to_explicit_types_impl(function->impl,
- nir_var_mem_constant,
- type_info))
- progress = true;
- }
-
- return progress;
-}
-
/**
* Return the offset source for a load/store intrinsic.
*/
diff --git a/src/gallium/frontends/clover/nir/invocation.cpp b/src/gallium/frontends/clover/nir/invocation.cpp
index 7f5b0460df6..6c0808e3da8 100644
--- a/src/gallium/frontends/clover/nir/invocation.cpp
+++ b/src/gallium/frontends/clover/nir/invocation.cpp
@@ -455,8 +455,15 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
NIR_PASS_V(nir, nir_opt_constant_folding);
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_mem_constant, NULL);
- NIR_PASS_V(nir, nir_lower_mem_constant_vars,
+ NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, nir_var_mem_constant,
glsl_get_cl_type_size_align);
+ if (nir->constant_data_size > 0) {
+ assert(nir->constant_data == NULL);
+ nir->constant_data = rzalloc_size(nir, nir->constant_data_size);
+ nir_gather_explicit_io_initializers(nir, nir->constant_data,
+ nir->constant_data_size,
+ nir_var_mem_constant);
+ }
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_constant,
spirv_options.constant_addr_format);