matdbg: Fix material collision (#8322)

Fix 3 bugs wrt matdbg:

1. The numbering scheme for materials with same name was buggy
2. The shared depth variants of the default material should also
   show up as active material variants.
3. When two instantiation of FMaterial point to the exact same
   bits, we still need to treat them as two materials. (Otherwise
   we wouldn't be able to modify one of them in matdbg).
This commit is contained in:
Powei Feng
2024-12-19 12:14:08 -08:00
committed by GitHub
parent 1f1389e668
commit aa09d86b5a
4 changed files with 22 additions and 9 deletions

View File

@@ -193,8 +193,12 @@ DebugServer::addMaterial(const CString& name, const void* data, size_t size, voi
return {};
}
const uint32_t seed = 42;
const MaterialKey key = utils::hash::murmurSlow((const uint8_t*) data, size, seed);
// Note that it's possible to have two materials with the exact same content (however wasteful),
// but they refer to different instantiation of FMaterial. Hence we hash on userdata and the
// material data.
constexpr uint32_t seed = 42;
uint64_t dataSpace[2] = {(uint64_t) data, (uint64_t) userdata};
uint32_t const key = utils::hash::murmur3((const uint32_t*) dataSpace, sizeof(dataSpace), seed);
// Retain a copy of the package to permit queries after the client application has
// freed up the original material package.