Added supervariantIndex check in Shader::OnShaderVariantAssetReady

Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com>
monroegm-disable-blank-issue-2
dmcdiarmid-ly 4 years ago
parent 5c603882b3
commit 1ef868437a

@ -50,6 +50,7 @@ namespace AZ
RPI::ShaderVariantStableId GetStableId() const { return m_stableId; }
const ShaderVariantId& GetShaderVariantId() const { return m_shaderVariantId; }
uint32_t GetSupervariantIndex() const;
//! Returns the shader stage function associated with the provided stage enum value.
const RHI::ShaderStageFunction* GetShaderStageFunction(RHI::ShaderStage shaderStage) const;

@ -253,6 +253,12 @@ namespace AZ
AZ_Assert(shaderVariantAsset, "Reloaded ShaderVariantAsset is null");
const ShaderVariantStableId stableId = shaderVariantAsset->GetStableId();
// check the supervariantIndex of the ShaderVariantAsset to make sure it matches the supervariantIndex of this shader instance
if (shaderVariantAsset->GetSupervariantIndex() != m_supervariantIndex.GetIndex())
{
return;
}
// We make a copy of the updated variant because OnShaderVariantReinitialized must not be called inside
// m_variantCacheMutex or deadlocks may occur.
// Or if there is an error, we leave this object in its default state to indicate there was an error.

@ -65,6 +65,11 @@ namespace AZ
return m_buildTimestamp;
}
uint32_t ShaderVariantAsset::GetSupervariantIndex() const
{
return (m_assetId.m_subId >> SupervariantIndexBitPosition) & SupervariantIndexMaxValue;
}
const RHI::ShaderStageFunction* ShaderVariantAsset::GetShaderStageFunction(RHI::ShaderStage shaderStage) const
{
return m_functionsByStage[static_cast<size_t>(shaderStage)].get();

Loading…
Cancel
Save