From bf16fd7a81ab8615003f59335b52eb6be1960fd1 Mon Sep 17 00:00:00 2001 From: Jannik Silvanus Date: Thu, 9 Nov 2023 17:40:27 +0100 Subject: [PATCH] llpc: Fix non-determinism in SpirvLowerRayQuery In SpirvLowerRayQuery, we generate a unique id for each traceRay call. This id is generated by hasing an increasing ID number, and the name of the module. However, the implementation was instead hashing the binary representation of a StringRef object, thereby hashing a pointer. This resulted in non-deterministic IR being generated. --- llpc/lower/llpcSpirvLowerRayQuery.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llpc/lower/llpcSpirvLowerRayQuery.cpp b/llpc/lower/llpcSpirvLowerRayQuery.cpp index 7f777acb92..d555fce808 100644 --- a/llpc/lower/llpcSpirvLowerRayQuery.cpp +++ b/llpc/lower/llpcSpirvLowerRayQuery.cpp @@ -1265,7 +1265,7 @@ void SpirvLowerRayQuery::initGlobalVariable() { unsigned SpirvLowerRayQuery::generateTraceRayStaticId() { Util::MetroHash64 hasher; hasher.Update(m_nextTraceRayId++); - hasher.Update(m_module->getName()); + hasher.Update(m_module->getName().bytes_begin(), m_module->getName().size()); MetroHash::Hash hash = {}; hasher.Finalize(hash.bytes);