Fix texture naming in Resource Trees

This commit is contained in:
Exter-N 2025-03-28 20:24:22 +01:00
parent de408e4d58
commit 6959789aa7

View file

@ -270,13 +270,13 @@ internal unsafe partial record ResolveContext(
if (samplerId.HasValue) if (samplerId.HasValue)
{ {
alreadyProcessedSamplerIds.Add(samplerId.Value); alreadyProcessedSamplerIds.Add(samplerId.Value);
var samplerCrc = GetSamplerCrcById(shpk, samplerId.Value); var textureCrc = GetTextureCrcById(shpk, samplerId.Value);
if (samplerCrc.HasValue) if (textureCrc.HasValue)
{ {
if (shpkNames != null && shpkNames.TryGetValue(samplerCrc.Value, out var samplerName)) if (shpkNames != null && shpkNames.TryGetValue(textureCrc.Value, out var samplerName))
name = samplerName.Value; name = samplerName.Value;
else else
name = $"Texture 0x{samplerCrc.Value:X8}"; name = $"Texture 0x{textureCrc.Value:X8}";
} }
} }
} }
@ -292,9 +292,9 @@ internal unsafe partial record ResolveContext(
return node; return node;
static uint? GetSamplerCrcById(ShaderPackage* shpk, uint id) static uint? GetTextureCrcById(ShaderPackage* shpk, uint id)
=> shpk->SamplersSpan.FindFirst(s => s.Id == id, out var s) => shpk->TexturesSpan.FindFirst(t => t.Id == id, out var t)
? s.CRC ? t.CRC
: null; : null;
static uint? GetTextureSamplerId(Material* mtrl, TextureResourceHandle* handle, HashSet<uint> alreadyVisitedSamplerIds) static uint? GetTextureSamplerId(Material* mtrl, TextureResourceHandle* handle, HashSet<uint> alreadyVisitedSamplerIds)