Skip to content

Commit

Permalink
Fix keyOffset when emitting get shader key function
Browse files Browse the repository at this point in the history
Signed-off-by: Akio Gaule <[email protected]>
  • Loading branch information
akioCL committed Jun 6, 2024
1 parent a4fc9bd commit 5468252
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/AzslcEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,7 @@ namespace AZ::ShaderCompiler
for (const auto& [uid, varInfo] : m_ir->m_symbols.GetOrderedSymbolsOfSubType_2<VarInfo>())
{
// For now only emit top level options
if (!IsTopLevelThroughTranslation(uid) || !varInfo->CheckHasStorageFlag(StorageFlag::Option) ||
(options.m_useSpecializationConstantsForOptions && varInfo->m_specializationId >= 0))
if (!IsTopLevelThroughTranslation(uid) || !varInfo->CheckHasStorageFlag(StorageFlag::Option))
{
continue;
}
Expand All @@ -422,15 +421,18 @@ namespace AZ::ShaderCompiler
m_out << "// Generated code: ShaderVariantOptions fallback value getters:\n";

auto shaderOptions = GetVariantList(options, true);
auto shaderOptionIndex = 0;

for (const auto& [uid, varInfo] : symbols)
for (uint32_t shaderOptionIndex = 0; shaderOptionIndex < symbols.size(); ++shaderOptionIndex)
{
const auto& [uid, varInfo] = symbols[shaderOptionIndex];
if (options.m_useSpecializationConstantsForOptions && varInfo->m_specializationId >= 0)
{
continue;
}

const auto keySizeInBits = shaderOptions["ShaderOptions"][shaderOptionIndex]["keySize"].asUInt();
const auto keyOffsetBits = shaderOptions["ShaderOptions"][shaderOptionIndex]["keyOffset"].asUInt();
const auto defaultValue = shaderOptions["ShaderOptions"][shaderOptionIndex]["defaultValue"].asString();

shaderOptionIndex++;
EmitGetShaderKeyFunction(m_shaderVariantFallbackUid, uid, keySizeInBits, keyOffsetBits, defaultValue, varInfo->GetTypeRefInfo());
}
}
Expand Down

0 comments on commit 5468252

Please sign in to comment.