[Mesa-dev] [PATCH 8/9] mesa: Add partial constant propagation pass for Mesa IR

Eric Anholt eric at anholt.net
Mon Aug 15 13:44:25 PDT 2011


On Mon, 15 Aug 2011 12:02:42 -0700, "Ian Romanick" <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> This cleans up some code generated by the IR-to-Mesa pass for i915.
> In particular, some shaders involving arrays of constant matrices
> result in really bad code.

I'm curious what sort of constructs led to this being needed at this
level but not at GLSL IR level.  I suspect that some of it (SEQ temp, a,
a handling, for example) might be things that we should be doing in
opt_algebraic and just failing to do.  Then one comment below.

> diff --git a/src/mesa/program/prog_opt_constant_fold.c b/src/mesa/program/prog_opt_constant_fold.c
> new file mode 100644
> index 0000000..2acd4f35
> --- /dev/null
> +++ b/src/mesa/program/prog_opt_constant_fold.c

> +      case OPCODE_DP2:
> +      case OPCODE_DP3:
> +      case OPCODE_DP4:
> +	 if (src_regs_are_constant(inst, 2)) {
> +	    float a[4];
> +	    float b[4];
> +	    float result;
> +
> +	    get_value(prog, &inst->SrcReg[0], a);
> +	    get_value(prog, &inst->SrcReg[1], b);
> +
> +	    result = (a[0] * b[0]) + (a[1] * b[1])
> +	       + (a[2] * b[2]) + (a[3] * b[3]);
> +
> +	    inst->Opcode = OPCODE_MOV;
> +	    inst->SrcReg[0] = src_reg_for_float(prog, result);
> +	    memset(& inst->SrcReg[1], 0, sizeof(inst->SrcReg[1]));
> +
> +	    progress = true;
> +	 }
> +	 break;

This seems unlikely to be correct for DP2, DP3.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110815/9386f966/attachment.pgp>


More information about the mesa-dev mailing list