Module: Mesa Branch: master Commit: 1885e356e6a4d425471c0bfa0aee5fcf98d19186 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1885e356e6a4d425471c0bfa0aee5fcf98d19186
Author: Jesse Natalie <[email protected]> Date: Fri Nov 13 15:08:10 2020 -0800 spirv: Allow spirv_to_nir callers to provide a float execution mode Reviewed-by: Jason Ekstrand <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7565> --- src/compiler/spirv/nir_spirv.h | 5 +++++ src/compiler/spirv/spirv_to_nir.c | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h index 5964184338b..b7d2432df7c 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 b8b6397c525..de3d12dc757 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, _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
