[Mesa-dev] [PATCH 2/2] i965: Implement nir_op_fquantize2f16
Michael Schellenberger Costa
mschellenbergercosta at googlemail.com
Wed Jan 13 00:01:08 PST 2016
Hi Jason
Am 13/01/2016 um 00:35 schrieb Jason Ekstrand:
> ---
> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 13 +++++++++++++
> src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 10 ++++++++++
> 2 files changed, 23 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 6213378..ffb8059 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -943,6 +943,19 @@ fs_visitor::nir_emit_alu(const fs_builder &bld, nir_alu_instr *instr)
> inst->saturate = instr->dest.saturate;
> break;
>
> + case nir_op_fquantize2f16: {
> + fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_D);
> +
> + /* The destination stride must be at least as big as the source stride. */
> + tmp.type = BRW_REGISTER_TYPE_W;
> + tmp.stride = 2;
After a comment like 'at least at big' one would normaly expect some
check to ensure that. Maybe add a "So set it to 2" or whatever
-Michael
> +
> + bld.emit(BRW_OPCODE_F32TO16, tmp, op[0]);
> + inst = bld.emit(BRW_OPCODE_F16TO32, result, tmp);
> + inst->saturate = instr->dest.saturate;
> + break;
> + }
> +
> case nir_op_fmin:
> case nir_op_imin:
> case nir_op_umin:
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> index 37f517d..77a2f8b 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> @@ -1177,6 +1177,16 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
> inst->saturate = instr->dest.saturate;
> break;
>
> + case nir_op_fquantize2f16: {
> + /* See also vec4_visitor::emit_pack_half_2x16() */
> + src_reg tmp = src_reg(this, glsl_type::uvec4_type);
> +
> + emit(F32TO16(dst_reg(tmp), op[0]));
> + inst = emit(F16TO32(dst, tmp));
> + inst->saturate = instr->dest.saturate;
> + break;
> + }
> +
> case nir_op_fmin:
> case nir_op_imin:
> case nir_op_umin:
>
More information about the mesa-dev
mailing list