Skip to content

Commit 73e4209

Browse files
authored
fix: Include entry layer name in PTX cache key (#1954)
The ptx cache key introduced in #1938 didn't include a shader's entry layer name in its cache key. The direct callable function generated during llvm construction includes this layer name, so we could get false positive cache hits when two identical networks with matching group names had different entry layer names. The end result is an optix compilation error. This PR extends the cache key to handle this scenario. Signed-off-by: Chris Hellmuth <chellmuth@gmail.com>
1 parent c48d717 commit 73e4209

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/liboslexec/instance.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,10 +857,14 @@ ShaderGroup::generate_optix_cache_key(string_view code)
857857
safegroup = Strutil::replace(name(), "/", "_", true);
858858
safegroup = Strutil::replace(safegroup, ":", "_", true);
859859

860-
// Cache key includes the groupname in addition to the serialized IR.
861-
// This is because the groupname makes its way into the ptx's direct callable name,
862-
// but isn't included in the serialization.
863-
std::string cache_key = fmtformat("cache-osl-ptx-{}-{}", safegroup, ir_key);
860+
ShaderInstance* inst = layer(nlayers() - 1);
861+
ustring layername = inst->layername();
862+
863+
// Cache key includes group and entry layer names in addition to the serialized IR.
864+
// This is because the group and layer names make their way into the ptx's
865+
// direct callable name, but isn't included in the serialization.
866+
std::string cache_key = fmtformat("cache-osl-ptx-{}-{}-{}", safegroup,
867+
layername, ir_key);
864868

865869
m_optix_cache_key = cache_key;
866870
}

0 commit comments

Comments
 (0)