From: Jesse Natalie Date: Fri, 13 Nov 2020 23:08:10 +0000 (-0800) Subject: spirv: Allow spirv_to_nir callers to provide a float execution mode X-Git-Tag: upstream/21.0.0~2424 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1885e356e6a4d425471c0bfa0aee5fcf98d19186;p=platform%2Fupstream%2Fmesa.git spirv: Allow spirv_to_nir callers to provide a float execution mode Reviewed-by: Jason Ekstrand Part-of: --- diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h index 5964184..b7d2432 100644 --- a/src/compiler/spirv/nir_spirv.h +++ b/src/compiler/spirv/nir_spirv.h @@ -69,6 +69,11 @@ struct spirv_to_nir_options { /* Create a nir library. */ bool create_library; + /* Initial value for shader_info::float_controls_execution_mode, + * indicates hardware requirements rather than shader author intent + */ + uint16_t float_controls_execution_mode; + struct spirv_supported_capabilities caps; /* Address format for various kinds of pointers. */ diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index b8b6397..de3d12d 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -4828,6 +4828,15 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point, } b->shader->info.float_controls_execution_mode |= execution_mode; + + for (unsigned bit_size = 16; bit_size <= 64; bit_size *= 2) { + vtn_fail_if(nir_is_denorm_flush_to_zero(b->shader->info.float_controls_execution_mode, bit_size) && + nir_is_denorm_preserve(b->shader->info.float_controls_execution_mode, bit_size), + "Cannot flush to zero and preserve denorms for the same bit size."); + vtn_fail_if(nir_is_rounding_mode_rtne(b->shader->info.float_controls_execution_mode, bit_size) && + nir_is_rounding_mode_rtz(b->shader->info.float_controls_execution_mode, bit_size), + "Cannot set rounding mode to RTNE and RTZ for the same bit size."); + } break; } @@ -5744,6 +5753,7 @@ spirv_to_nir(const uint32_t *words, size_t word_count, words+= 5; b->shader = nir_shader_create(b, stage, nir_options, NULL); + b->shader->info.float_controls_execution_mode = options->float_controls_execution_mode; /* Handle all the preamble instructions */ words = vtn_foreach_instruction(b, words, word_end,