Skip to content

Commit

Permalink
llpc: Fix non-determinism in SpirvLowerRayQuery
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jasilvanus committed Nov 9, 2023
1 parent 82ef966 commit bf16fd7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llpc/lower/llpcSpirvLowerRayQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bf16fd7

Please sign in to comment.