From 9520b70f75d7a695966f36ff619557c88c25a0dc Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 24 May 2021 05:19:43 +1000 Subject: [PATCH] llvmpipe: add the interesting bit of cpu detection to the cache. This should detect if someone changes CPU configuration that matters like in a VM Reviewed-by: Emma Anholt Fixes: 6c0c61cb48e8 ("llvmpipe: add infrastructure for disk cache support") Part-of: --- src/gallium/drivers/llvmpipe/lp_screen.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index c568d580c1b..c1d642bc299 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -816,6 +816,17 @@ llvmpipe_get_timestamp(struct pipe_screen *_screen) return os_time_get_nano(); } +static void update_cache_sha1_cpu(struct mesa_sha1 *ctx) +{ + const struct util_cpu_caps_t *cpu_caps = util_get_cpu_caps(); + /* + * Don't need the cpu cache affinity stuff. The rest + * is contained in first 5 dwords. + */ + STATIC_ASSERT(offsetof(struct util_cpu_caps_t, num_L3_caches) == 5 * sizeof(uint32_t)); + _mesa_sha1_update(ctx, cpu_caps, 5 * sizeof(uint32_t)); +} + static void lp_disk_cache_create(struct llvmpipe_screen *screen) { struct mesa_sha1 ctx; @@ -829,6 +840,7 @@ static void lp_disk_cache_create(struct llvmpipe_screen *screen) return; _mesa_sha1_update(&ctx, &gallivm_perf, sizeof(gallivm_perf)); + update_cache_sha1_cpu(&ctx); _mesa_sha1_final(&ctx, sha1); disk_cache_format_hex_id(cache_id, sha1, 20 * 2);