Skip to content

Commit c665438

Browse files
committed
fix: SDSL cache double-check validation
The lazy inner double-check in ShaderLoaderBase.LoadExternalBuffer skipped ValidateCachedHashes, so when the outer check detected a source hash mismatch and fell through, the inner check would hit the same (memory-cached) stale entry and return it unchanged. Now the inner check also validates hashes.
1 parent 3870349 commit c665438

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sources/shaders/Stride.Shaders.Compilers/ShaderLoaderBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public bool LoadExternalBuffer(string name, ReadOnlySpan<ShaderMacro> defines, [
6060
var lazy = compilingShaders.GetOrAdd(key, _ => new Lazy<(ShaderBuffers, ObjectId)>(() =>
6161
{
6262
// Double-check cache (another thread may have finished between our check and this factory)
63-
if (Cache.TryLoadFromCache(name, null, macrosArray, out var buf, out var h))
63+
if (Cache.TryLoadFromCache(name, null, macrosArray, out var buf, out var h) && ValidateCachedHashes(buf))
6464
return (buf, h);
6565

6666
if (!ExternalFileExists(name))

0 commit comments

Comments
 (0)