mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-17 06:00:35 +01:00
vtn/opencl: add ctz support
ctz is a CL2.0 opcode but 3.0 requires it as well so just add support for it. Tested against CTS integer_ops integer_ctz test. (long line broken up) Reviewed-by: Francisco Jerez <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7468>
This commit is contained in:
parent
725df7c15d
commit
9790fdf2ce
2 changed files with 13 additions and 0 deletions
|
|
@ -261,6 +261,16 @@ nir_clz_u(nir_builder *b, nir_ssa_def *a)
|
|||
return nir_u2u(b, val, a->bit_size);
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_ctz_u(nir_builder *b, nir_ssa_def *a)
|
||||
{
|
||||
nir_ssa_def *cond = nir_ieq(b, a, nir_imm_intN_t(b, 0, a->bit_size));
|
||||
|
||||
return nir_bcsel(b, cond,
|
||||
nir_imm_intN_t(b, a->bit_size, a->bit_size),
|
||||
nir_u2u(b, nir_find_lsb(b, a), a->bit_size));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -533,6 +533,8 @@ handle_special(struct vtn_builder *b, uint32_t opcode,
|
|||
return nir_normalize(nb, srcs[0]);
|
||||
case OpenCLstd_Clz:
|
||||
return nir_clz_u(nb, srcs[0]);
|
||||
case OpenCLstd_Ctz:
|
||||
return nir_ctz_u(nb, srcs[0]);
|
||||
case OpenCLstd_Select:
|
||||
return nir_select(nb, srcs[0], srcs[1], srcs[2]);
|
||||
case OpenCLstd_S_Upsample:
|
||||
|
|
@ -876,6 +878,7 @@ vtn_handle_opencl_instruction(struct vtn_builder *b, SpvOp ext_opcode,
|
|||
case OpenCLstd_S_Upsample:
|
||||
case OpenCLstd_U_Upsample:
|
||||
case OpenCLstd_Clz:
|
||||
case OpenCLstd_Ctz:
|
||||
case OpenCLstd_Native_exp:
|
||||
case OpenCLstd_Native_exp10:
|
||||
case OpenCLstd_Native_log:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue