| From 62ee563fd398169005906245831db680f813b19f Mon Sep 17 00:00:00 2001 | |
| From: Karol Herbst <kherbst@redhat.com> | |
| Date: Tue, 22 Sep 2026 14:11:09 +0200 | |
| Subject: [PATCH] nir/load_libclc: turn sys_path into an array | |
| Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/44624> | |
| Upstream: https://gitlab.freedesktop.org/mesa/mesa/-/commit/62ee563fd398169005906245831db680f813b19f | |
| Signed-off-by: Bernd Kuhls <bernd@kuhls.net> | |
| --- | |
| src/compiler/clc/nir_load_libclc.c | 55 +++++++++++++++++------------- | |
| 1 file changed, 31 insertions(+), 24 deletions(-) | |
| diff --git a/src/compiler/clc/nir_load_libclc.c b/src/compiler/clc/nir_load_libclc.c | |
| index 913dd8ff7a7..17b901db47c 100644 | |
| --- a/src/compiler/clc/nir_load_libclc.c | |
| +++ b/src/compiler/clc/nir_load_libclc.c | |
| @@ -52,7 +52,7 @@ struct clc_file { | |
| unsigned bit_size; | |
| const char *static_data; | |
| size_t static_data_size; | |
| - const char *sys_path; | |
| + const char *sys_paths[1]; | |
| }; | |
| static const struct clc_file libclc_files[] = { | |
| @@ -63,7 +63,9 @@ static const struct clc_file libclc_files[] = { | |
| .static_data_size = sizeof(libclc_spirv_mesa3d_spv), | |
| #endif | |
| #ifdef DYNAMIC_LIBCLC_PATH | |
| - .sys_path = DYNAMIC_LIBCLC_PATH "spirv-mesa3d-.spv", | |
| + .sys_paths = { | |
| + DYNAMIC_LIBCLC_PATH "spirv-mesa3d-.spv", | |
| + }, | |
| #endif | |
| }, | |
| { | |
| @@ -73,7 +75,9 @@ static const struct clc_file libclc_files[] = { | |
| .static_data_size = sizeof(libclc_spirv64_mesa3d_spv), | |
| #endif | |
| #ifdef DYNAMIC_LIBCLC_PATH | |
| - .sys_path = DYNAMIC_LIBCLC_PATH "spirv64-mesa3d-.spv", | |
| + .sys_paths = { | |
| + DYNAMIC_LIBCLC_PATH "spirv64-mesa3d-.spv", | |
| + }, | |
| #endif | |
| }, | |
| }; | |
| @@ -194,32 +198,35 @@ open_clc_data(struct clc_data *clc, unsigned ptr_bit_size) | |
| } | |
| #ifdef DYNAMIC_LIBCLC_PATH | |
| - int fd = open(clc->file->sys_path, O_RDONLY); | |
| - if (fd < 0) | |
| - return false; | |
| + for (unsigned i = 0; i < ARRAY_SIZE(clc->file->sys_paths); i++) { | |
| + const char *sys_path = clc->file->sys_paths[i]; | |
| + int fd = open(sys_path, O_RDONLY); | |
| + if (fd < 0) | |
| + continue; | |
| - struct stat stat; | |
| - int ret = fstat(fd, &stat); | |
| - if (ret < 0) { | |
| - fprintf(stderr, "fstat failed on %s: %m\n", clc->file->sys_path); | |
| - close(fd); | |
| - return false; | |
| - } | |
| + struct stat stat; | |
| + int ret = fstat(fd, &stat); | |
| + if (ret < 0) { | |
| + fprintf(stderr, "fstat failed on %s: %m\n", sys_path); | |
| + close(fd); | |
| + continue; | |
| + } | |
| - clc->fd = fd; | |
| - clc->size = stat.st_size; | |
| + clc->fd = fd; | |
| + clc->size = stat.st_size; | |
| - if (!map_clc_data(clc)) { | |
| - close_clc_data(clc); | |
| - return false; | |
| - } | |
| + if (!map_clc_data(clc)) { | |
| + close_clc_data(clc); | |
| + continue; | |
| + } | |
| - blake3_hasher ctx; | |
| - _mesa_blake3_init(&ctx); | |
| - _mesa_blake3_update(&ctx, clc->data, clc->size); | |
| - _mesa_blake3_final(&ctx, clc->cache_key); | |
| + blake3_hasher ctx; | |
| + _mesa_blake3_init(&ctx); | |
| + _mesa_blake3_update(&ctx, clc->data, clc->size); | |
| + _mesa_blake3_final(&ctx, clc->cache_key); | |
| - return true; | |
| + return true; | |
| + } | |
| #endif | |
| return false; | |
| -- | |
| 2.47.3 | |