nir: Add a conversion and rounding intrinsic
This new intrinsic is capable of handling the full range of conversions from OpenCL including rounding modes and possible saturation. The intention is that we'll emit this intrinsic directly from spirv_to_nir and then lower it to ALU ops later. Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6945>
This commit is contained in:
committed by
Marge Bot
parent
0aa08ae2f6
commit
588bb6686b
@@ -1476,6 +1476,30 @@ nir_load_reloc_const_intel(nir_builder *b, uint32_t id)
|
||||
return &load->dest.ssa;
|
||||
}
|
||||
|
||||
static inline nir_ssa_def *
|
||||
nir_convert_alu_types(nir_builder *b, nir_ssa_def *src,
|
||||
nir_alu_type src_type, nir_alu_type dest_type,
|
||||
nir_rounding_mode round, bool saturate)
|
||||
{
|
||||
assert(nir_alu_type_get_type_size(dest_type) != 0);
|
||||
assert(nir_alu_type_get_type_size(src_type) == 0 ||
|
||||
nir_alu_type_get_type_size(src_type) == src->bit_size);
|
||||
src_type = (nir_alu_type)(src_type | src->bit_size);
|
||||
|
||||
nir_intrinsic_instr *conv =
|
||||
nir_intrinsic_instr_create(b->shader, nir_intrinsic_convert_alu_types);
|
||||
conv->src[0] = nir_src_for_ssa(src);
|
||||
conv->num_components = src->num_components;
|
||||
nir_intrinsic_set_src_type(conv, src_type);
|
||||
nir_intrinsic_set_dest_type(conv, dest_type);
|
||||
nir_intrinsic_set_rounding_mode(conv, round);
|
||||
nir_intrinsic_set_saturate(conv, saturate);
|
||||
nir_ssa_dest_init(&conv->instr, &conv->dest, src->num_components,
|
||||
nir_alu_type_get_type_size(dest_type), NULL);
|
||||
nir_builder_instr_insert(b, &conv->instr);
|
||||
return &conv->dest.ssa;
|
||||
}
|
||||
|
||||
#include "nir_builder_opcodes.h"
|
||||
|
||||
static inline nir_ssa_def *
|
||||
|
||||
Reference in New Issue
Block a user