On Mon, 15 Aug 2011 12:02:42 -0700, "Ian Romanick" <i...@freedesktop.org> wrote:
> From: Ian Romanick <ian.d.roman...@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.

Attachment: pgpKZ0jsllbLc.pgp
Description: PGP signature

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to