gallium/ttn: Use variable create/add helpers

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
This commit is contained in:
Jason Ekstrand
2020-07-21 12:15:27 -05:00
committed by Marge Bot
parent a41a84d362
commit 473b0fc25d

View File

@@ -243,13 +243,11 @@ ttn_emit_declaration(struct ttn_compile *c)
if (file == TGSI_FILE_TEMPORARY) { if (file == TGSI_FILE_TEMPORARY) {
if (decl->Declaration.Array) { if (decl->Declaration.Array) {
/* for arrays, we create variables instead of registers: */ /* for arrays, we create variables instead of registers: */
nir_variable *var = rzalloc(b->shader, nir_variable); nir_variable *var =
nir_variable_create(b->shader, nir_var_shader_temp,
var->type = glsl_array_type(glsl_vec4_type(), array_size, 0); glsl_array_type(glsl_vec4_type(), array_size, 0),
var->data.mode = nir_var_shader_temp; ralloc_asprintf(b->shader, "arr_%d",
var->name = ralloc_asprintf(var, "arr_%d", decl->Array.ArrayID); decl->Array.ArrayID));
exec_list_push_tail(&b->shader->globals, &var->node);
for (i = 0; i < array_size; i++) { for (i = 0; i < array_size; i++) {
/* point all the matching slots to the same var, /* point all the matching slots to the same var,
@@ -380,7 +378,6 @@ ttn_emit_declaration(struct ttn_compile *c)
var->data.interpolation = var->data.interpolation =
ttn_translate_interp_mode(decl->Interp.Interpolate); ttn_translate_interp_mode(decl->Interp.Interpolate);
exec_list_push_tail(&b->shader->inputs, &var->node);
c->inputs[idx] = var; c->inputs[idx] = var;
for (int i = 0; i < array_size; i++) for (int i = 0; i < array_size; i++)
@@ -461,7 +458,6 @@ ttn_emit_declaration(struct ttn_compile *c)
c->output_regs[idx].reg = reg; c->output_regs[idx].reg = reg;
} }
exec_list_push_tail(&b->shader->outputs, &var->node);
c->outputs[idx] = var; c->outputs[idx] = var;
for (int i = 0; i < array_size; i++) for (int i = 0; i < array_size; i++)
@@ -472,14 +468,14 @@ ttn_emit_declaration(struct ttn_compile *c)
var->data.mode = nir_var_uniform; var->data.mode = nir_var_uniform;
var->name = ralloc_asprintf(var, "uniform_%d", idx); var->name = ralloc_asprintf(var, "uniform_%d", idx);
var->data.location = idx; var->data.location = idx;
exec_list_push_tail(&b->shader->uniforms, &var->node);
break; break;
default: default:
unreachable("bad declaration file"); unreachable("bad declaration file");
return; return;
} }
nir_shader_add_variable(b->shader, var);
if (is_array) if (is_array)
break; break;
} }