pco, pygen: add fdiv/frcp support

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33998>
This commit is contained in:
Simon Perretta 2024-11-30 11:39:08 +00:00 committed by Marge Bot
parent 7fb0223c93
commit f1b63fe3f9
4 changed files with 37 additions and 0 deletions

View file

@ -559,6 +559,20 @@ encode_map(O_FMAD,
]
)
encode_map(O_FRCP,
encodings=[
(I_SNGL_EXT, [
('sngl_op', 'rcp'),
('s0neg', (RM_NEG, 'src[0]')),
('s0abs', (RM_ABS, 'src[0]'))
]),
(I_SNGL, [('sngl_op', 'rcp')], [
(RM_NEG, 'src[0]', '== false'),
(RM_ABS, 'src[0]', '== false')
])
]
)
encode_map(O_MBYP,
encodings=[
(I_SNGL_EXT, [
@ -753,6 +767,23 @@ group_map(O_FMAD,
dests=[('w[0]', ('0', 'dest[0]'), 'ft0')]
)
group_map(O_FRCP,
hdr=(I_IGRP_HDR_MAIN, [
('oporg', 'p0'),
('olchk', OM_OLCHK),
('w1p', False),
('w0p', True),
('cc', OM_EXEC_CND),
('end', OM_END),
('atom', OM_ATOM),
('rpt', OM_RPT)
]),
enc_ops=[('0', O_FRCP)],
srcs=[('s[0]', ('0', 'src[0]'), 's0')],
iss=[('is[4]', 'ft0')],
dests=[('w[0]', ('0', 'dest[0]'), 'ft0')]
)
group_map(O_MBYP,
hdr=(I_IGRP_HDR_MAIN, [
('oporg', 'p0'),

View file

@ -25,6 +25,7 @@ static const struct spirv_to_nir_options pco_base_spirv_options = {
static const nir_shader_compiler_options pco_base_nir_options = {
.fuse_ffma32 = true,
.lower_fdiv = true,
.lower_fquantize2f16 = true,
.lower_layer_fs_input_to_sysval = true,
.compact_arrays = true,

View file

@ -277,6 +277,7 @@ OM_ALU_RPT1 = [OM_OLCHK, OM_EXEC_CND, OM_END, OM_ATOM]
O_FADD = hw_op('fadd', OM_ALU + [OM_SAT], 1, 2, [], [[RM_ABS, RM_NEG, RM_FLR], [RM_ABS]])
O_FMUL = hw_op('fmul', OM_ALU + [OM_SAT], 1, 2, [], [[RM_ABS, RM_NEG, RM_FLR], [RM_ABS]])
O_FMAD = hw_op('fmad', OM_ALU + [OM_SAT, OM_LP], 1, 3, [], [[RM_ABS, RM_NEG], [RM_ABS, RM_NEG], [RM_ABS, RM_NEG, RM_FLR]])
O_FRCP = hw_op('frcp', OM_ALU, 1, 1, [], [[RM_ABS, RM_NEG]])
O_MBYP = hw_op('mbyp', OM_ALU, 1, 1, [], [[RM_ABS, RM_NEG]])
O_PCK = hw_op('pck', OM_ALU + [OM_PCK_FMT, OM_ROUNDZERO, OM_SCALE], 1, 1)

View file

@ -647,6 +647,10 @@ static pco_instr *trans_alu(trans_ctx *tctx, nir_alu_instr *alu)
instr = pco_fmad(&tctx->b, dest, src[0], src[1], src[2]);
break;
case nir_op_frcp:
instr = pco_frcp(&tctx->b, dest, src[0]);
break;
case nir_op_pack_unorm_4x8:
instr = pco_pck(&tctx->b,
dest,