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 <vd.kraats@hccnet.nl>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35605>
This commit is contained in:
GKraats 2025-06-18 16:07:56 +02:00 committed by Marge Bot
parent 3c01e6139a
commit 686266d2f1

View file

@ -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,
};