mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Use staging vars for non-const params
Non-const params use references and so need somewhere to store the arguments. Local variables could be passed directly (parameters normally require function storage class, which local variables are), but that's a potential optimization for later.
This commit is contained in:
parent
698430630d
commit
5033dc9a12
1 changed files with 19 additions and 1 deletions
|
@ -911,7 +911,25 @@ spirv_call (const expr_t *call, spirvctx_t *ctx)
|
|||
list_scatter_rev (&call->branch.args->list, args);
|
||||
for (int i = 0; i < num_args; i++) {
|
||||
auto a = args[i];
|
||||
if (func_type->func.param_quals[i] == pq_const) {
|
||||
arg_ids[i] = spirv_emit_expr (a, ctx);
|
||||
} else {
|
||||
auto psym = new_symbol ("param");
|
||||
psym->type = reference_type (get_type (a));
|
||||
psym->sy_type = sy_var;
|
||||
psym->var.storage = SpvStorageClassFunction;
|
||||
psym->id = spirv_variable (psym, ctx);
|
||||
psym->lvalue = true;
|
||||
arg_ids[i] = psym->id;
|
||||
if (func_type->func.param_quals[i] != pq_out) {
|
||||
if (a->type == ex_inout) {
|
||||
a = a->inout.in;
|
||||
}
|
||||
auto pexpr = new_symbol_expr (psym);
|
||||
auto assign = assign_expr (pexpr, a);
|
||||
spirv_emit_expr (assign, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned id = spirv_id (ctx);
|
||||
|
|
Loading…
Reference in a new issue