From 286c245e985831310bd64e0135bc9508dea37482 Mon Sep 17 00:00:00 2001 From: GKraats Date: Wed, 18 Jun 2025 16:07:56 +0200 Subject: [PATCH] crocus: Fix shader precompilation on Gen6 and higher By default crocus precompiles shaders, to avoid stuttering at screens, caused by compiling shaders at the drawing phase. Unfortunately at intel Gen 6 and higher the precompiled version of the fragment shaders is not used and every fragment shader is compiled twice. These double fragment shaders also are added to the memory cache and disk cache. This is caused by setting wrong values to variables at the key during precompiling at routine crocus_create_fs_state() at src/gallium/drivers/crocus/crocus_program.c, which differ from values at crocus_populate_fs_key() at src/gallium/drivers/crocus/crocus_state.c. This commit solves 3 problems: it adjusts the predicted value 'input_slots_valid' at Gen 6 it adjusts the predicted value 'ignore_sample_mask_out' at Gen 6 and higher it predicts the value 'multisample_fbo' , which helps if samplemask is used Cc: mesa-stable Signed-off-by: GKraats Reviewed-by: Kenneth Graunke (cherry picked from commit 686266d2f1aae3027fd039386c166ce3fadfce7f) Part-of: --- .pick_status.json | 2 +- src/gallium/drivers/crocus/crocus_program.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index b0a1a6be8a7..a760fd62817 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2554,7 +2554,7 @@ "description": "crocus: Fix shader precompilation on Gen6 and higher", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/crocus/crocus_program.c b/src/gallium/drivers/crocus/crocus_program.c index 5be1a0d6f05..6ee7bc84fbd 100644 --- a/src/gallium/drivers/crocus/crocus_program.c +++ b/src/gallium/drivers/crocus/crocus_program.c @@ -2869,14 +2869,15 @@ crocus_create_fs_state(struct pipe_context *ctx, BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)); bool can_rearrange_varyings = - screen->devinfo.ver > 6 && util_bitcount64(info->inputs_read & ELK_FS_VARYING_INPUT_MASK) <= 16; + screen->devinfo.ver > 5 && util_bitcount64(info->inputs_read & ELK_FS_VARYING_INPUT_MASK) <= 16; const struct intel_device_info *devinfo = &screen->devinfo; struct elk_wm_prog_key key = { KEY_INIT(), .nr_color_regions = util_bitcount(color_outputs), .coherent_fb_fetch = false, - .ignore_sample_mask_out = screen->devinfo.ver < 6 ? 1 : 0, + .multisample_fbo = (info->outputs_written & BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)) ? ELK_ALWAYS : ELK_NEVER, + .ignore_sample_mask_out = !key.multisample_fbo, .input_slots_valid = can_rearrange_varyings ? 0 : info->inputs_read | VARYING_BIT_POS, };