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:
Jason Ekstrand
2020-09-30 15:19:45 -05:00
committed by Marge Bot
parent 0aa08ae2f6
commit 588bb6686b
5 changed files with 73 additions and 4 deletions
+10
View File
@@ -546,6 +546,16 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state)
unsigned dest_bit_size = 0;
unsigned src_bit_sizes[NIR_INTRINSIC_MAX_INPUTS] = { 0, };
switch (instr->intrinsic) {
case nir_intrinsic_convert_alu_types: {
nir_alu_type src_type = nir_intrinsic_src_type(instr);
nir_alu_type dest_type = nir_intrinsic_dest_type(instr);
dest_bit_size = nir_alu_type_get_type_size(dest_type);
src_bit_sizes[0] = nir_alu_type_get_type_size(src_type);
validate_assert(state, dest_bit_size != 0);
validate_assert(state, src_bit_sizes[0] != 0);
break;
}
case nir_intrinsic_load_param: {
unsigned param_idx = nir_intrinsic_param_idx(instr);
validate_assert(state, param_idx < state->impl->function->num_params);