From 686266d2f1aae3027fd039386c166ce3fadfce7f 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 Part-of: --- src/gallium/drivers/crocus/crocus_program.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/crocus/crocus_program.c b/src/gallium/drivers/crocus/crocus_program.c index 9c6f23400bb..b6882d950a5 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_fs_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, };