[Mesa-dev] [PATCH] r600g/cayman: fix integer multiplication output overwrite

Glenn Kennard glenn.kennard at gmail.com
Mon Nov 17 16:50:56 PST 2014


On Tue, 18 Nov 2014 00:56:38 +0100, Dave Airlie <airlied at gmail.com> wrote:

> From: Dave Airlie <airlied at redhat.com>
>
> This fixes  
> tests/spec/glsl-1.10/execution/fs-op-assign-mult-ivec2-ivec2-overwrite.shader_test.
>
> Reported-by: ghallberg on irc
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/gallium/drivers/r600/r600_shader.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/r600/r600_shader.c  
> b/src/gallium/drivers/r600/r600_shader.c
> index aab4215..02efc92 100644
> --- a/src/gallium/drivers/r600/r600_shader.c
> +++ b/src/gallium/drivers/r600/r600_shader.c
> @@ -2729,6 +2729,9 @@ static int cayman_mul_int_instr(struct  
> r600_shader_ctx *ctx)
>  	int i, j, k, r;
>  	struct r600_bytecode_alu alu;
>  	int last_slot = (inst->Dst[0].Register.WriteMask & 0x8) ? 4 : 3;
> +	int t1 = ctx->temp_reg;
> +	int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
> +
>  	for (k = 0; k < last_slot; k++) {
>  		if (!(inst->Dst[0].Register.WriteMask & (1 << k)))
>  			continue;
> @@ -2739,7 +2742,8 @@ static int cayman_mul_int_instr(struct  
> r600_shader_ctx *ctx)
>  			for (j = 0; j < inst->Instruction.NumSrcRegs; j++) {
>  				r600_bytecode_src(&alu.src[j], &ctx->src[j], k);
>  			}
> -			tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
> +			alu.dst.sel = t1;
> +			alu.dst.chan = i;
>  			alu.dst.write = (i == k);
>  			if (i == 3)
>  				alu.last = 1;
> @@ -2748,6 +2752,23 @@ static int cayman_mul_int_instr(struct  
> r600_shader_ctx *ctx)
>  				return r;
>  		}
>  	}
> +
> +	for (i = 0 ; i < last_slot; i++) {
> +		if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
> +			continue;
> +		memset(&alu, 0, sizeof(struct r600_bytecode_alu));
> +		alu.op = ALU_OP1_MOV;
> +		alu.src[0].sel = t1;
> +		alu.src[0].chan = i;
> +		tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
> +		alu.dst.write = 1;
> +		if (i == lasti)
> +			alu.last = 1;
> +		r = r600_bytecode_add_alu(ctx->bc, &alu);
> +		if (r)
> +			return r;
> +	}
> +
>  	return 0;
>  }
>

Trivial nit: last_slot is no longer needed and can be removed.

With a bit of luck it will also fix  
https://bugs.freedesktop.org/show_bug.cgi?id=85376

Reviewed-by: Glenn Kennard <glenn.kennard at gmail.com>


More information about the mesa-dev mailing list