From: Jason Ekstrand Date: Mon, 19 Oct 2015 23:08:23 +0000 (-0700) Subject: nir/spirv: Use the new nir_variable helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=12c30c94987f2dd2e7bad1c84d2bd7df2c7b01d8;p=mesa.git nir/spirv: Use the new nir_variable helpers --- diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 2ba8216c0b4..819109385ee 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -825,28 +825,14 @@ get_builtin_variable(struct vtn_builder *b, nir_variable *var = b->builtins[builtin]; if (!var) { - var = ralloc(b->shader, nir_variable); - var->type = type; - + int location; nir_variable_mode mode; - vtn_get_builtin_location(builtin, &var->data.location, &mode); - var->data.explicit_location = true; - var->data.mode = mode; - var->name = ralloc_strdup(var, "builtin"); + vtn_get_builtin_location(builtin, &location, &mode); - switch (mode) { - case nir_var_shader_in: - exec_list_push_tail(&b->shader->inputs, &var->node); - break; - case nir_var_shader_out: - exec_list_push_tail(&b->shader->outputs, &var->node); - break; - case nir_var_system_value: - exec_list_push_tail(&b->shader->system_values, &var->node); - break; - default: - unreachable("bad builtin mode"); - } + var = nir_variable_create(b->shader, mode, type, "builtin"); + + var->data.location = location; + var->data.explicit_location = true; b->builtins[builtin] = var; } @@ -1277,26 +1263,12 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode, if (builtin_block) break; - switch (var->data.mode) { - case nir_var_shader_in: - exec_list_push_tail(&b->shader->inputs, &var->node); - break; - case nir_var_shader_out: - exec_list_push_tail(&b->shader->outputs, &var->node); - break; - case nir_var_global: - exec_list_push_tail(&b->shader->globals, &var->node); - break; - case nir_var_local: - exec_list_push_tail(&b->impl->locals, &var->node); - break; - case nir_var_uniform: - exec_list_push_tail(&b->shader->uniforms, &var->node); - break; - case nir_var_system_value: - exec_list_push_tail(&b->shader->system_values, &var->node); - break; + if (var->data.mode == nir_var_local) { + nir_function_impl_add_variable(b->impl, var); + } else { + nir_shader_add_variable(b->shader, var); } + break; }