The Build Time Stamp of ShaderAsset And (#5373)

* The Build Time Stamp of ShaderAsset And
ShaderVariantAsset Should Be Based On
GetTimeUTCMilliSecond()

GetTimeNowMicroseconds() is useful to measure time stamp differences.
GetTimeUTCMilliSecond() is for time stamps based on absolute clock/wall time.

* Updated DiffuseGlobalIllumination precompiled shaders

Co-authored-by: dmcdiar <dmcdiar@amazon.com>
Signed-off-by: galibzon <66021303+galibzon@users.noreply.github.com>
monroegm-disable-blank-issue-2
galibzon 4 years ago committed by GitHub
parent 520c2b52d4
commit b0dfe26232
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -82,7 +82,7 @@ namespace AZ
// Register Shader Asset Builder
AssetBuilderSDK::AssetBuilderDesc shaderAssetBuilderDescriptor;
shaderAssetBuilderDescriptor.m_name = "Shader Asset Builder";
shaderAssetBuilderDescriptor.m_version = 107; // Required .azsl extension in .shader file references
shaderAssetBuilderDescriptor.m_version = 108; // The Build Time Stamp of ShaderAsset And ShaderVariantAsset Should Be Based On GetTimeUTCMilliSecond()
// .shader file changes trigger rebuilds
shaderAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern( AZStd::string::format("*.%s", RPI::ShaderSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard));
shaderAssetBuilderDescriptor.m_busId = azrtti_typeid<ShaderAssetBuilder>();
@ -108,7 +108,7 @@ namespace AZ
shaderVariantAssetBuilderDescriptor.m_name = "Shader Variant Asset Builder";
// Both "Shader Variant Asset Builder" and "Shader Asset Builder" produce ShaderVariantAsset products. If you update
// ShaderVariantAsset you will need to update BOTH version numbers, not just "Shader Variant Asset Builder".
shaderVariantAssetBuilderDescriptor.m_version = 26; // [AZSL] Changing inlineConstant to rootConstant keyword work.
shaderVariantAssetBuilderDescriptor.m_version = 27; // The Build Time Stamp of ShaderAsset And ShaderVariantAsset Should Be Based On GetTimeUTCMilliSecond().
shaderVariantAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern(AZStd::string::format("*.%s", RPI::ShaderVariantListSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard));
shaderVariantAssetBuilderDescriptor.m_busId = azrtti_typeid<ShaderVariantAssetBuilder>();
shaderVariantAssetBuilderDescriptor.m_createJobFunction = AZStd::bind(&ShaderVariantAssetBuilder::CreateJobs, &m_shaderVariantAssetBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2);

@ -162,7 +162,7 @@ namespace AZ
// has the same value, because later the ShaderVariantTreeAsset job will fetch this value from the local ShaderAsset
// which could cross platforms (i.e. building an android ShaderVariantTreeAsset on PC would fetch the tiemstamp from
// the PC's ShaderAsset).
AZStd::sys_time_t shaderAssetBuildTimestamp = AZStd::GetTimeNowMicroSecond();
AZ::u64 shaderAssetBuildTimestamp = AZStd::GetTimeUTCMilliSecond();
// Need to get the name of the azsl file from the .shader source asset, to be able to declare a dependency to SRG Layout Job.
// and the macro options to preprocess.
@ -229,8 +229,8 @@ namespace AZ
} // for all request.m_enabledPlatforms
AZ_TracePrintf(
ShaderAssetBuilderName, "CreateJobs for %s took %llu microseconds", shaderAssetSourceFileFullPath.c_str(),
AZStd::GetTimeNowMicroSecond() - shaderAssetBuildTimestamp);
ShaderAssetBuilderName, "CreateJobs for %s took %llu milliseconds", shaderAssetSourceFileFullPath.c_str(),
AZStd::GetTimeUTCMilliSecond() - shaderAssetBuildTimestamp);
response.m_result = AssetBuilderSDK::CreateJobsResultCode::Success;
}
@ -355,8 +355,8 @@ namespace AZ
return;
}
// Get the time stamp string as sys_time_t, and also convert back to string to make sure it was converted correctly.
AZStd::sys_time_t shaderAssetBuildTimestamp = 0;
// Get the time stamp string as u64, and also convert back to string to make sure it was converted correctly.
AZ::u64 shaderAssetBuildTimestamp = 0;
auto shaderAssetBuildTimestampIterator = request.m_jobDescription.m_jobParameters.find(ShaderAssetBuildTimestampParam);
if (shaderAssetBuildTimestampIterator != request.m_jobDescription.m_jobParameters.end())
{

@ -765,7 +765,7 @@ namespace AZ
return;
}
const AZStd::sys_time_t shaderVariantAssetBuildTimestamp = AZStd::GetTimeNowMicroSecond();
const AZ::u64 shaderVariantAssetBuildTimestamp = AZStd::GetTimeUTCMilliSecond();
auto supervariantList = ShaderBuilderUtility::GetSupervariantListFromShaderSourceData(shaderSourceDescriptor);

@ -38,7 +38,7 @@ namespace AZ
const AZStd::string& m_tempDirPath;
//! Used to synchronize versions of the ShaderAsset and ShaderVariantAsset,
//! especially during hot-reload. A (ShaderVariantAsset.timestamp) >= (ShaderAsset.timestamp).
const AZStd::sys_time_t m_assetBuildTimestamp;
const AZ::u64 m_assetBuildTimestamp;
const RPI::ShaderSourceData& m_shaderSourceDataDescriptor;
const RPI::ShaderOptionGroupLayout& m_shaderOptionGroupLayout;
const MapOfStringToStageType& m_shaderEntryPoints;

@ -40,7 +40,7 @@ namespace AZ
//! Set the timestamp value when the ProcessJob() started.
//! This is needed to synchronize between the ShaderAsset and ShaderVariantAsset when hot-reloading shaders.
//! The idea is that this timestamp must be greater or equal than the ShaderAsset.
void SetBuildTimestamp(AZStd::sys_time_t buildTimestamp);
void SetBuildTimestamp(AZ::u64 buildTimestamp);
//! Assigns a shaderStageFunction, which contains the byte code, to the slot dictated by the shader stage.
void SetShaderFunction(RHI::ShaderStage shaderStage, RHI::Ptr<RHI::ShaderStageFunction> shaderStageFunction);

@ -294,7 +294,7 @@ namespace AZ
Name m_drawListName;
//! Use to synchronize versions of the ShaderAsset and ShaderVariantTreeAsset, especially during hot-reload.
AZStd::sys_time_t m_shaderAssetBuildTimestamp = 0;
AZ::u64 m_shaderAssetBuildTimestamp = 0;
///////////////////////////////////////////////////////////////////

@ -61,7 +61,7 @@ namespace AZ
//! Return the timestamp when this asset was built, and it must be >= than the timestamp of the main ShaderAsset.
//! This is used to synchronize versions of the ShaderAsset and ShaderVariantAsset, especially during hot-reload.
AZStd::sys_time_t GetBuildTimestamp() const;
AZ::u64 GetBuildTimestamp() const;
bool IsRootVariant() const { return m_stableId == RPI::RootShaderVariantStableId; }
@ -80,7 +80,7 @@ namespace AZ
AZStd::array<RHI::Ptr<RHI::ShaderStageFunction>, RHI::ShaderStageCount> m_functionsByStage;
//! Used to synchronize versions of the ShaderAsset and ShaderVariantAsset, especially during hot-reload.
AZStd::sys_time_t m_buildTimestamp = 0;
AZ::u64 m_buildTimestamp = 0;
};
class ShaderVariantAssetHandler final

@ -92,7 +92,7 @@ namespace AZ
/////////////////////////////////////////////////////////////////////
// Methods for all shader variant types
void ShaderVariantAssetCreator::SetBuildTimestamp(AZStd::sys_time_t buildTimestamp)
void ShaderVariantAssetCreator::SetBuildTimestamp(AZ::u64 buildTimestamp)
{
if (ValidateIsReady())
{

@ -202,17 +202,17 @@ namespace AZ
return;
}
AZ_Assert(m_asset->m_shaderAssetBuildTimestamp == m_reloadedRootShaderVariantAsset->GetBuildTimestamp(),
"shaderAsset timeStamp=%lld, but Root ShaderVariantAsset timeStamp=%lld",
"shaderAsset '%s' timeStamp=%lld, but Root ShaderVariantAsset timeStamp=%lld", m_asset.GetHint().c_str(),
m_asset->m_shaderAssetBuildTimestamp, m_reloadedRootShaderVariantAsset->GetBuildTimestamp());
m_asset->UpdateRootShaderVariantAsset(m_supervariantIndex, m_reloadedRootShaderVariantAsset);
m_reloadedRootShaderVariantAsset = {}; // Clear the temporary reference.
if (ShaderReloadDebugTracker::IsEnabled())
{
auto makeTimeString = [](AZStd::sys_time_t timestamp, AZStd::sys_time_t now)
auto makeTimeString = [](AZ::u64 timestamp, AZ::u64 now)
{
AZStd::sys_time_t elapsedMicroseconds = now - timestamp;
double elapsedSeconds = aznumeric_cast<double>(elapsedMicroseconds / 1'000'000);
AZ::u64 elapsedMillis = now - timestamp;
double elapsedSeconds = aznumeric_cast<double>(elapsedMillis / 1'000);
AZStd::string timeString = AZStd::string::format("%lld (%f seconds ago)", timestamp, elapsedSeconds);
return timeString;
};

@ -60,7 +60,7 @@ namespace AZ
}
}
AZStd::sys_time_t ShaderVariantAsset::GetBuildTimestamp() const
AZ::u64 ShaderVariantAsset::GetBuildTimestamp() const
{
return m_buildTimestamp;
}

Loading…
Cancel
Save