mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Implement incop for SPIR-V
I think I got it right, but it's hard to tell because my shaders use ++ only for the iterator of loops so the result is thrown away.
This commit is contained in:
parent
270c57e46e
commit
e9eae1c75f
2 changed files with 25 additions and 0 deletions
|
@ -2203,6 +2203,7 @@ expr_incop (sblock_t *sblock, const expr_t *e, operand_t **op)
|
||||||
sblock = statement_single (sblock, assign);
|
sblock = statement_single (sblock, assign);
|
||||||
sblock = statement_subexpr (sblock, tmp, op);
|
sblock = statement_subexpr (sblock, tmp, op);
|
||||||
}
|
}
|
||||||
|
// binary_expr will take care of pointers
|
||||||
auto one = new_int_expr (1, false);
|
auto one = new_int_expr (1, false);
|
||||||
auto type = get_type (e->incop.expr);
|
auto type = get_type (e->incop.expr);
|
||||||
if (is_scalar (type)) {
|
if (is_scalar (type)) {
|
||||||
|
|
|
@ -1669,6 +1669,29 @@ spirv_extend (const expr_t *e, spirvctx_t *ctx)
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned
|
||||||
|
spirv_incop (const expr_t *e, spirvctx_t *ctx)
|
||||||
|
{
|
||||||
|
scoped_src_loc (e);
|
||||||
|
|
||||||
|
// binary_expr will take care of pointers (FIXME is this correct for
|
||||||
|
// spir-v?)
|
||||||
|
auto one = new_int_expr (1, false);
|
||||||
|
auto type = get_type (e->incop.expr);
|
||||||
|
if (is_scalar (type)) {
|
||||||
|
one = cast_expr (type, one);
|
||||||
|
}
|
||||||
|
auto dst = new_expr ();
|
||||||
|
*dst = *e->incop.expr;
|
||||||
|
dst->id = 0;
|
||||||
|
auto incop = binary_expr (e->incop.op, e->incop.expr, one);
|
||||||
|
unsigned inc_id = spirv_emit_expr (incop, ctx);
|
||||||
|
unsigned src_id = incop->expr.e1->id;
|
||||||
|
auto assign = assign_expr (dst, incop);
|
||||||
|
spirv_emit_expr (assign, ctx);
|
||||||
|
return e->incop.postop ? src_id : inc_id;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
spirv_cond (const expr_t *e, spirvctx_t *ctx)
|
spirv_cond (const expr_t *e, spirvctx_t *ctx)
|
||||||
{
|
{
|
||||||
|
@ -1827,6 +1850,7 @@ spirv_emit_expr (const expr_t *e, spirvctx_t *ctx)
|
||||||
[ex_return] = spirv_return,
|
[ex_return] = spirv_return,
|
||||||
[ex_swizzle] = spirv_swizzle,
|
[ex_swizzle] = spirv_swizzle,
|
||||||
[ex_extend] = spirv_extend,
|
[ex_extend] = spirv_extend,
|
||||||
|
[ex_incop] = spirv_incop,
|
||||||
[ex_cond] = spirv_cond,
|
[ex_cond] = spirv_cond,
|
||||||
[ex_field] = spirv_field_array,
|
[ex_field] = spirv_field_array,
|
||||||
[ex_array] = spirv_field_array,
|
[ex_array] = spirv_field_array,
|
||||||
|
|
Loading…
Reference in a new issue