From c573260c9beb3f6429214abc0898b5f5765e75f3 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Mon, 11 Oct 2021 22:31:25 +1100 Subject: [PATCH] glsl: switch to NIR based implementation of lower_const_arrays_to_uniforms() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shader-db results iris (BDW): total instructions in shared programs: 17523543 -> 17513909 (-0.05%) instructions in affected programs: 218091 -> 208457 (-4.42%) helped: 69 HURT: 327 helped stats (abs) min: 2 max: 2919 x̄: 160.84 x̃: 12 helped stats (rel) min: 0.21% max: 96.88% x̄: 14.87% x̃: 6.40% HURT stats (abs) min: 1 max: 47 x̄: 4.48 x̃: 1 HURT stats (rel) min: 0.10% max: 22.02% x̄: 3.33% x̃: 0.18% 95% mean confidence interval for instructions value: -45.02 -3.63 95% mean confidence interval for instructions %-change: -1.16% 1.47% Inconclusive result (%-change mean confidence interval includes 0). total loops in shared programs: 4875 -> 4868 (-0.14%) loops in affected programs: 7 -> 0 helped: 7 HURT: 0 helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 helped stats (rel) min: 100.00% max: 100.00% x̄: 100.00% x̃: 100.00% 95% mean confidence interval for loops value: -1.00 -1.00 95% mean confidence interval for loops %-change: -100.00% -100.00% Loops are helped. total cycles in shared programs: 858032406 -> 857984712 (<.01%) cycles in affected programs: 22940290 -> 22892596 (-0.21%) helped: 155 HURT: 312 helped stats (abs) min: 1 max: 49696 x̄: 1697.70 x̃: 62 helped stats (rel) min: <.01% max: 70.84% x̄: 5.60% x̃: 0.82% HURT stats (abs) min: 1 max: 19640 x̄: 690.54 x̃: 100 HURT stats (rel) min: <.01% max: 217.23% x̄: 33.57% x̃: 0.92% 95% mean confidence interval for cycles value: -436.09 231.84 95% mean confidence interval for cycles %-change: 15.39% 25.75% Inconclusive result (value mean confidence interval includes 0). total spills in shared programs: 16289 -> 15205 (-6.65%) spills in affected programs: 2753 -> 1669 (-39.38%) helped: 9 HURT: 1 total fills in shared programs: 20347 -> 20324 (-0.11%) fills in affected programs: 1642 -> 1619 (-1.40%) helped: 9 HURT: 1 total sends in shared programs: 972151 -> 971960 (-0.02%) sends in affected programs: 1910 -> 1719 (-10.00%) helped: 25 HURT: 20 helped stats (abs) min: 1 max: 50 x̄: 9.00 x̃: 2 helped stats (rel) min: 0.87% max: 53.76% x̄: 13.89% x̃: 6.25% HURT stats (abs) min: 1 max: 8 x̄: 1.70 x̃: 1 HURT stats (rel) min: 8.33% max: 200.00% x̄: 52.36% x̃: 33.33% 95% mean confidence interval for sends value: -8.19 -0.29 95% mean confidence interval for sends %-change: -1.07% 32.18% Inconclusive result (%-change mean confidence interval includes 0). LOST: 3 GAINED: 27 Note a small number of tests fail on lima and r300 after this patch. However since we are doing the correct thing here and they only fail due to a slight increase in instruction count pushing them over their instruction count limit, we are defering that issue to a different bug report for further discussion. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6540 Acked-by: Emma Anholt Part-of: --- src/compiler/glsl/gl_nir_linker.c | 5 +++++ src/compiler/glsl/linker.cpp | 7 ------- src/gallium/drivers/lima/ci/lima-fails.txt | 3 +++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index e0b36a224d1..356563a78d9 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -968,6 +968,11 @@ gl_nir_link_glsl(const struct gl_constants *consts, for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_linked_shader *shader = prog->_LinkedShaders[i]; if (shader) { + if (consts->GLSLLowerConstArrays) { + nir_lower_const_arrays_to_uniforms(shader->Program->nir, + consts->Program[i].MaxUniformComponents); + } + const nir_remove_dead_variables_options opts = { .can_remove_var = can_remove_uniform, }; diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 5a94e182cc1..6dd6ae6f292 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -3915,13 +3915,6 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) * propagate any elements accessed directly. */ linker_optimisation_loop(consts, prog->_LinkedShaders[i]->ir, i); - - /* Call opts after lowering const arrays to copy propagate things. */ - if (consts->GLSLLowerConstArrays && - lower_const_arrays_to_uniforms(prog->_LinkedShaders[i]->ir, i, - consts->Program[i].MaxUniformComponents)) - linker_optimisation_loop(consts, prog->_LinkedShaders[i]->ir, i); - } /* Check and validate stream emissions in geometry shaders */ diff --git a/src/gallium/drivers/lima/ci/lima-fails.txt b/src/gallium/drivers/lima/ci/lima-fails.txt index 8d9fe6483be..58035199bc7 100644 --- a/src/gallium/drivers/lima/ci/lima-fails.txt +++ b/src/gallium/drivers/lima/ci/lima-fails.txt @@ -31,6 +31,9 @@ dEQP-GLES2.functional.fragment_ops.depth_stencil.write_mask.stencil,Fail dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2d_bias,Fail dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2dproj_vec3_bias,Fail dEQP-GLES2.functional.shaders.texture_functions.fragment.texture2dproj_vec4_bias,Fail +dEQP-GLES2.functional.shaders.indexing.tmp_array.vec2_const_write_dynamic_read_vertex,Fail +dEQP-GLES2.functional.shaders.indexing.tmp_array.vec3_const_write_dynamic_read_vertex,Fail +dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_const_write_dynamic_read_vertex,Fail dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_linear_linear_clamp_rgba8888,Fail dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_linear_linear_mirror_rgba8888,Fail dEQP-GLES2.functional.texture.filtering.2d.linear_mipmap_linear_nearest_clamp_rgba8888,Fail