diff options
author | Tom Stellard <[email protected]> | 2012-01-14 09:09:54 -0500 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2012-01-30 13:37:00 -0500 |
commit | 82b71db03ddaf0eed504412c9169db37cf9bdadc (patch) | |
tree | 4f4e6e3f0f3b875bfd17ed101f06fd42d9bd3a66 /src/gallium/auxiliary/tgsi | |
parent | 6b63e25b3d7a6ac0bd738c139ead0c7e7ad84368 (diff) |
gallium: Move duplicated helper macros to tgsi_exec.h
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_exec.h | 13 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_ppc.c | 78 |
2 files changed, 45 insertions, 46 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 613b3837eb3..d9e93ce138d 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -45,6 +45,19 @@ extern "C" { #define TGSI_NUM_CHANNELS 4 /* R,G,B,A */ #define TGSI_QUAD_SIZE 4 /* 4 pixel/quad */ +#define TGSI_FOR_EACH_CHANNEL( CHAN )\ + for (CHAN = 0; CHAN < TGSI_NUM_CHANNELS; CHAN++) + +#define TGSI_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\ + ((INST)->Dst[0].Register.WriteMask & (1 << (CHAN))) + +#define TGSI_IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\ + if (TGSI_IS_DST0_CHANNEL_ENABLED( INST, CHAN )) + +#define TGSI_FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\ + TGSI_FOR_EACH_CHANNEL( CHAN )\ + TGSI_IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN ) + /** * Registers may be treated as float, signed int or unsigned int. diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c index 36400c7fe68..1e00e2e54ed 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ppc.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c @@ -56,20 +56,6 @@ ppc_builtin_constants[] = { 1.0f, -128.0f, 128.0, 0.0 }; - -#define FOR_EACH_CHANNEL( CHAN )\ - for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++) - -#define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\ - ((INST).Dst[0].Register.WriteMask & (1 << (CHAN))) - -#define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\ - if (IS_DST0_CHANNEL_ENABLED( INST, CHAN )) - -#define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\ - FOR_EACH_CHANNEL( CHAN )\ - IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN ) - /** * How many TGSI temps should be implemented with real PPC vector registers * rather than memory. @@ -583,7 +569,7 @@ emit_scalar_unaryop(struct gen_context *gen, struct tgsi_full_instruction *inst) assert(0); } - FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + TGSI_FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { emit_store(gen, v1, inst, chan_index, FALSE); } @@ -597,7 +583,7 @@ emit_unaryop(struct gen_context *gen, struct tgsi_full_instruction *inst) { uint chan_index; - FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan_index) { + TGSI_FOR_EACH_DST0_ENABLED_CHANNEL(inst, chan_index) { int v0 = get_src_vec(gen, inst, 0, chan_index); /* v0 = srcreg[0] */ int v1 = get_dst_vec(gen, inst, chan_index); switch (inst->Instruction.Opcode) { @@ -647,7 +633,7 @@ emit_binop(struct gen_context *gen, struct tgsi_full_instruction *inst) ppc_vzero(gen->f, zero_vec); } - FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan) { + TGSI_FOR_EACH_DST0_ENABLED_CHANNEL(inst, chan) { /* fetch src operands */ int v0 = get_src_vec(gen, inst, 0, chan); int v1 = get_src_vec(gen, inst, 1, chan); @@ -690,7 +676,7 @@ emit_triop(struct gen_context *gen, struct tgsi_full_instruction *inst) { uint chan; - FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan) { + TGSI_FOR_EACH_DST0_ENABLED_CHANNEL(inst, chan) { /* fetch src operands */ int v0 = get_src_vec(gen, inst, 0, chan); int v1 = get_src_vec(gen, inst, 1, chan); @@ -727,7 +713,7 @@ emit_inequality(struct gen_context *gen, struct tgsi_full_instruction *inst) uint chan; int one_vec = gen_one_vec(gen); - FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan) { + TGSI_FOR_EACH_DST0_ENABLED_CHANNEL(inst, chan) { /* fetch src operands */ int v0 = get_src_vec(gen, inst, 0, chan); int v1 = get_src_vec(gen, inst, 1, chan); @@ -806,7 +792,7 @@ emit_dotprod(struct gen_context *gen, struct tgsi_full_instruction *inst) ppc_vaddfp(gen->f, v2, v2, v1); /* v2 = v2 + v1 */ } - FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan_index) { + TGSI_FOR_EACH_DST0_ENABLED_CHANNEL(inst, chan_index) { emit_store(gen, v2, inst, chan_index, FALSE); /* store v2, free v2 later */ } @@ -841,13 +827,13 @@ emit_lit(struct gen_context *gen, struct tgsi_full_instruction *inst) int one_vec = gen_one_vec(gen); /* Compute X */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_X)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_X)) { emit_store(gen, one_vec, inst, TGSI_CHAN_X, FALSE); } /* Compute Y, Z */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Y) || - IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Z)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Y) || + TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Z)) { int x_vec; int zero_vec = ppc_allocate_vec_register(gen->f); @@ -856,11 +842,11 @@ emit_lit(struct gen_context *gen, struct tgsi_full_instruction *inst) ppc_vzero(gen->f, zero_vec); /* zero = {0,0,0,0} */ ppc_vmaxfp(gen->f, x_vec, x_vec, zero_vec); /* x_vec = max(x_vec, 0) */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Y)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Y)) { emit_store(gen, x_vec, inst, TGSI_CHAN_Y, FALSE); } - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Z)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Z)) { int y_vec, w_vec; int z_vec = ppc_allocate_vec_register(gen->f); int pow_vec = ppc_allocate_vec_register(gen->f); @@ -901,7 +887,7 @@ emit_lit(struct gen_context *gen, struct tgsi_full_instruction *inst) } /* Compute W */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_W)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_W)) { emit_store(gen, one_vec, inst, TGSI_CHAN_W, FALSE); } @@ -919,7 +905,7 @@ emit_exp(struct gen_context *gen, struct tgsi_full_instruction *inst) src_vec = get_src_vec(gen, inst, 0, TGSI_CHAN_X); /* Compute X = 2^floor(src) */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_X)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_X)) { int dst_vec = get_dst_vec(gen, inst, TGSI_CHAN_X); int tmp_vec = ppc_allocate_vec_register(gen->f); ppc_vrfim(gen->f, tmp_vec, src_vec); /* tmp = floor(src); */ @@ -929,7 +915,7 @@ emit_exp(struct gen_context *gen, struct tgsi_full_instruction *inst) } /* Compute Y = src - floor(src) */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Y)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Y)) { int dst_vec = get_dst_vec(gen, inst, TGSI_CHAN_Y); int tmp_vec = ppc_allocate_vec_register(gen->f); ppc_vrfim(gen->f, tmp_vec, src_vec); /* tmp = floor(src); */ @@ -939,14 +925,14 @@ emit_exp(struct gen_context *gen, struct tgsi_full_instruction *inst) } /* Compute Z = RoughApprox2ToX(src) */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Z)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Z)) { int dst_vec = get_dst_vec(gen, inst, TGSI_CHAN_Z); ppc_vexptefp(gen->f, dst_vec, src_vec); /* dst = 2 ^ src */ emit_store(gen, dst_vec, inst, TGSI_CHAN_Z, TRUE); } /* Compute W = 1.0 */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_W)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_W)) { emit_store(gen, one_vec, inst, TGSI_CHAN_W, FALSE); } @@ -968,8 +954,8 @@ emit_log(struct gen_context *gen, struct tgsi_full_instruction *inst) abs_vec = ppc_allocate_vec_register(gen->f); ppc_vandc(gen->f, abs_vec, src_vec, bit31_vec); /* abs = src & ~bit31 */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_X) && - IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Y)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_X) && + TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Y)) { /* compute tmp = floor(log2(abs)) */ int tmp_vec = ppc_allocate_vec_register(gen->f); @@ -977,12 +963,12 @@ emit_log(struct gen_context *gen, struct tgsi_full_instruction *inst) ppc_vrfim(gen->f, tmp_vec, tmp_vec); /* tmp = floor(tmp); */ /* Compute X = tmp */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_X)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_X)) { emit_store(gen, tmp_vec, inst, TGSI_CHAN_X, FALSE); } /* Compute Y = abs / 2^tmp */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Y)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Y)) { const int zero_vec = ppc_allocate_vec_register(gen->f); ppc_vzero(gen->f, zero_vec); ppc_vexptefp(gen->f, tmp_vec, tmp_vec); /* tmp = 2 ^ tmp */ @@ -997,14 +983,14 @@ emit_log(struct gen_context *gen, struct tgsi_full_instruction *inst) } /* Compute Z = RoughApproxLog2(abs) */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Z)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Z)) { int dst_vec = get_dst_vec(gen, inst, TGSI_CHAN_Z); ppc_vlogefp(gen->f, dst_vec, abs_vec); /* dst = log2(abs) */ emit_store(gen, dst_vec, inst, TGSI_CHAN_Z, TRUE); } /* Compute W = 1.0 */ - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_W)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_W)) { emit_store(gen, one_vec, inst, TGSI_CHAN_W, FALSE); } @@ -1023,7 +1009,7 @@ emit_pow(struct gen_context *gen, struct tgsi_full_instruction *inst) ppc_vec_pow(gen->f, pow_vec, s0_vec, s1_vec); - FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan) { + TGSI_FOR_EACH_DST0_ENABLED_CHANNEL(inst, chan) { emit_store(gen, pow_vec, inst, chan, FALSE); } @@ -1047,37 +1033,37 @@ emit_xpd(struct gen_context *gen, struct tgsi_full_instruction *inst) tmp_vec = ppc_allocate_vec_register(gen->f); tmp2_vec = ppc_allocate_vec_register(gen->f); - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Y) || - IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Z)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Y) || + TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Z)) { x0_vec = get_src_vec(gen, inst, 0, TGSI_CHAN_X); x1_vec = get_src_vec(gen, inst, 1, TGSI_CHAN_X); } - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_X) || - IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Z)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_X) || + TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Z)) { y0_vec = get_src_vec(gen, inst, 0, TGSI_CHAN_Y); y1_vec = get_src_vec(gen, inst, 1, TGSI_CHAN_Y); } - if (IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_X) || - IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Y)) { + if (TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_X) || + TGSI_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Y)) { z0_vec = get_src_vec(gen, inst, 0, TGSI_CHAN_Z); z1_vec = get_src_vec(gen, inst, 1, TGSI_CHAN_Z); } - IF_IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_X) { + TGSI_IF_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_X) { /* tmp = y0 * z1 */ ppc_vmaddfp(gen->f, tmp_vec, y0_vec, z1_vec, zero_vec); /* tmp = tmp - z0 * y1*/ ppc_vnmsubfp(gen->f, tmp_vec, tmp_vec, z0_vec, y1_vec); emit_store(gen, tmp_vec, inst, TGSI_CHAN_X, FALSE); } - IF_IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Y) { + TGSI_IF_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Y) { /* tmp = z0 * x1 */ ppc_vmaddfp(gen->f, tmp_vec, z0_vec, x1_vec, zero_vec); /* tmp = tmp - x0 * z1 */ ppc_vnmsubfp(gen->f, tmp_vec, tmp_vec, x0_vec, z1_vec); emit_store(gen, tmp_vec, inst, TGSI_CHAN_Y, FALSE); } - IF_IS_DST0_CHANNEL_ENABLED(*inst, TGSI_CHAN_Z) { + TGSI_IF_IS_DST0_CHANNEL_ENABLED(inst, TGSI_CHAN_Z) { /* tmp = x0 * y1 */ ppc_vmaddfp(gen->f, tmp_vec, x0_vec, y1_vec, zero_vec); /* tmp = tmp - y0 * x1 */ |