mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 13:50:11 +01:00
radeonsi: add a way to override the disk cache key with radeonsi-build-id
This is similar to radv-build-id which is mainly used on SteamOS for shaders pre-compilation. For RadeonSI, it also useful to have this option to force the disk cache key to be uniq for redistributed shaders accross machines when it's safe. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35629>
This commit is contained in:
parent
2815287f55
commit
dc4be89e7c
3 changed files with 34 additions and 0 deletions
|
|
@ -750,6 +750,14 @@ option(
|
|||
'Can be extracted with readelf -x .note.gnu.build-id'
|
||||
)
|
||||
|
||||
option(
|
||||
'radeonsi-build-id',
|
||||
type : 'string',
|
||||
value : '',
|
||||
description : 'Override build id for shader cache keys (hex string). ' +
|
||||
'Can be extracted with readelf -x .note.gnu.build-id'
|
||||
)
|
||||
|
||||
option(
|
||||
'min-windows-version',
|
||||
type : 'integer',
|
||||
|
|
|
|||
|
|
@ -154,6 +154,11 @@ if with_amdgpu_virtio
|
|||
libradeonsi_cflags += ['-DHAVE_AMDGPU_VIRTIO']
|
||||
endif
|
||||
|
||||
radeonsi_build_id = get_option('radeonsi-build-id')
|
||||
if radeonsi_build_id != ''
|
||||
libradeonsi_cflags += '-DRADEONSI_BUILD_ID_OVERRIDE="' + radeonsi_build_id + '"'
|
||||
endif
|
||||
|
||||
libradeonsi = static_library(
|
||||
'radeonsi',
|
||||
[files_libradeonsi, sid_tables_h],
|
||||
|
|
|
|||
|
|
@ -1108,6 +1108,18 @@ static void si_test_vmfault(struct si_screen *sscreen, uint64_t test_flags)
|
|||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_hex(char *out, const char *in, unsigned length)
|
||||
{
|
||||
for (unsigned i = 0; i < length; ++i)
|
||||
out[i] = 0;
|
||||
|
||||
for (unsigned i = 0; i < 2 * length; ++i) {
|
||||
unsigned v = in[i] <= '9' ? in[i] - '0' : (in[i] >= 'a' ? (in[i] - 'a' + 10) : (in[i] - 'A' + 10));
|
||||
out[i / 2] |= v << (4 * (1 - i % 2));
|
||||
}
|
||||
}
|
||||
|
||||
static void si_disk_cache_create(struct si_screen *sscreen)
|
||||
{
|
||||
/* Don't use the cache if shader dumping is enabled. */
|
||||
|
|
@ -1120,8 +1132,17 @@ static void si_disk_cache_create(struct si_screen *sscreen)
|
|||
|
||||
_mesa_sha1_init(&ctx);
|
||||
|
||||
#ifdef RADEONSI_BUILD_ID_OVERRIDE
|
||||
{
|
||||
unsigned size = strlen(RADEONSI_BUILD_ID_OVERRIDE) / 2;
|
||||
char *data = alloca(size);
|
||||
parse_hex(data, RADEONSI_BUILD_ID_OVERRIDE, size);
|
||||
_mesa_sha1_update(&ctx, data, size);
|
||||
}
|
||||
#else
|
||||
if (!disk_cache_get_function_identifier(si_disk_cache_create, &ctx))
|
||||
return;
|
||||
#endif
|
||||
|
||||
#if AMD_LLVM_AVAILABLE
|
||||
if (!disk_cache_get_function_identifier(LLVMInitializeAMDGPUTargetInfo, &ctx))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue