From 4e60d4d52af358fc81332c6121d2e556bf302e73 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 11 Jul 2019 14:22:59 +0200 Subject: [PATCH] zink: clean up opcode-emitting a bit Acked-by: Jordan Justen --- .../drivers/zink/nir_to_spirv/nir_to_spirv.c | 28 ++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index f7a7024..074bc00 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -783,16 +783,17 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) result = emit_unop(ctx, spirv_op, dest_type, src[0]); \ break; + UNOP(nir_op_fneg, SpvOpFNegate) + UNOP(nir_op_fddx, SpvOpDPdx) + UNOP(nir_op_fddy, SpvOpDPdy) +#undef UNOP + #define BUILTIN_UNOP(nir_op, spirv_op) \ case nir_op: \ assert(nir_op_infos[alu->op].num_inputs == 1); \ result = emit_builtin_unop(ctx, spirv_op, dest_type, src[0]); \ break; - UNOP(nir_op_fneg, SpvOpFNegate) - UNOP(nir_op_fddx, SpvOpDPdx) - UNOP(nir_op_fddy, SpvOpDPdy) - BUILTIN_UNOP(nir_op_fabs, GLSLstd450FAbs) BUILTIN_UNOP(nir_op_fsqrt, GLSLstd450Sqrt) BUILTIN_UNOP(nir_op_frsq, GLSLstd450InverseSqrt) @@ -806,6 +807,7 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) BUILTIN_UNOP(nir_op_fsign, GLSLstd450FSign) BUILTIN_UNOP(nir_op_fsin, GLSLstd450Sin) BUILTIN_UNOP(nir_op_fcos, GLSLstd450Cos) +#undef BUILTIN_UNOP case nir_op_frcp: { assert(nir_op_infos[alu->op].num_inputs == 1); @@ -816,21 +818,12 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) } break; -#undef UNOP -#undef BUILTIN_UNOP - #define BINOP(nir_op, spirv_op) \ case nir_op: \ assert(nir_op_infos[alu->op].num_inputs == 2); \ result = emit_binop(ctx, spirv_op, dest_type, src[0], src[1]); \ break; -#define BUILTIN_BINOP(nir_op, spirv_op) \ - case nir_op: \ - assert(nir_op_infos[alu->op].num_inputs == 2); \ - result = emit_builtin_binop(ctx, spirv_op, dest_type, src[0], src[1]); \ - break; - BINOP(nir_op_iadd, SpvOpIAdd) BINOP(nir_op_isub, SpvOpISub) BINOP(nir_op_imul, SpvOpIMul) @@ -840,11 +833,16 @@ emit_alu(struct ntv_context *ctx, nir_alu_instr *alu) BINOP(nir_op_fmod, SpvOpFMod) BINOP(nir_op_flt, SpvOpFUnordLessThan) BINOP(nir_op_fge, SpvOpFUnordGreaterThanEqual) +#undef BINOP + +#define BUILTIN_BINOP(nir_op, spirv_op) \ + case nir_op: \ + assert(nir_op_infos[alu->op].num_inputs == 2); \ + result = emit_builtin_binop(ctx, spirv_op, dest_type, src[0], src[1]); \ + break; BUILTIN_BINOP(nir_op_fmin, GLSLstd450FMin) BUILTIN_BINOP(nir_op_fmax, GLSLstd450FMax) - -#undef BINOP #undef BUILTIN_BINOP case nir_op_fdot2: -- 2.7.4