From 066a5729552925fc53e345b9e86a8699ba7ac451 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 25 Apr 2017 00:31:47 +0200 Subject: [PATCH] st/glsl_to_tgsi: disable the merge registers pass conditionally MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The main goal of this pass to merge temporary registers in order to reduce the total number of registers and also to produce optimal TGSI code. In fact, compilers seem to be confused when temporary variables are already merged, maybe because it's done too early in the process. Skipping the pass, reduce both the register pressure and the code size, at least for Nouveau and RadeonSI because they have a real backend compiler. Found by luck while fixing an issue in the TGSI dead code elimination pass which affects tex instructions with bindless samplers. Signed-off-by: Samuel Pitoiset Reviewed-by: Nicolai Hähnle Reviewed-by: Marek Olšák --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index de7fe7837a4..8ca90f6c43d 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -6639,6 +6639,7 @@ get_mesa_program_tgsi(struct gl_context *ctx, &ctx->Const.ShaderCompilerOptions[shader->Stage]; struct pipe_screen *pscreen = ctx->st->pipe->screen; enum pipe_shader_type ptarget = st_shader_stage_to_ptarget(shader->Stage); + unsigned skip_merge_registers; validate_ir_tree(shader->ir); @@ -6660,6 +6661,9 @@ get_mesa_program_tgsi(struct gl_context *ctx, PIPE_SHADER_CAP_TGSI_FMA_SUPPORTED); v->has_tex_txf_lz = pscreen->get_param(pscreen, PIPE_CAP_TGSI_TEX_TXF_LZ); + skip_merge_registers = + pscreen->get_shader_param(pscreen, ptarget, + PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS); _mesa_generate_parameters_list_for_uniforms(shader_program, shader, prog->Parameters); @@ -6712,7 +6716,8 @@ get_mesa_program_tgsi(struct gl_context *ctx, while (v->eliminate_dead_code()); v->merge_two_dsts(); - v->merge_registers(); + if (!skip_merge_registers) + v->merge_registers(); v->renumber_registers(); /* Write the END instruction. */ -- 2.30.2