From 4258ab45b75831db0270e07ed918e5f3b3a9a86f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 17 Mar 2021 10:39:35 -0700 Subject: [PATCH] nir_to_tgsi: Respect PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the driver can't do it, we shouldn't be putting it in the TGSI, regardless of what the NIR compiler above us decided. Reviewed-by: Marek Olšák Reviewed-by: Neha Bhende Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index e6e5c3c67e8..723786cf845 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -2646,9 +2646,12 @@ nir_to_tgsi_lower_64bit_to_vec2(nir_shader *s) } static void -ntt_fix_nir_options(struct nir_shader *s) +ntt_fix_nir_options(struct pipe_screen *screen, struct nir_shader *s) { const struct nir_shader_compiler_options *options = s->options; + bool lower_fsqrt = + !screen->get_shader_param(screen, pipe_shader_type_from_mesa(s->info.stage), + PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED); if (!options->lower_extract_byte || !options->lower_extract_word || @@ -2657,7 +2660,8 @@ ntt_fix_nir_options(struct nir_shader *s) !options->lower_fmod || !options->lower_rotate || !options->lower_uniforms_to_ubo || - !options->lower_vector_cmp) { + !options->lower_vector_cmp || + options->lower_fsqrt != lower_fsqrt) { nir_shader_compiler_options *new_options = ralloc(s, nir_shader_compiler_options); *new_options = *s->options; @@ -2669,6 +2673,7 @@ ntt_fix_nir_options(struct nir_shader *s) new_options->lower_rotate = true; new_options->lower_uniforms_to_ubo = true, new_options->lower_vector_cmp = true; + new_options->lower_fsqrt = lower_fsqrt; s->options = new_options; } @@ -2694,7 +2699,7 @@ nir_to_tgsi(struct nir_shader *s, PIPE_SHADER_CAP_INTEGERS); const struct nir_shader_compiler_options *original_options = s->options; - ntt_fix_nir_options(s); + ntt_fix_nir_options(screen, s); NIR_PASS_V(s, nir_lower_io, nir_var_shader_in | nir_var_shader_out, type_size, (nir_lower_io_options)0);